documentation.d.ts 3.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674876758767687677876788767987680876818768287683876848768587686876878768887689876908769187692876938769487695876968769787698876998770087701877028770387704877058770687707877088770987710877118771287713877148771587716877178771887719877208772187722877238772487725877268772787728877298773087731877328773387734877358773687737877388773987740877418774287743877448774587746877478774887749877508775187752877538775487755877568775787758877598776087761877628776387764877658776687767877688776987770877718777287773877748777587776877778777887779877808778187782877838778487785877868778787788877898779087791877928779387794877958779687797877988779987800878018780287803878048780587806878078780887809878108781187812878138781487815878168781787818878198782087821878228782387824878258782687827878288782987830878318783287833878348783587836878378783887839878408784187842878438784487845878468784787848878498785087851878528785387854878558785687857878588785987860878618786287863878648786587866878678786887869878708787187872878738787487875878768787787878878798788087881878828788387884878858788687887878888788987890878918789287893878948789587896878978789887899879008790187902879038790487905879068790787908879098791087911879128791387914879158791687917879188791987920879218792287923879248792587926879278792887929879308793187932879338793487935879368793787938879398794087941879428794387944879458794687947879488794987950879518795287953879548795587956879578795887959879608796187962879638796487965879668796787968879698797087971879728797387974879758797687977879788797987980879818798287983879848798587986879878798887989879908799187992879938799487995879968799787998879998800088001880028800388004880058800688007880088800988010880118801288013880148801588016880178801888019880208802188022880238802488025880268802788028880298803088031880328803388034880358803688037880388803988040880418804288043880448804588046880478804888049880508805188052880538805488055880568805788058880598806088061880628806388064880658806688067880688806988070880718807288073880748807588076880778807888079880808808188082880838808488085880868808788088880898809088091880928809388094880958809688097880988809988100881018810288103881048810588106881078810888109881108811188112881138811488115881168811788118881198812088121881228812388124881258812688127881288812988130881318813288133881348813588136881378813888139881408814188142881438814488145881468814788148881498815088151881528815388154881558815688157881588815988160881618816288163881648816588166881678816888169881708817188172881738817488175881768817788178881798818088181881828818388184881858818688187881888818988190881918819288193881948819588196881978819888199882008820188202882038820488205882068820788208882098821088211882128821388214882158821688217882188821988220882218822288223882248822588226882278822888229882308823188232882338823488235882368823788238882398824088241882428824388244882458824688247882488824988250882518825288253882548825588256882578825888259882608826188262882638826488265882668826788268882698827088271882728827388274882758827688277882788827988280882818828288283882848828588286882878828888289882908829188292882938829488295882968829788298882998830088301883028830388304883058830688307883088830988310883118831288313883148831588316
  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 _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 element Defines the element the controls should be listened from
  6411. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6412. */
  6413. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6414. /**
  6415. * Detach the current controls from the specified dom element.
  6416. * @param element Defines the element to stop listening the inputs from
  6417. */
  6418. detachControl(element: Nullable<HTMLElement>): void;
  6419. /**
  6420. * Update the current camera state depending on the inputs that have been used this frame.
  6421. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6422. */
  6423. checkInputs?: () => void;
  6424. }
  6425. /**
  6426. * Represents a map of input types to input instance or input index to input instance.
  6427. */
  6428. export interface CameraInputsMap<TCamera extends Camera> {
  6429. /**
  6430. * Accessor to the input by input type.
  6431. */
  6432. [name: string]: ICameraInput<TCamera>;
  6433. /**
  6434. * Accessor to the input by input index.
  6435. */
  6436. [idx: number]: ICameraInput<TCamera>;
  6437. }
  6438. /**
  6439. * This represents the input manager used within a camera.
  6440. * It helps dealing with all the different kind of input attached to a camera.
  6441. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6442. */
  6443. export class CameraInputsManager<TCamera extends Camera> {
  6444. /**
  6445. * Defines the list of inputs attahed to the camera.
  6446. */
  6447. attached: CameraInputsMap<TCamera>;
  6448. /**
  6449. * Defines the dom element the camera is collecting inputs from.
  6450. * This is null if the controls have not been attached.
  6451. */
  6452. attachedElement: Nullable<HTMLElement>;
  6453. /**
  6454. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6455. */
  6456. noPreventDefault: boolean;
  6457. /**
  6458. * Defined the camera the input manager belongs to.
  6459. */
  6460. camera: TCamera;
  6461. /**
  6462. * Update the current camera state depending on the inputs that have been used this frame.
  6463. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6464. */
  6465. checkInputs: () => void;
  6466. /**
  6467. * Instantiate a new Camera Input Manager.
  6468. * @param camera Defines the camera the input manager blongs to
  6469. */
  6470. constructor(camera: TCamera);
  6471. /**
  6472. * Add an input method to a camera
  6473. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6474. * @param input camera input method
  6475. */
  6476. add(input: ICameraInput<TCamera>): void;
  6477. /**
  6478. * Remove a specific input method from a camera
  6479. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6480. * @param inputToRemove camera input method
  6481. */
  6482. remove(inputToRemove: ICameraInput<TCamera>): void;
  6483. /**
  6484. * Remove a specific input type from a camera
  6485. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6486. * @param inputType the type of the input to remove
  6487. */
  6488. removeByType(inputType: string): void;
  6489. private _addCheckInputs;
  6490. /**
  6491. * Attach the input controls to the currently attached dom element to listen the events from.
  6492. * @param input Defines the input to attach
  6493. */
  6494. attachInput(input: ICameraInput<TCamera>): void;
  6495. /**
  6496. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6497. * @param element Defines the dom element to collect the events from
  6498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6499. */
  6500. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6501. /**
  6502. * Detach the current manager inputs controls from a specific dom element.
  6503. * @param element Defines the dom element to collect the events from
  6504. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6505. */
  6506. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6507. /**
  6508. * Rebuild the dynamic inputCheck function from the current list of
  6509. * defined inputs in the manager.
  6510. */
  6511. rebuildInputCheck(): void;
  6512. /**
  6513. * Remove all attached input methods from a camera
  6514. */
  6515. clear(): void;
  6516. /**
  6517. * Serialize the current input manager attached to a camera.
  6518. * This ensures than once parsed,
  6519. * the input associated to the camera will be identical to the current ones
  6520. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6521. */
  6522. serialize(serializedCamera: any): void;
  6523. /**
  6524. * Parses an input manager serialized JSON to restore the previous list of inputs
  6525. * and states associated to a camera.
  6526. * @param parsedCamera Defines the JSON to parse
  6527. */
  6528. parse(parsedCamera: any): void;
  6529. }
  6530. }
  6531. declare module BABYLON {
  6532. /**
  6533. * Class used to store data that will be store in GPU memory
  6534. */
  6535. export class Buffer {
  6536. private _engine;
  6537. private _buffer;
  6538. /** @hidden */
  6539. _data: Nullable<DataArray>;
  6540. private _updatable;
  6541. private _instanced;
  6542. private _divisor;
  6543. /**
  6544. * Gets the byte stride.
  6545. */
  6546. readonly byteStride: number;
  6547. /**
  6548. * Constructor
  6549. * @param engine the engine
  6550. * @param data the data to use for this buffer
  6551. * @param updatable whether the data is updatable
  6552. * @param stride the stride (optional)
  6553. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6554. * @param instanced whether the buffer is instanced (optional)
  6555. * @param useBytes set to true if the stride in in bytes (optional)
  6556. * @param divisor sets an optional divisor for instances (1 by default)
  6557. */
  6558. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6559. /**
  6560. * Create a new VertexBuffer based on the current buffer
  6561. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6562. * @param offset defines offset in the buffer (0 by default)
  6563. * @param size defines the size in floats of attributes (position is 3 for instance)
  6564. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6565. * @param instanced defines if the vertex buffer contains indexed data
  6566. * @param useBytes defines if the offset and stride are in bytes *
  6567. * @param divisor sets an optional divisor for instances (1 by default)
  6568. * @returns the new vertex buffer
  6569. */
  6570. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6571. /**
  6572. * Gets a boolean indicating if the Buffer is updatable?
  6573. * @returns true if the buffer is updatable
  6574. */
  6575. isUpdatable(): boolean;
  6576. /**
  6577. * Gets current buffer's data
  6578. * @returns a DataArray or null
  6579. */
  6580. getData(): Nullable<DataArray>;
  6581. /**
  6582. * Gets underlying native buffer
  6583. * @returns underlying native buffer
  6584. */
  6585. getBuffer(): Nullable<DataBuffer>;
  6586. /**
  6587. * Gets the stride in float32 units (i.e. byte stride / 4).
  6588. * May not be an integer if the byte stride is not divisible by 4.
  6589. * @returns the stride in float32 units
  6590. * @deprecated Please use byteStride instead.
  6591. */
  6592. getStrideSize(): number;
  6593. /**
  6594. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6595. * @param data defines the data to store
  6596. */
  6597. create(data?: Nullable<DataArray>): void;
  6598. /** @hidden */
  6599. _rebuild(): void;
  6600. /**
  6601. * Update current buffer data
  6602. * @param data defines the data to store
  6603. */
  6604. update(data: DataArray): void;
  6605. /**
  6606. * Updates the data directly.
  6607. * @param data the new data
  6608. * @param offset the new offset
  6609. * @param vertexCount the vertex count (optional)
  6610. * @param useBytes set to true if the offset is in bytes
  6611. */
  6612. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6613. /**
  6614. * Release all resources
  6615. */
  6616. dispose(): void;
  6617. }
  6618. /**
  6619. * Specialized buffer used to store vertex data
  6620. */
  6621. export class VertexBuffer {
  6622. /** @hidden */
  6623. _buffer: Buffer;
  6624. private _kind;
  6625. private _size;
  6626. private _ownsBuffer;
  6627. private _instanced;
  6628. private _instanceDivisor;
  6629. /**
  6630. * The byte type.
  6631. */
  6632. static readonly BYTE: number;
  6633. /**
  6634. * The unsigned byte type.
  6635. */
  6636. static readonly UNSIGNED_BYTE: number;
  6637. /**
  6638. * The short type.
  6639. */
  6640. static readonly SHORT: number;
  6641. /**
  6642. * The unsigned short type.
  6643. */
  6644. static readonly UNSIGNED_SHORT: number;
  6645. /**
  6646. * The integer type.
  6647. */
  6648. static readonly INT: number;
  6649. /**
  6650. * The unsigned integer type.
  6651. */
  6652. static readonly UNSIGNED_INT: number;
  6653. /**
  6654. * The float type.
  6655. */
  6656. static readonly FLOAT: number;
  6657. /**
  6658. * Gets or sets the instance divisor when in instanced mode
  6659. */
  6660. get instanceDivisor(): number;
  6661. set instanceDivisor(value: number);
  6662. /**
  6663. * Gets the byte stride.
  6664. */
  6665. readonly byteStride: number;
  6666. /**
  6667. * Gets the byte offset.
  6668. */
  6669. readonly byteOffset: number;
  6670. /**
  6671. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6672. */
  6673. readonly normalized: boolean;
  6674. /**
  6675. * Gets the data type of each component in the array.
  6676. */
  6677. readonly type: number;
  6678. /**
  6679. * Constructor
  6680. * @param engine the engine
  6681. * @param data the data to use for this vertex buffer
  6682. * @param kind the vertex buffer kind
  6683. * @param updatable whether the data is updatable
  6684. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6685. * @param stride the stride (optional)
  6686. * @param instanced whether the buffer is instanced (optional)
  6687. * @param offset the offset of the data (optional)
  6688. * @param size the number of components (optional)
  6689. * @param type the type of the component (optional)
  6690. * @param normalized whether the data contains normalized data (optional)
  6691. * @param useBytes set to true if stride and offset are in bytes (optional)
  6692. * @param divisor defines the instance divisor to use (1 by default)
  6693. */
  6694. 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);
  6695. /** @hidden */
  6696. _rebuild(): void;
  6697. /**
  6698. * Returns the kind of the VertexBuffer (string)
  6699. * @returns a string
  6700. */
  6701. getKind(): string;
  6702. /**
  6703. * Gets a boolean indicating if the VertexBuffer is updatable?
  6704. * @returns true if the buffer is updatable
  6705. */
  6706. isUpdatable(): boolean;
  6707. /**
  6708. * Gets current buffer's data
  6709. * @returns a DataArray or null
  6710. */
  6711. getData(): Nullable<DataArray>;
  6712. /**
  6713. * Gets underlying native buffer
  6714. * @returns underlying native buffer
  6715. */
  6716. getBuffer(): Nullable<DataBuffer>;
  6717. /**
  6718. * Gets the stride in float32 units (i.e. byte stride / 4).
  6719. * May not be an integer if the byte stride is not divisible by 4.
  6720. * @returns the stride in float32 units
  6721. * @deprecated Please use byteStride instead.
  6722. */
  6723. getStrideSize(): number;
  6724. /**
  6725. * Returns the offset as a multiple of the type byte length.
  6726. * @returns the offset in bytes
  6727. * @deprecated Please use byteOffset instead.
  6728. */
  6729. getOffset(): number;
  6730. /**
  6731. * Returns the number of components per vertex attribute (integer)
  6732. * @returns the size in float
  6733. */
  6734. getSize(): number;
  6735. /**
  6736. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6737. * @returns true if this buffer is instanced
  6738. */
  6739. getIsInstanced(): boolean;
  6740. /**
  6741. * Returns the instancing divisor, zero for non-instanced (integer).
  6742. * @returns a number
  6743. */
  6744. getInstanceDivisor(): number;
  6745. /**
  6746. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6747. * @param data defines the data to store
  6748. */
  6749. create(data?: DataArray): void;
  6750. /**
  6751. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6752. * This function will create a new buffer if the current one is not updatable
  6753. * @param data defines the data to store
  6754. */
  6755. update(data: DataArray): void;
  6756. /**
  6757. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6758. * Returns the directly updated WebGLBuffer.
  6759. * @param data the new data
  6760. * @param offset the new offset
  6761. * @param useBytes set to true if the offset is in bytes
  6762. */
  6763. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6764. /**
  6765. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6766. */
  6767. dispose(): void;
  6768. /**
  6769. * Enumerates each value of this vertex buffer as numbers.
  6770. * @param count the number of values to enumerate
  6771. * @param callback the callback function called for each value
  6772. */
  6773. forEach(count: number, callback: (value: number, index: number) => void): void;
  6774. /**
  6775. * Positions
  6776. */
  6777. static readonly PositionKind: string;
  6778. /**
  6779. * Normals
  6780. */
  6781. static readonly NormalKind: string;
  6782. /**
  6783. * Tangents
  6784. */
  6785. static readonly TangentKind: string;
  6786. /**
  6787. * Texture coordinates
  6788. */
  6789. static readonly UVKind: string;
  6790. /**
  6791. * Texture coordinates 2
  6792. */
  6793. static readonly UV2Kind: string;
  6794. /**
  6795. * Texture coordinates 3
  6796. */
  6797. static readonly UV3Kind: string;
  6798. /**
  6799. * Texture coordinates 4
  6800. */
  6801. static readonly UV4Kind: string;
  6802. /**
  6803. * Texture coordinates 5
  6804. */
  6805. static readonly UV5Kind: string;
  6806. /**
  6807. * Texture coordinates 6
  6808. */
  6809. static readonly UV6Kind: string;
  6810. /**
  6811. * Colors
  6812. */
  6813. static readonly ColorKind: string;
  6814. /**
  6815. * Matrix indices (for bones)
  6816. */
  6817. static readonly MatricesIndicesKind: string;
  6818. /**
  6819. * Matrix weights (for bones)
  6820. */
  6821. static readonly MatricesWeightsKind: string;
  6822. /**
  6823. * Additional matrix indices (for bones)
  6824. */
  6825. static readonly MatricesIndicesExtraKind: string;
  6826. /**
  6827. * Additional matrix weights (for bones)
  6828. */
  6829. static readonly MatricesWeightsExtraKind: string;
  6830. /**
  6831. * Deduces the stride given a kind.
  6832. * @param kind The kind string to deduce
  6833. * @returns The deduced stride
  6834. */
  6835. static DeduceStride(kind: string): number;
  6836. /**
  6837. * Gets the byte length of the given type.
  6838. * @param type the type
  6839. * @returns the number of bytes
  6840. */
  6841. static GetTypeByteLength(type: number): number;
  6842. /**
  6843. * Enumerates each value of the given parameters as numbers.
  6844. * @param data the data to enumerate
  6845. * @param byteOffset the byte offset of the data
  6846. * @param byteStride the byte stride of the data
  6847. * @param componentCount the number of components per element
  6848. * @param componentType the type of the component
  6849. * @param count the number of values to enumerate
  6850. * @param normalized whether the data is normalized
  6851. * @param callback the callback function called for each value
  6852. */
  6853. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6854. private static _GetFloatValue;
  6855. }
  6856. }
  6857. declare module BABYLON {
  6858. /**
  6859. * The options Interface for creating a Capsule Mesh
  6860. */
  6861. export interface ICreateCapsuleOptions {
  6862. /** The Orientation of the capsule. Default : Vector3.Up() */
  6863. orientation?: Vector3;
  6864. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6865. subdivisions: number;
  6866. /** Number of cylindrical segments on the capsule. */
  6867. tessellation: number;
  6868. /** Height or Length of the capsule. */
  6869. height: number;
  6870. /** Radius of the capsule. */
  6871. radius: number;
  6872. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6873. capSubdivisions: number;
  6874. /** Overwrite for the top radius. */
  6875. radiusTop?: number;
  6876. /** Overwrite for the bottom radius. */
  6877. radiusBottom?: number;
  6878. /** Overwrite for the top capSubdivisions. */
  6879. topCapSubdivisions?: number;
  6880. /** Overwrite for the bottom capSubdivisions. */
  6881. bottomCapSubdivisions?: number;
  6882. }
  6883. /**
  6884. * Class containing static functions to help procedurally build meshes
  6885. */
  6886. export class CapsuleBuilder {
  6887. /**
  6888. * Creates a capsule or a pill mesh
  6889. * @param name defines the name of the mesh
  6890. * @param options The constructors options.
  6891. * @param scene The scene the mesh is scoped to.
  6892. * @returns Capsule Mesh
  6893. */
  6894. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6895. }
  6896. }
  6897. declare module BABYLON {
  6898. /**
  6899. * @hidden
  6900. */
  6901. export class IntersectionInfo {
  6902. bu: Nullable<number>;
  6903. bv: Nullable<number>;
  6904. distance: number;
  6905. faceId: number;
  6906. subMeshId: number;
  6907. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6908. }
  6909. }
  6910. declare module BABYLON {
  6911. /**
  6912. * Class used to store bounding sphere information
  6913. */
  6914. export class BoundingSphere {
  6915. /**
  6916. * Gets the center of the bounding sphere in local space
  6917. */
  6918. readonly center: Vector3;
  6919. /**
  6920. * Radius of the bounding sphere in local space
  6921. */
  6922. radius: number;
  6923. /**
  6924. * Gets the center of the bounding sphere in world space
  6925. */
  6926. readonly centerWorld: Vector3;
  6927. /**
  6928. * Radius of the bounding sphere in world space
  6929. */
  6930. radiusWorld: number;
  6931. /**
  6932. * Gets the minimum vector in local space
  6933. */
  6934. readonly minimum: Vector3;
  6935. /**
  6936. * Gets the maximum vector in local space
  6937. */
  6938. readonly maximum: Vector3;
  6939. private _worldMatrix;
  6940. private static readonly TmpVector3;
  6941. /**
  6942. * Creates a new bounding sphere
  6943. * @param min defines the minimum vector (in local space)
  6944. * @param max defines the maximum vector (in local space)
  6945. * @param worldMatrix defines the new world matrix
  6946. */
  6947. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6948. /**
  6949. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6950. * @param min defines the new minimum vector (in local space)
  6951. * @param max defines the new maximum vector (in local space)
  6952. * @param worldMatrix defines the new world matrix
  6953. */
  6954. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6955. /**
  6956. * Scale the current bounding sphere by applying a scale factor
  6957. * @param factor defines the scale factor to apply
  6958. * @returns the current bounding box
  6959. */
  6960. scale(factor: number): BoundingSphere;
  6961. /**
  6962. * Gets the world matrix of the bounding box
  6963. * @returns a matrix
  6964. */
  6965. getWorldMatrix(): DeepImmutable<Matrix>;
  6966. /** @hidden */
  6967. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6968. /**
  6969. * Tests if the bounding sphere is intersecting the frustum planes
  6970. * @param frustumPlanes defines the frustum planes to test
  6971. * @returns true if there is an intersection
  6972. */
  6973. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6974. /**
  6975. * Tests if the bounding sphere center is in between the frustum planes.
  6976. * Used for optimistic fast inclusion.
  6977. * @param frustumPlanes defines the frustum planes to test
  6978. * @returns true if the sphere center is in between the frustum planes
  6979. */
  6980. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6981. /**
  6982. * Tests if a point is inside the bounding sphere
  6983. * @param point defines the point to test
  6984. * @returns true if the point is inside the bounding sphere
  6985. */
  6986. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6987. /**
  6988. * Checks if two sphere intersct
  6989. * @param sphere0 sphere 0
  6990. * @param sphere1 sphere 1
  6991. * @returns true if the speres intersect
  6992. */
  6993. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6994. }
  6995. }
  6996. declare module BABYLON {
  6997. /**
  6998. * Class used to store bounding box information
  6999. */
  7000. export class BoundingBox implements ICullable {
  7001. /**
  7002. * Gets the 8 vectors representing the bounding box in local space
  7003. */
  7004. readonly vectors: Vector3[];
  7005. /**
  7006. * Gets the center of the bounding box in local space
  7007. */
  7008. readonly center: Vector3;
  7009. /**
  7010. * Gets the center of the bounding box in world space
  7011. */
  7012. readonly centerWorld: Vector3;
  7013. /**
  7014. * Gets the extend size in local space
  7015. */
  7016. readonly extendSize: Vector3;
  7017. /**
  7018. * Gets the extend size in world space
  7019. */
  7020. readonly extendSizeWorld: Vector3;
  7021. /**
  7022. * Gets the OBB (object bounding box) directions
  7023. */
  7024. readonly directions: Vector3[];
  7025. /**
  7026. * Gets the 8 vectors representing the bounding box in world space
  7027. */
  7028. readonly vectorsWorld: Vector3[];
  7029. /**
  7030. * Gets the minimum vector in world space
  7031. */
  7032. readonly minimumWorld: Vector3;
  7033. /**
  7034. * Gets the maximum vector in world space
  7035. */
  7036. readonly maximumWorld: Vector3;
  7037. /**
  7038. * Gets the minimum vector in local space
  7039. */
  7040. readonly minimum: Vector3;
  7041. /**
  7042. * Gets the maximum vector in local space
  7043. */
  7044. readonly maximum: Vector3;
  7045. private _worldMatrix;
  7046. private static readonly TmpVector3;
  7047. /**
  7048. * @hidden
  7049. */
  7050. _tag: number;
  7051. /**
  7052. * Creates a new bounding box
  7053. * @param min defines the minimum vector (in local space)
  7054. * @param max defines the maximum vector (in local space)
  7055. * @param worldMatrix defines the new world matrix
  7056. */
  7057. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7058. /**
  7059. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7060. * @param min defines the new minimum vector (in local space)
  7061. * @param max defines the new maximum vector (in local space)
  7062. * @param worldMatrix defines the new world matrix
  7063. */
  7064. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7065. /**
  7066. * Scale the current bounding box by applying a scale factor
  7067. * @param factor defines the scale factor to apply
  7068. * @returns the current bounding box
  7069. */
  7070. scale(factor: number): BoundingBox;
  7071. /**
  7072. * Gets the world matrix of the bounding box
  7073. * @returns a matrix
  7074. */
  7075. getWorldMatrix(): DeepImmutable<Matrix>;
  7076. /** @hidden */
  7077. _update(world: DeepImmutable<Matrix>): void;
  7078. /**
  7079. * Tests if the bounding box is intersecting the frustum planes
  7080. * @param frustumPlanes defines the frustum planes to test
  7081. * @returns true if there is an intersection
  7082. */
  7083. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7084. /**
  7085. * Tests if the bounding box is entirely inside the frustum planes
  7086. * @param frustumPlanes defines the frustum planes to test
  7087. * @returns true if there is an inclusion
  7088. */
  7089. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7090. /**
  7091. * Tests if a point is inside the bounding box
  7092. * @param point defines the point to test
  7093. * @returns true if the point is inside the bounding box
  7094. */
  7095. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7096. /**
  7097. * Tests if the bounding box intersects with a bounding sphere
  7098. * @param sphere defines the sphere to test
  7099. * @returns true if there is an intersection
  7100. */
  7101. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7102. /**
  7103. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7104. * @param min defines the min vector to use
  7105. * @param max defines the max vector to use
  7106. * @returns true if there is an intersection
  7107. */
  7108. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7109. /**
  7110. * Tests if two bounding boxes are intersections
  7111. * @param box0 defines the first box to test
  7112. * @param box1 defines the second box to test
  7113. * @returns true if there is an intersection
  7114. */
  7115. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7116. /**
  7117. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7118. * @param minPoint defines the minimum vector of the bounding box
  7119. * @param maxPoint defines the maximum vector of the bounding box
  7120. * @param sphereCenter defines the sphere center
  7121. * @param sphereRadius defines the sphere radius
  7122. * @returns true if there is an intersection
  7123. */
  7124. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7125. /**
  7126. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7127. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7128. * @param frustumPlanes defines the frustum planes to test
  7129. * @return true if there is an inclusion
  7130. */
  7131. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7132. /**
  7133. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7134. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7135. * @param frustumPlanes defines the frustum planes to test
  7136. * @return true if there is an intersection
  7137. */
  7138. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7139. }
  7140. }
  7141. declare module BABYLON {
  7142. /** @hidden */
  7143. export class Collider {
  7144. /** Define if a collision was found */
  7145. collisionFound: boolean;
  7146. /**
  7147. * Define last intersection point in local space
  7148. */
  7149. intersectionPoint: Vector3;
  7150. /**
  7151. * Define last collided mesh
  7152. */
  7153. collidedMesh: Nullable<AbstractMesh>;
  7154. private _collisionPoint;
  7155. private _planeIntersectionPoint;
  7156. private _tempVector;
  7157. private _tempVector2;
  7158. private _tempVector3;
  7159. private _tempVector4;
  7160. private _edge;
  7161. private _baseToVertex;
  7162. private _destinationPoint;
  7163. private _slidePlaneNormal;
  7164. private _displacementVector;
  7165. /** @hidden */
  7166. _radius: Vector3;
  7167. /** @hidden */
  7168. _retry: number;
  7169. private _velocity;
  7170. private _basePoint;
  7171. private _epsilon;
  7172. /** @hidden */
  7173. _velocityWorldLength: number;
  7174. /** @hidden */
  7175. _basePointWorld: Vector3;
  7176. private _velocityWorld;
  7177. private _normalizedVelocity;
  7178. /** @hidden */
  7179. _initialVelocity: Vector3;
  7180. /** @hidden */
  7181. _initialPosition: Vector3;
  7182. private _nearestDistance;
  7183. private _collisionMask;
  7184. get collisionMask(): number;
  7185. set collisionMask(mask: number);
  7186. /**
  7187. * Gets the plane normal used to compute the sliding response (in local space)
  7188. */
  7189. get slidePlaneNormal(): Vector3;
  7190. /** @hidden */
  7191. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7192. /** @hidden */
  7193. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7194. /** @hidden */
  7195. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7196. /** @hidden */
  7197. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7198. /** @hidden */
  7199. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7200. /** @hidden */
  7201. _getResponse(pos: Vector3, vel: Vector3): void;
  7202. }
  7203. }
  7204. declare module BABYLON {
  7205. /**
  7206. * Interface for cullable objects
  7207. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7208. */
  7209. export interface ICullable {
  7210. /**
  7211. * Checks if the object or part of the object is in the frustum
  7212. * @param frustumPlanes Camera near/planes
  7213. * @returns true if the object is in frustum otherwise false
  7214. */
  7215. isInFrustum(frustumPlanes: Plane[]): boolean;
  7216. /**
  7217. * Checks if a cullable object (mesh...) is in the camera frustum
  7218. * Unlike isInFrustum this cheks the full bounding box
  7219. * @param frustumPlanes Camera near/planes
  7220. * @returns true if the object is in frustum otherwise false
  7221. */
  7222. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7223. }
  7224. /**
  7225. * Info for a bounding data of a mesh
  7226. */
  7227. export class BoundingInfo implements ICullable {
  7228. /**
  7229. * Bounding box for the mesh
  7230. */
  7231. readonly boundingBox: BoundingBox;
  7232. /**
  7233. * Bounding sphere for the mesh
  7234. */
  7235. readonly boundingSphere: BoundingSphere;
  7236. private _isLocked;
  7237. private static readonly TmpVector3;
  7238. /**
  7239. * Constructs bounding info
  7240. * @param minimum min vector of the bounding box/sphere
  7241. * @param maximum max vector of the bounding box/sphere
  7242. * @param worldMatrix defines the new world matrix
  7243. */
  7244. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7245. /**
  7246. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7247. * @param min defines the new minimum vector (in local space)
  7248. * @param max defines the new maximum vector (in local space)
  7249. * @param worldMatrix defines the new world matrix
  7250. */
  7251. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7252. /**
  7253. * min vector of the bounding box/sphere
  7254. */
  7255. get minimum(): Vector3;
  7256. /**
  7257. * max vector of the bounding box/sphere
  7258. */
  7259. get maximum(): Vector3;
  7260. /**
  7261. * If the info is locked and won't be updated to avoid perf overhead
  7262. */
  7263. get isLocked(): boolean;
  7264. set isLocked(value: boolean);
  7265. /**
  7266. * Updates the bounding sphere and box
  7267. * @param world world matrix to be used to update
  7268. */
  7269. update(world: DeepImmutable<Matrix>): void;
  7270. /**
  7271. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7272. * @param center New center of the bounding info
  7273. * @param extend New extend of the bounding info
  7274. * @returns the current bounding info
  7275. */
  7276. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7277. /**
  7278. * Scale the current bounding info by applying a scale factor
  7279. * @param factor defines the scale factor to apply
  7280. * @returns the current bounding info
  7281. */
  7282. scale(factor: number): BoundingInfo;
  7283. /**
  7284. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7285. * @param frustumPlanes defines the frustum to test
  7286. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7287. * @returns true if the bounding info is in the frustum planes
  7288. */
  7289. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7290. /**
  7291. * Gets the world distance between the min and max points of the bounding box
  7292. */
  7293. get diagonalLength(): number;
  7294. /**
  7295. * Checks if a cullable object (mesh...) is in the camera frustum
  7296. * Unlike isInFrustum this cheks the full bounding box
  7297. * @param frustumPlanes Camera near/planes
  7298. * @returns true if the object is in frustum otherwise false
  7299. */
  7300. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7301. /** @hidden */
  7302. _checkCollision(collider: Collider): boolean;
  7303. /**
  7304. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7305. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7306. * @param point the point to check intersection with
  7307. * @returns if the point intersects
  7308. */
  7309. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7310. /**
  7311. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7312. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7313. * @param boundingInfo the bounding info to check intersection with
  7314. * @param precise if the intersection should be done using OBB
  7315. * @returns if the bounding info intersects
  7316. */
  7317. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7318. }
  7319. }
  7320. declare module BABYLON {
  7321. /**
  7322. * Extracts minimum and maximum values from a list of indexed positions
  7323. * @param positions defines the positions to use
  7324. * @param indices defines the indices to the positions
  7325. * @param indexStart defines the start index
  7326. * @param indexCount defines the end index
  7327. * @param bias defines bias value to add to the result
  7328. * @return minimum and maximum values
  7329. */
  7330. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7331. minimum: Vector3;
  7332. maximum: Vector3;
  7333. };
  7334. /**
  7335. * Extracts minimum and maximum values from a list of positions
  7336. * @param positions defines the positions to use
  7337. * @param start defines the start index in the positions array
  7338. * @param count defines the number of positions to handle
  7339. * @param bias defines bias value to add to the result
  7340. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7341. * @return minimum and maximum values
  7342. */
  7343. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7344. minimum: Vector3;
  7345. maximum: Vector3;
  7346. };
  7347. }
  7348. declare module BABYLON {
  7349. /** @hidden */
  7350. export class WebGLDataBuffer extends DataBuffer {
  7351. private _buffer;
  7352. constructor(resource: WebGLBuffer);
  7353. get underlyingResource(): any;
  7354. }
  7355. }
  7356. declare module BABYLON {
  7357. /** @hidden */
  7358. export class WebGLPipelineContext implements IPipelineContext {
  7359. engine: ThinEngine;
  7360. program: Nullable<WebGLProgram>;
  7361. context?: WebGLRenderingContext;
  7362. vertexShader?: WebGLShader;
  7363. fragmentShader?: WebGLShader;
  7364. isParallelCompiled: boolean;
  7365. onCompiled?: () => void;
  7366. transformFeedback?: WebGLTransformFeedback | null;
  7367. vertexCompilationError: Nullable<string>;
  7368. fragmentCompilationError: Nullable<string>;
  7369. programLinkError: Nullable<string>;
  7370. programValidationError: Nullable<string>;
  7371. get isAsync(): boolean;
  7372. get isReady(): boolean;
  7373. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7374. _getVertexShaderCode(): string | null;
  7375. _getFragmentShaderCode(): string | null;
  7376. }
  7377. }
  7378. declare module BABYLON {
  7379. interface ThinEngine {
  7380. /**
  7381. * Create an uniform buffer
  7382. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7383. * @param elements defines the content of the uniform buffer
  7384. * @returns the webGL uniform buffer
  7385. */
  7386. createUniformBuffer(elements: FloatArray): DataBuffer;
  7387. /**
  7388. * Create a dynamic uniform buffer
  7389. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7390. * @param elements defines the content of the uniform buffer
  7391. * @returns the webGL uniform buffer
  7392. */
  7393. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7394. /**
  7395. * Update an existing uniform buffer
  7396. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7397. * @param uniformBuffer defines the target uniform buffer
  7398. * @param elements defines the content to update
  7399. * @param offset defines the offset in the uniform buffer where update should start
  7400. * @param count defines the size of the data to update
  7401. */
  7402. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7403. /**
  7404. * Bind an uniform buffer to the current webGL context
  7405. * @param buffer defines the buffer to bind
  7406. */
  7407. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7408. /**
  7409. * Bind a buffer to the current webGL context at a given location
  7410. * @param buffer defines the buffer to bind
  7411. * @param location defines the index where to bind the buffer
  7412. */
  7413. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7414. /**
  7415. * Bind a specific block at a given index in a specific shader program
  7416. * @param pipelineContext defines the pipeline context to use
  7417. * @param blockName defines the block name
  7418. * @param index defines the index where to bind the block
  7419. */
  7420. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7421. }
  7422. }
  7423. declare module BABYLON {
  7424. /**
  7425. * Uniform buffer objects.
  7426. *
  7427. * Handles blocks of uniform on the GPU.
  7428. *
  7429. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7430. *
  7431. * For more information, please refer to :
  7432. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7433. */
  7434. export class UniformBuffer {
  7435. private _engine;
  7436. private _buffer;
  7437. private _data;
  7438. private _bufferData;
  7439. private _dynamic?;
  7440. private _uniformLocations;
  7441. private _uniformSizes;
  7442. private _uniformLocationPointer;
  7443. private _needSync;
  7444. private _noUBO;
  7445. private _currentEffect;
  7446. /** @hidden */
  7447. _alreadyBound: boolean;
  7448. private static _MAX_UNIFORM_SIZE;
  7449. private static _tempBuffer;
  7450. /**
  7451. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7452. * This is dynamic to allow compat with webgl 1 and 2.
  7453. * You will need to pass the name of the uniform as well as the value.
  7454. */
  7455. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7456. /**
  7457. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7458. * This is dynamic to allow compat with webgl 1 and 2.
  7459. * You will need to pass the name of the uniform as well as the value.
  7460. */
  7461. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7462. /**
  7463. * Lambda to Update a single float in a uniform buffer.
  7464. * This is dynamic to allow compat with webgl 1 and 2.
  7465. * You will need to pass the name of the uniform as well as the value.
  7466. */
  7467. updateFloat: (name: string, x: number) => void;
  7468. /**
  7469. * Lambda to Update a vec2 of float in a uniform buffer.
  7470. * This is dynamic to allow compat with webgl 1 and 2.
  7471. * You will need to pass the name of the uniform as well as the value.
  7472. */
  7473. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7474. /**
  7475. * Lambda to Update a vec3 of float in a uniform buffer.
  7476. * This is dynamic to allow compat with webgl 1 and 2.
  7477. * You will need to pass the name of the uniform as well as the value.
  7478. */
  7479. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7480. /**
  7481. * Lambda to Update a vec4 of float in a uniform buffer.
  7482. * This is dynamic to allow compat with webgl 1 and 2.
  7483. * You will need to pass the name of the uniform as well as the value.
  7484. */
  7485. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7486. /**
  7487. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7488. * This is dynamic to allow compat with webgl 1 and 2.
  7489. * You will need to pass the name of the uniform as well as the value.
  7490. */
  7491. updateMatrix: (name: string, mat: Matrix) => void;
  7492. /**
  7493. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7494. * This is dynamic to allow compat with webgl 1 and 2.
  7495. * You will need to pass the name of the uniform as well as the value.
  7496. */
  7497. updateVector3: (name: string, vector: Vector3) => void;
  7498. /**
  7499. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7500. * This is dynamic to allow compat with webgl 1 and 2.
  7501. * You will need to pass the name of the uniform as well as the value.
  7502. */
  7503. updateVector4: (name: string, vector: Vector4) => void;
  7504. /**
  7505. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7506. * This is dynamic to allow compat with webgl 1 and 2.
  7507. * You will need to pass the name of the uniform as well as the value.
  7508. */
  7509. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7510. /**
  7511. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7512. * This is dynamic to allow compat with webgl 1 and 2.
  7513. * You will need to pass the name of the uniform as well as the value.
  7514. */
  7515. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7516. /**
  7517. * Instantiates a new Uniform buffer objects.
  7518. *
  7519. * Handles blocks of uniform on the GPU.
  7520. *
  7521. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7522. *
  7523. * For more information, please refer to :
  7524. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7525. * @param engine Define the engine the buffer is associated with
  7526. * @param data Define the data contained in the buffer
  7527. * @param dynamic Define if the buffer is updatable
  7528. */
  7529. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7530. /**
  7531. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7532. * or just falling back on setUniformXXX calls.
  7533. */
  7534. get useUbo(): boolean;
  7535. /**
  7536. * Indicates if the WebGL underlying uniform buffer is in sync
  7537. * with the javascript cache data.
  7538. */
  7539. get isSync(): boolean;
  7540. /**
  7541. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7542. * Also, a dynamic UniformBuffer will disable cache verification and always
  7543. * update the underlying WebGL uniform buffer to the GPU.
  7544. * @returns if Dynamic, otherwise false
  7545. */
  7546. isDynamic(): boolean;
  7547. /**
  7548. * The data cache on JS side.
  7549. * @returns the underlying data as a float array
  7550. */
  7551. getData(): Float32Array;
  7552. /**
  7553. * The underlying WebGL Uniform buffer.
  7554. * @returns the webgl buffer
  7555. */
  7556. getBuffer(): Nullable<DataBuffer>;
  7557. /**
  7558. * std140 layout specifies how to align data within an UBO structure.
  7559. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7560. * for specs.
  7561. */
  7562. private _fillAlignment;
  7563. /**
  7564. * Adds an uniform in the buffer.
  7565. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7566. * for the layout to be correct !
  7567. * @param name Name of the uniform, as used in the uniform block in the shader.
  7568. * @param size Data size, or data directly.
  7569. */
  7570. addUniform(name: string, size: number | number[]): void;
  7571. /**
  7572. * Adds a Matrix 4x4 to the uniform buffer.
  7573. * @param name Name of the uniform, as used in the uniform block in the shader.
  7574. * @param mat A 4x4 matrix.
  7575. */
  7576. addMatrix(name: string, mat: Matrix): void;
  7577. /**
  7578. * Adds a vec2 to the uniform buffer.
  7579. * @param name Name of the uniform, as used in the uniform block in the shader.
  7580. * @param x Define the x component value of the vec2
  7581. * @param y Define the y component value of the vec2
  7582. */
  7583. addFloat2(name: string, x: number, y: number): void;
  7584. /**
  7585. * Adds a vec3 to the uniform buffer.
  7586. * @param name Name of the uniform, as used in the uniform block in the shader.
  7587. * @param x Define the x component value of the vec3
  7588. * @param y Define the y component value of the vec3
  7589. * @param z Define the z component value of the vec3
  7590. */
  7591. addFloat3(name: string, x: number, y: number, z: number): void;
  7592. /**
  7593. * Adds a vec3 to the uniform buffer.
  7594. * @param name Name of the uniform, as used in the uniform block in the shader.
  7595. * @param color Define the vec3 from a Color
  7596. */
  7597. addColor3(name: string, color: Color3): void;
  7598. /**
  7599. * Adds a vec4 to the uniform buffer.
  7600. * @param name Name of the uniform, as used in the uniform block in the shader.
  7601. * @param color Define the rgb components from a Color
  7602. * @param alpha Define the a component of the vec4
  7603. */
  7604. addColor4(name: string, color: Color3, alpha: number): void;
  7605. /**
  7606. * Adds a vec3 to the uniform buffer.
  7607. * @param name Name of the uniform, as used in the uniform block in the shader.
  7608. * @param vector Define the vec3 components from a Vector
  7609. */
  7610. addVector3(name: string, vector: Vector3): void;
  7611. /**
  7612. * Adds a Matrix 3x3 to the uniform buffer.
  7613. * @param name Name of the uniform, as used in the uniform block in the shader.
  7614. */
  7615. addMatrix3x3(name: string): void;
  7616. /**
  7617. * Adds a Matrix 2x2 to the uniform buffer.
  7618. * @param name Name of the uniform, as used in the uniform block in the shader.
  7619. */
  7620. addMatrix2x2(name: string): void;
  7621. /**
  7622. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7623. */
  7624. create(): void;
  7625. /** @hidden */
  7626. _rebuild(): void;
  7627. /**
  7628. * Updates the WebGL Uniform Buffer on the GPU.
  7629. * If the `dynamic` flag is set to true, no cache comparison is done.
  7630. * Otherwise, the buffer will be updated only if the cache differs.
  7631. */
  7632. update(): void;
  7633. /**
  7634. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7635. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7636. * @param data Define the flattened data
  7637. * @param size Define the size of the data.
  7638. */
  7639. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7640. private _valueCache;
  7641. private _cacheMatrix;
  7642. private _updateMatrix3x3ForUniform;
  7643. private _updateMatrix3x3ForEffect;
  7644. private _updateMatrix2x2ForEffect;
  7645. private _updateMatrix2x2ForUniform;
  7646. private _updateFloatForEffect;
  7647. private _updateFloatForUniform;
  7648. private _updateFloat2ForEffect;
  7649. private _updateFloat2ForUniform;
  7650. private _updateFloat3ForEffect;
  7651. private _updateFloat3ForUniform;
  7652. private _updateFloat4ForEffect;
  7653. private _updateFloat4ForUniform;
  7654. private _updateMatrixForEffect;
  7655. private _updateMatrixForUniform;
  7656. private _updateVector3ForEffect;
  7657. private _updateVector3ForUniform;
  7658. private _updateVector4ForEffect;
  7659. private _updateVector4ForUniform;
  7660. private _updateColor3ForEffect;
  7661. private _updateColor3ForUniform;
  7662. private _updateColor4ForEffect;
  7663. private _updateColor4ForUniform;
  7664. /**
  7665. * Sets a sampler uniform on the effect.
  7666. * @param name Define the name of the sampler.
  7667. * @param texture Define the texture to set in the sampler
  7668. */
  7669. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7670. /**
  7671. * Directly updates the value of the uniform in the cache AND on the GPU.
  7672. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7673. * @param data Define the flattened data
  7674. */
  7675. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7676. /**
  7677. * Binds this uniform buffer to an effect.
  7678. * @param effect Define the effect to bind the buffer to
  7679. * @param name Name of the uniform block in the shader.
  7680. */
  7681. bindToEffect(effect: Effect, name: string): void;
  7682. /**
  7683. * Disposes the uniform buffer.
  7684. */
  7685. dispose(): void;
  7686. }
  7687. }
  7688. declare module BABYLON {
  7689. /**
  7690. * Enum that determines the text-wrapping mode to use.
  7691. */
  7692. export enum InspectableType {
  7693. /**
  7694. * Checkbox for booleans
  7695. */
  7696. Checkbox = 0,
  7697. /**
  7698. * Sliders for numbers
  7699. */
  7700. Slider = 1,
  7701. /**
  7702. * Vector3
  7703. */
  7704. Vector3 = 2,
  7705. /**
  7706. * Quaternions
  7707. */
  7708. Quaternion = 3,
  7709. /**
  7710. * Color3
  7711. */
  7712. Color3 = 4,
  7713. /**
  7714. * String
  7715. */
  7716. String = 5
  7717. }
  7718. /**
  7719. * Interface used to define custom inspectable properties.
  7720. * This interface is used by the inspector to display custom property grids
  7721. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7722. */
  7723. export interface IInspectable {
  7724. /**
  7725. * Gets the label to display
  7726. */
  7727. label: string;
  7728. /**
  7729. * Gets the name of the property to edit
  7730. */
  7731. propertyName: string;
  7732. /**
  7733. * Gets the type of the editor to use
  7734. */
  7735. type: InspectableType;
  7736. /**
  7737. * Gets the minimum value of the property when using in "slider" mode
  7738. */
  7739. min?: number;
  7740. /**
  7741. * Gets the maximum value of the property when using in "slider" mode
  7742. */
  7743. max?: number;
  7744. /**
  7745. * Gets the setp to use when using in "slider" mode
  7746. */
  7747. step?: number;
  7748. }
  7749. }
  7750. declare module BABYLON {
  7751. /**
  7752. * Class used to provide helper for timing
  7753. */
  7754. export class TimingTools {
  7755. /**
  7756. * Polyfill for setImmediate
  7757. * @param action defines the action to execute after the current execution block
  7758. */
  7759. static SetImmediate(action: () => void): void;
  7760. }
  7761. }
  7762. declare module BABYLON {
  7763. /**
  7764. * Class used to enable instatition of objects by class name
  7765. */
  7766. export class InstantiationTools {
  7767. /**
  7768. * Use this object to register external classes like custom textures or material
  7769. * to allow the laoders to instantiate them
  7770. */
  7771. static RegisteredExternalClasses: {
  7772. [key: string]: Object;
  7773. };
  7774. /**
  7775. * Tries to instantiate a new object from a given class name
  7776. * @param className defines the class name to instantiate
  7777. * @returns the new object or null if the system was not able to do the instantiation
  7778. */
  7779. static Instantiate(className: string): any;
  7780. }
  7781. }
  7782. declare module BABYLON {
  7783. /**
  7784. * Define options used to create a depth texture
  7785. */
  7786. export class DepthTextureCreationOptions {
  7787. /** Specifies whether or not a stencil should be allocated in the texture */
  7788. generateStencil?: boolean;
  7789. /** Specifies whether or not bilinear filtering is enable on the texture */
  7790. bilinearFiltering?: boolean;
  7791. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7792. comparisonFunction?: number;
  7793. /** Specifies if the created texture is a cube texture */
  7794. isCube?: boolean;
  7795. }
  7796. }
  7797. declare module BABYLON {
  7798. interface ThinEngine {
  7799. /**
  7800. * Creates a depth stencil cube texture.
  7801. * This is only available in WebGL 2.
  7802. * @param size The size of face edge in the cube texture.
  7803. * @param options The options defining the cube texture.
  7804. * @returns The cube texture
  7805. */
  7806. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7807. /**
  7808. * Creates a cube texture
  7809. * @param rootUrl defines the url where the files to load is located
  7810. * @param scene defines the current scene
  7811. * @param files defines the list of files to load (1 per face)
  7812. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7813. * @param onLoad defines an optional callback raised when the texture is loaded
  7814. * @param onError defines an optional callback raised if there is an issue to load the texture
  7815. * @param format defines the format of the data
  7816. * @param forcedExtension defines the extension to use to pick the right loader
  7817. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7818. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7819. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7820. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7821. * @param loaderOptions options to be passed to the loader
  7822. * @returns the cube texture as an InternalTexture
  7823. */
  7824. 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;
  7825. /**
  7826. * Creates a cube texture
  7827. * @param rootUrl defines the url where the files to load is located
  7828. * @param scene defines the current scene
  7829. * @param files defines the list of files to load (1 per face)
  7830. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7831. * @param onLoad defines an optional callback raised when the texture is loaded
  7832. * @param onError defines an optional callback raised if there is an issue to load the texture
  7833. * @param format defines the format of the data
  7834. * @param forcedExtension defines the extension to use to pick the right loader
  7835. * @returns the cube texture as an InternalTexture
  7836. */
  7837. 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;
  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. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7849. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7850. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7851. * @returns the cube texture as an InternalTexture
  7852. */
  7853. 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;
  7854. /** @hidden */
  7855. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7856. /** @hidden */
  7857. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7858. /** @hidden */
  7859. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7860. /** @hidden */
  7861. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7862. /**
  7863. * @hidden
  7864. */
  7865. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  7866. }
  7867. }
  7868. declare module BABYLON {
  7869. /**
  7870. * Class for creating a cube texture
  7871. */
  7872. export class CubeTexture extends BaseTexture {
  7873. private _delayedOnLoad;
  7874. /**
  7875. * Observable triggered once the texture has been loaded.
  7876. */
  7877. onLoadObservable: Observable<CubeTexture>;
  7878. /**
  7879. * The url of the texture
  7880. */
  7881. url: string;
  7882. /**
  7883. * Gets or sets the center of the bounding box associated with the cube texture.
  7884. * It must define where the camera used to render the texture was set
  7885. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7886. */
  7887. boundingBoxPosition: Vector3;
  7888. private _boundingBoxSize;
  7889. /**
  7890. * Gets or sets the size of the bounding box associated with the cube texture
  7891. * When defined, the cubemap will switch to local mode
  7892. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7893. * @example https://www.babylonjs-playground.com/#RNASML
  7894. */
  7895. set boundingBoxSize(value: Vector3);
  7896. /**
  7897. * Returns the bounding box size
  7898. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7899. */
  7900. get boundingBoxSize(): Vector3;
  7901. protected _rotationY: number;
  7902. /**
  7903. * Sets texture matrix rotation angle around Y axis in radians.
  7904. */
  7905. set rotationY(value: number);
  7906. /**
  7907. * Gets texture matrix rotation angle around Y axis radians.
  7908. */
  7909. get rotationY(): number;
  7910. /**
  7911. * Are mip maps generated for this texture or not.
  7912. */
  7913. get noMipmap(): boolean;
  7914. private _noMipmap;
  7915. private _files;
  7916. protected _forcedExtension: Nullable<string>;
  7917. private _extensions;
  7918. private _textureMatrix;
  7919. private _format;
  7920. private _createPolynomials;
  7921. private _loaderOptions;
  7922. /**
  7923. * Creates a cube texture from an array of image urls
  7924. * @param files defines an array of image urls
  7925. * @param scene defines the hosting scene
  7926. * @param noMipmap specifies if mip maps are not used
  7927. * @returns a cube texture
  7928. */
  7929. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7930. /**
  7931. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7932. * @param url defines the url of the prefiltered texture
  7933. * @param scene defines the scene the texture is attached to
  7934. * @param forcedExtension defines the extension of the file if different from the url
  7935. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7936. * @return the prefiltered texture
  7937. */
  7938. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7939. /**
  7940. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7941. * as prefiltered data.
  7942. * @param rootUrl defines the url of the texture or the root name of the six images
  7943. * @param null defines the scene or engine the texture is attached to
  7944. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7945. * @param noMipmap defines if mipmaps should be created or not
  7946. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7947. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7948. * @param onError defines a callback triggered in case of error during load
  7949. * @param format defines the internal format to use for the texture once loaded
  7950. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7951. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7952. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7953. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7954. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7955. * @param loaderOptions options to be passed to the loader
  7956. * @return the cube texture
  7957. */
  7958. 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);
  7959. /**
  7960. * Get the current class name of the texture useful for serialization or dynamic coding.
  7961. * @returns "CubeTexture"
  7962. */
  7963. getClassName(): string;
  7964. /**
  7965. * Update the url (and optional buffer) of this texture if url was null during construction.
  7966. * @param url the url of the texture
  7967. * @param forcedExtension defines the extension to use
  7968. * @param onLoad callback called when the texture is loaded (defaults to null)
  7969. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7970. */
  7971. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7972. /**
  7973. * Delays loading of the cube texture
  7974. * @param forcedExtension defines the extension to use
  7975. */
  7976. delayLoad(forcedExtension?: string): void;
  7977. /**
  7978. * Returns the reflection texture matrix
  7979. * @returns the reflection texture matrix
  7980. */
  7981. getReflectionTextureMatrix(): Matrix;
  7982. /**
  7983. * Sets the reflection texture matrix
  7984. * @param value Reflection texture matrix
  7985. */
  7986. setReflectionTextureMatrix(value: Matrix): void;
  7987. /**
  7988. * Parses text to create a cube texture
  7989. * @param parsedTexture define the serialized text to read from
  7990. * @param scene defines the hosting scene
  7991. * @param rootUrl defines the root url of the cube texture
  7992. * @returns a cube texture
  7993. */
  7994. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7995. /**
  7996. * Makes a clone, or deep copy, of the cube texture
  7997. * @returns a new cube texture
  7998. */
  7999. clone(): CubeTexture;
  8000. }
  8001. }
  8002. declare module BABYLON {
  8003. /**
  8004. * Manages the defines for the Material
  8005. */
  8006. export class MaterialDefines {
  8007. /** @hidden */
  8008. protected _keys: string[];
  8009. private _isDirty;
  8010. /** @hidden */
  8011. _renderId: number;
  8012. /** @hidden */
  8013. _areLightsDirty: boolean;
  8014. /** @hidden */
  8015. _areLightsDisposed: boolean;
  8016. /** @hidden */
  8017. _areAttributesDirty: boolean;
  8018. /** @hidden */
  8019. _areTexturesDirty: boolean;
  8020. /** @hidden */
  8021. _areFresnelDirty: boolean;
  8022. /** @hidden */
  8023. _areMiscDirty: boolean;
  8024. /** @hidden */
  8025. _arePrePassDirty: boolean;
  8026. /** @hidden */
  8027. _areImageProcessingDirty: boolean;
  8028. /** @hidden */
  8029. _normals: boolean;
  8030. /** @hidden */
  8031. _uvs: boolean;
  8032. /** @hidden */
  8033. _needNormals: boolean;
  8034. /** @hidden */
  8035. _needUVs: boolean;
  8036. [id: string]: any;
  8037. /**
  8038. * Specifies if the material needs to be re-calculated
  8039. */
  8040. get isDirty(): boolean;
  8041. /**
  8042. * Marks the material to indicate that it has been re-calculated
  8043. */
  8044. markAsProcessed(): void;
  8045. /**
  8046. * Marks the material to indicate that it needs to be re-calculated
  8047. */
  8048. markAsUnprocessed(): void;
  8049. /**
  8050. * Marks the material to indicate all of its defines need to be re-calculated
  8051. */
  8052. markAllAsDirty(): void;
  8053. /**
  8054. * Marks the material to indicate that image processing needs to be re-calculated
  8055. */
  8056. markAsImageProcessingDirty(): void;
  8057. /**
  8058. * Marks the material to indicate the lights need to be re-calculated
  8059. * @param disposed Defines whether the light is dirty due to dispose or not
  8060. */
  8061. markAsLightDirty(disposed?: boolean): void;
  8062. /**
  8063. * Marks the attribute state as changed
  8064. */
  8065. markAsAttributesDirty(): void;
  8066. /**
  8067. * Marks the texture state as changed
  8068. */
  8069. markAsTexturesDirty(): void;
  8070. /**
  8071. * Marks the fresnel state as changed
  8072. */
  8073. markAsFresnelDirty(): void;
  8074. /**
  8075. * Marks the misc state as changed
  8076. */
  8077. markAsMiscDirty(): void;
  8078. /**
  8079. * Marks the prepass state as changed
  8080. */
  8081. markAsPrePassDirty(): void;
  8082. /**
  8083. * Rebuilds the material defines
  8084. */
  8085. rebuild(): void;
  8086. /**
  8087. * Specifies if two material defines are equal
  8088. * @param other - A material define instance to compare to
  8089. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8090. */
  8091. isEqual(other: MaterialDefines): boolean;
  8092. /**
  8093. * Clones this instance's defines to another instance
  8094. * @param other - material defines to clone values to
  8095. */
  8096. cloneTo(other: MaterialDefines): void;
  8097. /**
  8098. * Resets the material define values
  8099. */
  8100. reset(): void;
  8101. /**
  8102. * Converts the material define values to a string
  8103. * @returns - String of material define information
  8104. */
  8105. toString(): string;
  8106. }
  8107. }
  8108. declare module BABYLON {
  8109. /**
  8110. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8111. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8112. * 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;
  8113. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8114. */
  8115. export class ColorCurves {
  8116. private _dirty;
  8117. private _tempColor;
  8118. private _globalCurve;
  8119. private _highlightsCurve;
  8120. private _midtonesCurve;
  8121. private _shadowsCurve;
  8122. private _positiveCurve;
  8123. private _negativeCurve;
  8124. private _globalHue;
  8125. private _globalDensity;
  8126. private _globalSaturation;
  8127. private _globalExposure;
  8128. /**
  8129. * Gets the global Hue value.
  8130. * 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).
  8131. */
  8132. get globalHue(): number;
  8133. /**
  8134. * Sets the global Hue value.
  8135. * 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).
  8136. */
  8137. set globalHue(value: number);
  8138. /**
  8139. * Gets the global Density value.
  8140. * 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.
  8141. * Values less than zero provide a filter of opposite hue.
  8142. */
  8143. get globalDensity(): number;
  8144. /**
  8145. * Sets the global Density value.
  8146. * 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.
  8147. * Values less than zero provide a filter of opposite hue.
  8148. */
  8149. set globalDensity(value: number);
  8150. /**
  8151. * Gets the global Saturation value.
  8152. * 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.
  8153. */
  8154. get globalSaturation(): number;
  8155. /**
  8156. * Sets the global Saturation value.
  8157. * 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.
  8158. */
  8159. set globalSaturation(value: number);
  8160. /**
  8161. * Gets the global Exposure value.
  8162. * 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.
  8163. */
  8164. get globalExposure(): number;
  8165. /**
  8166. * Sets the global Exposure value.
  8167. * 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.
  8168. */
  8169. set globalExposure(value: number);
  8170. private _highlightsHue;
  8171. private _highlightsDensity;
  8172. private _highlightsSaturation;
  8173. private _highlightsExposure;
  8174. /**
  8175. * Gets the highlights Hue value.
  8176. * 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).
  8177. */
  8178. get highlightsHue(): number;
  8179. /**
  8180. * Sets the highlights Hue value.
  8181. * 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).
  8182. */
  8183. set highlightsHue(value: number);
  8184. /**
  8185. * Gets the highlights Density value.
  8186. * 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.
  8187. * Values less than zero provide a filter of opposite hue.
  8188. */
  8189. get highlightsDensity(): number;
  8190. /**
  8191. * Sets the highlights Density value.
  8192. * 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.
  8193. * Values less than zero provide a filter of opposite hue.
  8194. */
  8195. set highlightsDensity(value: number);
  8196. /**
  8197. * Gets the highlights Saturation value.
  8198. * 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.
  8199. */
  8200. get highlightsSaturation(): number;
  8201. /**
  8202. * Sets the highlights Saturation value.
  8203. * 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.
  8204. */
  8205. set highlightsSaturation(value: number);
  8206. /**
  8207. * Gets the highlights Exposure value.
  8208. * 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.
  8209. */
  8210. get highlightsExposure(): number;
  8211. /**
  8212. * Sets the highlights Exposure value.
  8213. * 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.
  8214. */
  8215. set highlightsExposure(value: number);
  8216. private _midtonesHue;
  8217. private _midtonesDensity;
  8218. private _midtonesSaturation;
  8219. private _midtonesExposure;
  8220. /**
  8221. * Gets the midtones Hue value.
  8222. * 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).
  8223. */
  8224. get midtonesHue(): number;
  8225. /**
  8226. * Sets the midtones Hue value.
  8227. * 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).
  8228. */
  8229. set midtonesHue(value: number);
  8230. /**
  8231. * Gets the midtones Density value.
  8232. * 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.
  8233. * Values less than zero provide a filter of opposite hue.
  8234. */
  8235. get midtonesDensity(): number;
  8236. /**
  8237. * Sets the midtones Density value.
  8238. * 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.
  8239. * Values less than zero provide a filter of opposite hue.
  8240. */
  8241. set midtonesDensity(value: number);
  8242. /**
  8243. * Gets the midtones Saturation value.
  8244. * 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.
  8245. */
  8246. get midtonesSaturation(): number;
  8247. /**
  8248. * Sets the midtones Saturation value.
  8249. * 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.
  8250. */
  8251. set midtonesSaturation(value: number);
  8252. /**
  8253. * Gets the midtones Exposure value.
  8254. * 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.
  8255. */
  8256. get midtonesExposure(): number;
  8257. /**
  8258. * Sets the midtones Exposure value.
  8259. * 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.
  8260. */
  8261. set midtonesExposure(value: number);
  8262. private _shadowsHue;
  8263. private _shadowsDensity;
  8264. private _shadowsSaturation;
  8265. private _shadowsExposure;
  8266. /**
  8267. * Gets the shadows Hue value.
  8268. * 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).
  8269. */
  8270. get shadowsHue(): number;
  8271. /**
  8272. * Sets the shadows Hue value.
  8273. * 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).
  8274. */
  8275. set shadowsHue(value: number);
  8276. /**
  8277. * Gets the shadows Density value.
  8278. * 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.
  8279. * Values less than zero provide a filter of opposite hue.
  8280. */
  8281. get shadowsDensity(): number;
  8282. /**
  8283. * Sets the shadows Density value.
  8284. * 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.
  8285. * Values less than zero provide a filter of opposite hue.
  8286. */
  8287. set shadowsDensity(value: number);
  8288. /**
  8289. * Gets the shadows Saturation value.
  8290. * 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.
  8291. */
  8292. get shadowsSaturation(): number;
  8293. /**
  8294. * Sets the shadows Saturation value.
  8295. * 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.
  8296. */
  8297. set shadowsSaturation(value: number);
  8298. /**
  8299. * Gets the shadows Exposure value.
  8300. * 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.
  8301. */
  8302. get shadowsExposure(): number;
  8303. /**
  8304. * Sets the shadows Exposure value.
  8305. * 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.
  8306. */
  8307. set shadowsExposure(value: number);
  8308. /**
  8309. * Returns the class name
  8310. * @returns The class name
  8311. */
  8312. getClassName(): string;
  8313. /**
  8314. * Binds the color curves to the shader.
  8315. * @param colorCurves The color curve to bind
  8316. * @param effect The effect to bind to
  8317. * @param positiveUniform The positive uniform shader parameter
  8318. * @param neutralUniform The neutral uniform shader parameter
  8319. * @param negativeUniform The negative uniform shader parameter
  8320. */
  8321. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8322. /**
  8323. * Prepare the list of uniforms associated with the ColorCurves effects.
  8324. * @param uniformsList The list of uniforms used in the effect
  8325. */
  8326. static PrepareUniforms(uniformsList: string[]): void;
  8327. /**
  8328. * Returns color grading data based on a hue, density, saturation and exposure value.
  8329. * @param filterHue The hue of the color filter.
  8330. * @param filterDensity The density of the color filter.
  8331. * @param saturation The saturation.
  8332. * @param exposure The exposure.
  8333. * @param result The result data container.
  8334. */
  8335. private getColorGradingDataToRef;
  8336. /**
  8337. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8338. * @param value The input slider value in range [-100,100].
  8339. * @returns Adjusted value.
  8340. */
  8341. private static applyColorGradingSliderNonlinear;
  8342. /**
  8343. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8344. * @param hue The hue (H) input.
  8345. * @param saturation The saturation (S) input.
  8346. * @param brightness The brightness (B) input.
  8347. * @result An RGBA color represented as Vector4.
  8348. */
  8349. private static fromHSBToRef;
  8350. /**
  8351. * Returns a value clamped between min and max
  8352. * @param value The value to clamp
  8353. * @param min The minimum of value
  8354. * @param max The maximum of value
  8355. * @returns The clamped value.
  8356. */
  8357. private static clamp;
  8358. /**
  8359. * Clones the current color curve instance.
  8360. * @return The cloned curves
  8361. */
  8362. clone(): ColorCurves;
  8363. /**
  8364. * Serializes the current color curve instance to a json representation.
  8365. * @return a JSON representation
  8366. */
  8367. serialize(): any;
  8368. /**
  8369. * Parses the color curve from a json representation.
  8370. * @param source the JSON source to parse
  8371. * @return The parsed curves
  8372. */
  8373. static Parse(source: any): ColorCurves;
  8374. }
  8375. }
  8376. declare module BABYLON {
  8377. /**
  8378. * Interface to follow in your material defines to integrate easily the
  8379. * Image proccessing functions.
  8380. * @hidden
  8381. */
  8382. export interface IImageProcessingConfigurationDefines {
  8383. IMAGEPROCESSING: boolean;
  8384. VIGNETTE: boolean;
  8385. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8386. VIGNETTEBLENDMODEOPAQUE: boolean;
  8387. TONEMAPPING: boolean;
  8388. TONEMAPPING_ACES: boolean;
  8389. CONTRAST: boolean;
  8390. EXPOSURE: boolean;
  8391. COLORCURVES: boolean;
  8392. COLORGRADING: boolean;
  8393. COLORGRADING3D: boolean;
  8394. SAMPLER3DGREENDEPTH: boolean;
  8395. SAMPLER3DBGRMAP: boolean;
  8396. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8397. }
  8398. /**
  8399. * @hidden
  8400. */
  8401. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8402. IMAGEPROCESSING: boolean;
  8403. VIGNETTE: boolean;
  8404. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8405. VIGNETTEBLENDMODEOPAQUE: boolean;
  8406. TONEMAPPING: boolean;
  8407. TONEMAPPING_ACES: boolean;
  8408. CONTRAST: boolean;
  8409. COLORCURVES: boolean;
  8410. COLORGRADING: boolean;
  8411. COLORGRADING3D: boolean;
  8412. SAMPLER3DGREENDEPTH: boolean;
  8413. SAMPLER3DBGRMAP: boolean;
  8414. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8415. EXPOSURE: boolean;
  8416. constructor();
  8417. }
  8418. /**
  8419. * This groups together the common properties used for image processing either in direct forward pass
  8420. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8421. * or not.
  8422. */
  8423. export class ImageProcessingConfiguration {
  8424. /**
  8425. * Default tone mapping applied in BabylonJS.
  8426. */
  8427. static readonly TONEMAPPING_STANDARD: number;
  8428. /**
  8429. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8430. * to other engines rendering to increase portability.
  8431. */
  8432. static readonly TONEMAPPING_ACES: number;
  8433. /**
  8434. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8435. */
  8436. colorCurves: Nullable<ColorCurves>;
  8437. private _colorCurvesEnabled;
  8438. /**
  8439. * Gets wether the color curves effect is enabled.
  8440. */
  8441. get colorCurvesEnabled(): boolean;
  8442. /**
  8443. * Sets wether the color curves effect is enabled.
  8444. */
  8445. set colorCurvesEnabled(value: boolean);
  8446. private _colorGradingTexture;
  8447. /**
  8448. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8449. */
  8450. get colorGradingTexture(): Nullable<BaseTexture>;
  8451. /**
  8452. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8453. */
  8454. set colorGradingTexture(value: Nullable<BaseTexture>);
  8455. private _colorGradingEnabled;
  8456. /**
  8457. * Gets wether the color grading effect is enabled.
  8458. */
  8459. get colorGradingEnabled(): boolean;
  8460. /**
  8461. * Sets wether the color grading effect is enabled.
  8462. */
  8463. set colorGradingEnabled(value: boolean);
  8464. private _colorGradingWithGreenDepth;
  8465. /**
  8466. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8467. */
  8468. get colorGradingWithGreenDepth(): boolean;
  8469. /**
  8470. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8471. */
  8472. set colorGradingWithGreenDepth(value: boolean);
  8473. private _colorGradingBGR;
  8474. /**
  8475. * Gets wether the color grading texture contains BGR values.
  8476. */
  8477. get colorGradingBGR(): boolean;
  8478. /**
  8479. * Sets wether the color grading texture contains BGR values.
  8480. */
  8481. set colorGradingBGR(value: boolean);
  8482. /** @hidden */
  8483. _exposure: number;
  8484. /**
  8485. * Gets the Exposure used in the effect.
  8486. */
  8487. get exposure(): number;
  8488. /**
  8489. * Sets the Exposure used in the effect.
  8490. */
  8491. set exposure(value: number);
  8492. private _toneMappingEnabled;
  8493. /**
  8494. * Gets wether the tone mapping effect is enabled.
  8495. */
  8496. get toneMappingEnabled(): boolean;
  8497. /**
  8498. * Sets wether the tone mapping effect is enabled.
  8499. */
  8500. set toneMappingEnabled(value: boolean);
  8501. private _toneMappingType;
  8502. /**
  8503. * Gets the type of tone mapping effect.
  8504. */
  8505. get toneMappingType(): number;
  8506. /**
  8507. * Sets the type of tone mapping effect used in BabylonJS.
  8508. */
  8509. set toneMappingType(value: number);
  8510. protected _contrast: number;
  8511. /**
  8512. * Gets the contrast used in the effect.
  8513. */
  8514. get contrast(): number;
  8515. /**
  8516. * Sets the contrast used in the effect.
  8517. */
  8518. set contrast(value: number);
  8519. /**
  8520. * Vignette stretch size.
  8521. */
  8522. vignetteStretch: number;
  8523. /**
  8524. * Vignette centre X Offset.
  8525. */
  8526. vignetteCentreX: number;
  8527. /**
  8528. * Vignette centre Y Offset.
  8529. */
  8530. vignetteCentreY: number;
  8531. /**
  8532. * Vignette weight or intensity of the vignette effect.
  8533. */
  8534. vignetteWeight: number;
  8535. /**
  8536. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8537. * if vignetteEnabled is set to true.
  8538. */
  8539. vignetteColor: Color4;
  8540. /**
  8541. * Camera field of view used by the Vignette effect.
  8542. */
  8543. vignetteCameraFov: number;
  8544. private _vignetteBlendMode;
  8545. /**
  8546. * Gets the vignette blend mode allowing different kind of effect.
  8547. */
  8548. get vignetteBlendMode(): number;
  8549. /**
  8550. * Sets the vignette blend mode allowing different kind of effect.
  8551. */
  8552. set vignetteBlendMode(value: number);
  8553. private _vignetteEnabled;
  8554. /**
  8555. * Gets wether the vignette effect is enabled.
  8556. */
  8557. get vignetteEnabled(): boolean;
  8558. /**
  8559. * Sets wether the vignette effect is enabled.
  8560. */
  8561. set vignetteEnabled(value: boolean);
  8562. private _applyByPostProcess;
  8563. /**
  8564. * Gets wether the image processing is applied through a post process or not.
  8565. */
  8566. get applyByPostProcess(): boolean;
  8567. /**
  8568. * Sets wether the image processing is applied through a post process or not.
  8569. */
  8570. set applyByPostProcess(value: boolean);
  8571. private _isEnabled;
  8572. /**
  8573. * Gets wether the image processing is enabled or not.
  8574. */
  8575. get isEnabled(): boolean;
  8576. /**
  8577. * Sets wether the image processing is enabled or not.
  8578. */
  8579. set isEnabled(value: boolean);
  8580. /**
  8581. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8582. */
  8583. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8584. /**
  8585. * Method called each time the image processing information changes requires to recompile the effect.
  8586. */
  8587. protected _updateParameters(): void;
  8588. /**
  8589. * Gets the current class name.
  8590. * @return "ImageProcessingConfiguration"
  8591. */
  8592. getClassName(): string;
  8593. /**
  8594. * Prepare the list of uniforms associated with the Image Processing effects.
  8595. * @param uniforms The list of uniforms used in the effect
  8596. * @param defines the list of defines currently in use
  8597. */
  8598. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8599. /**
  8600. * Prepare the list of samplers associated with the Image Processing effects.
  8601. * @param samplersList The list of uniforms used in the effect
  8602. * @param defines the list of defines currently in use
  8603. */
  8604. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8605. /**
  8606. * Prepare the list of defines associated to the shader.
  8607. * @param defines the list of defines to complete
  8608. * @param forPostProcess Define if we are currently in post process mode or not
  8609. */
  8610. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8611. /**
  8612. * Returns true if all the image processing information are ready.
  8613. * @returns True if ready, otherwise, false
  8614. */
  8615. isReady(): boolean;
  8616. /**
  8617. * Binds the image processing to the shader.
  8618. * @param effect The effect to bind to
  8619. * @param overrideAspectRatio Override the aspect ratio of the effect
  8620. */
  8621. bind(effect: Effect, overrideAspectRatio?: number): void;
  8622. /**
  8623. * Clones the current image processing instance.
  8624. * @return The cloned image processing
  8625. */
  8626. clone(): ImageProcessingConfiguration;
  8627. /**
  8628. * Serializes the current image processing instance to a json representation.
  8629. * @return a JSON representation
  8630. */
  8631. serialize(): any;
  8632. /**
  8633. * Parses the image processing from a json representation.
  8634. * @param source the JSON source to parse
  8635. * @return The parsed image processing
  8636. */
  8637. static Parse(source: any): ImageProcessingConfiguration;
  8638. private static _VIGNETTEMODE_MULTIPLY;
  8639. private static _VIGNETTEMODE_OPAQUE;
  8640. /**
  8641. * Used to apply the vignette as a mix with the pixel color.
  8642. */
  8643. static get VIGNETTEMODE_MULTIPLY(): number;
  8644. /**
  8645. * Used to apply the vignette as a replacement of the pixel color.
  8646. */
  8647. static get VIGNETTEMODE_OPAQUE(): number;
  8648. }
  8649. }
  8650. declare module BABYLON {
  8651. /** @hidden */
  8652. export var postprocessVertexShader: {
  8653. name: string;
  8654. shader: string;
  8655. };
  8656. }
  8657. declare module BABYLON {
  8658. /**
  8659. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8660. */
  8661. export type RenderTargetTextureSize = number | {
  8662. width: number;
  8663. height: number;
  8664. layers?: number;
  8665. };
  8666. interface ThinEngine {
  8667. /**
  8668. * Creates a new render target texture
  8669. * @param size defines the size of the texture
  8670. * @param options defines the options used to create the texture
  8671. * @returns a new render target texture stored in an InternalTexture
  8672. */
  8673. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8674. /**
  8675. * Creates a depth stencil texture.
  8676. * This is only available in WebGL 2 or with the depth texture extension available.
  8677. * @param size The size of face edge in the texture.
  8678. * @param options The options defining the texture.
  8679. * @returns The texture
  8680. */
  8681. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8682. /** @hidden */
  8683. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8684. }
  8685. }
  8686. declare module BABYLON {
  8687. /**
  8688. * Defines the kind of connection point for node based material
  8689. */
  8690. export enum NodeMaterialBlockConnectionPointTypes {
  8691. /** Float */
  8692. Float = 1,
  8693. /** Int */
  8694. Int = 2,
  8695. /** Vector2 */
  8696. Vector2 = 4,
  8697. /** Vector3 */
  8698. Vector3 = 8,
  8699. /** Vector4 */
  8700. Vector4 = 16,
  8701. /** Color3 */
  8702. Color3 = 32,
  8703. /** Color4 */
  8704. Color4 = 64,
  8705. /** Matrix */
  8706. Matrix = 128,
  8707. /** Custom object */
  8708. Object = 256,
  8709. /** Detect type based on connection */
  8710. AutoDetect = 1024,
  8711. /** Output type that will be defined by input type */
  8712. BasedOnInput = 2048
  8713. }
  8714. }
  8715. declare module BABYLON {
  8716. /**
  8717. * Enum used to define the target of a block
  8718. */
  8719. export enum NodeMaterialBlockTargets {
  8720. /** Vertex shader */
  8721. Vertex = 1,
  8722. /** Fragment shader */
  8723. Fragment = 2,
  8724. /** Neutral */
  8725. Neutral = 4,
  8726. /** Vertex and Fragment */
  8727. VertexAndFragment = 3
  8728. }
  8729. }
  8730. declare module BABYLON {
  8731. /**
  8732. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8733. */
  8734. export enum NodeMaterialBlockConnectionPointMode {
  8735. /** Value is an uniform */
  8736. Uniform = 0,
  8737. /** Value is a mesh attribute */
  8738. Attribute = 1,
  8739. /** Value is a varying between vertex and fragment shaders */
  8740. Varying = 2,
  8741. /** Mode is undefined */
  8742. Undefined = 3
  8743. }
  8744. }
  8745. declare module BABYLON {
  8746. /**
  8747. * Enum used to define system values e.g. values automatically provided by the system
  8748. */
  8749. export enum NodeMaterialSystemValues {
  8750. /** World */
  8751. World = 1,
  8752. /** View */
  8753. View = 2,
  8754. /** Projection */
  8755. Projection = 3,
  8756. /** ViewProjection */
  8757. ViewProjection = 4,
  8758. /** WorldView */
  8759. WorldView = 5,
  8760. /** WorldViewProjection */
  8761. WorldViewProjection = 6,
  8762. /** CameraPosition */
  8763. CameraPosition = 7,
  8764. /** Fog Color */
  8765. FogColor = 8,
  8766. /** Delta time */
  8767. DeltaTime = 9
  8768. }
  8769. }
  8770. declare module BABYLON {
  8771. /** Defines supported spaces */
  8772. export enum Space {
  8773. /** Local (object) space */
  8774. LOCAL = 0,
  8775. /** World space */
  8776. WORLD = 1,
  8777. /** Bone space */
  8778. BONE = 2
  8779. }
  8780. /** Defines the 3 main axes */
  8781. export class Axis {
  8782. /** X axis */
  8783. static X: Vector3;
  8784. /** Y axis */
  8785. static Y: Vector3;
  8786. /** Z axis */
  8787. static Z: Vector3;
  8788. }
  8789. /**
  8790. * Defines cartesian components.
  8791. */
  8792. export enum Coordinate {
  8793. /** X axis */
  8794. X = 0,
  8795. /** Y axis */
  8796. Y = 1,
  8797. /** Z axis */
  8798. Z = 2
  8799. }
  8800. }
  8801. declare module BABYLON {
  8802. /**
  8803. * Represents a camera frustum
  8804. */
  8805. export class Frustum {
  8806. /**
  8807. * Gets the planes representing the frustum
  8808. * @param transform matrix to be applied to the returned planes
  8809. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8810. */
  8811. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8812. /**
  8813. * Gets the near frustum plane transformed by the transform matrix
  8814. * @param transform transformation matrix to be applied to the resulting frustum plane
  8815. * @param frustumPlane the resuling frustum plane
  8816. */
  8817. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8818. /**
  8819. * Gets the far frustum plane transformed by the transform matrix
  8820. * @param transform transformation matrix to be applied to the resulting frustum plane
  8821. * @param frustumPlane the resuling frustum plane
  8822. */
  8823. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8824. /**
  8825. * Gets the left frustum plane transformed by the transform matrix
  8826. * @param transform transformation matrix to be applied to the resulting frustum plane
  8827. * @param frustumPlane the resuling frustum plane
  8828. */
  8829. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8830. /**
  8831. * Gets the right frustum plane transformed by the transform matrix
  8832. * @param transform transformation matrix to be applied to the resulting frustum plane
  8833. * @param frustumPlane the resuling frustum plane
  8834. */
  8835. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8836. /**
  8837. * Gets the top frustum plane transformed by the transform matrix
  8838. * @param transform transformation matrix to be applied to the resulting frustum plane
  8839. * @param frustumPlane the resuling frustum plane
  8840. */
  8841. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8842. /**
  8843. * Gets the bottom frustum plane transformed by the transform matrix
  8844. * @param transform transformation matrix to be applied to the resulting frustum plane
  8845. * @param frustumPlane the resuling frustum plane
  8846. */
  8847. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8848. /**
  8849. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8850. * @param transform transformation matrix to be applied to the resulting frustum planes
  8851. * @param frustumPlanes the resuling frustum planes
  8852. */
  8853. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8854. }
  8855. }
  8856. declare module BABYLON {
  8857. /**
  8858. * Interface for the size containing width and height
  8859. */
  8860. export interface ISize {
  8861. /**
  8862. * Width
  8863. */
  8864. width: number;
  8865. /**
  8866. * Heighht
  8867. */
  8868. height: number;
  8869. }
  8870. /**
  8871. * Size containing widht and height
  8872. */
  8873. export class Size implements ISize {
  8874. /**
  8875. * Width
  8876. */
  8877. width: number;
  8878. /**
  8879. * Height
  8880. */
  8881. height: number;
  8882. /**
  8883. * Creates a Size object from the given width and height (floats).
  8884. * @param width width of the new size
  8885. * @param height height of the new size
  8886. */
  8887. constructor(width: number, height: number);
  8888. /**
  8889. * Returns a string with the Size width and height
  8890. * @returns a string with the Size width and height
  8891. */
  8892. toString(): string;
  8893. /**
  8894. * "Size"
  8895. * @returns the string "Size"
  8896. */
  8897. getClassName(): string;
  8898. /**
  8899. * Returns the Size hash code.
  8900. * @returns a hash code for a unique width and height
  8901. */
  8902. getHashCode(): number;
  8903. /**
  8904. * Updates the current size from the given one.
  8905. * @param src the given size
  8906. */
  8907. copyFrom(src: Size): void;
  8908. /**
  8909. * Updates in place the current Size from the given floats.
  8910. * @param width width of the new size
  8911. * @param height height of the new size
  8912. * @returns the updated Size.
  8913. */
  8914. copyFromFloats(width: number, height: number): Size;
  8915. /**
  8916. * Updates in place the current Size from the given floats.
  8917. * @param width width to set
  8918. * @param height height to set
  8919. * @returns the updated Size.
  8920. */
  8921. set(width: number, height: number): Size;
  8922. /**
  8923. * Multiplies the width and height by numbers
  8924. * @param w factor to multiple the width by
  8925. * @param h factor to multiple the height by
  8926. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8927. */
  8928. multiplyByFloats(w: number, h: number): Size;
  8929. /**
  8930. * Clones the size
  8931. * @returns a new Size copied from the given one.
  8932. */
  8933. clone(): Size;
  8934. /**
  8935. * True if the current Size and the given one width and height are strictly equal.
  8936. * @param other the other size to compare against
  8937. * @returns True if the current Size and the given one width and height are strictly equal.
  8938. */
  8939. equals(other: Size): boolean;
  8940. /**
  8941. * The surface of the Size : width * height (float).
  8942. */
  8943. get surface(): number;
  8944. /**
  8945. * Create a new size of zero
  8946. * @returns a new Size set to (0.0, 0.0)
  8947. */
  8948. static Zero(): Size;
  8949. /**
  8950. * Sums the width and height of two sizes
  8951. * @param otherSize size to add to this size
  8952. * @returns a new Size set as the addition result of the current Size and the given one.
  8953. */
  8954. add(otherSize: Size): Size;
  8955. /**
  8956. * Subtracts the width and height of two
  8957. * @param otherSize size to subtract to this size
  8958. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8959. */
  8960. subtract(otherSize: Size): Size;
  8961. /**
  8962. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8963. * @param start starting size to lerp between
  8964. * @param end end size to lerp between
  8965. * @param amount amount to lerp between the start and end values
  8966. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8967. */
  8968. static Lerp(start: Size, end: Size, amount: number): Size;
  8969. }
  8970. }
  8971. declare module BABYLON {
  8972. /**
  8973. * Contains position and normal vectors for a vertex
  8974. */
  8975. export class PositionNormalVertex {
  8976. /** the position of the vertex (defaut: 0,0,0) */
  8977. position: Vector3;
  8978. /** the normal of the vertex (defaut: 0,1,0) */
  8979. normal: Vector3;
  8980. /**
  8981. * Creates a PositionNormalVertex
  8982. * @param position the position of the vertex (defaut: 0,0,0)
  8983. * @param normal the normal of the vertex (defaut: 0,1,0)
  8984. */
  8985. constructor(
  8986. /** the position of the vertex (defaut: 0,0,0) */
  8987. position?: Vector3,
  8988. /** the normal of the vertex (defaut: 0,1,0) */
  8989. normal?: Vector3);
  8990. /**
  8991. * Clones the PositionNormalVertex
  8992. * @returns the cloned PositionNormalVertex
  8993. */
  8994. clone(): PositionNormalVertex;
  8995. }
  8996. /**
  8997. * Contains position, normal and uv vectors for a vertex
  8998. */
  8999. export class PositionNormalTextureVertex {
  9000. /** the position of the vertex (defaut: 0,0,0) */
  9001. position: Vector3;
  9002. /** the normal of the vertex (defaut: 0,1,0) */
  9003. normal: Vector3;
  9004. /** the uv of the vertex (default: 0,0) */
  9005. uv: Vector2;
  9006. /**
  9007. * Creates a PositionNormalTextureVertex
  9008. * @param position the position of the vertex (defaut: 0,0,0)
  9009. * @param normal the normal of the vertex (defaut: 0,1,0)
  9010. * @param uv the uv of the vertex (default: 0,0)
  9011. */
  9012. constructor(
  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. * Clones the PositionNormalTextureVertex
  9021. * @returns the cloned PositionNormalTextureVertex
  9022. */
  9023. clone(): PositionNormalTextureVertex;
  9024. }
  9025. }
  9026. declare module BABYLON {
  9027. /**
  9028. * Enum defining the type of animations supported by InputBlock
  9029. */
  9030. export enum AnimatedInputBlockTypes {
  9031. /** No animation */
  9032. None = 0,
  9033. /** Time based animation. Will only work for floats */
  9034. Time = 1
  9035. }
  9036. }
  9037. declare module BABYLON {
  9038. /**
  9039. * Interface describing all the common properties and methods a shadow light needs to implement.
  9040. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9041. * as well as binding the different shadow properties to the effects.
  9042. */
  9043. export interface IShadowLight extends Light {
  9044. /**
  9045. * The light id in the scene (used in scene.findLighById for instance)
  9046. */
  9047. id: string;
  9048. /**
  9049. * The position the shdow will be casted from.
  9050. */
  9051. position: Vector3;
  9052. /**
  9053. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9054. */
  9055. direction: Vector3;
  9056. /**
  9057. * The transformed position. Position of the light in world space taking parenting in account.
  9058. */
  9059. transformedPosition: Vector3;
  9060. /**
  9061. * The transformed direction. Direction of the light in world space taking parenting in account.
  9062. */
  9063. transformedDirection: Vector3;
  9064. /**
  9065. * The friendly name of the light in the scene.
  9066. */
  9067. name: string;
  9068. /**
  9069. * Defines the shadow projection clipping minimum z value.
  9070. */
  9071. shadowMinZ: number;
  9072. /**
  9073. * Defines the shadow projection clipping maximum z value.
  9074. */
  9075. shadowMaxZ: number;
  9076. /**
  9077. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9078. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9079. */
  9080. computeTransformedInformation(): boolean;
  9081. /**
  9082. * Gets the scene the light belongs to.
  9083. * @returns The scene
  9084. */
  9085. getScene(): Scene;
  9086. /**
  9087. * Callback defining a custom Projection Matrix Builder.
  9088. * This can be used to override the default projection matrix computation.
  9089. */
  9090. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9091. /**
  9092. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9093. * @param matrix The materix to updated with the projection information
  9094. * @param viewMatrix The transform matrix of the light
  9095. * @param renderList The list of mesh to render in the map
  9096. * @returns The current light
  9097. */
  9098. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9099. /**
  9100. * Gets the current depth scale used in ESM.
  9101. * @returns The scale
  9102. */
  9103. getDepthScale(): number;
  9104. /**
  9105. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9106. * @returns true if a cube texture needs to be use
  9107. */
  9108. needCube(): boolean;
  9109. /**
  9110. * Detects if the projection matrix requires to be recomputed this frame.
  9111. * @returns true if it requires to be recomputed otherwise, false.
  9112. */
  9113. needProjectionMatrixCompute(): boolean;
  9114. /**
  9115. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9116. */
  9117. forceProjectionMatrixCompute(): void;
  9118. /**
  9119. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9120. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9121. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9122. */
  9123. getShadowDirection(faceIndex?: number): Vector3;
  9124. /**
  9125. * Gets the minZ used for shadow according to both the scene and the light.
  9126. * @param activeCamera The camera we are returning the min for
  9127. * @returns the depth min z
  9128. */
  9129. getDepthMinZ(activeCamera: Camera): number;
  9130. /**
  9131. * Gets the maxZ used for shadow according to both the scene and the light.
  9132. * @param activeCamera The camera we are returning the max for
  9133. * @returns the depth max z
  9134. */
  9135. getDepthMaxZ(activeCamera: Camera): number;
  9136. }
  9137. /**
  9138. * Base implementation IShadowLight
  9139. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9140. */
  9141. export abstract class ShadowLight extends Light implements IShadowLight {
  9142. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9143. protected _position: Vector3;
  9144. protected _setPosition(value: Vector3): void;
  9145. /**
  9146. * Sets the position the shadow will be casted from. Also use as the light position for both
  9147. * point and spot lights.
  9148. */
  9149. get position(): Vector3;
  9150. /**
  9151. * Sets the position the shadow will be casted from. Also use as the light position for both
  9152. * point and spot lights.
  9153. */
  9154. set position(value: Vector3);
  9155. protected _direction: Vector3;
  9156. protected _setDirection(value: Vector3): void;
  9157. /**
  9158. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9159. * Also use as the light direction on spot and directional lights.
  9160. */
  9161. get direction(): Vector3;
  9162. /**
  9163. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9164. * Also use as the light direction on spot and directional lights.
  9165. */
  9166. set direction(value: Vector3);
  9167. protected _shadowMinZ: number;
  9168. /**
  9169. * Gets the shadow projection clipping minimum z value.
  9170. */
  9171. get shadowMinZ(): number;
  9172. /**
  9173. * Sets the shadow projection clipping minimum z value.
  9174. */
  9175. set shadowMinZ(value: number);
  9176. protected _shadowMaxZ: number;
  9177. /**
  9178. * Sets the shadow projection clipping maximum z value.
  9179. */
  9180. get shadowMaxZ(): number;
  9181. /**
  9182. * Gets the shadow projection clipping maximum z value.
  9183. */
  9184. set shadowMaxZ(value: number);
  9185. /**
  9186. * Callback defining a custom Projection Matrix Builder.
  9187. * This can be used to override the default projection matrix computation.
  9188. */
  9189. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9190. /**
  9191. * The transformed position. Position of the light in world space taking parenting in account.
  9192. */
  9193. transformedPosition: Vector3;
  9194. /**
  9195. * The transformed direction. Direction of the light in world space taking parenting in account.
  9196. */
  9197. transformedDirection: Vector3;
  9198. private _needProjectionMatrixCompute;
  9199. /**
  9200. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9201. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9202. */
  9203. computeTransformedInformation(): boolean;
  9204. /**
  9205. * Return the depth scale used for the shadow map.
  9206. * @returns the depth scale.
  9207. */
  9208. getDepthScale(): number;
  9209. /**
  9210. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9211. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9212. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9213. */
  9214. getShadowDirection(faceIndex?: number): Vector3;
  9215. /**
  9216. * Returns the ShadowLight absolute position in the World.
  9217. * @returns the position vector in world space
  9218. */
  9219. getAbsolutePosition(): Vector3;
  9220. /**
  9221. * Sets the ShadowLight direction toward the passed target.
  9222. * @param target The point to target in local space
  9223. * @returns the updated ShadowLight direction
  9224. */
  9225. setDirectionToTarget(target: Vector3): Vector3;
  9226. /**
  9227. * Returns the light rotation in euler definition.
  9228. * @returns the x y z rotation in local space.
  9229. */
  9230. getRotation(): Vector3;
  9231. /**
  9232. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9233. * @returns true if a cube texture needs to be use
  9234. */
  9235. needCube(): boolean;
  9236. /**
  9237. * Detects if the projection matrix requires to be recomputed this frame.
  9238. * @returns true if it requires to be recomputed otherwise, false.
  9239. */
  9240. needProjectionMatrixCompute(): boolean;
  9241. /**
  9242. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9243. */
  9244. forceProjectionMatrixCompute(): void;
  9245. /** @hidden */
  9246. _initCache(): void;
  9247. /** @hidden */
  9248. _isSynchronized(): boolean;
  9249. /**
  9250. * Computes the world matrix of the node
  9251. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9252. * @returns the world matrix
  9253. */
  9254. computeWorldMatrix(force?: boolean): Matrix;
  9255. /**
  9256. * Gets the minZ used for shadow according to both the scene and the light.
  9257. * @param activeCamera The camera we are returning the min for
  9258. * @returns the depth min z
  9259. */
  9260. getDepthMinZ(activeCamera: Camera): number;
  9261. /**
  9262. * Gets the maxZ used for shadow according to both the scene and the light.
  9263. * @param activeCamera The camera we are returning the max for
  9264. * @returns the depth max z
  9265. */
  9266. getDepthMaxZ(activeCamera: Camera): number;
  9267. /**
  9268. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9269. * @param matrix The materix to updated with the projection information
  9270. * @param viewMatrix The transform matrix of the light
  9271. * @param renderList The list of mesh to render in the map
  9272. * @returns The current light
  9273. */
  9274. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9275. }
  9276. }
  9277. declare module BABYLON {
  9278. /** @hidden */
  9279. export var packingFunctions: {
  9280. name: string;
  9281. shader: string;
  9282. };
  9283. }
  9284. declare module BABYLON {
  9285. /** @hidden */
  9286. export var bayerDitherFunctions: {
  9287. name: string;
  9288. shader: string;
  9289. };
  9290. }
  9291. declare module BABYLON {
  9292. /** @hidden */
  9293. export var shadowMapFragmentDeclaration: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module BABYLON {
  9299. /** @hidden */
  9300. export var clipPlaneFragmentDeclaration: {
  9301. name: string;
  9302. shader: string;
  9303. };
  9304. }
  9305. declare module BABYLON {
  9306. /** @hidden */
  9307. export var clipPlaneFragment: {
  9308. name: string;
  9309. shader: string;
  9310. };
  9311. }
  9312. declare module BABYLON {
  9313. /** @hidden */
  9314. export var shadowMapFragment: {
  9315. name: string;
  9316. shader: string;
  9317. };
  9318. }
  9319. declare module BABYLON {
  9320. /** @hidden */
  9321. export var shadowMapPixelShader: {
  9322. name: string;
  9323. shader: string;
  9324. };
  9325. }
  9326. declare module BABYLON {
  9327. /** @hidden */
  9328. export var bonesDeclaration: {
  9329. name: string;
  9330. shader: string;
  9331. };
  9332. }
  9333. declare module BABYLON {
  9334. /** @hidden */
  9335. export var morphTargetsVertexGlobalDeclaration: {
  9336. name: string;
  9337. shader: string;
  9338. };
  9339. }
  9340. declare module BABYLON {
  9341. /** @hidden */
  9342. export var morphTargetsVertexDeclaration: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module BABYLON {
  9348. /** @hidden */
  9349. export var instancesDeclaration: {
  9350. name: string;
  9351. shader: string;
  9352. };
  9353. }
  9354. declare module BABYLON {
  9355. /** @hidden */
  9356. export var helperFunctions: {
  9357. name: string;
  9358. shader: string;
  9359. };
  9360. }
  9361. declare module BABYLON {
  9362. /** @hidden */
  9363. export var shadowMapVertexDeclaration: {
  9364. name: string;
  9365. shader: string;
  9366. };
  9367. }
  9368. declare module BABYLON {
  9369. /** @hidden */
  9370. export var clipPlaneVertexDeclaration: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module BABYLON {
  9376. /** @hidden */
  9377. export var morphTargetsVertex: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module BABYLON {
  9383. /** @hidden */
  9384. export var instancesVertex: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module BABYLON {
  9390. /** @hidden */
  9391. export var bonesVertex: {
  9392. name: string;
  9393. shader: string;
  9394. };
  9395. }
  9396. declare module BABYLON {
  9397. /** @hidden */
  9398. export var shadowMapVertexNormalBias: {
  9399. name: string;
  9400. shader: string;
  9401. };
  9402. }
  9403. declare module BABYLON {
  9404. /** @hidden */
  9405. export var shadowMapVertexMetric: {
  9406. name: string;
  9407. shader: string;
  9408. };
  9409. }
  9410. declare module BABYLON {
  9411. /** @hidden */
  9412. export var clipPlaneVertex: {
  9413. name: string;
  9414. shader: string;
  9415. };
  9416. }
  9417. declare module BABYLON {
  9418. /** @hidden */
  9419. export var shadowMapVertexShader: {
  9420. name: string;
  9421. shader: string;
  9422. };
  9423. }
  9424. declare module BABYLON {
  9425. /** @hidden */
  9426. export var depthBoxBlurPixelShader: {
  9427. name: string;
  9428. shader: string;
  9429. };
  9430. }
  9431. declare module BABYLON {
  9432. /** @hidden */
  9433. export var shadowMapFragmentSoftTransparentShadow: {
  9434. name: string;
  9435. shader: string;
  9436. };
  9437. }
  9438. declare module BABYLON {
  9439. /**
  9440. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9441. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9442. */
  9443. export class EffectFallbacks implements IEffectFallbacks {
  9444. private _defines;
  9445. private _currentRank;
  9446. private _maxRank;
  9447. private _mesh;
  9448. /**
  9449. * Removes the fallback from the bound mesh.
  9450. */
  9451. unBindMesh(): void;
  9452. /**
  9453. * Adds a fallback on the specified property.
  9454. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9455. * @param define The name of the define in the shader
  9456. */
  9457. addFallback(rank: number, define: string): void;
  9458. /**
  9459. * Sets the mesh to use CPU skinning when needing to fallback.
  9460. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9461. * @param mesh The mesh to use the fallbacks.
  9462. */
  9463. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9464. /**
  9465. * Checks to see if more fallbacks are still availible.
  9466. */
  9467. get hasMoreFallbacks(): boolean;
  9468. /**
  9469. * Removes the defines that should be removed when falling back.
  9470. * @param currentDefines defines the current define statements for the shader.
  9471. * @param effect defines the current effect we try to compile
  9472. * @returns The resulting defines with defines of the current rank removed.
  9473. */
  9474. reduce(currentDefines: string, effect: Effect): string;
  9475. }
  9476. }
  9477. declare module BABYLON {
  9478. /**
  9479. * Interface used to define Action
  9480. */
  9481. export interface IAction {
  9482. /**
  9483. * Trigger for the action
  9484. */
  9485. trigger: number;
  9486. /** Options of the trigger */
  9487. triggerOptions: any;
  9488. /**
  9489. * Gets the trigger parameters
  9490. * @returns the trigger parameters
  9491. */
  9492. getTriggerParameter(): any;
  9493. /**
  9494. * Internal only - executes current action event
  9495. * @hidden
  9496. */
  9497. _executeCurrent(evt?: ActionEvent): void;
  9498. /**
  9499. * Serialize placeholder for child classes
  9500. * @param parent of child
  9501. * @returns the serialized object
  9502. */
  9503. serialize(parent: any): any;
  9504. /**
  9505. * Internal only
  9506. * @hidden
  9507. */
  9508. _prepare(): void;
  9509. /**
  9510. * Internal only - manager for action
  9511. * @hidden
  9512. */
  9513. _actionManager: Nullable<AbstractActionManager>;
  9514. /**
  9515. * Adds action to chain of actions, may be a DoNothingAction
  9516. * @param action defines the next action to execute
  9517. * @returns The action passed in
  9518. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9519. */
  9520. then(action: IAction): IAction;
  9521. }
  9522. /**
  9523. * The action to be carried out following a trigger
  9524. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9525. */
  9526. export class Action implements IAction {
  9527. /** the trigger, with or without parameters, for the action */
  9528. triggerOptions: any;
  9529. /**
  9530. * Trigger for the action
  9531. */
  9532. trigger: number;
  9533. /**
  9534. * Internal only - manager for action
  9535. * @hidden
  9536. */
  9537. _actionManager: ActionManager;
  9538. private _nextActiveAction;
  9539. private _child;
  9540. private _condition?;
  9541. private _triggerParameter;
  9542. /**
  9543. * An event triggered prior to action being executed.
  9544. */
  9545. onBeforeExecuteObservable: Observable<Action>;
  9546. /**
  9547. * Creates a new Action
  9548. * @param triggerOptions the trigger, with or without parameters, for the action
  9549. * @param condition an optional determinant of action
  9550. */
  9551. constructor(
  9552. /** the trigger, with or without parameters, for the action */
  9553. triggerOptions: any, condition?: Condition);
  9554. /**
  9555. * Internal only
  9556. * @hidden
  9557. */
  9558. _prepare(): void;
  9559. /**
  9560. * Gets the trigger parameters
  9561. * @returns the trigger parameters
  9562. */
  9563. getTriggerParameter(): any;
  9564. /**
  9565. * Internal only - executes current action event
  9566. * @hidden
  9567. */
  9568. _executeCurrent(evt?: ActionEvent): void;
  9569. /**
  9570. * Execute placeholder for child classes
  9571. * @param evt optional action event
  9572. */
  9573. execute(evt?: ActionEvent): void;
  9574. /**
  9575. * Skips to next active action
  9576. */
  9577. skipToNextActiveAction(): void;
  9578. /**
  9579. * Adds action to chain of actions, may be a DoNothingAction
  9580. * @param action defines the next action to execute
  9581. * @returns The action passed in
  9582. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9583. */
  9584. then(action: Action): Action;
  9585. /**
  9586. * Internal only
  9587. * @hidden
  9588. */
  9589. _getProperty(propertyPath: string): string;
  9590. /**
  9591. * Internal only
  9592. * @hidden
  9593. */
  9594. _getEffectiveTarget(target: any, propertyPath: string): any;
  9595. /**
  9596. * Serialize placeholder for child classes
  9597. * @param parent of child
  9598. * @returns the serialized object
  9599. */
  9600. serialize(parent: any): any;
  9601. /**
  9602. * Internal only called by serialize
  9603. * @hidden
  9604. */
  9605. protected _serialize(serializedAction: any, parent?: any): any;
  9606. /**
  9607. * Internal only
  9608. * @hidden
  9609. */
  9610. static _SerializeValueAsString: (value: any) => string;
  9611. /**
  9612. * Internal only
  9613. * @hidden
  9614. */
  9615. static _GetTargetProperty: (target: Scene | Node) => {
  9616. name: string;
  9617. targetType: string;
  9618. value: string;
  9619. };
  9620. }
  9621. }
  9622. declare module BABYLON {
  9623. /**
  9624. * A Condition applied to an Action
  9625. */
  9626. export class Condition {
  9627. /**
  9628. * Internal only - manager for action
  9629. * @hidden
  9630. */
  9631. _actionManager: ActionManager;
  9632. /**
  9633. * Internal only
  9634. * @hidden
  9635. */
  9636. _evaluationId: number;
  9637. /**
  9638. * Internal only
  9639. * @hidden
  9640. */
  9641. _currentResult: boolean;
  9642. /**
  9643. * Creates a new Condition
  9644. * @param actionManager the manager of the action the condition is applied to
  9645. */
  9646. constructor(actionManager: ActionManager);
  9647. /**
  9648. * Check if the current condition is valid
  9649. * @returns a boolean
  9650. */
  9651. isValid(): boolean;
  9652. /**
  9653. * Internal only
  9654. * @hidden
  9655. */
  9656. _getProperty(propertyPath: string): string;
  9657. /**
  9658. * Internal only
  9659. * @hidden
  9660. */
  9661. _getEffectiveTarget(target: any, propertyPath: string): any;
  9662. /**
  9663. * Serialize placeholder for child classes
  9664. * @returns the serialized object
  9665. */
  9666. serialize(): any;
  9667. /**
  9668. * Internal only
  9669. * @hidden
  9670. */
  9671. protected _serialize(serializedCondition: any): any;
  9672. }
  9673. /**
  9674. * Defines specific conditional operators as extensions of Condition
  9675. */
  9676. export class ValueCondition extends Condition {
  9677. /** path to specify the property of the target the conditional operator uses */
  9678. propertyPath: string;
  9679. /** the value compared by the conditional operator against the current value of the property */
  9680. value: any;
  9681. /** the conditional operator, default ValueCondition.IsEqual */
  9682. operator: number;
  9683. /**
  9684. * Internal only
  9685. * @hidden
  9686. */
  9687. private static _IsEqual;
  9688. /**
  9689. * Internal only
  9690. * @hidden
  9691. */
  9692. private static _IsDifferent;
  9693. /**
  9694. * Internal only
  9695. * @hidden
  9696. */
  9697. private static _IsGreater;
  9698. /**
  9699. * Internal only
  9700. * @hidden
  9701. */
  9702. private static _IsLesser;
  9703. /**
  9704. * returns the number for IsEqual
  9705. */
  9706. static get IsEqual(): number;
  9707. /**
  9708. * Returns the number for IsDifferent
  9709. */
  9710. static get IsDifferent(): number;
  9711. /**
  9712. * Returns the number for IsGreater
  9713. */
  9714. static get IsGreater(): number;
  9715. /**
  9716. * Returns the number for IsLesser
  9717. */
  9718. static get IsLesser(): number;
  9719. /**
  9720. * Internal only The action manager for the condition
  9721. * @hidden
  9722. */
  9723. _actionManager: ActionManager;
  9724. /**
  9725. * Internal only
  9726. * @hidden
  9727. */
  9728. private _target;
  9729. /**
  9730. * Internal only
  9731. * @hidden
  9732. */
  9733. private _effectiveTarget;
  9734. /**
  9735. * Internal only
  9736. * @hidden
  9737. */
  9738. private _property;
  9739. /**
  9740. * Creates a new ValueCondition
  9741. * @param actionManager manager for the action the condition applies to
  9742. * @param target for the action
  9743. * @param propertyPath path to specify the property of the target the conditional operator uses
  9744. * @param value the value compared by the conditional operator against the current value of the property
  9745. * @param operator the conditional operator, default ValueCondition.IsEqual
  9746. */
  9747. constructor(actionManager: ActionManager, target: any,
  9748. /** path to specify the property of the target the conditional operator uses */
  9749. propertyPath: string,
  9750. /** the value compared by the conditional operator against the current value of the property */
  9751. value: any,
  9752. /** the conditional operator, default ValueCondition.IsEqual */
  9753. operator?: number);
  9754. /**
  9755. * Compares the given value with the property value for the specified conditional operator
  9756. * @returns the result of the comparison
  9757. */
  9758. isValid(): boolean;
  9759. /**
  9760. * Serialize the ValueCondition into a JSON compatible object
  9761. * @returns serialization object
  9762. */
  9763. serialize(): any;
  9764. /**
  9765. * Gets the name of the conditional operator for the ValueCondition
  9766. * @param operator the conditional operator
  9767. * @returns the name
  9768. */
  9769. static GetOperatorName(operator: number): string;
  9770. }
  9771. /**
  9772. * Defines a predicate condition as an extension of Condition
  9773. */
  9774. export class PredicateCondition extends Condition {
  9775. /** defines the predicate function used to validate the condition */
  9776. predicate: () => boolean;
  9777. /**
  9778. * Internal only - manager for action
  9779. * @hidden
  9780. */
  9781. _actionManager: ActionManager;
  9782. /**
  9783. * Creates a new PredicateCondition
  9784. * @param actionManager manager for the action the condition applies to
  9785. * @param predicate defines the predicate function used to validate the condition
  9786. */
  9787. constructor(actionManager: ActionManager,
  9788. /** defines the predicate function used to validate the condition */
  9789. predicate: () => boolean);
  9790. /**
  9791. * @returns the validity of the predicate condition
  9792. */
  9793. isValid(): boolean;
  9794. }
  9795. /**
  9796. * Defines a state condition as an extension of Condition
  9797. */
  9798. export class StateCondition extends Condition {
  9799. /** Value to compare with target state */
  9800. value: string;
  9801. /**
  9802. * Internal only - manager for action
  9803. * @hidden
  9804. */
  9805. _actionManager: ActionManager;
  9806. /**
  9807. * Internal only
  9808. * @hidden
  9809. */
  9810. private _target;
  9811. /**
  9812. * Creates a new StateCondition
  9813. * @param actionManager manager for the action the condition applies to
  9814. * @param target of the condition
  9815. * @param value to compare with target state
  9816. */
  9817. constructor(actionManager: ActionManager, target: any,
  9818. /** Value to compare with target state */
  9819. value: string);
  9820. /**
  9821. * Gets a boolean indicating if the current condition is met
  9822. * @returns the validity of the state
  9823. */
  9824. isValid(): boolean;
  9825. /**
  9826. * Serialize the StateCondition into a JSON compatible object
  9827. * @returns serialization object
  9828. */
  9829. serialize(): any;
  9830. }
  9831. }
  9832. declare module BABYLON {
  9833. /**
  9834. * This defines an action responsible to toggle a boolean once triggered.
  9835. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9836. */
  9837. export class SwitchBooleanAction extends Action {
  9838. /**
  9839. * The path to the boolean property in the target object
  9840. */
  9841. propertyPath: string;
  9842. private _target;
  9843. private _effectiveTarget;
  9844. private _property;
  9845. /**
  9846. * Instantiate the action
  9847. * @param triggerOptions defines the trigger options
  9848. * @param target defines the object containing the boolean
  9849. * @param propertyPath defines the path to the boolean property in the target object
  9850. * @param condition defines the trigger related conditions
  9851. */
  9852. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9853. /** @hidden */
  9854. _prepare(): void;
  9855. /**
  9856. * Execute the action toggle the boolean value.
  9857. */
  9858. execute(): void;
  9859. /**
  9860. * Serializes the actions and its related information.
  9861. * @param parent defines the object to serialize in
  9862. * @returns the serialized object
  9863. */
  9864. serialize(parent: any): any;
  9865. }
  9866. /**
  9867. * This defines an action responsible to set a the state field of the target
  9868. * to a desired value once triggered.
  9869. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9870. */
  9871. export class SetStateAction extends Action {
  9872. /**
  9873. * The value to store in the state field.
  9874. */
  9875. value: string;
  9876. private _target;
  9877. /**
  9878. * Instantiate the action
  9879. * @param triggerOptions defines the trigger options
  9880. * @param target defines the object containing the state property
  9881. * @param value defines the value to store in the state field
  9882. * @param condition defines the trigger related conditions
  9883. */
  9884. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9885. /**
  9886. * Execute the action and store the value on the target state property.
  9887. */
  9888. execute(): void;
  9889. /**
  9890. * Serializes the actions and its related information.
  9891. * @param parent defines the object to serialize in
  9892. * @returns the serialized object
  9893. */
  9894. serialize(parent: any): any;
  9895. }
  9896. /**
  9897. * This defines an action responsible to set a property of the target
  9898. * to a desired value once triggered.
  9899. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9900. */
  9901. export class SetValueAction extends Action {
  9902. /**
  9903. * The path of the property to set in the target.
  9904. */
  9905. propertyPath: string;
  9906. /**
  9907. * The value to set in the property
  9908. */
  9909. value: any;
  9910. private _target;
  9911. private _effectiveTarget;
  9912. private _property;
  9913. /**
  9914. * Instantiate the action
  9915. * @param triggerOptions defines the trigger options
  9916. * @param target defines the object containing the property
  9917. * @param propertyPath defines the path of the property to set in the target
  9918. * @param value defines the value to set in the property
  9919. * @param condition defines the trigger related conditions
  9920. */
  9921. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9922. /** @hidden */
  9923. _prepare(): void;
  9924. /**
  9925. * Execute the action and set the targetted property to the desired value.
  9926. */
  9927. execute(): void;
  9928. /**
  9929. * Serializes the actions and its related information.
  9930. * @param parent defines the object to serialize in
  9931. * @returns the serialized object
  9932. */
  9933. serialize(parent: any): any;
  9934. }
  9935. /**
  9936. * This defines an action responsible to increment the target value
  9937. * to a desired value once triggered.
  9938. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9939. */
  9940. export class IncrementValueAction extends Action {
  9941. /**
  9942. * The path of the property to increment in the target.
  9943. */
  9944. propertyPath: string;
  9945. /**
  9946. * The value we should increment the property by.
  9947. */
  9948. value: any;
  9949. private _target;
  9950. private _effectiveTarget;
  9951. private _property;
  9952. /**
  9953. * Instantiate the action
  9954. * @param triggerOptions defines the trigger options
  9955. * @param target defines the object containing the property
  9956. * @param propertyPath defines the path of the property to increment in the target
  9957. * @param value defines the value value we should increment the property by
  9958. * @param condition defines the trigger related conditions
  9959. */
  9960. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9961. /** @hidden */
  9962. _prepare(): void;
  9963. /**
  9964. * Execute the action and increment the target of the value amount.
  9965. */
  9966. execute(): void;
  9967. /**
  9968. * Serializes the actions and its related information.
  9969. * @param parent defines the object to serialize in
  9970. * @returns the serialized object
  9971. */
  9972. serialize(parent: any): any;
  9973. }
  9974. /**
  9975. * This defines an action responsible to start an animation once triggered.
  9976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9977. */
  9978. export class PlayAnimationAction extends Action {
  9979. /**
  9980. * Where the animation should start (animation frame)
  9981. */
  9982. from: number;
  9983. /**
  9984. * Where the animation should stop (animation frame)
  9985. */
  9986. to: number;
  9987. /**
  9988. * Define if the animation should loop or stop after the first play.
  9989. */
  9990. loop?: boolean;
  9991. private _target;
  9992. /**
  9993. * Instantiate the action
  9994. * @param triggerOptions defines the trigger options
  9995. * @param target defines the target animation or animation name
  9996. * @param from defines from where the animation should start (animation frame)
  9997. * @param end defines where the animation should stop (animation frame)
  9998. * @param loop defines if the animation should loop or stop after the first play
  9999. * @param condition defines the trigger related conditions
  10000. */
  10001. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10002. /** @hidden */
  10003. _prepare(): void;
  10004. /**
  10005. * Execute the action and play the animation.
  10006. */
  10007. execute(): void;
  10008. /**
  10009. * Serializes the actions and its related information.
  10010. * @param parent defines the object to serialize in
  10011. * @returns the serialized object
  10012. */
  10013. serialize(parent: any): any;
  10014. }
  10015. /**
  10016. * This defines an action responsible to stop an animation once triggered.
  10017. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10018. */
  10019. export class StopAnimationAction extends Action {
  10020. private _target;
  10021. /**
  10022. * Instantiate the action
  10023. * @param triggerOptions defines the trigger options
  10024. * @param target defines the target animation or animation name
  10025. * @param condition defines the trigger related conditions
  10026. */
  10027. constructor(triggerOptions: any, target: any, condition?: Condition);
  10028. /** @hidden */
  10029. _prepare(): void;
  10030. /**
  10031. * Execute the action and stop the animation.
  10032. */
  10033. execute(): void;
  10034. /**
  10035. * Serializes the actions and its related information.
  10036. * @param parent defines the object to serialize in
  10037. * @returns the serialized object
  10038. */
  10039. serialize(parent: any): any;
  10040. }
  10041. /**
  10042. * This defines an action responsible that does nothing once triggered.
  10043. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10044. */
  10045. export class DoNothingAction extends Action {
  10046. /**
  10047. * Instantiate the action
  10048. * @param triggerOptions defines the trigger options
  10049. * @param condition defines the trigger related conditions
  10050. */
  10051. constructor(triggerOptions?: any, condition?: Condition);
  10052. /**
  10053. * Execute the action and do nothing.
  10054. */
  10055. execute(): void;
  10056. /**
  10057. * Serializes the actions and its related information.
  10058. * @param parent defines the object to serialize in
  10059. * @returns the serialized object
  10060. */
  10061. serialize(parent: any): any;
  10062. }
  10063. /**
  10064. * This defines an action responsible to trigger several actions once triggered.
  10065. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10066. */
  10067. export class CombineAction extends Action {
  10068. /**
  10069. * The list of aggregated animations to run.
  10070. */
  10071. children: Action[];
  10072. /**
  10073. * Instantiate the action
  10074. * @param triggerOptions defines the trigger options
  10075. * @param children defines the list of aggregated animations to run
  10076. * @param condition defines the trigger related conditions
  10077. */
  10078. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10079. /** @hidden */
  10080. _prepare(): void;
  10081. /**
  10082. * Execute the action and executes all the aggregated actions.
  10083. */
  10084. execute(evt: ActionEvent): void;
  10085. /**
  10086. * Serializes the actions and its related information.
  10087. * @param parent defines the object to serialize in
  10088. * @returns the serialized object
  10089. */
  10090. serialize(parent: any): any;
  10091. }
  10092. /**
  10093. * This defines an action responsible to run code (external event) once triggered.
  10094. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10095. */
  10096. export class ExecuteCodeAction extends Action {
  10097. /**
  10098. * The callback function to run.
  10099. */
  10100. func: (evt: ActionEvent) => void;
  10101. /**
  10102. * Instantiate the action
  10103. * @param triggerOptions defines the trigger options
  10104. * @param func defines the callback function to run
  10105. * @param condition defines the trigger related conditions
  10106. */
  10107. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10108. /**
  10109. * Execute the action and run the attached code.
  10110. */
  10111. execute(evt: ActionEvent): void;
  10112. }
  10113. /**
  10114. * This defines an action responsible to set the parent property of the target once triggered.
  10115. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10116. */
  10117. export class SetParentAction extends Action {
  10118. private _parent;
  10119. private _target;
  10120. /**
  10121. * Instantiate the action
  10122. * @param triggerOptions defines the trigger options
  10123. * @param target defines the target containing the parent property
  10124. * @param parent defines from where the animation should start (animation frame)
  10125. * @param condition defines the trigger related conditions
  10126. */
  10127. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10128. /** @hidden */
  10129. _prepare(): void;
  10130. /**
  10131. * Execute the action and set the parent property.
  10132. */
  10133. execute(): void;
  10134. /**
  10135. * Serializes the actions and its related information.
  10136. * @param parent defines the object to serialize in
  10137. * @returns the serialized object
  10138. */
  10139. serialize(parent: any): any;
  10140. }
  10141. }
  10142. declare module BABYLON {
  10143. /**
  10144. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10145. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10146. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10147. */
  10148. export class ActionManager extends AbstractActionManager {
  10149. /**
  10150. * Nothing
  10151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10152. */
  10153. static readonly NothingTrigger: number;
  10154. /**
  10155. * On pick
  10156. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10157. */
  10158. static readonly OnPickTrigger: number;
  10159. /**
  10160. * On left pick
  10161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10162. */
  10163. static readonly OnLeftPickTrigger: number;
  10164. /**
  10165. * On right pick
  10166. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10167. */
  10168. static readonly OnRightPickTrigger: number;
  10169. /**
  10170. * On center pick
  10171. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10172. */
  10173. static readonly OnCenterPickTrigger: number;
  10174. /**
  10175. * On pick down
  10176. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10177. */
  10178. static readonly OnPickDownTrigger: number;
  10179. /**
  10180. * On double pick
  10181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10182. */
  10183. static readonly OnDoublePickTrigger: number;
  10184. /**
  10185. * On pick up
  10186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10187. */
  10188. static readonly OnPickUpTrigger: number;
  10189. /**
  10190. * On pick out.
  10191. * This trigger will only be raised if you also declared a OnPickDown
  10192. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10193. */
  10194. static readonly OnPickOutTrigger: number;
  10195. /**
  10196. * On long press
  10197. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10198. */
  10199. static readonly OnLongPressTrigger: number;
  10200. /**
  10201. * On pointer over
  10202. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10203. */
  10204. static readonly OnPointerOverTrigger: number;
  10205. /**
  10206. * On pointer out
  10207. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10208. */
  10209. static readonly OnPointerOutTrigger: number;
  10210. /**
  10211. * On every frame
  10212. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10213. */
  10214. static readonly OnEveryFrameTrigger: number;
  10215. /**
  10216. * On intersection enter
  10217. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10218. */
  10219. static readonly OnIntersectionEnterTrigger: number;
  10220. /**
  10221. * On intersection exit
  10222. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10223. */
  10224. static readonly OnIntersectionExitTrigger: number;
  10225. /**
  10226. * On key down
  10227. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10228. */
  10229. static readonly OnKeyDownTrigger: number;
  10230. /**
  10231. * On key up
  10232. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10233. */
  10234. static readonly OnKeyUpTrigger: number;
  10235. private _scene;
  10236. /**
  10237. * Creates a new action manager
  10238. * @param scene defines the hosting scene
  10239. */
  10240. constructor(scene: Scene);
  10241. /**
  10242. * Releases all associated resources
  10243. */
  10244. dispose(): void;
  10245. /**
  10246. * Gets hosting scene
  10247. * @returns the hosting scene
  10248. */
  10249. getScene(): Scene;
  10250. /**
  10251. * Does this action manager handles actions of any of the given triggers
  10252. * @param triggers defines the triggers to be tested
  10253. * @return a boolean indicating whether one (or more) of the triggers is handled
  10254. */
  10255. hasSpecificTriggers(triggers: number[]): boolean;
  10256. /**
  10257. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10258. * speed.
  10259. * @param triggerA defines the trigger to be tested
  10260. * @param triggerB defines the trigger to be tested
  10261. * @return a boolean indicating whether one (or more) of the triggers is handled
  10262. */
  10263. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10264. /**
  10265. * Does this action manager handles actions of a given trigger
  10266. * @param trigger defines the trigger to be tested
  10267. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10268. * @return whether the trigger is handled
  10269. */
  10270. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10271. /**
  10272. * Does this action manager has pointer triggers
  10273. */
  10274. get hasPointerTriggers(): boolean;
  10275. /**
  10276. * Does this action manager has pick triggers
  10277. */
  10278. get hasPickTriggers(): boolean;
  10279. /**
  10280. * Registers an action to this action manager
  10281. * @param action defines the action to be registered
  10282. * @return the action amended (prepared) after registration
  10283. */
  10284. registerAction(action: IAction): Nullable<IAction>;
  10285. /**
  10286. * Unregisters an action to this action manager
  10287. * @param action defines the action to be unregistered
  10288. * @return a boolean indicating whether the action has been unregistered
  10289. */
  10290. unregisterAction(action: IAction): Boolean;
  10291. /**
  10292. * Process a specific trigger
  10293. * @param trigger defines the trigger to process
  10294. * @param evt defines the event details to be processed
  10295. */
  10296. processTrigger(trigger: number, evt?: IActionEvent): void;
  10297. /** @hidden */
  10298. _getEffectiveTarget(target: any, propertyPath: string): any;
  10299. /** @hidden */
  10300. _getProperty(propertyPath: string): string;
  10301. /**
  10302. * Serialize this manager to a JSON object
  10303. * @param name defines the property name to store this manager
  10304. * @returns a JSON representation of this manager
  10305. */
  10306. serialize(name: string): any;
  10307. /**
  10308. * Creates a new ActionManager from a JSON data
  10309. * @param parsedActions defines the JSON data to read from
  10310. * @param object defines the hosting mesh
  10311. * @param scene defines the hosting scene
  10312. */
  10313. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10314. /**
  10315. * Get a trigger name by index
  10316. * @param trigger defines the trigger index
  10317. * @returns a trigger name
  10318. */
  10319. static GetTriggerName(trigger: number): string;
  10320. }
  10321. }
  10322. declare module BABYLON {
  10323. /**
  10324. * Class used to represent a sprite
  10325. * @see https://doc.babylonjs.com/babylon101/sprites
  10326. */
  10327. export class Sprite implements IAnimatable {
  10328. /** defines the name */
  10329. name: string;
  10330. /** Gets or sets the current world position */
  10331. position: Vector3;
  10332. /** Gets or sets the main color */
  10333. color: Color4;
  10334. /** Gets or sets the width */
  10335. width: number;
  10336. /** Gets or sets the height */
  10337. height: number;
  10338. /** Gets or sets rotation angle */
  10339. angle: number;
  10340. /** Gets or sets the cell index in the sprite sheet */
  10341. cellIndex: number;
  10342. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10343. cellRef: string;
  10344. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10345. invertU: boolean;
  10346. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10347. invertV: boolean;
  10348. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10349. disposeWhenFinishedAnimating: boolean;
  10350. /** Gets the list of attached animations */
  10351. animations: Nullable<Array<Animation>>;
  10352. /** Gets or sets a boolean indicating if the sprite can be picked */
  10353. isPickable: boolean;
  10354. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10355. useAlphaForPicking: boolean;
  10356. /** @hidden */
  10357. _xOffset: number;
  10358. /** @hidden */
  10359. _yOffset: number;
  10360. /** @hidden */
  10361. _xSize: number;
  10362. /** @hidden */
  10363. _ySize: number;
  10364. /**
  10365. * Gets or sets the associated action manager
  10366. */
  10367. actionManager: Nullable<ActionManager>;
  10368. /**
  10369. * An event triggered when the control has been disposed
  10370. */
  10371. onDisposeObservable: Observable<Sprite>;
  10372. private _animationStarted;
  10373. private _loopAnimation;
  10374. private _fromIndex;
  10375. private _toIndex;
  10376. private _delay;
  10377. private _direction;
  10378. private _manager;
  10379. private _time;
  10380. private _onAnimationEnd;
  10381. /**
  10382. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10383. */
  10384. isVisible: boolean;
  10385. /**
  10386. * Gets or sets the sprite size
  10387. */
  10388. get size(): number;
  10389. set size(value: number);
  10390. /**
  10391. * Returns a boolean indicating if the animation is started
  10392. */
  10393. get animationStarted(): boolean;
  10394. /**
  10395. * Gets or sets the unique id of the sprite
  10396. */
  10397. uniqueId: number;
  10398. /**
  10399. * Gets the manager of this sprite
  10400. */
  10401. get manager(): ISpriteManager;
  10402. /**
  10403. * Creates a new Sprite
  10404. * @param name defines the name
  10405. * @param manager defines the manager
  10406. */
  10407. constructor(
  10408. /** defines the name */
  10409. name: string, manager: ISpriteManager);
  10410. /**
  10411. * Returns the string "Sprite"
  10412. * @returns "Sprite"
  10413. */
  10414. getClassName(): string;
  10415. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10416. get fromIndex(): number;
  10417. set fromIndex(value: number);
  10418. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10419. get toIndex(): number;
  10420. set toIndex(value: number);
  10421. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10422. get loopAnimation(): boolean;
  10423. set loopAnimation(value: boolean);
  10424. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10425. get delay(): number;
  10426. set delay(value: number);
  10427. /**
  10428. * Starts an animation
  10429. * @param from defines the initial key
  10430. * @param to defines the end key
  10431. * @param loop defines if the animation must loop
  10432. * @param delay defines the start delay (in ms)
  10433. * @param onAnimationEnd defines a callback to call when animation ends
  10434. */
  10435. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10436. /** Stops current animation (if any) */
  10437. stopAnimation(): void;
  10438. /** @hidden */
  10439. _animate(deltaTime: number): void;
  10440. /** Release associated resources */
  10441. dispose(): void;
  10442. /**
  10443. * Serializes the sprite to a JSON object
  10444. * @returns the JSON object
  10445. */
  10446. serialize(): any;
  10447. /**
  10448. * Parses a JSON object to create a new sprite
  10449. * @param parsedSprite The JSON object to parse
  10450. * @param manager defines the hosting manager
  10451. * @returns the new sprite
  10452. */
  10453. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10454. }
  10455. }
  10456. declare module BABYLON {
  10457. /**
  10458. * Information about the result of picking within a scene
  10459. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10460. */
  10461. export class PickingInfo {
  10462. /** @hidden */
  10463. _pickingUnavailable: boolean;
  10464. /**
  10465. * If the pick collided with an object
  10466. */
  10467. hit: boolean;
  10468. /**
  10469. * Distance away where the pick collided
  10470. */
  10471. distance: number;
  10472. /**
  10473. * The location of pick collision
  10474. */
  10475. pickedPoint: Nullable<Vector3>;
  10476. /**
  10477. * The mesh corresponding the the pick collision
  10478. */
  10479. pickedMesh: Nullable<AbstractMesh>;
  10480. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10481. bu: number;
  10482. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10483. bv: number;
  10484. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10485. faceId: number;
  10486. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10487. subMeshFaceId: number;
  10488. /** Id of the the submesh that was picked */
  10489. subMeshId: number;
  10490. /** If a sprite was picked, this will be the sprite the pick collided with */
  10491. pickedSprite: Nullable<Sprite>;
  10492. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10493. thinInstanceIndex: number;
  10494. /**
  10495. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10496. */
  10497. originMesh: Nullable<AbstractMesh>;
  10498. /**
  10499. * The ray that was used to perform the picking.
  10500. */
  10501. ray: Nullable<Ray>;
  10502. /**
  10503. * Gets the normal correspodning to the face the pick collided with
  10504. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10505. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10506. * @returns The normal correspodning to the face the pick collided with
  10507. */
  10508. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10509. /**
  10510. * Gets the texture coordinates of where the pick occured
  10511. * @returns the vector containing the coordnates of the texture
  10512. */
  10513. getTextureCoordinates(): Nullable<Vector2>;
  10514. }
  10515. }
  10516. declare module BABYLON {
  10517. /**
  10518. * Class representing a ray with position and direction
  10519. */
  10520. export class Ray {
  10521. /** origin point */
  10522. origin: Vector3;
  10523. /** direction */
  10524. direction: Vector3;
  10525. /** length of the ray */
  10526. length: number;
  10527. private static readonly _TmpVector3;
  10528. private _tmpRay;
  10529. /**
  10530. * Creates a new ray
  10531. * @param origin origin point
  10532. * @param direction direction
  10533. * @param length length of the ray
  10534. */
  10535. constructor(
  10536. /** origin point */
  10537. origin: Vector3,
  10538. /** direction */
  10539. direction: Vector3,
  10540. /** length of the ray */
  10541. length?: number);
  10542. /**
  10543. * Checks if the ray intersects a box
  10544. * This does not account for the ray lenght by design to improve perfs.
  10545. * @param minimum bound of the box
  10546. * @param maximum bound of the box
  10547. * @param intersectionTreshold extra extend to be added to the box in all direction
  10548. * @returns if the box was hit
  10549. */
  10550. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10551. /**
  10552. * Checks if the ray intersects a box
  10553. * This does not account for the ray lenght by design to improve perfs.
  10554. * @param box the bounding box to check
  10555. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10556. * @returns if the box was hit
  10557. */
  10558. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10559. /**
  10560. * If the ray hits a sphere
  10561. * @param sphere the bounding sphere to check
  10562. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10563. * @returns true if it hits the sphere
  10564. */
  10565. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10566. /**
  10567. * If the ray hits a triange
  10568. * @param vertex0 triangle vertex
  10569. * @param vertex1 triangle vertex
  10570. * @param vertex2 triangle vertex
  10571. * @returns intersection information if hit
  10572. */
  10573. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10574. /**
  10575. * Checks if ray intersects a plane
  10576. * @param plane the plane to check
  10577. * @returns the distance away it was hit
  10578. */
  10579. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10580. /**
  10581. * Calculate the intercept of a ray on a given axis
  10582. * @param axis to check 'x' | 'y' | 'z'
  10583. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10584. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10585. */
  10586. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10587. /**
  10588. * Checks if ray intersects a mesh
  10589. * @param mesh the mesh to check
  10590. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10591. * @returns picking info of the intersecton
  10592. */
  10593. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10594. /**
  10595. * Checks if ray intersects a mesh
  10596. * @param meshes the meshes to check
  10597. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10598. * @param results array to store result in
  10599. * @returns Array of picking infos
  10600. */
  10601. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10602. private _comparePickingInfo;
  10603. private static smallnum;
  10604. private static rayl;
  10605. /**
  10606. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10607. * @param sega the first point of the segment to test the intersection against
  10608. * @param segb the second point of the segment to test the intersection against
  10609. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10610. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10611. */
  10612. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10613. /**
  10614. * Update the ray from viewport position
  10615. * @param x position
  10616. * @param y y position
  10617. * @param viewportWidth viewport width
  10618. * @param viewportHeight viewport height
  10619. * @param world world matrix
  10620. * @param view view matrix
  10621. * @param projection projection matrix
  10622. * @returns this ray updated
  10623. */
  10624. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10625. /**
  10626. * Creates a ray with origin and direction of 0,0,0
  10627. * @returns the new ray
  10628. */
  10629. static Zero(): Ray;
  10630. /**
  10631. * Creates a new ray from screen space and viewport
  10632. * @param x position
  10633. * @param y y position
  10634. * @param viewportWidth viewport width
  10635. * @param viewportHeight viewport height
  10636. * @param world world matrix
  10637. * @param view view matrix
  10638. * @param projection projection matrix
  10639. * @returns new ray
  10640. */
  10641. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10642. /**
  10643. * 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
  10644. * transformed to the given world matrix.
  10645. * @param origin The origin point
  10646. * @param end The end point
  10647. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10648. * @returns the new ray
  10649. */
  10650. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10651. /**
  10652. * Transforms a ray by a matrix
  10653. * @param ray ray to transform
  10654. * @param matrix matrix to apply
  10655. * @returns the resulting new ray
  10656. */
  10657. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10658. /**
  10659. * Transforms a ray by a matrix
  10660. * @param ray ray to transform
  10661. * @param matrix matrix to apply
  10662. * @param result ray to store result in
  10663. */
  10664. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10665. /**
  10666. * Unproject a ray from screen space to object space
  10667. * @param sourceX defines the screen space x coordinate to use
  10668. * @param sourceY defines the screen space y coordinate to use
  10669. * @param viewportWidth defines the current width of the viewport
  10670. * @param viewportHeight defines the current height of the viewport
  10671. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10672. * @param view defines the view matrix to use
  10673. * @param projection defines the projection matrix to use
  10674. */
  10675. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10676. }
  10677. /**
  10678. * Type used to define predicate used to select faces when a mesh intersection is detected
  10679. */
  10680. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10681. interface Scene {
  10682. /** @hidden */
  10683. _tempPickingRay: Nullable<Ray>;
  10684. /** @hidden */
  10685. _cachedRayForTransform: Ray;
  10686. /** @hidden */
  10687. _pickWithRayInverseMatrix: Matrix;
  10688. /** @hidden */
  10689. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10690. /** @hidden */
  10691. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10692. /** @hidden */
  10693. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10694. }
  10695. }
  10696. declare module BABYLON {
  10697. /**
  10698. * Groups all the scene component constants in one place to ease maintenance.
  10699. * @hidden
  10700. */
  10701. export class SceneComponentConstants {
  10702. static readonly NAME_EFFECTLAYER: string;
  10703. static readonly NAME_LAYER: string;
  10704. static readonly NAME_LENSFLARESYSTEM: string;
  10705. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10706. static readonly NAME_PARTICLESYSTEM: string;
  10707. static readonly NAME_GAMEPAD: string;
  10708. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10709. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10710. static readonly NAME_PREPASSRENDERER: string;
  10711. static readonly NAME_DEPTHRENDERER: string;
  10712. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10713. static readonly NAME_SPRITE: string;
  10714. static readonly NAME_SUBSURFACE: string;
  10715. static readonly NAME_OUTLINERENDERER: string;
  10716. static readonly NAME_PROCEDURALTEXTURE: string;
  10717. static readonly NAME_SHADOWGENERATOR: string;
  10718. static readonly NAME_OCTREE: string;
  10719. static readonly NAME_PHYSICSENGINE: string;
  10720. static readonly NAME_AUDIO: string;
  10721. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10722. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10723. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10724. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10725. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10726. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10727. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10728. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10729. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10730. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10731. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10732. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10733. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10734. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10735. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10736. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10737. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10738. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10739. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10740. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10741. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10742. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10743. static readonly STEP_AFTERRENDER_AUDIO: number;
  10744. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10745. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10746. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10747. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10748. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10749. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10750. static readonly STEP_POINTERMOVE_SPRITE: number;
  10751. static readonly STEP_POINTERDOWN_SPRITE: number;
  10752. static readonly STEP_POINTERUP_SPRITE: number;
  10753. }
  10754. /**
  10755. * This represents a scene component.
  10756. *
  10757. * This is used to decouple the dependency the scene is having on the different workloads like
  10758. * layers, post processes...
  10759. */
  10760. export interface ISceneComponent {
  10761. /**
  10762. * The name of the component. Each component must have a unique name.
  10763. */
  10764. name: string;
  10765. /**
  10766. * The scene the component belongs to.
  10767. */
  10768. scene: Scene;
  10769. /**
  10770. * Register the component to one instance of a scene.
  10771. */
  10772. register(): void;
  10773. /**
  10774. * Rebuilds the elements related to this component in case of
  10775. * context lost for instance.
  10776. */
  10777. rebuild(): void;
  10778. /**
  10779. * Disposes the component and the associated ressources.
  10780. */
  10781. dispose(): void;
  10782. }
  10783. /**
  10784. * This represents a SERIALIZABLE scene component.
  10785. *
  10786. * This extends Scene Component to add Serialization methods on top.
  10787. */
  10788. export interface ISceneSerializableComponent extends ISceneComponent {
  10789. /**
  10790. * Adds all the elements from the container to the scene
  10791. * @param container the container holding the elements
  10792. */
  10793. addFromContainer(container: AbstractScene): void;
  10794. /**
  10795. * Removes all the elements in the container from the scene
  10796. * @param container contains the elements to remove
  10797. * @param dispose if the removed element should be disposed (default: false)
  10798. */
  10799. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10800. /**
  10801. * Serializes the component data to the specified json object
  10802. * @param serializationObject The object to serialize to
  10803. */
  10804. serialize(serializationObject: any): void;
  10805. }
  10806. /**
  10807. * Strong typing of a Mesh related stage step action
  10808. */
  10809. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10810. /**
  10811. * Strong typing of a Evaluate Sub Mesh related stage step action
  10812. */
  10813. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10814. /**
  10815. * Strong typing of a pre active Mesh related stage step action
  10816. */
  10817. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10818. /**
  10819. * Strong typing of a Camera related stage step action
  10820. */
  10821. export type CameraStageAction = (camera: Camera) => void;
  10822. /**
  10823. * Strong typing of a Camera Frame buffer related stage step action
  10824. */
  10825. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10826. /**
  10827. * Strong typing of a Render Target related stage step action
  10828. */
  10829. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10830. /**
  10831. * Strong typing of a RenderingGroup related stage step action
  10832. */
  10833. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10834. /**
  10835. * Strong typing of a Mesh Render related stage step action
  10836. */
  10837. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10838. /**
  10839. * Strong typing of a simple stage step action
  10840. */
  10841. export type SimpleStageAction = () => void;
  10842. /**
  10843. * Strong typing of a render target action.
  10844. */
  10845. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10846. /**
  10847. * Strong typing of a pointer move action.
  10848. */
  10849. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10850. /**
  10851. * Strong typing of a pointer up/down action.
  10852. */
  10853. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10854. /**
  10855. * Representation of a stage in the scene (Basically a list of ordered steps)
  10856. * @hidden
  10857. */
  10858. export class Stage<T extends Function> extends Array<{
  10859. index: number;
  10860. component: ISceneComponent;
  10861. action: T;
  10862. }> {
  10863. /**
  10864. * Hide ctor from the rest of the world.
  10865. * @param items The items to add.
  10866. */
  10867. private constructor();
  10868. /**
  10869. * Creates a new Stage.
  10870. * @returns A new instance of a Stage
  10871. */
  10872. static Create<T extends Function>(): Stage<T>;
  10873. /**
  10874. * Registers a step in an ordered way in the targeted stage.
  10875. * @param index Defines the position to register the step in
  10876. * @param component Defines the component attached to the step
  10877. * @param action Defines the action to launch during the step
  10878. */
  10879. registerStep(index: number, component: ISceneComponent, action: T): void;
  10880. /**
  10881. * Clears all the steps from the stage.
  10882. */
  10883. clear(): void;
  10884. }
  10885. }
  10886. declare module BABYLON {
  10887. interface Scene {
  10888. /** @hidden */
  10889. _pointerOverSprite: Nullable<Sprite>;
  10890. /** @hidden */
  10891. _pickedDownSprite: Nullable<Sprite>;
  10892. /** @hidden */
  10893. _tempSpritePickingRay: Nullable<Ray>;
  10894. /**
  10895. * All of the sprite managers added to this scene
  10896. * @see https://doc.babylonjs.com/babylon101/sprites
  10897. */
  10898. spriteManagers: Array<ISpriteManager>;
  10899. /**
  10900. * An event triggered when sprites rendering is about to start
  10901. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10902. */
  10903. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10904. /**
  10905. * An event triggered when sprites rendering is done
  10906. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10907. */
  10908. onAfterSpritesRenderingObservable: Observable<Scene>;
  10909. /** @hidden */
  10910. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10911. /** Launch a ray to try to pick a sprite in the scene
  10912. * @param x position on screen
  10913. * @param y position on screen
  10914. * @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
  10915. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10916. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10917. * @returns a PickingInfo
  10918. */
  10919. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10920. /** Use the given ray to pick a sprite in the scene
  10921. * @param ray The ray (in world space) to use to pick meshes
  10922. * @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
  10923. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10924. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10925. * @returns a PickingInfo
  10926. */
  10927. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10928. /** @hidden */
  10929. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10930. /** Launch a ray to try to pick sprites in the scene
  10931. * @param x position on screen
  10932. * @param y position on screen
  10933. * @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
  10934. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10935. * @returns a PickingInfo array
  10936. */
  10937. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10938. /** Use the given ray to pick sprites in the scene
  10939. * @param ray The ray (in world space) to use to pick meshes
  10940. * @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
  10941. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10942. * @returns a PickingInfo array
  10943. */
  10944. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10945. /**
  10946. * Force the sprite under the pointer
  10947. * @param sprite defines the sprite to use
  10948. */
  10949. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10950. /**
  10951. * Gets the sprite under the pointer
  10952. * @returns a Sprite or null if no sprite is under the pointer
  10953. */
  10954. getPointerOverSprite(): Nullable<Sprite>;
  10955. }
  10956. /**
  10957. * Defines the sprite scene component responsible to manage sprites
  10958. * in a given scene.
  10959. */
  10960. export class SpriteSceneComponent implements ISceneComponent {
  10961. /**
  10962. * The component name helpfull to identify the component in the list of scene components.
  10963. */
  10964. readonly name: string;
  10965. /**
  10966. * The scene the component belongs to.
  10967. */
  10968. scene: Scene;
  10969. /** @hidden */
  10970. private _spritePredicate;
  10971. /**
  10972. * Creates a new instance of the component for the given scene
  10973. * @param scene Defines the scene to register the component in
  10974. */
  10975. constructor(scene: Scene);
  10976. /**
  10977. * Registers the component in a given scene
  10978. */
  10979. register(): void;
  10980. /**
  10981. * Rebuilds the elements related to this component in case of
  10982. * context lost for instance.
  10983. */
  10984. rebuild(): void;
  10985. /**
  10986. * Disposes the component and the associated ressources.
  10987. */
  10988. dispose(): void;
  10989. private _pickSpriteButKeepRay;
  10990. private _pointerMove;
  10991. private _pointerDown;
  10992. private _pointerUp;
  10993. }
  10994. }
  10995. declare module BABYLON {
  10996. /** @hidden */
  10997. export var fogFragmentDeclaration: {
  10998. name: string;
  10999. shader: string;
  11000. };
  11001. }
  11002. declare module BABYLON {
  11003. /** @hidden */
  11004. export var fogFragment: {
  11005. name: string;
  11006. shader: string;
  11007. };
  11008. }
  11009. declare module BABYLON {
  11010. /** @hidden */
  11011. export var imageProcessingCompatibility: {
  11012. name: string;
  11013. shader: string;
  11014. };
  11015. }
  11016. declare module BABYLON {
  11017. /** @hidden */
  11018. export var spritesPixelShader: {
  11019. name: string;
  11020. shader: string;
  11021. };
  11022. }
  11023. declare module BABYLON {
  11024. /** @hidden */
  11025. export var fogVertexDeclaration: {
  11026. name: string;
  11027. shader: string;
  11028. };
  11029. }
  11030. declare module BABYLON {
  11031. /** @hidden */
  11032. export var spritesVertexShader: {
  11033. name: string;
  11034. shader: string;
  11035. };
  11036. }
  11037. declare module BABYLON {
  11038. /**
  11039. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11040. */
  11041. export interface ISpriteManager extends IDisposable {
  11042. /**
  11043. * Gets manager's name
  11044. */
  11045. name: string;
  11046. /**
  11047. * Restricts the camera to viewing objects with the same layerMask.
  11048. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11049. */
  11050. layerMask: number;
  11051. /**
  11052. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11053. */
  11054. isPickable: boolean;
  11055. /**
  11056. * Gets the hosting scene
  11057. */
  11058. scene: Scene;
  11059. /**
  11060. * Specifies the rendering group id for this mesh (0 by default)
  11061. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11062. */
  11063. renderingGroupId: number;
  11064. /**
  11065. * Defines the list of sprites managed by the manager.
  11066. */
  11067. sprites: Array<Sprite>;
  11068. /**
  11069. * Gets or sets the spritesheet texture
  11070. */
  11071. texture: Texture;
  11072. /** Defines the default width of a cell in the spritesheet */
  11073. cellWidth: number;
  11074. /** Defines the default height of a cell in the spritesheet */
  11075. cellHeight: number;
  11076. /**
  11077. * Tests the intersection of a sprite with a specific ray.
  11078. * @param ray The ray we are sending to test the collision
  11079. * @param camera The camera space we are sending rays in
  11080. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11081. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11082. * @returns picking info or null.
  11083. */
  11084. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11085. /**
  11086. * Intersects the sprites with a ray
  11087. * @param ray defines the ray to intersect with
  11088. * @param camera defines the current active camera
  11089. * @param predicate defines a predicate used to select candidate sprites
  11090. * @returns null if no hit or a PickingInfo array
  11091. */
  11092. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11093. /**
  11094. * Renders the list of sprites on screen.
  11095. */
  11096. render(): void;
  11097. }
  11098. /**
  11099. * Class used to manage multiple sprites on the same spritesheet
  11100. * @see https://doc.babylonjs.com/babylon101/sprites
  11101. */
  11102. export class SpriteManager implements ISpriteManager {
  11103. /** defines the manager's name */
  11104. name: string;
  11105. /** Define the Url to load snippets */
  11106. static SnippetUrl: string;
  11107. /** Snippet ID if the manager was created from the snippet server */
  11108. snippetId: string;
  11109. /** Gets the list of sprites */
  11110. sprites: Sprite[];
  11111. /** Gets or sets the rendering group id (0 by default) */
  11112. renderingGroupId: number;
  11113. /** Gets or sets camera layer mask */
  11114. layerMask: number;
  11115. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11116. fogEnabled: boolean;
  11117. /** Gets or sets a boolean indicating if the sprites are pickable */
  11118. isPickable: boolean;
  11119. /** Defines the default width of a cell in the spritesheet */
  11120. cellWidth: number;
  11121. /** Defines the default height of a cell in the spritesheet */
  11122. cellHeight: number;
  11123. /** Associative array from JSON sprite data file */
  11124. private _cellData;
  11125. /** Array of sprite names from JSON sprite data file */
  11126. private _spriteMap;
  11127. /** True when packed cell data from JSON file is ready*/
  11128. private _packedAndReady;
  11129. private _textureContent;
  11130. private _useInstancing;
  11131. /**
  11132. * An event triggered when the manager is disposed.
  11133. */
  11134. onDisposeObservable: Observable<SpriteManager>;
  11135. private _onDisposeObserver;
  11136. /**
  11137. * Callback called when the manager is disposed
  11138. */
  11139. set onDispose(callback: () => void);
  11140. private _capacity;
  11141. private _fromPacked;
  11142. private _spriteTexture;
  11143. private _epsilon;
  11144. private _scene;
  11145. private _vertexData;
  11146. private _buffer;
  11147. private _vertexBuffers;
  11148. private _spriteBuffer;
  11149. private _indexBuffer;
  11150. private _effectBase;
  11151. private _effectFog;
  11152. private _vertexBufferSize;
  11153. /**
  11154. * Gets or sets the unique id of the sprite
  11155. */
  11156. uniqueId: number;
  11157. /**
  11158. * Gets the array of sprites
  11159. */
  11160. get children(): Sprite[];
  11161. /**
  11162. * Gets the hosting scene
  11163. */
  11164. get scene(): Scene;
  11165. /**
  11166. * Gets the capacity of the manager
  11167. */
  11168. get capacity(): number;
  11169. /**
  11170. * Gets or sets the spritesheet texture
  11171. */
  11172. get texture(): Texture;
  11173. set texture(value: Texture);
  11174. private _blendMode;
  11175. /**
  11176. * Blend mode use to render the particle, it can be any of
  11177. * the static Constants.ALPHA_x properties provided in this class.
  11178. * Default value is Constants.ALPHA_COMBINE
  11179. */
  11180. get blendMode(): number;
  11181. set blendMode(blendMode: number);
  11182. /** Disables writing to the depth buffer when rendering the sprites.
  11183. * It can be handy to disable depth writing when using textures without alpha channel
  11184. * and setting some specific blend modes.
  11185. */
  11186. disableDepthWrite: boolean;
  11187. /**
  11188. * Creates a new sprite manager
  11189. * @param name defines the manager's name
  11190. * @param imgUrl defines the sprite sheet url
  11191. * @param capacity defines the maximum allowed number of sprites
  11192. * @param cellSize defines the size of a sprite cell
  11193. * @param scene defines the hosting scene
  11194. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11195. * @param samplingMode defines the smapling mode to use with spritesheet
  11196. * @param fromPacked set to false; do not alter
  11197. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11198. */
  11199. constructor(
  11200. /** defines the manager's name */
  11201. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11202. /**
  11203. * Returns the string "SpriteManager"
  11204. * @returns "SpriteManager"
  11205. */
  11206. getClassName(): string;
  11207. private _makePacked;
  11208. private _appendSpriteVertex;
  11209. private _checkTextureAlpha;
  11210. /**
  11211. * Intersects the sprites with a ray
  11212. * @param ray defines the ray to intersect with
  11213. * @param camera defines the current active camera
  11214. * @param predicate defines a predicate used to select candidate sprites
  11215. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11216. * @returns null if no hit or a PickingInfo
  11217. */
  11218. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11219. /**
  11220. * Intersects the sprites with a ray
  11221. * @param ray defines the ray to intersect with
  11222. * @param camera defines the current active camera
  11223. * @param predicate defines a predicate used to select candidate sprites
  11224. * @returns null if no hit or a PickingInfo array
  11225. */
  11226. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11227. /**
  11228. * Render all child sprites
  11229. */
  11230. render(): void;
  11231. /**
  11232. * Release associated resources
  11233. */
  11234. dispose(): void;
  11235. /**
  11236. * Serializes the sprite manager to a JSON object
  11237. * @param serializeTexture defines if the texture must be serialized as well
  11238. * @returns the JSON object
  11239. */
  11240. serialize(serializeTexture?: boolean): any;
  11241. /**
  11242. * Parses a JSON object to create a new sprite manager.
  11243. * @param parsedManager The JSON object to parse
  11244. * @param scene The scene to create the sprite managerin
  11245. * @param rootUrl The root url to use to load external dependencies like texture
  11246. * @returns the new sprite manager
  11247. */
  11248. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11249. /**
  11250. * Creates a sprite manager from a snippet saved in a remote file
  11251. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11252. * @param url defines the url to load from
  11253. * @param scene defines the hosting scene
  11254. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11255. * @returns a promise that will resolve to the new sprite manager
  11256. */
  11257. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11258. /**
  11259. * Creates a sprite manager from a snippet saved by the sprite editor
  11260. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11261. * @param scene defines the hosting scene
  11262. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11263. * @returns a promise that will resolve to the new sprite manager
  11264. */
  11265. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11266. }
  11267. }
  11268. declare module BABYLON {
  11269. /** Interface used by value gradients (color, factor, ...) */
  11270. export interface IValueGradient {
  11271. /**
  11272. * Gets or sets the gradient value (between 0 and 1)
  11273. */
  11274. gradient: number;
  11275. }
  11276. /** Class used to store color4 gradient */
  11277. export class ColorGradient implements IValueGradient {
  11278. /**
  11279. * Gets or sets the gradient value (between 0 and 1)
  11280. */
  11281. gradient: number;
  11282. /**
  11283. * Gets or sets first associated color
  11284. */
  11285. color1: Color4;
  11286. /**
  11287. * Gets or sets second associated color
  11288. */
  11289. color2?: Color4 | undefined;
  11290. /**
  11291. * Creates a new color4 gradient
  11292. * @param gradient gets or sets the gradient value (between 0 and 1)
  11293. * @param color1 gets or sets first associated color
  11294. * @param color2 gets or sets first second color
  11295. */
  11296. constructor(
  11297. /**
  11298. * Gets or sets the gradient value (between 0 and 1)
  11299. */
  11300. gradient: number,
  11301. /**
  11302. * Gets or sets first associated color
  11303. */
  11304. color1: Color4,
  11305. /**
  11306. * Gets or sets second associated color
  11307. */
  11308. color2?: Color4 | undefined);
  11309. /**
  11310. * Will get a color picked randomly between color1 and color2.
  11311. * If color2 is undefined then color1 will be used
  11312. * @param result defines the target Color4 to store the result in
  11313. */
  11314. getColorToRef(result: Color4): void;
  11315. }
  11316. /** Class used to store color 3 gradient */
  11317. export class Color3Gradient implements IValueGradient {
  11318. /**
  11319. * Gets or sets the gradient value (between 0 and 1)
  11320. */
  11321. gradient: number;
  11322. /**
  11323. * Gets or sets the associated color
  11324. */
  11325. color: Color3;
  11326. /**
  11327. * Creates a new color3 gradient
  11328. * @param gradient gets or sets the gradient value (between 0 and 1)
  11329. * @param color gets or sets associated color
  11330. */
  11331. constructor(
  11332. /**
  11333. * Gets or sets the gradient value (between 0 and 1)
  11334. */
  11335. gradient: number,
  11336. /**
  11337. * Gets or sets the associated color
  11338. */
  11339. color: Color3);
  11340. }
  11341. /** Class used to store factor gradient */
  11342. export class FactorGradient implements IValueGradient {
  11343. /**
  11344. * Gets or sets the gradient value (between 0 and 1)
  11345. */
  11346. gradient: number;
  11347. /**
  11348. * Gets or sets first associated factor
  11349. */
  11350. factor1: number;
  11351. /**
  11352. * Gets or sets second associated factor
  11353. */
  11354. factor2?: number | undefined;
  11355. /**
  11356. * Creates a new factor gradient
  11357. * @param gradient gets or sets the gradient value (between 0 and 1)
  11358. * @param factor1 gets or sets first associated factor
  11359. * @param factor2 gets or sets second associated factor
  11360. */
  11361. constructor(
  11362. /**
  11363. * Gets or sets the gradient value (between 0 and 1)
  11364. */
  11365. gradient: number,
  11366. /**
  11367. * Gets or sets first associated factor
  11368. */
  11369. factor1: number,
  11370. /**
  11371. * Gets or sets second associated factor
  11372. */
  11373. factor2?: number | undefined);
  11374. /**
  11375. * Will get a number picked randomly between factor1 and factor2.
  11376. * If factor2 is undefined then factor1 will be used
  11377. * @returns the picked number
  11378. */
  11379. getFactor(): number;
  11380. }
  11381. /**
  11382. * Helper used to simplify some generic gradient tasks
  11383. */
  11384. export class GradientHelper {
  11385. /**
  11386. * Gets the current gradient from an array of IValueGradient
  11387. * @param ratio defines the current ratio to get
  11388. * @param gradients defines the array of IValueGradient
  11389. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11390. */
  11391. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11392. }
  11393. }
  11394. declare module BABYLON {
  11395. interface ThinEngine {
  11396. /**
  11397. * Creates a raw texture
  11398. * @param data defines the data to store in the texture
  11399. * @param width defines the width of the texture
  11400. * @param height defines the height of the texture
  11401. * @param format defines the format of the data
  11402. * @param generateMipMaps defines if the engine should generate the mip levels
  11403. * @param invertY defines if data must be stored with Y axis inverted
  11404. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11405. * @param compression defines the compression used (null by default)
  11406. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11407. * @returns the raw texture inside an InternalTexture
  11408. */
  11409. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11410. /**
  11411. * Update a raw texture
  11412. * @param texture defines the texture to update
  11413. * @param data defines the data to store in the texture
  11414. * @param format defines the format of the data
  11415. * @param invertY defines if data must be stored with Y axis inverted
  11416. */
  11417. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11418. /**
  11419. * Update a raw texture
  11420. * @param texture defines the texture to update
  11421. * @param data defines the data to store in the texture
  11422. * @param format defines the format of the data
  11423. * @param invertY defines if data must be stored with Y axis inverted
  11424. * @param compression defines the compression used (null by default)
  11425. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11426. */
  11427. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11428. /**
  11429. * Creates a new raw cube texture
  11430. * @param data defines the array of data to use to create each face
  11431. * @param size defines the size of the textures
  11432. * @param format defines the format of the data
  11433. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11434. * @param generateMipMaps defines if the engine should generate the mip levels
  11435. * @param invertY defines if data must be stored with Y axis inverted
  11436. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11437. * @param compression defines the compression used (null by default)
  11438. * @returns the cube texture as an InternalTexture
  11439. */
  11440. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11441. /**
  11442. * Update a raw cube texture
  11443. * @param texture defines the texture to udpdate
  11444. * @param data defines the data to store
  11445. * @param format defines the data format
  11446. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11447. * @param invertY defines if data must be stored with Y axis inverted
  11448. */
  11449. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11450. /**
  11451. * Update a raw cube texture
  11452. * @param texture defines the texture to udpdate
  11453. * @param data defines the data to store
  11454. * @param format defines the data format
  11455. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11456. * @param invertY defines if data must be stored with Y axis inverted
  11457. * @param compression defines the compression used (null by default)
  11458. */
  11459. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11460. /**
  11461. * Update a raw cube texture
  11462. * @param texture defines the texture to udpdate
  11463. * @param data defines the data to store
  11464. * @param format defines the data format
  11465. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11466. * @param invertY defines if data must be stored with Y axis inverted
  11467. * @param compression defines the compression used (null by default)
  11468. * @param level defines which level of the texture to update
  11469. */
  11470. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11471. /**
  11472. * Creates a new raw cube texture from a specified url
  11473. * @param url defines the url where the data is located
  11474. * @param scene defines the current scene
  11475. * @param size defines the size of the textures
  11476. * @param format defines the format of the data
  11477. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11478. * @param noMipmap defines if the engine should avoid generating the mip levels
  11479. * @param callback defines a callback used to extract texture data from loaded data
  11480. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11481. * @param onLoad defines a callback called when texture is loaded
  11482. * @param onError defines a callback called if there is an error
  11483. * @returns the cube texture as an InternalTexture
  11484. */
  11485. 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;
  11486. /**
  11487. * Creates a new raw cube texture from a specified url
  11488. * @param url defines the url where the data is located
  11489. * @param scene defines the current scene
  11490. * @param size defines the size of the textures
  11491. * @param format defines the format of the data
  11492. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11493. * @param noMipmap defines if the engine should avoid generating the mip levels
  11494. * @param callback defines a callback used to extract texture data from loaded data
  11495. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11496. * @param onLoad defines a callback called when texture is loaded
  11497. * @param onError defines a callback called if there is an error
  11498. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11499. * @param invertY defines if data must be stored with Y axis inverted
  11500. * @returns the cube texture as an InternalTexture
  11501. */
  11502. 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;
  11503. /**
  11504. * Creates a new raw 3D texture
  11505. * @param data defines the data used to create the texture
  11506. * @param width defines the width of the texture
  11507. * @param height defines the height of the texture
  11508. * @param depth defines the depth of the texture
  11509. * @param format defines the format of the texture
  11510. * @param generateMipMaps defines if the engine must generate mip levels
  11511. * @param invertY defines if data must be stored with Y axis inverted
  11512. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11513. * @param compression defines the compressed used (can be null)
  11514. * @param textureType defines the compressed used (can be null)
  11515. * @returns a new raw 3D texture (stored in an InternalTexture)
  11516. */
  11517. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11518. /**
  11519. * Update a raw 3D texture
  11520. * @param texture defines the texture to update
  11521. * @param data defines the data to store
  11522. * @param format defines the data format
  11523. * @param invertY defines if data must be stored with Y axis inverted
  11524. */
  11525. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11526. /**
  11527. * Update a raw 3D texture
  11528. * @param texture defines the texture to update
  11529. * @param data defines the data to store
  11530. * @param format defines the data format
  11531. * @param invertY defines if data must be stored with Y axis inverted
  11532. * @param compression defines the used compression (can be null)
  11533. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11534. */
  11535. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11536. /**
  11537. * Creates a new raw 2D array texture
  11538. * @param data defines the data used to create the texture
  11539. * @param width defines the width of the texture
  11540. * @param height defines the height of the texture
  11541. * @param depth defines the number of layers of the texture
  11542. * @param format defines the format of the texture
  11543. * @param generateMipMaps defines if the engine must generate mip levels
  11544. * @param invertY defines if data must be stored with Y axis inverted
  11545. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11546. * @param compression defines the compressed used (can be null)
  11547. * @param textureType defines the compressed used (can be null)
  11548. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11549. */
  11550. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11551. /**
  11552. * Update a raw 2D array texture
  11553. * @param texture defines the texture to update
  11554. * @param data defines the data to store
  11555. * @param format defines the data format
  11556. * @param invertY defines if data must be stored with Y axis inverted
  11557. */
  11558. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11559. /**
  11560. * Update a raw 2D array texture
  11561. * @param texture defines the texture to update
  11562. * @param data defines the data to store
  11563. * @param format defines the data format
  11564. * @param invertY defines if data must be stored with Y axis inverted
  11565. * @param compression defines the used compression (can be null)
  11566. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11567. */
  11568. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11569. }
  11570. }
  11571. declare module BABYLON {
  11572. /**
  11573. * Raw texture can help creating a texture directly from an array of data.
  11574. * This can be super useful if you either get the data from an uncompressed source or
  11575. * if you wish to create your texture pixel by pixel.
  11576. */
  11577. export class RawTexture extends Texture {
  11578. /**
  11579. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11580. */
  11581. format: number;
  11582. /**
  11583. * Instantiates a new RawTexture.
  11584. * Raw texture can help creating a texture directly from an array of data.
  11585. * This can be super useful if you either get the data from an uncompressed source or
  11586. * if you wish to create your texture pixel by pixel.
  11587. * @param data define the array of data to use to create the texture
  11588. * @param width define the width of the texture
  11589. * @param height define the height of the texture
  11590. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11591. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11592. * @param generateMipMaps define whether mip maps should be generated or not
  11593. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11594. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11595. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11596. */
  11597. constructor(data: ArrayBufferView, width: number, height: number,
  11598. /**
  11599. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11600. */
  11601. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11602. /**
  11603. * Updates the texture underlying data.
  11604. * @param data Define the new data of the texture
  11605. */
  11606. update(data: ArrayBufferView): void;
  11607. /**
  11608. * Creates a luminance texture from some data.
  11609. * @param data Define the texture data
  11610. * @param width Define the width of the texture
  11611. * @param height Define the height of the texture
  11612. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11613. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11614. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11615. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11616. * @returns the luminance texture
  11617. */
  11618. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11619. /**
  11620. * Creates a luminance alpha texture from some data.
  11621. * @param data Define the texture data
  11622. * @param width Define the width of the texture
  11623. * @param height Define the height of the texture
  11624. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11625. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11626. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11627. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11628. * @returns the luminance alpha texture
  11629. */
  11630. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11631. /**
  11632. * Creates an alpha texture from some data.
  11633. * @param data Define the texture data
  11634. * @param width Define the width of the texture
  11635. * @param height Define the height of the texture
  11636. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11637. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11638. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11639. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11640. * @returns the alpha texture
  11641. */
  11642. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11643. /**
  11644. * Creates a RGB texture from some data.
  11645. * @param data Define the texture data
  11646. * @param width Define the width of the texture
  11647. * @param height Define the height of the texture
  11648. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11649. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11650. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11651. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11652. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11653. * @returns the RGB alpha texture
  11654. */
  11655. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11656. /**
  11657. * Creates a RGBA 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 RGBA texture
  11667. */
  11668. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11669. /**
  11670. * Creates a R 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 R texture
  11680. */
  11681. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11682. }
  11683. }
  11684. declare module BABYLON {
  11685. interface ThinEngine {
  11686. /**
  11687. * Update a dynamic index buffer
  11688. * @param indexBuffer defines the target index buffer
  11689. * @param indices defines the data to update
  11690. * @param offset defines the offset in the target index buffer where update should start
  11691. */
  11692. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11693. /**
  11694. * Updates a dynamic vertex buffer.
  11695. * @param vertexBuffer the vertex buffer to update
  11696. * @param data the data used to update the vertex buffer
  11697. * @param byteOffset the byte offset of the data
  11698. * @param byteLength the byte length of the data
  11699. */
  11700. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11701. }
  11702. }
  11703. declare module BABYLON {
  11704. interface AbstractScene {
  11705. /**
  11706. * The list of procedural textures added to the scene
  11707. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11708. */
  11709. proceduralTextures: Array<ProceduralTexture>;
  11710. }
  11711. /**
  11712. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11713. * in a given scene.
  11714. */
  11715. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11716. /**
  11717. * The component name helpfull to identify the component in the list of scene components.
  11718. */
  11719. readonly name: string;
  11720. /**
  11721. * The scene the component belongs to.
  11722. */
  11723. scene: Scene;
  11724. /**
  11725. * Creates a new instance of the component for the given scene
  11726. * @param scene Defines the scene to register the component in
  11727. */
  11728. constructor(scene: Scene);
  11729. /**
  11730. * Registers the component in a given scene
  11731. */
  11732. register(): void;
  11733. /**
  11734. * Rebuilds the elements related to this component in case of
  11735. * context lost for instance.
  11736. */
  11737. rebuild(): void;
  11738. /**
  11739. * Disposes the component and the associated ressources.
  11740. */
  11741. dispose(): void;
  11742. private _beforeClear;
  11743. }
  11744. }
  11745. declare module BABYLON {
  11746. interface ThinEngine {
  11747. /**
  11748. * Creates a new render target cube texture
  11749. * @param size defines the size of the texture
  11750. * @param options defines the options used to create the texture
  11751. * @returns a new render target cube texture stored in an InternalTexture
  11752. */
  11753. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11754. }
  11755. }
  11756. declare module BABYLON {
  11757. /** @hidden */
  11758. export var proceduralVertexShader: {
  11759. name: string;
  11760. shader: string;
  11761. };
  11762. }
  11763. declare module BABYLON {
  11764. /**
  11765. * 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.
  11766. * This is the base class of any Procedural texture and contains most of the shareable code.
  11767. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11768. */
  11769. export class ProceduralTexture extends Texture {
  11770. /**
  11771. * Define if the texture is enabled or not (disabled texture will not render)
  11772. */
  11773. isEnabled: boolean;
  11774. /**
  11775. * Define if the texture must be cleared before rendering (default is true)
  11776. */
  11777. autoClear: boolean;
  11778. /**
  11779. * Callback called when the texture is generated
  11780. */
  11781. onGenerated: () => void;
  11782. /**
  11783. * Event raised when the texture is generated
  11784. */
  11785. onGeneratedObservable: Observable<ProceduralTexture>;
  11786. /**
  11787. * Event raised before the texture is generated
  11788. */
  11789. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11790. /**
  11791. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11792. */
  11793. nodeMaterialSource: Nullable<NodeMaterial>;
  11794. /** @hidden */
  11795. _generateMipMaps: boolean;
  11796. /** @hidden **/
  11797. _effect: Effect;
  11798. /** @hidden */
  11799. _textures: {
  11800. [key: string]: Texture;
  11801. };
  11802. /** @hidden */
  11803. protected _fallbackTexture: Nullable<Texture>;
  11804. private _size;
  11805. private _currentRefreshId;
  11806. private _frameId;
  11807. private _refreshRate;
  11808. private _vertexBuffers;
  11809. private _indexBuffer;
  11810. private _uniforms;
  11811. private _samplers;
  11812. private _fragment;
  11813. private _floats;
  11814. private _ints;
  11815. private _floatsArrays;
  11816. private _colors3;
  11817. private _colors4;
  11818. private _vectors2;
  11819. private _vectors3;
  11820. private _matrices;
  11821. private _fallbackTextureUsed;
  11822. private _fullEngine;
  11823. private _cachedDefines;
  11824. private _contentUpdateId;
  11825. private _contentData;
  11826. /**
  11827. * Instantiates a new procedural texture.
  11828. * 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.
  11829. * This is the base class of any Procedural texture and contains most of the shareable code.
  11830. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11831. * @param name Define the name of the texture
  11832. * @param size Define the size of the texture to create
  11833. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11834. * @param scene Define the scene the texture belongs to
  11835. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11836. * @param generateMipMaps Define if the texture should creates mip maps or not
  11837. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11838. * @param textureType The FBO internal texture type
  11839. */
  11840. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  11841. /**
  11842. * The effect that is created when initializing the post process.
  11843. * @returns The created effect corresponding the the postprocess.
  11844. */
  11845. getEffect(): Effect;
  11846. /**
  11847. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11848. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11849. */
  11850. getContent(): Nullable<ArrayBufferView>;
  11851. private _createIndexBuffer;
  11852. /** @hidden */
  11853. _rebuild(): void;
  11854. /**
  11855. * Resets the texture in order to recreate its associated resources.
  11856. * This can be called in case of context loss
  11857. */
  11858. reset(): void;
  11859. protected _getDefines(): string;
  11860. /**
  11861. * Is the texture ready to be used ? (rendered at least once)
  11862. * @returns true if ready, otherwise, false.
  11863. */
  11864. isReady(): boolean;
  11865. /**
  11866. * Resets the refresh counter of the texture and start bak from scratch.
  11867. * Could be useful to regenerate the texture if it is setup to render only once.
  11868. */
  11869. resetRefreshCounter(): void;
  11870. /**
  11871. * Set the fragment shader to use in order to render the texture.
  11872. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11873. */
  11874. setFragment(fragment: any): void;
  11875. /**
  11876. * Define the refresh rate of the texture or the rendering frequency.
  11877. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11878. */
  11879. get refreshRate(): number;
  11880. set refreshRate(value: number);
  11881. /** @hidden */
  11882. _shouldRender(): boolean;
  11883. /**
  11884. * Get the size the texture is rendering at.
  11885. * @returns the size (on cube texture it is always squared)
  11886. */
  11887. getRenderSize(): RenderTargetTextureSize;
  11888. /**
  11889. * Resize the texture to new value.
  11890. * @param size Define the new size the texture should have
  11891. * @param generateMipMaps Define whether the new texture should create mip maps
  11892. */
  11893. resize(size: number, generateMipMaps: boolean): void;
  11894. private _checkUniform;
  11895. /**
  11896. * Set a texture in the shader program used to render.
  11897. * @param name Define the name of the uniform samplers as defined in the shader
  11898. * @param texture Define the texture to bind to this sampler
  11899. * @return the texture itself allowing "fluent" like uniform updates
  11900. */
  11901. setTexture(name: string, texture: Texture): ProceduralTexture;
  11902. /**
  11903. * Set a float in the shader.
  11904. * @param name Define the name of the uniform as defined in the shader
  11905. * @param value Define the value to give to the uniform
  11906. * @return the texture itself allowing "fluent" like uniform updates
  11907. */
  11908. setFloat(name: string, value: number): ProceduralTexture;
  11909. /**
  11910. * Set a int in the shader.
  11911. * @param name Define the name of the uniform as defined in the shader
  11912. * @param value Define the value to give to the uniform
  11913. * @return the texture itself allowing "fluent" like uniform updates
  11914. */
  11915. setInt(name: string, value: number): ProceduralTexture;
  11916. /**
  11917. * Set an array of floats in the shader.
  11918. * @param name Define the name of the uniform as defined in the shader
  11919. * @param value Define the value to give to the uniform
  11920. * @return the texture itself allowing "fluent" like uniform updates
  11921. */
  11922. setFloats(name: string, value: number[]): ProceduralTexture;
  11923. /**
  11924. * Set a vec3 in the shader from a Color3.
  11925. * @param name Define the name of the uniform as defined in the shader
  11926. * @param value Define the value to give to the uniform
  11927. * @return the texture itself allowing "fluent" like uniform updates
  11928. */
  11929. setColor3(name: string, value: Color3): ProceduralTexture;
  11930. /**
  11931. * Set a vec4 in the shader from a Color4.
  11932. * @param name Define the name of the uniform as defined in the shader
  11933. * @param value Define the value to give to the uniform
  11934. * @return the texture itself allowing "fluent" like uniform updates
  11935. */
  11936. setColor4(name: string, value: Color4): ProceduralTexture;
  11937. /**
  11938. * Set a vec2 in the shader from a Vector2.
  11939. * @param name Define the name of the uniform as defined in the shader
  11940. * @param value Define the value to give to the uniform
  11941. * @return the texture itself allowing "fluent" like uniform updates
  11942. */
  11943. setVector2(name: string, value: Vector2): ProceduralTexture;
  11944. /**
  11945. * Set a vec3 in the shader from a Vector3.
  11946. * @param name Define the name of the uniform as defined in the shader
  11947. * @param value Define the value to give to the uniform
  11948. * @return the texture itself allowing "fluent" like uniform updates
  11949. */
  11950. setVector3(name: string, value: Vector3): ProceduralTexture;
  11951. /**
  11952. * Set a mat4 in the shader from a MAtrix.
  11953. * @param name Define the name of the uniform as defined in the shader
  11954. * @param value Define the value to give to the uniform
  11955. * @return the texture itself allowing "fluent" like uniform updates
  11956. */
  11957. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11958. /**
  11959. * Render the texture to its associated render target.
  11960. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11961. */
  11962. render(useCameraPostProcess?: boolean): void;
  11963. /**
  11964. * Clone the texture.
  11965. * @returns the cloned texture
  11966. */
  11967. clone(): ProceduralTexture;
  11968. /**
  11969. * Dispose the texture and release its asoociated resources.
  11970. */
  11971. dispose(): void;
  11972. }
  11973. }
  11974. declare module BABYLON {
  11975. /**
  11976. * This represents the base class for particle system in Babylon.
  11977. * 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.
  11978. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11979. * @example https://doc.babylonjs.com/babylon101/particles
  11980. */
  11981. export class BaseParticleSystem {
  11982. /**
  11983. * Source color is added to the destination color without alpha affecting the result
  11984. */
  11985. static BLENDMODE_ONEONE: number;
  11986. /**
  11987. * Blend current color and particle color using particle’s alpha
  11988. */
  11989. static BLENDMODE_STANDARD: number;
  11990. /**
  11991. * Add current color and particle color multiplied by particle’s alpha
  11992. */
  11993. static BLENDMODE_ADD: number;
  11994. /**
  11995. * Multiply current color with particle color
  11996. */
  11997. static BLENDMODE_MULTIPLY: number;
  11998. /**
  11999. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12000. */
  12001. static BLENDMODE_MULTIPLYADD: number;
  12002. /**
  12003. * List of animations used by the particle system.
  12004. */
  12005. animations: Animation[];
  12006. /**
  12007. * Gets or sets the unique id of the particle system
  12008. */
  12009. uniqueId: number;
  12010. /**
  12011. * The id of the Particle system.
  12012. */
  12013. id: string;
  12014. /**
  12015. * The friendly name of the Particle system.
  12016. */
  12017. name: string;
  12018. /**
  12019. * Snippet ID if the particle system was created from the snippet server
  12020. */
  12021. snippetId: string;
  12022. /**
  12023. * The rendering group used by the Particle system to chose when to render.
  12024. */
  12025. renderingGroupId: number;
  12026. /**
  12027. * The emitter represents the Mesh or position we are attaching the particle system to.
  12028. */
  12029. emitter: Nullable<AbstractMesh | Vector3>;
  12030. /**
  12031. * The maximum number of particles to emit per frame
  12032. */
  12033. emitRate: number;
  12034. /**
  12035. * If you want to launch only a few particles at once, that can be done, as well.
  12036. */
  12037. manualEmitCount: number;
  12038. /**
  12039. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12040. */
  12041. updateSpeed: number;
  12042. /**
  12043. * The amount of time the particle system is running (depends of the overall update speed).
  12044. */
  12045. targetStopDuration: number;
  12046. /**
  12047. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12048. */
  12049. disposeOnStop: boolean;
  12050. /**
  12051. * Minimum power of emitting particles.
  12052. */
  12053. minEmitPower: number;
  12054. /**
  12055. * Maximum power of emitting particles.
  12056. */
  12057. maxEmitPower: number;
  12058. /**
  12059. * Minimum life time of emitting particles.
  12060. */
  12061. minLifeTime: number;
  12062. /**
  12063. * Maximum life time of emitting particles.
  12064. */
  12065. maxLifeTime: number;
  12066. /**
  12067. * Minimum Size of emitting particles.
  12068. */
  12069. minSize: number;
  12070. /**
  12071. * Maximum Size of emitting particles.
  12072. */
  12073. maxSize: number;
  12074. /**
  12075. * Minimum scale of emitting particles on X axis.
  12076. */
  12077. minScaleX: number;
  12078. /**
  12079. * Maximum scale of emitting particles on X axis.
  12080. */
  12081. maxScaleX: number;
  12082. /**
  12083. * Minimum scale of emitting particles on Y axis.
  12084. */
  12085. minScaleY: number;
  12086. /**
  12087. * Maximum scale of emitting particles on Y axis.
  12088. */
  12089. maxScaleY: number;
  12090. /**
  12091. * Gets or sets the minimal initial rotation in radians.
  12092. */
  12093. minInitialRotation: number;
  12094. /**
  12095. * Gets or sets the maximal initial rotation in radians.
  12096. */
  12097. maxInitialRotation: number;
  12098. /**
  12099. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12100. */
  12101. minAngularSpeed: number;
  12102. /**
  12103. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12104. */
  12105. maxAngularSpeed: number;
  12106. /**
  12107. * The texture used to render each particle. (this can be a spritesheet)
  12108. */
  12109. particleTexture: Nullable<BaseTexture>;
  12110. /**
  12111. * The layer mask we are rendering the particles through.
  12112. */
  12113. layerMask: number;
  12114. /**
  12115. * This can help using your own shader to render the particle system.
  12116. * The according effect will be created
  12117. */
  12118. customShader: any;
  12119. /**
  12120. * By default particle system starts as soon as they are created. This prevents the
  12121. * automatic start to happen and let you decide when to start emitting particles.
  12122. */
  12123. preventAutoStart: boolean;
  12124. private _noiseTexture;
  12125. /**
  12126. * Gets or sets a texture used to add random noise to particle positions
  12127. */
  12128. get noiseTexture(): Nullable<ProceduralTexture>;
  12129. set noiseTexture(value: Nullable<ProceduralTexture>);
  12130. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12131. noiseStrength: Vector3;
  12132. /**
  12133. * Callback triggered when the particle animation is ending.
  12134. */
  12135. onAnimationEnd: Nullable<() => void>;
  12136. /**
  12137. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12138. */
  12139. blendMode: number;
  12140. /**
  12141. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12142. * to override the particles.
  12143. */
  12144. forceDepthWrite: boolean;
  12145. /** 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 */
  12146. preWarmCycles: number;
  12147. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12148. preWarmStepOffset: number;
  12149. /**
  12150. * 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)
  12151. */
  12152. spriteCellChangeSpeed: number;
  12153. /**
  12154. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12155. */
  12156. startSpriteCellID: number;
  12157. /**
  12158. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12159. */
  12160. endSpriteCellID: number;
  12161. /**
  12162. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12163. */
  12164. spriteCellWidth: number;
  12165. /**
  12166. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12167. */
  12168. spriteCellHeight: number;
  12169. /**
  12170. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12171. */
  12172. spriteRandomStartCell: boolean;
  12173. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12174. translationPivot: Vector2;
  12175. /** @hidden */
  12176. protected _isAnimationSheetEnabled: boolean;
  12177. /**
  12178. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12179. */
  12180. beginAnimationOnStart: boolean;
  12181. /**
  12182. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12183. */
  12184. beginAnimationFrom: number;
  12185. /**
  12186. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12187. */
  12188. beginAnimationTo: number;
  12189. /**
  12190. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12191. */
  12192. beginAnimationLoop: boolean;
  12193. /**
  12194. * Gets or sets a world offset applied to all particles
  12195. */
  12196. worldOffset: Vector3;
  12197. /**
  12198. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12199. */
  12200. get isAnimationSheetEnabled(): boolean;
  12201. set isAnimationSheetEnabled(value: boolean);
  12202. /**
  12203. * Get hosting scene
  12204. * @returns the scene
  12205. */
  12206. getScene(): Nullable<Scene>;
  12207. /**
  12208. * You can use gravity if you want to give an orientation to your particles.
  12209. */
  12210. gravity: Vector3;
  12211. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12212. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12213. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12214. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12215. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12216. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12217. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12218. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12219. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12220. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12221. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12222. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12223. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12224. /**
  12225. * Defines the delay in milliseconds before starting the system (0 by default)
  12226. */
  12227. startDelay: number;
  12228. /**
  12229. * Gets the current list of drag gradients.
  12230. * You must use addDragGradient and removeDragGradient to udpate this list
  12231. * @returns the list of drag gradients
  12232. */
  12233. getDragGradients(): Nullable<Array<FactorGradient>>;
  12234. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12235. limitVelocityDamping: number;
  12236. /**
  12237. * Gets the current list of limit velocity gradients.
  12238. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12239. * @returns the list of limit velocity gradients
  12240. */
  12241. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12242. /**
  12243. * Gets the current list of color gradients.
  12244. * You must use addColorGradient and removeColorGradient to udpate this list
  12245. * @returns the list of color gradients
  12246. */
  12247. getColorGradients(): Nullable<Array<ColorGradient>>;
  12248. /**
  12249. * Gets the current list of size gradients.
  12250. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12251. * @returns the list of size gradients
  12252. */
  12253. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12254. /**
  12255. * Gets the current list of color remap gradients.
  12256. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12257. * @returns the list of color remap gradients
  12258. */
  12259. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12260. /**
  12261. * Gets the current list of alpha remap gradients.
  12262. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12263. * @returns the list of alpha remap gradients
  12264. */
  12265. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12266. /**
  12267. * Gets the current list of life time gradients.
  12268. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12269. * @returns the list of life time gradients
  12270. */
  12271. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12272. /**
  12273. * Gets the current list of angular speed gradients.
  12274. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12275. * @returns the list of angular speed gradients
  12276. */
  12277. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12278. /**
  12279. * Gets the current list of velocity gradients.
  12280. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12281. * @returns the list of velocity gradients
  12282. */
  12283. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12284. /**
  12285. * Gets the current list of start size gradients.
  12286. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12287. * @returns the list of start size gradients
  12288. */
  12289. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12290. /**
  12291. * Gets the current list of emit rate gradients.
  12292. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12293. * @returns the list of emit rate gradients
  12294. */
  12295. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12296. /**
  12297. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12298. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12299. */
  12300. get direction1(): Vector3;
  12301. set direction1(value: Vector3);
  12302. /**
  12303. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12304. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12305. */
  12306. get direction2(): Vector3;
  12307. set direction2(value: Vector3);
  12308. /**
  12309. * 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.
  12310. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12311. */
  12312. get minEmitBox(): Vector3;
  12313. set minEmitBox(value: Vector3);
  12314. /**
  12315. * 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.
  12316. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12317. */
  12318. get maxEmitBox(): Vector3;
  12319. set maxEmitBox(value: Vector3);
  12320. /**
  12321. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12322. */
  12323. color1: Color4;
  12324. /**
  12325. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12326. */
  12327. color2: Color4;
  12328. /**
  12329. * Color the particle will have at the end of its lifetime
  12330. */
  12331. colorDead: Color4;
  12332. /**
  12333. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12334. */
  12335. textureMask: Color4;
  12336. /**
  12337. * The particle emitter type defines the emitter used by the particle system.
  12338. * It can be for example box, sphere, or cone...
  12339. */
  12340. particleEmitterType: IParticleEmitterType;
  12341. /** @hidden */
  12342. _isSubEmitter: boolean;
  12343. /**
  12344. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12345. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12346. */
  12347. billboardMode: number;
  12348. protected _isBillboardBased: boolean;
  12349. /**
  12350. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12351. */
  12352. get isBillboardBased(): boolean;
  12353. set isBillboardBased(value: boolean);
  12354. /**
  12355. * The scene the particle system belongs to.
  12356. */
  12357. protected _scene: Nullable<Scene>;
  12358. /**
  12359. * The engine the particle system belongs to.
  12360. */
  12361. protected _engine: ThinEngine;
  12362. /**
  12363. * Local cache of defines for image processing.
  12364. */
  12365. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12366. /**
  12367. * Default configuration related to image processing available in the standard Material.
  12368. */
  12369. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12370. /**
  12371. * Gets the image processing configuration used either in this material.
  12372. */
  12373. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12374. /**
  12375. * Sets the Default image processing configuration used either in the this material.
  12376. *
  12377. * If sets to null, the scene one is in use.
  12378. */
  12379. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12380. /**
  12381. * Attaches a new image processing configuration to the Standard Material.
  12382. * @param configuration
  12383. */
  12384. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12385. /** @hidden */
  12386. protected _reset(): void;
  12387. /** @hidden */
  12388. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12389. /**
  12390. * Instantiates a particle system.
  12391. * 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.
  12392. * @param name The name of the particle system
  12393. */
  12394. constructor(name: string);
  12395. /**
  12396. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12397. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12398. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12399. * @returns the emitter
  12400. */
  12401. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12402. /**
  12403. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12404. * @param radius The radius of the hemisphere to emit from
  12405. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12406. * @returns the emitter
  12407. */
  12408. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12409. /**
  12410. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12411. * @param radius The radius of the sphere to emit from
  12412. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12413. * @returns the emitter
  12414. */
  12415. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12416. /**
  12417. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12418. * @param radius The radius of the sphere to emit from
  12419. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12420. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12421. * @returns the emitter
  12422. */
  12423. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12424. /**
  12425. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12426. * @param radius The radius of the emission cylinder
  12427. * @param height The height of the emission cylinder
  12428. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12429. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12430. * @returns the emitter
  12431. */
  12432. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12433. /**
  12434. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12435. * @param radius The radius of the cylinder to emit from
  12436. * @param height The height of the emission cylinder
  12437. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12438. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12439. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12440. * @returns the emitter
  12441. */
  12442. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12443. /**
  12444. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12445. * @param radius The radius of the cone to emit from
  12446. * @param angle The base angle of the cone
  12447. * @returns the emitter
  12448. */
  12449. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12450. /**
  12451. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12452. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12453. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12454. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12455. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12456. * @returns the emitter
  12457. */
  12458. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12459. }
  12460. }
  12461. declare module BABYLON {
  12462. /**
  12463. * Type of sub emitter
  12464. */
  12465. export enum SubEmitterType {
  12466. /**
  12467. * Attached to the particle over it's lifetime
  12468. */
  12469. ATTACHED = 0,
  12470. /**
  12471. * Created when the particle dies
  12472. */
  12473. END = 1
  12474. }
  12475. /**
  12476. * Sub emitter class used to emit particles from an existing particle
  12477. */
  12478. export class SubEmitter {
  12479. /**
  12480. * the particle system to be used by the sub emitter
  12481. */
  12482. particleSystem: ParticleSystem;
  12483. /**
  12484. * Type of the submitter (Default: END)
  12485. */
  12486. type: SubEmitterType;
  12487. /**
  12488. * 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)
  12489. * Note: This only is supported when using an emitter of type Mesh
  12490. */
  12491. inheritDirection: boolean;
  12492. /**
  12493. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12494. */
  12495. inheritedVelocityAmount: number;
  12496. /**
  12497. * Creates a sub emitter
  12498. * @param particleSystem the particle system to be used by the sub emitter
  12499. */
  12500. constructor(
  12501. /**
  12502. * the particle system to be used by the sub emitter
  12503. */
  12504. particleSystem: ParticleSystem);
  12505. /**
  12506. * Clones the sub emitter
  12507. * @returns the cloned sub emitter
  12508. */
  12509. clone(): SubEmitter;
  12510. /**
  12511. * Serialize current object to a JSON object
  12512. * @returns the serialized object
  12513. */
  12514. serialize(): any;
  12515. /** @hidden */
  12516. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12517. /**
  12518. * Creates a new SubEmitter from a serialized JSON version
  12519. * @param serializationObject defines the JSON object to read from
  12520. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12521. * @param rootUrl defines the rootUrl for data loading
  12522. * @returns a new SubEmitter
  12523. */
  12524. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12525. /** Release associated resources */
  12526. dispose(): void;
  12527. }
  12528. }
  12529. declare module BABYLON {
  12530. /** @hidden */
  12531. export var imageProcessingDeclaration: {
  12532. name: string;
  12533. shader: string;
  12534. };
  12535. }
  12536. declare module BABYLON {
  12537. /** @hidden */
  12538. export var imageProcessingFunctions: {
  12539. name: string;
  12540. shader: string;
  12541. };
  12542. }
  12543. declare module BABYLON {
  12544. /** @hidden */
  12545. export var particlesPixelShader: {
  12546. name: string;
  12547. shader: string;
  12548. };
  12549. }
  12550. declare module BABYLON {
  12551. /** @hidden */
  12552. export var particlesVertexShader: {
  12553. name: string;
  12554. shader: string;
  12555. };
  12556. }
  12557. declare module BABYLON {
  12558. /**
  12559. * Interface used to define entities containing multiple clip planes
  12560. */
  12561. export interface IClipPlanesHolder {
  12562. /**
  12563. * Gets or sets the active clipplane 1
  12564. */
  12565. clipPlane: Nullable<Plane>;
  12566. /**
  12567. * Gets or sets the active clipplane 2
  12568. */
  12569. clipPlane2: Nullable<Plane>;
  12570. /**
  12571. * Gets or sets the active clipplane 3
  12572. */
  12573. clipPlane3: Nullable<Plane>;
  12574. /**
  12575. * Gets or sets the active clipplane 4
  12576. */
  12577. clipPlane4: Nullable<Plane>;
  12578. /**
  12579. * Gets or sets the active clipplane 5
  12580. */
  12581. clipPlane5: Nullable<Plane>;
  12582. /**
  12583. * Gets or sets the active clipplane 6
  12584. */
  12585. clipPlane6: Nullable<Plane>;
  12586. }
  12587. }
  12588. declare module BABYLON {
  12589. /**
  12590. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12591. *
  12592. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12593. *
  12594. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12595. */
  12596. export class ThinMaterialHelper {
  12597. /**
  12598. * Binds the clip plane information from the holder to the effect.
  12599. * @param effect The effect we are binding the data to
  12600. * @param holder The entity containing the clip plane information
  12601. */
  12602. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12603. }
  12604. }
  12605. declare module BABYLON {
  12606. interface ThinEngine {
  12607. /**
  12608. * Sets alpha constants used by some alpha blending modes
  12609. * @param r defines the red component
  12610. * @param g defines the green component
  12611. * @param b defines the blue component
  12612. * @param a defines the alpha component
  12613. */
  12614. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12615. /**
  12616. * Sets the current alpha mode
  12617. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12618. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12619. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12620. */
  12621. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12622. /**
  12623. * Gets the current alpha mode
  12624. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12625. * @returns the current alpha mode
  12626. */
  12627. getAlphaMode(): number;
  12628. /**
  12629. * Sets the current alpha equation
  12630. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12631. */
  12632. setAlphaEquation(equation: number): void;
  12633. /**
  12634. * Gets the current alpha equation.
  12635. * @returns the current alpha equation
  12636. */
  12637. getAlphaEquation(): number;
  12638. }
  12639. }
  12640. declare module BABYLON {
  12641. /**
  12642. * This represents a particle system in Babylon.
  12643. * 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.
  12644. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12645. * @example https://doc.babylonjs.com/babylon101/particles
  12646. */
  12647. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12648. /**
  12649. * Billboard mode will only apply to Y axis
  12650. */
  12651. static readonly BILLBOARDMODE_Y: number;
  12652. /**
  12653. * Billboard mode will apply to all axes
  12654. */
  12655. static readonly BILLBOARDMODE_ALL: number;
  12656. /**
  12657. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12658. */
  12659. static readonly BILLBOARDMODE_STRETCHED: number;
  12660. /**
  12661. * This function can be defined to provide custom update for active particles.
  12662. * This function will be called instead of regular update (age, position, color, etc.).
  12663. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12664. */
  12665. updateFunction: (particles: Particle[]) => void;
  12666. private _emitterWorldMatrix;
  12667. /**
  12668. * This function can be defined to specify initial direction for every new particle.
  12669. * It by default use the emitterType defined function
  12670. */
  12671. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12672. /**
  12673. * This function can be defined to specify initial position for every new particle.
  12674. * It by default use the emitterType defined function
  12675. */
  12676. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12677. /**
  12678. * @hidden
  12679. */
  12680. _inheritedVelocityOffset: Vector3;
  12681. /**
  12682. * An event triggered when the system is disposed
  12683. */
  12684. onDisposeObservable: Observable<IParticleSystem>;
  12685. /**
  12686. * An event triggered when the system is stopped
  12687. */
  12688. onStoppedObservable: Observable<IParticleSystem>;
  12689. private _onDisposeObserver;
  12690. /**
  12691. * Sets a callback that will be triggered when the system is disposed
  12692. */
  12693. set onDispose(callback: () => void);
  12694. private _particles;
  12695. private _epsilon;
  12696. private _capacity;
  12697. private _stockParticles;
  12698. private _newPartsExcess;
  12699. private _vertexData;
  12700. private _vertexBuffer;
  12701. private _vertexBuffers;
  12702. private _spriteBuffer;
  12703. private _indexBuffer;
  12704. private _effect;
  12705. private _customEffect;
  12706. private _cachedDefines;
  12707. private _scaledColorStep;
  12708. private _colorDiff;
  12709. private _scaledDirection;
  12710. private _scaledGravity;
  12711. private _currentRenderId;
  12712. private _alive;
  12713. private _useInstancing;
  12714. private _vertexArrayObject;
  12715. private _started;
  12716. private _stopped;
  12717. private _actualFrame;
  12718. private _scaledUpdateSpeed;
  12719. private _vertexBufferSize;
  12720. /** @hidden */
  12721. _currentEmitRateGradient: Nullable<FactorGradient>;
  12722. /** @hidden */
  12723. _currentEmitRate1: number;
  12724. /** @hidden */
  12725. _currentEmitRate2: number;
  12726. /** @hidden */
  12727. _currentStartSizeGradient: Nullable<FactorGradient>;
  12728. /** @hidden */
  12729. _currentStartSize1: number;
  12730. /** @hidden */
  12731. _currentStartSize2: number;
  12732. private readonly _rawTextureWidth;
  12733. private _rampGradientsTexture;
  12734. private _useRampGradients;
  12735. /** Gets or sets a matrix to use to compute projection */
  12736. defaultProjectionMatrix: Matrix;
  12737. /** Gets or sets a matrix to use to compute view */
  12738. defaultViewMatrix: Matrix;
  12739. /** Gets or sets a boolean indicating that ramp gradients must be used
  12740. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12741. */
  12742. get useRampGradients(): boolean;
  12743. set useRampGradients(value: boolean);
  12744. /**
  12745. * 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.
  12746. * 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: [])
  12747. */
  12748. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12749. private _subEmitters;
  12750. /**
  12751. * @hidden
  12752. * If the particle systems emitter should be disposed when the particle system is disposed
  12753. */
  12754. _disposeEmitterOnDispose: boolean;
  12755. /**
  12756. * The current active Sub-systems, this property is used by the root particle system only.
  12757. */
  12758. activeSubSystems: Array<ParticleSystem>;
  12759. /**
  12760. * Specifies if the particles are updated in emitter local space or world space
  12761. */
  12762. isLocal: boolean;
  12763. private _rootParticleSystem;
  12764. /**
  12765. * Gets the current list of active particles
  12766. */
  12767. get particles(): Particle[];
  12768. /**
  12769. * Gets the number of particles active at the same time.
  12770. * @returns The number of active particles.
  12771. */
  12772. getActiveCount(): number;
  12773. /**
  12774. * Returns the string "ParticleSystem"
  12775. * @returns a string containing the class name
  12776. */
  12777. getClassName(): string;
  12778. /**
  12779. * Gets a boolean indicating that the system is stopping
  12780. * @returns true if the system is currently stopping
  12781. */
  12782. isStopping(): boolean;
  12783. /**
  12784. * Gets the custom effect used to render the particles
  12785. * @param blendMode Blend mode for which the effect should be retrieved
  12786. * @returns The effect
  12787. */
  12788. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12789. /**
  12790. * Sets the custom effect used to render the particles
  12791. * @param effect The effect to set
  12792. * @param blendMode Blend mode for which the effect should be set
  12793. */
  12794. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12795. /** @hidden */
  12796. private _onBeforeDrawParticlesObservable;
  12797. /**
  12798. * Observable that will be called just before the particles are drawn
  12799. */
  12800. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12801. /**
  12802. * Gets the name of the particle vertex shader
  12803. */
  12804. get vertexShaderName(): string;
  12805. /**
  12806. * Instantiates a particle system.
  12807. * 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.
  12808. * @param name The name of the particle system
  12809. * @param capacity The max number of particles alive at the same time
  12810. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12811. * @param customEffect a custom effect used to change the way particles are rendered by default
  12812. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12813. * @param epsilon Offset used to render the particles
  12814. */
  12815. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12816. private _addFactorGradient;
  12817. private _removeFactorGradient;
  12818. /**
  12819. * Adds a new life time gradient
  12820. * @param gradient defines the gradient to use (between 0 and 1)
  12821. * @param factor defines the life time factor to affect to the specified gradient
  12822. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12823. * @returns the current particle system
  12824. */
  12825. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12826. /**
  12827. * Remove a specific life time gradient
  12828. * @param gradient defines the gradient to remove
  12829. * @returns the current particle system
  12830. */
  12831. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12832. /**
  12833. * Adds a new size gradient
  12834. * @param gradient defines the gradient to use (between 0 and 1)
  12835. * @param factor defines the size factor to affect to the specified gradient
  12836. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12837. * @returns the current particle system
  12838. */
  12839. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12840. /**
  12841. * Remove a specific size gradient
  12842. * @param gradient defines the gradient to remove
  12843. * @returns the current particle system
  12844. */
  12845. removeSizeGradient(gradient: number): IParticleSystem;
  12846. /**
  12847. * Adds a new color remap gradient
  12848. * @param gradient defines the gradient to use (between 0 and 1)
  12849. * @param min defines the color remap minimal range
  12850. * @param max defines the color remap maximal range
  12851. * @returns the current particle system
  12852. */
  12853. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12854. /**
  12855. * Remove a specific color remap gradient
  12856. * @param gradient defines the gradient to remove
  12857. * @returns the current particle system
  12858. */
  12859. removeColorRemapGradient(gradient: number): IParticleSystem;
  12860. /**
  12861. * Adds a new alpha remap gradient
  12862. * @param gradient defines the gradient to use (between 0 and 1)
  12863. * @param min defines the alpha remap minimal range
  12864. * @param max defines the alpha remap maximal range
  12865. * @returns the current particle system
  12866. */
  12867. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12868. /**
  12869. * Remove a specific alpha remap gradient
  12870. * @param gradient defines the gradient to remove
  12871. * @returns the current particle system
  12872. */
  12873. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12874. /**
  12875. * Adds a new angular speed gradient
  12876. * @param gradient defines the gradient to use (between 0 and 1)
  12877. * @param factor defines the angular speed to affect to the specified gradient
  12878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12879. * @returns the current particle system
  12880. */
  12881. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12882. /**
  12883. * Remove a specific angular speed gradient
  12884. * @param gradient defines the gradient to remove
  12885. * @returns the current particle system
  12886. */
  12887. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12888. /**
  12889. * Adds a new velocity gradient
  12890. * @param gradient defines the gradient to use (between 0 and 1)
  12891. * @param factor defines the velocity to affect to the specified gradient
  12892. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12893. * @returns the current particle system
  12894. */
  12895. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12896. /**
  12897. * Remove a specific velocity gradient
  12898. * @param gradient defines the gradient to remove
  12899. * @returns the current particle system
  12900. */
  12901. removeVelocityGradient(gradient: number): IParticleSystem;
  12902. /**
  12903. * Adds a new limit velocity gradient
  12904. * @param gradient defines the gradient to use (between 0 and 1)
  12905. * @param factor defines the limit velocity value to affect to the specified gradient
  12906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12907. * @returns the current particle system
  12908. */
  12909. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12910. /**
  12911. * Remove a specific limit velocity gradient
  12912. * @param gradient defines the gradient to remove
  12913. * @returns the current particle system
  12914. */
  12915. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12916. /**
  12917. * Adds a new drag gradient
  12918. * @param gradient defines the gradient to use (between 0 and 1)
  12919. * @param factor defines the drag value to affect to the specified gradient
  12920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12921. * @returns the current particle system
  12922. */
  12923. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12924. /**
  12925. * Remove a specific drag gradient
  12926. * @param gradient defines the gradient to remove
  12927. * @returns the current particle system
  12928. */
  12929. removeDragGradient(gradient: number): IParticleSystem;
  12930. /**
  12931. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12932. * @param gradient defines the gradient to use (between 0 and 1)
  12933. * @param factor defines the emit rate value to affect to the specified gradient
  12934. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12935. * @returns the current particle system
  12936. */
  12937. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12938. /**
  12939. * Remove a specific emit rate gradient
  12940. * @param gradient defines the gradient to remove
  12941. * @returns the current particle system
  12942. */
  12943. removeEmitRateGradient(gradient: number): IParticleSystem;
  12944. /**
  12945. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12946. * @param gradient defines the gradient to use (between 0 and 1)
  12947. * @param factor defines the start size value to affect to the specified gradient
  12948. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12949. * @returns the current particle system
  12950. */
  12951. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12952. /**
  12953. * Remove a specific start size gradient
  12954. * @param gradient defines the gradient to remove
  12955. * @returns the current particle system
  12956. */
  12957. removeStartSizeGradient(gradient: number): IParticleSystem;
  12958. private _createRampGradientTexture;
  12959. /**
  12960. * Gets the current list of ramp gradients.
  12961. * You must use addRampGradient and removeRampGradient to udpate this list
  12962. * @returns the list of ramp gradients
  12963. */
  12964. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12965. /** Force the system to rebuild all gradients that need to be resync */
  12966. forceRefreshGradients(): void;
  12967. private _syncRampGradientTexture;
  12968. /**
  12969. * Adds a new ramp gradient used to remap particle colors
  12970. * @param gradient defines the gradient to use (between 0 and 1)
  12971. * @param color defines the color to affect to the specified gradient
  12972. * @returns the current particle system
  12973. */
  12974. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12975. /**
  12976. * Remove a specific ramp gradient
  12977. * @param gradient defines the gradient to remove
  12978. * @returns the current particle system
  12979. */
  12980. removeRampGradient(gradient: number): ParticleSystem;
  12981. /**
  12982. * Adds a new color gradient
  12983. * @param gradient defines the gradient to use (between 0 and 1)
  12984. * @param color1 defines the color to affect to the specified gradient
  12985. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12986. * @returns this particle system
  12987. */
  12988. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12989. /**
  12990. * Remove a specific color gradient
  12991. * @param gradient defines the gradient to remove
  12992. * @returns this particle system
  12993. */
  12994. removeColorGradient(gradient: number): IParticleSystem;
  12995. private _fetchR;
  12996. protected _reset(): void;
  12997. private _resetEffect;
  12998. private _createVertexBuffers;
  12999. private _createIndexBuffer;
  13000. /**
  13001. * Gets the maximum number of particles active at the same time.
  13002. * @returns The max number of active particles.
  13003. */
  13004. getCapacity(): number;
  13005. /**
  13006. * Gets whether there are still active particles in the system.
  13007. * @returns True if it is alive, otherwise false.
  13008. */
  13009. isAlive(): boolean;
  13010. /**
  13011. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13012. * @returns True if it has been started, otherwise false.
  13013. */
  13014. isStarted(): boolean;
  13015. private _prepareSubEmitterInternalArray;
  13016. /**
  13017. * Starts the particle system and begins to emit
  13018. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13019. */
  13020. start(delay?: number): void;
  13021. /**
  13022. * Stops the particle system.
  13023. * @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.
  13024. */
  13025. stop(stopSubEmitters?: boolean): void;
  13026. /**
  13027. * Remove all active particles
  13028. */
  13029. reset(): void;
  13030. /**
  13031. * @hidden (for internal use only)
  13032. */
  13033. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13034. /**
  13035. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13036. * Its lifetime will start back at 0.
  13037. */
  13038. recycleParticle: (particle: Particle) => void;
  13039. private _stopSubEmitters;
  13040. private _createParticle;
  13041. private _removeFromRoot;
  13042. private _emitFromParticle;
  13043. private _update;
  13044. /** @hidden */
  13045. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13046. /** @hidden */
  13047. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13048. /**
  13049. * Fill the defines array according to the current settings of the particle system
  13050. * @param defines Array to be updated
  13051. * @param blendMode blend mode to take into account when updating the array
  13052. */
  13053. fillDefines(defines: Array<string>, blendMode: number): void;
  13054. /**
  13055. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13056. * @param uniforms Uniforms array to fill
  13057. * @param attributes Attributes array to fill
  13058. * @param samplers Samplers array to fill
  13059. */
  13060. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13061. /** @hidden */
  13062. private _getEffect;
  13063. /**
  13064. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13065. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13066. */
  13067. animate(preWarmOnly?: boolean): void;
  13068. private _appendParticleVertices;
  13069. /**
  13070. * Rebuilds the particle system.
  13071. */
  13072. rebuild(): void;
  13073. /**
  13074. * Is this system ready to be used/rendered
  13075. * @return true if the system is ready
  13076. */
  13077. isReady(): boolean;
  13078. private _render;
  13079. /**
  13080. * Renders the particle system in its current state.
  13081. * @returns the current number of particles
  13082. */
  13083. render(): number;
  13084. /**
  13085. * Disposes the particle system and free the associated resources
  13086. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13087. */
  13088. dispose(disposeTexture?: boolean): void;
  13089. /**
  13090. * Clones the particle system.
  13091. * @param name The name of the cloned object
  13092. * @param newEmitter The new emitter to use
  13093. * @returns the cloned particle system
  13094. */
  13095. clone(name: string, newEmitter: any): ParticleSystem;
  13096. /**
  13097. * Serializes the particle system to a JSON object
  13098. * @param serializeTexture defines if the texture must be serialized as well
  13099. * @returns the JSON object
  13100. */
  13101. serialize(serializeTexture?: boolean): any;
  13102. /** @hidden */
  13103. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13104. /** @hidden */
  13105. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13106. /**
  13107. * Parses a JSON object to create a particle system.
  13108. * @param parsedParticleSystem The JSON object to parse
  13109. * @param sceneOrEngine The scene or the engine to create the particle system in
  13110. * @param rootUrl The root url to use to load external dependencies like texture
  13111. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13112. * @returns the Parsed particle system
  13113. */
  13114. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13115. }
  13116. }
  13117. declare module BABYLON {
  13118. /**
  13119. * A particle represents one of the element emitted by a particle system.
  13120. * This is mainly define by its coordinates, direction, velocity and age.
  13121. */
  13122. export class Particle {
  13123. /**
  13124. * The particle system the particle belongs to.
  13125. */
  13126. particleSystem: ParticleSystem;
  13127. private static _Count;
  13128. /**
  13129. * Unique ID of the particle
  13130. */
  13131. id: number;
  13132. /**
  13133. * The world position of the particle in the scene.
  13134. */
  13135. position: Vector3;
  13136. /**
  13137. * The world direction of the particle in the scene.
  13138. */
  13139. direction: Vector3;
  13140. /**
  13141. * The color of the particle.
  13142. */
  13143. color: Color4;
  13144. /**
  13145. * The color change of the particle per step.
  13146. */
  13147. colorStep: Color4;
  13148. /**
  13149. * Defines how long will the life of the particle be.
  13150. */
  13151. lifeTime: number;
  13152. /**
  13153. * The current age of the particle.
  13154. */
  13155. age: number;
  13156. /**
  13157. * The current size of the particle.
  13158. */
  13159. size: number;
  13160. /**
  13161. * The current scale of the particle.
  13162. */
  13163. scale: Vector2;
  13164. /**
  13165. * The current angle of the particle.
  13166. */
  13167. angle: number;
  13168. /**
  13169. * Defines how fast is the angle changing.
  13170. */
  13171. angularSpeed: number;
  13172. /**
  13173. * Defines the cell index used by the particle to be rendered from a sprite.
  13174. */
  13175. cellIndex: number;
  13176. /**
  13177. * The information required to support color remapping
  13178. */
  13179. remapData: Vector4;
  13180. /** @hidden */
  13181. _randomCellOffset?: number;
  13182. /** @hidden */
  13183. _initialDirection: Nullable<Vector3>;
  13184. /** @hidden */
  13185. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13186. /** @hidden */
  13187. _initialStartSpriteCellID: number;
  13188. /** @hidden */
  13189. _initialEndSpriteCellID: number;
  13190. /** @hidden */
  13191. _currentColorGradient: Nullable<ColorGradient>;
  13192. /** @hidden */
  13193. _currentColor1: Color4;
  13194. /** @hidden */
  13195. _currentColor2: Color4;
  13196. /** @hidden */
  13197. _currentSizeGradient: Nullable<FactorGradient>;
  13198. /** @hidden */
  13199. _currentSize1: number;
  13200. /** @hidden */
  13201. _currentSize2: number;
  13202. /** @hidden */
  13203. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13204. /** @hidden */
  13205. _currentAngularSpeed1: number;
  13206. /** @hidden */
  13207. _currentAngularSpeed2: number;
  13208. /** @hidden */
  13209. _currentVelocityGradient: Nullable<FactorGradient>;
  13210. /** @hidden */
  13211. _currentVelocity1: number;
  13212. /** @hidden */
  13213. _currentVelocity2: number;
  13214. /** @hidden */
  13215. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13216. /** @hidden */
  13217. _currentLimitVelocity1: number;
  13218. /** @hidden */
  13219. _currentLimitVelocity2: number;
  13220. /** @hidden */
  13221. _currentDragGradient: Nullable<FactorGradient>;
  13222. /** @hidden */
  13223. _currentDrag1: number;
  13224. /** @hidden */
  13225. _currentDrag2: number;
  13226. /** @hidden */
  13227. _randomNoiseCoordinates1: Vector3;
  13228. /** @hidden */
  13229. _randomNoiseCoordinates2: Vector3;
  13230. /** @hidden */
  13231. _localPosition?: Vector3;
  13232. /**
  13233. * Creates a new instance Particle
  13234. * @param particleSystem the particle system the particle belongs to
  13235. */
  13236. constructor(
  13237. /**
  13238. * The particle system the particle belongs to.
  13239. */
  13240. particleSystem: ParticleSystem);
  13241. private updateCellInfoFromSystem;
  13242. /**
  13243. * Defines how the sprite cell index is updated for the particle
  13244. */
  13245. updateCellIndex(): void;
  13246. /** @hidden */
  13247. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13248. /** @hidden */
  13249. _inheritParticleInfoToSubEmitters(): void;
  13250. /** @hidden */
  13251. _reset(): void;
  13252. /**
  13253. * Copy the properties of particle to another one.
  13254. * @param other the particle to copy the information to.
  13255. */
  13256. copyTo(other: Particle): void;
  13257. }
  13258. }
  13259. declare module BABYLON {
  13260. /**
  13261. * Particle emitter represents a volume emitting particles.
  13262. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13263. */
  13264. export interface IParticleEmitterType {
  13265. /**
  13266. * Called by the particle System when the direction is computed for the created particle.
  13267. * @param worldMatrix is the world matrix of the particle system
  13268. * @param directionToUpdate is the direction vector to update with the result
  13269. * @param particle is the particle we are computed the direction for
  13270. * @param isLocal defines if the direction should be set in local space
  13271. */
  13272. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13273. /**
  13274. * Called by the particle System when the position is computed for the created particle.
  13275. * @param worldMatrix is the world matrix of the particle system
  13276. * @param positionToUpdate is the position vector to update with the result
  13277. * @param particle is the particle we are computed the position for
  13278. * @param isLocal defines if the position should be set in local space
  13279. */
  13280. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13281. /**
  13282. * Clones the current emitter and returns a copy of it
  13283. * @returns the new emitter
  13284. */
  13285. clone(): IParticleEmitterType;
  13286. /**
  13287. * Called by the GPUParticleSystem to setup the update shader
  13288. * @param effect defines the update shader
  13289. */
  13290. applyToShader(effect: Effect): void;
  13291. /**
  13292. * Returns a string to use to update the GPU particles update shader
  13293. * @returns the effect defines string
  13294. */
  13295. getEffectDefines(): string;
  13296. /**
  13297. * Returns a string representing the class name
  13298. * @returns a string containing the class name
  13299. */
  13300. getClassName(): string;
  13301. /**
  13302. * Serializes the particle system to a JSON object.
  13303. * @returns the JSON object
  13304. */
  13305. serialize(): any;
  13306. /**
  13307. * Parse properties from a JSON object
  13308. * @param serializationObject defines the JSON object
  13309. * @param scene defines the hosting scene
  13310. */
  13311. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13312. }
  13313. }
  13314. declare module BABYLON {
  13315. /**
  13316. * Particle emitter emitting particles from the inside of a box.
  13317. * It emits the particles randomly between 2 given directions.
  13318. */
  13319. export class BoxParticleEmitter implements IParticleEmitterType {
  13320. /**
  13321. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13322. */
  13323. direction1: Vector3;
  13324. /**
  13325. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13326. */
  13327. direction2: Vector3;
  13328. /**
  13329. * 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.
  13330. */
  13331. minEmitBox: Vector3;
  13332. /**
  13333. * 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.
  13334. */
  13335. maxEmitBox: Vector3;
  13336. /**
  13337. * Creates a new instance BoxParticleEmitter
  13338. */
  13339. constructor();
  13340. /**
  13341. * Called by the particle System when the direction is computed for the created particle.
  13342. * @param worldMatrix is the world matrix of the particle system
  13343. * @param directionToUpdate is the direction vector to update with the result
  13344. * @param particle is the particle we are computed the direction for
  13345. * @param isLocal defines if the direction should be set in local space
  13346. */
  13347. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13348. /**
  13349. * Called by the particle System when the position is computed for the created particle.
  13350. * @param worldMatrix is the world matrix of the particle system
  13351. * @param positionToUpdate is the position vector to update with the result
  13352. * @param particle is the particle we are computed the position for
  13353. * @param isLocal defines if the position should be set in local space
  13354. */
  13355. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13356. /**
  13357. * Clones the current emitter and returns a copy of it
  13358. * @returns the new emitter
  13359. */
  13360. clone(): BoxParticleEmitter;
  13361. /**
  13362. * Called by the GPUParticleSystem to setup the update shader
  13363. * @param effect defines the update shader
  13364. */
  13365. applyToShader(effect: Effect): void;
  13366. /**
  13367. * Returns a string to use to update the GPU particles update shader
  13368. * @returns a string containng the defines string
  13369. */
  13370. getEffectDefines(): string;
  13371. /**
  13372. * Returns the string "BoxParticleEmitter"
  13373. * @returns a string containing the class name
  13374. */
  13375. getClassName(): string;
  13376. /**
  13377. * Serializes the particle system to a JSON object.
  13378. * @returns the JSON object
  13379. */
  13380. serialize(): any;
  13381. /**
  13382. * Parse properties from a JSON object
  13383. * @param serializationObject defines the JSON object
  13384. */
  13385. parse(serializationObject: any): void;
  13386. }
  13387. }
  13388. declare module BABYLON {
  13389. /**
  13390. * Particle emitter emitting particles from the inside of a cone.
  13391. * It emits the particles alongside the cone volume from the base to the particle.
  13392. * The emission direction might be randomized.
  13393. */
  13394. export class ConeParticleEmitter implements IParticleEmitterType {
  13395. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13396. directionRandomizer: number;
  13397. private _radius;
  13398. private _angle;
  13399. private _height;
  13400. /**
  13401. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13402. */
  13403. radiusRange: number;
  13404. /**
  13405. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13406. */
  13407. heightRange: number;
  13408. /**
  13409. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13410. */
  13411. emitFromSpawnPointOnly: boolean;
  13412. /**
  13413. * Gets or sets the radius of the emission cone
  13414. */
  13415. get radius(): number;
  13416. set radius(value: number);
  13417. /**
  13418. * Gets or sets the angle of the emission cone
  13419. */
  13420. get angle(): number;
  13421. set angle(value: number);
  13422. private _buildHeight;
  13423. /**
  13424. * Creates a new instance ConeParticleEmitter
  13425. * @param radius the radius of the emission cone (1 by default)
  13426. * @param angle the cone base angle (PI by default)
  13427. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13428. */
  13429. constructor(radius?: number, angle?: number,
  13430. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13431. directionRandomizer?: number);
  13432. /**
  13433. * Called by the particle System when the direction is computed for the created particle.
  13434. * @param worldMatrix is the world matrix of the particle system
  13435. * @param directionToUpdate is the direction vector to update with the result
  13436. * @param particle is the particle we are computed the direction for
  13437. * @param isLocal defines if the direction should be set in local space
  13438. */
  13439. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13440. /**
  13441. * Called by the particle System when the position is computed for the created particle.
  13442. * @param worldMatrix is the world matrix of the particle system
  13443. * @param positionToUpdate is the position vector to update with the result
  13444. * @param particle is the particle we are computed the position for
  13445. * @param isLocal defines if the position should be set in local space
  13446. */
  13447. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13448. /**
  13449. * Clones the current emitter and returns a copy of it
  13450. * @returns the new emitter
  13451. */
  13452. clone(): ConeParticleEmitter;
  13453. /**
  13454. * Called by the GPUParticleSystem to setup the update shader
  13455. * @param effect defines the update shader
  13456. */
  13457. applyToShader(effect: Effect): void;
  13458. /**
  13459. * Returns a string to use to update the GPU particles update shader
  13460. * @returns a string containng the defines string
  13461. */
  13462. getEffectDefines(): string;
  13463. /**
  13464. * Returns the string "ConeParticleEmitter"
  13465. * @returns a string containing the class name
  13466. */
  13467. getClassName(): string;
  13468. /**
  13469. * Serializes the particle system to a JSON object.
  13470. * @returns the JSON object
  13471. */
  13472. serialize(): any;
  13473. /**
  13474. * Parse properties from a JSON object
  13475. * @param serializationObject defines the JSON object
  13476. */
  13477. parse(serializationObject: any): void;
  13478. }
  13479. }
  13480. declare module BABYLON {
  13481. /**
  13482. * Particle emitter emitting particles from the inside of a cylinder.
  13483. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13484. */
  13485. export class CylinderParticleEmitter implements IParticleEmitterType {
  13486. /**
  13487. * The radius of the emission cylinder.
  13488. */
  13489. radius: number;
  13490. /**
  13491. * The height of the emission cylinder.
  13492. */
  13493. height: number;
  13494. /**
  13495. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13496. */
  13497. radiusRange: number;
  13498. /**
  13499. * How much to randomize the particle direction [0-1].
  13500. */
  13501. directionRandomizer: number;
  13502. /**
  13503. * Creates a new instance CylinderParticleEmitter
  13504. * @param radius the radius of the emission cylinder (1 by default)
  13505. * @param height the height of the emission cylinder (1 by default)
  13506. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13507. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13508. */
  13509. constructor(
  13510. /**
  13511. * The radius of the emission cylinder.
  13512. */
  13513. radius?: number,
  13514. /**
  13515. * The height of the emission cylinder.
  13516. */
  13517. height?: number,
  13518. /**
  13519. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13520. */
  13521. radiusRange?: number,
  13522. /**
  13523. * How much to randomize the particle direction [0-1].
  13524. */
  13525. directionRandomizer?: number);
  13526. /**
  13527. * Called by the particle System when the direction is computed for the created particle.
  13528. * @param worldMatrix is the world matrix of the particle system
  13529. * @param directionToUpdate is the direction vector to update with the result
  13530. * @param particle is the particle we are computed the direction for
  13531. * @param isLocal defines if the direction should be set in local space
  13532. */
  13533. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13534. /**
  13535. * Called by the particle System when the position is computed for the created particle.
  13536. * @param worldMatrix is the world matrix of the particle system
  13537. * @param positionToUpdate is the position vector to update with the result
  13538. * @param particle is the particle we are computed the position for
  13539. * @param isLocal defines if the position should be set in local space
  13540. */
  13541. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13542. /**
  13543. * Clones the current emitter and returns a copy of it
  13544. * @returns the new emitter
  13545. */
  13546. clone(): CylinderParticleEmitter;
  13547. /**
  13548. * Called by the GPUParticleSystem to setup the update shader
  13549. * @param effect defines the update shader
  13550. */
  13551. applyToShader(effect: Effect): void;
  13552. /**
  13553. * Returns a string to use to update the GPU particles update shader
  13554. * @returns a string containng the defines string
  13555. */
  13556. getEffectDefines(): string;
  13557. /**
  13558. * Returns the string "CylinderParticleEmitter"
  13559. * @returns a string containing the class name
  13560. */
  13561. getClassName(): string;
  13562. /**
  13563. * Serializes the particle system to a JSON object.
  13564. * @returns the JSON object
  13565. */
  13566. serialize(): any;
  13567. /**
  13568. * Parse properties from a JSON object
  13569. * @param serializationObject defines the JSON object
  13570. */
  13571. parse(serializationObject: any): void;
  13572. }
  13573. /**
  13574. * Particle emitter emitting particles from the inside of a cylinder.
  13575. * It emits the particles randomly between two vectors.
  13576. */
  13577. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13578. /**
  13579. * The min limit of the emission direction.
  13580. */
  13581. direction1: Vector3;
  13582. /**
  13583. * The max limit of the emission direction.
  13584. */
  13585. direction2: Vector3;
  13586. /**
  13587. * Creates a new instance CylinderDirectedParticleEmitter
  13588. * @param radius the radius of the emission cylinder (1 by default)
  13589. * @param height the height of the emission cylinder (1 by default)
  13590. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13591. * @param direction1 the min limit of the emission direction (up vector by default)
  13592. * @param direction2 the max limit of the emission direction (up vector by default)
  13593. */
  13594. constructor(radius?: number, height?: number, radiusRange?: number,
  13595. /**
  13596. * The min limit of the emission direction.
  13597. */
  13598. direction1?: Vector3,
  13599. /**
  13600. * The max limit of the emission direction.
  13601. */
  13602. direction2?: Vector3);
  13603. /**
  13604. * Called by the particle System when the direction is computed for the created particle.
  13605. * @param worldMatrix is the world matrix of the particle system
  13606. * @param directionToUpdate is the direction vector to update with the result
  13607. * @param particle is the particle we are computed the direction for
  13608. */
  13609. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13610. /**
  13611. * Clones the current emitter and returns a copy of it
  13612. * @returns the new emitter
  13613. */
  13614. clone(): CylinderDirectedParticleEmitter;
  13615. /**
  13616. * Called by the GPUParticleSystem to setup the update shader
  13617. * @param effect defines the update shader
  13618. */
  13619. applyToShader(effect: Effect): void;
  13620. /**
  13621. * Returns a string to use to update the GPU particles update shader
  13622. * @returns a string containng the defines string
  13623. */
  13624. getEffectDefines(): string;
  13625. /**
  13626. * Returns the string "CylinderDirectedParticleEmitter"
  13627. * @returns a string containing the class name
  13628. */
  13629. getClassName(): string;
  13630. /**
  13631. * Serializes the particle system to a JSON object.
  13632. * @returns the JSON object
  13633. */
  13634. serialize(): any;
  13635. /**
  13636. * Parse properties from a JSON object
  13637. * @param serializationObject defines the JSON object
  13638. */
  13639. parse(serializationObject: any): void;
  13640. }
  13641. }
  13642. declare module BABYLON {
  13643. /**
  13644. * Particle emitter emitting particles from the inside of a hemisphere.
  13645. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13646. */
  13647. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13648. /**
  13649. * The radius of the emission hemisphere.
  13650. */
  13651. radius: number;
  13652. /**
  13653. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13654. */
  13655. radiusRange: number;
  13656. /**
  13657. * How much to randomize the particle direction [0-1].
  13658. */
  13659. directionRandomizer: number;
  13660. /**
  13661. * Creates a new instance HemisphericParticleEmitter
  13662. * @param radius the radius of the emission hemisphere (1 by default)
  13663. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13664. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13665. */
  13666. constructor(
  13667. /**
  13668. * The radius of the emission hemisphere.
  13669. */
  13670. radius?: number,
  13671. /**
  13672. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13673. */
  13674. radiusRange?: number,
  13675. /**
  13676. * How much to randomize the particle direction [0-1].
  13677. */
  13678. directionRandomizer?: number);
  13679. /**
  13680. * Called by the particle System when the direction is computed for the created particle.
  13681. * @param worldMatrix is the world matrix of the particle system
  13682. * @param directionToUpdate is the direction vector to update with the result
  13683. * @param particle is the particle we are computed the direction for
  13684. * @param isLocal defines if the direction should be set in local space
  13685. */
  13686. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13687. /**
  13688. * Called by the particle System when the position is computed for the created particle.
  13689. * @param worldMatrix is the world matrix of the particle system
  13690. * @param positionToUpdate is the position vector to update with the result
  13691. * @param particle is the particle we are computed the position for
  13692. * @param isLocal defines if the position should be set in local space
  13693. */
  13694. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13695. /**
  13696. * Clones the current emitter and returns a copy of it
  13697. * @returns the new emitter
  13698. */
  13699. clone(): HemisphericParticleEmitter;
  13700. /**
  13701. * Called by the GPUParticleSystem to setup the update shader
  13702. * @param effect defines the update shader
  13703. */
  13704. applyToShader(effect: Effect): void;
  13705. /**
  13706. * Returns a string to use to update the GPU particles update shader
  13707. * @returns a string containng the defines string
  13708. */
  13709. getEffectDefines(): string;
  13710. /**
  13711. * Returns the string "HemisphericParticleEmitter"
  13712. * @returns a string containing the class name
  13713. */
  13714. getClassName(): string;
  13715. /**
  13716. * Serializes the particle system to a JSON object.
  13717. * @returns the JSON object
  13718. */
  13719. serialize(): any;
  13720. /**
  13721. * Parse properties from a JSON object
  13722. * @param serializationObject defines the JSON object
  13723. */
  13724. parse(serializationObject: any): void;
  13725. }
  13726. }
  13727. declare module BABYLON {
  13728. /**
  13729. * Particle emitter emitting particles from a point.
  13730. * It emits the particles randomly between 2 given directions.
  13731. */
  13732. export class PointParticleEmitter implements IParticleEmitterType {
  13733. /**
  13734. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13735. */
  13736. direction1: Vector3;
  13737. /**
  13738. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13739. */
  13740. direction2: Vector3;
  13741. /**
  13742. * Creates a new instance PointParticleEmitter
  13743. */
  13744. constructor();
  13745. /**
  13746. * Called by the particle System when the direction is computed for the created particle.
  13747. * @param worldMatrix is the world matrix of the particle system
  13748. * @param directionToUpdate is the direction vector to update with the result
  13749. * @param particle is the particle we are computed the direction for
  13750. * @param isLocal defines if the direction should be set in local space
  13751. */
  13752. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13753. /**
  13754. * Called by the particle System when the position is computed for the created particle.
  13755. * @param worldMatrix is the world matrix of the particle system
  13756. * @param positionToUpdate is the position vector to update with the result
  13757. * @param particle is the particle we are computed the position for
  13758. * @param isLocal defines if the position should be set in local space
  13759. */
  13760. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13761. /**
  13762. * Clones the current emitter and returns a copy of it
  13763. * @returns the new emitter
  13764. */
  13765. clone(): PointParticleEmitter;
  13766. /**
  13767. * Called by the GPUParticleSystem to setup the update shader
  13768. * @param effect defines the update shader
  13769. */
  13770. applyToShader(effect: Effect): void;
  13771. /**
  13772. * Returns a string to use to update the GPU particles update shader
  13773. * @returns a string containng the defines string
  13774. */
  13775. getEffectDefines(): string;
  13776. /**
  13777. * Returns the string "PointParticleEmitter"
  13778. * @returns a string containing the class name
  13779. */
  13780. getClassName(): string;
  13781. /**
  13782. * Serializes the particle system to a JSON object.
  13783. * @returns the JSON object
  13784. */
  13785. serialize(): any;
  13786. /**
  13787. * Parse properties from a JSON object
  13788. * @param serializationObject defines the JSON object
  13789. */
  13790. parse(serializationObject: any): void;
  13791. }
  13792. }
  13793. declare module BABYLON {
  13794. /**
  13795. * Particle emitter emitting particles from the inside of a sphere.
  13796. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13797. */
  13798. export class SphereParticleEmitter implements IParticleEmitterType {
  13799. /**
  13800. * The radius of the emission sphere.
  13801. */
  13802. radius: number;
  13803. /**
  13804. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13805. */
  13806. radiusRange: number;
  13807. /**
  13808. * How much to randomize the particle direction [0-1].
  13809. */
  13810. directionRandomizer: number;
  13811. /**
  13812. * Creates a new instance SphereParticleEmitter
  13813. * @param radius the radius of the emission sphere (1 by default)
  13814. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13815. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13816. */
  13817. constructor(
  13818. /**
  13819. * The radius of the emission sphere.
  13820. */
  13821. radius?: number,
  13822. /**
  13823. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13824. */
  13825. radiusRange?: number,
  13826. /**
  13827. * How much to randomize the particle direction [0-1].
  13828. */
  13829. directionRandomizer?: number);
  13830. /**
  13831. * Called by the particle System when the direction is computed for the created particle.
  13832. * @param worldMatrix is the world matrix of the particle system
  13833. * @param directionToUpdate is the direction vector to update with the result
  13834. * @param particle is the particle we are computed the direction for
  13835. * @param isLocal defines if the direction should be set in local space
  13836. */
  13837. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13838. /**
  13839. * Called by the particle System when the position is computed for the created particle.
  13840. * @param worldMatrix is the world matrix of the particle system
  13841. * @param positionToUpdate is the position vector to update with the result
  13842. * @param particle is the particle we are computed the position for
  13843. * @param isLocal defines if the position should be set in local space
  13844. */
  13845. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13846. /**
  13847. * Clones the current emitter and returns a copy of it
  13848. * @returns the new emitter
  13849. */
  13850. clone(): SphereParticleEmitter;
  13851. /**
  13852. * Called by the GPUParticleSystem to setup the update shader
  13853. * @param effect defines the update shader
  13854. */
  13855. applyToShader(effect: Effect): void;
  13856. /**
  13857. * Returns a string to use to update the GPU particles update shader
  13858. * @returns a string containng the defines string
  13859. */
  13860. getEffectDefines(): string;
  13861. /**
  13862. * Returns the string "SphereParticleEmitter"
  13863. * @returns a string containing the class name
  13864. */
  13865. getClassName(): string;
  13866. /**
  13867. * Serializes the particle system to a JSON object.
  13868. * @returns the JSON object
  13869. */
  13870. serialize(): any;
  13871. /**
  13872. * Parse properties from a JSON object
  13873. * @param serializationObject defines the JSON object
  13874. */
  13875. parse(serializationObject: any): void;
  13876. }
  13877. /**
  13878. * Particle emitter emitting particles from the inside of a sphere.
  13879. * It emits the particles randomly between two vectors.
  13880. */
  13881. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13882. /**
  13883. * The min limit of the emission direction.
  13884. */
  13885. direction1: Vector3;
  13886. /**
  13887. * The max limit of the emission direction.
  13888. */
  13889. direction2: Vector3;
  13890. /**
  13891. * Creates a new instance SphereDirectedParticleEmitter
  13892. * @param radius the radius of the emission sphere (1 by default)
  13893. * @param direction1 the min limit of the emission direction (up vector by default)
  13894. * @param direction2 the max limit of the emission direction (up vector by default)
  13895. */
  13896. constructor(radius?: number,
  13897. /**
  13898. * The min limit of the emission direction.
  13899. */
  13900. direction1?: Vector3,
  13901. /**
  13902. * The max limit of the emission direction.
  13903. */
  13904. direction2?: Vector3);
  13905. /**
  13906. * Called by the particle System when the direction is computed for the created particle.
  13907. * @param worldMatrix is the world matrix of the particle system
  13908. * @param directionToUpdate is the direction vector to update with the result
  13909. * @param particle is the particle we are computed the direction for
  13910. */
  13911. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13912. /**
  13913. * Clones the current emitter and returns a copy of it
  13914. * @returns the new emitter
  13915. */
  13916. clone(): SphereDirectedParticleEmitter;
  13917. /**
  13918. * Called by the GPUParticleSystem to setup the update shader
  13919. * @param effect defines the update shader
  13920. */
  13921. applyToShader(effect: Effect): void;
  13922. /**
  13923. * Returns a string to use to update the GPU particles update shader
  13924. * @returns a string containng the defines string
  13925. */
  13926. getEffectDefines(): string;
  13927. /**
  13928. * Returns the string "SphereDirectedParticleEmitter"
  13929. * @returns a string containing the class name
  13930. */
  13931. getClassName(): string;
  13932. /**
  13933. * Serializes the particle system to a JSON object.
  13934. * @returns the JSON object
  13935. */
  13936. serialize(): any;
  13937. /**
  13938. * Parse properties from a JSON object
  13939. * @param serializationObject defines the JSON object
  13940. */
  13941. parse(serializationObject: any): void;
  13942. }
  13943. }
  13944. declare module BABYLON {
  13945. /**
  13946. * Particle emitter emitting particles from a custom list of positions.
  13947. */
  13948. export class CustomParticleEmitter implements IParticleEmitterType {
  13949. /**
  13950. * Gets or sets the position generator that will create the inital position of each particle.
  13951. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13952. */
  13953. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13954. /**
  13955. * Gets or sets the destination generator that will create the final destination of each particle.
  13956. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13957. */
  13958. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13959. /**
  13960. * Creates a new instance CustomParticleEmitter
  13961. */
  13962. constructor();
  13963. /**
  13964. * Called by the particle System when the direction is computed for the created particle.
  13965. * @param worldMatrix is the world matrix of the particle system
  13966. * @param directionToUpdate is the direction vector to update with the result
  13967. * @param particle is the particle we are computed the direction for
  13968. * @param isLocal defines if the direction should be set in local space
  13969. */
  13970. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13971. /**
  13972. * Called by the particle System when the position is computed for the created particle.
  13973. * @param worldMatrix is the world matrix of the particle system
  13974. * @param positionToUpdate is the position vector to update with the result
  13975. * @param particle is the particle we are computed the position for
  13976. * @param isLocal defines if the position should be set in local space
  13977. */
  13978. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13979. /**
  13980. * Clones the current emitter and returns a copy of it
  13981. * @returns the new emitter
  13982. */
  13983. clone(): CustomParticleEmitter;
  13984. /**
  13985. * Called by the GPUParticleSystem to setup the update shader
  13986. * @param effect defines the update shader
  13987. */
  13988. applyToShader(effect: Effect): void;
  13989. /**
  13990. * Returns a string to use to update the GPU particles update shader
  13991. * @returns a string containng the defines string
  13992. */
  13993. getEffectDefines(): string;
  13994. /**
  13995. * Returns the string "PointParticleEmitter"
  13996. * @returns a string containing the class name
  13997. */
  13998. getClassName(): string;
  13999. /**
  14000. * Serializes the particle system to a JSON object.
  14001. * @returns the JSON object
  14002. */
  14003. serialize(): any;
  14004. /**
  14005. * Parse properties from a JSON object
  14006. * @param serializationObject defines the JSON object
  14007. */
  14008. parse(serializationObject: any): void;
  14009. }
  14010. }
  14011. declare module BABYLON {
  14012. /**
  14013. * Particle emitter emitting particles from the inside of a box.
  14014. * It emits the particles randomly between 2 given directions.
  14015. */
  14016. export class MeshParticleEmitter implements IParticleEmitterType {
  14017. private _indices;
  14018. private _positions;
  14019. private _normals;
  14020. private _storedNormal;
  14021. private _mesh;
  14022. /**
  14023. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14024. */
  14025. direction1: Vector3;
  14026. /**
  14027. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14028. */
  14029. direction2: Vector3;
  14030. /**
  14031. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14032. */
  14033. useMeshNormalsForDirection: boolean;
  14034. /** Defines the mesh to use as source */
  14035. get mesh(): Nullable<AbstractMesh>;
  14036. set mesh(value: Nullable<AbstractMesh>);
  14037. /**
  14038. * Creates a new instance MeshParticleEmitter
  14039. * @param mesh defines the mesh to use as source
  14040. */
  14041. constructor(mesh?: Nullable<AbstractMesh>);
  14042. /**
  14043. * Called by the particle System when the direction is computed for the created particle.
  14044. * @param worldMatrix is the world matrix of the particle system
  14045. * @param directionToUpdate is the direction vector to update with the result
  14046. * @param particle is the particle we are computed the direction for
  14047. * @param isLocal defines if the direction should be set in local space
  14048. */
  14049. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14050. /**
  14051. * Called by the particle System when the position is computed for the created particle.
  14052. * @param worldMatrix is the world matrix of the particle system
  14053. * @param positionToUpdate is the position vector to update with the result
  14054. * @param particle is the particle we are computed the position for
  14055. * @param isLocal defines if the position should be set in local space
  14056. */
  14057. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14058. /**
  14059. * Clones the current emitter and returns a copy of it
  14060. * @returns the new emitter
  14061. */
  14062. clone(): MeshParticleEmitter;
  14063. /**
  14064. * Called by the GPUParticleSystem to setup the update shader
  14065. * @param effect defines the update shader
  14066. */
  14067. applyToShader(effect: Effect): void;
  14068. /**
  14069. * Returns a string to use to update the GPU particles update shader
  14070. * @returns a string containng the defines string
  14071. */
  14072. getEffectDefines(): string;
  14073. /**
  14074. * Returns the string "BoxParticleEmitter"
  14075. * @returns a string containing the class name
  14076. */
  14077. getClassName(): string;
  14078. /**
  14079. * Serializes the particle system to a JSON object.
  14080. * @returns the JSON object
  14081. */
  14082. serialize(): any;
  14083. /**
  14084. * Parse properties from a JSON object
  14085. * @param serializationObject defines the JSON object
  14086. * @param scene defines the hosting scene
  14087. */
  14088. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14089. }
  14090. }
  14091. declare module BABYLON {
  14092. /**
  14093. * Interface representing a particle system in Babylon.js.
  14094. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14095. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14096. */
  14097. export interface IParticleSystem {
  14098. /**
  14099. * List of animations used by the particle system.
  14100. */
  14101. animations: Animation[];
  14102. /**
  14103. * The id of the Particle system.
  14104. */
  14105. id: string;
  14106. /**
  14107. * The name of the Particle system.
  14108. */
  14109. name: string;
  14110. /**
  14111. * The emitter represents the Mesh or position we are attaching the particle system to.
  14112. */
  14113. emitter: Nullable<AbstractMesh | Vector3>;
  14114. /**
  14115. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14116. */
  14117. isBillboardBased: boolean;
  14118. /**
  14119. * The rendering group used by the Particle system to chose when to render.
  14120. */
  14121. renderingGroupId: number;
  14122. /**
  14123. * The layer mask we are rendering the particles through.
  14124. */
  14125. layerMask: number;
  14126. /**
  14127. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14128. */
  14129. updateSpeed: number;
  14130. /**
  14131. * The amount of time the particle system is running (depends of the overall update speed).
  14132. */
  14133. targetStopDuration: number;
  14134. /**
  14135. * The texture used to render each particle. (this can be a spritesheet)
  14136. */
  14137. particleTexture: Nullable<BaseTexture>;
  14138. /**
  14139. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14140. */
  14141. blendMode: number;
  14142. /**
  14143. * Minimum life time of emitting particles.
  14144. */
  14145. minLifeTime: number;
  14146. /**
  14147. * Maximum life time of emitting particles.
  14148. */
  14149. maxLifeTime: number;
  14150. /**
  14151. * Minimum Size of emitting particles.
  14152. */
  14153. minSize: number;
  14154. /**
  14155. * Maximum Size of emitting particles.
  14156. */
  14157. maxSize: number;
  14158. /**
  14159. * Minimum scale of emitting particles on X axis.
  14160. */
  14161. minScaleX: number;
  14162. /**
  14163. * Maximum scale of emitting particles on X axis.
  14164. */
  14165. maxScaleX: number;
  14166. /**
  14167. * Minimum scale of emitting particles on Y axis.
  14168. */
  14169. minScaleY: number;
  14170. /**
  14171. * Maximum scale of emitting particles on Y axis.
  14172. */
  14173. maxScaleY: number;
  14174. /**
  14175. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14176. */
  14177. color1: Color4;
  14178. /**
  14179. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14180. */
  14181. color2: Color4;
  14182. /**
  14183. * Color the particle will have at the end of its lifetime.
  14184. */
  14185. colorDead: Color4;
  14186. /**
  14187. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14188. */
  14189. emitRate: number;
  14190. /**
  14191. * You can use gravity if you want to give an orientation to your particles.
  14192. */
  14193. gravity: Vector3;
  14194. /**
  14195. * Minimum power of emitting particles.
  14196. */
  14197. minEmitPower: number;
  14198. /**
  14199. * Maximum power of emitting particles.
  14200. */
  14201. maxEmitPower: number;
  14202. /**
  14203. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14204. */
  14205. minAngularSpeed: number;
  14206. /**
  14207. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14208. */
  14209. maxAngularSpeed: number;
  14210. /**
  14211. * Gets or sets the minimal initial rotation in radians.
  14212. */
  14213. minInitialRotation: number;
  14214. /**
  14215. * Gets or sets the maximal initial rotation in radians.
  14216. */
  14217. maxInitialRotation: number;
  14218. /**
  14219. * The particle emitter type defines the emitter used by the particle system.
  14220. * It can be for example box, sphere, or cone...
  14221. */
  14222. particleEmitterType: Nullable<IParticleEmitterType>;
  14223. /**
  14224. * Defines the delay in milliseconds before starting the system (0 by default)
  14225. */
  14226. startDelay: number;
  14227. /**
  14228. * 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
  14229. */
  14230. preWarmCycles: number;
  14231. /**
  14232. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14233. */
  14234. preWarmStepOffset: number;
  14235. /**
  14236. * 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)
  14237. */
  14238. spriteCellChangeSpeed: number;
  14239. /**
  14240. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14241. */
  14242. startSpriteCellID: number;
  14243. /**
  14244. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14245. */
  14246. endSpriteCellID: number;
  14247. /**
  14248. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14249. */
  14250. spriteCellWidth: number;
  14251. /**
  14252. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14253. */
  14254. spriteCellHeight: number;
  14255. /**
  14256. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14257. */
  14258. spriteRandomStartCell: boolean;
  14259. /**
  14260. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14261. */
  14262. isAnimationSheetEnabled: boolean;
  14263. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14264. translationPivot: Vector2;
  14265. /**
  14266. * Gets or sets a texture used to add random noise to particle positions
  14267. */
  14268. noiseTexture: Nullable<BaseTexture>;
  14269. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14270. noiseStrength: Vector3;
  14271. /**
  14272. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14273. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14274. */
  14275. billboardMode: number;
  14276. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14277. limitVelocityDamping: number;
  14278. /**
  14279. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14280. */
  14281. beginAnimationOnStart: boolean;
  14282. /**
  14283. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14284. */
  14285. beginAnimationFrom: number;
  14286. /**
  14287. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14288. */
  14289. beginAnimationTo: number;
  14290. /**
  14291. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14292. */
  14293. beginAnimationLoop: boolean;
  14294. /**
  14295. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14296. */
  14297. disposeOnStop: boolean;
  14298. /**
  14299. * Specifies if the particles are updated in emitter local space or world space
  14300. */
  14301. isLocal: boolean;
  14302. /** Snippet ID if the particle system was created from the snippet server */
  14303. snippetId: string;
  14304. /** Gets or sets a matrix to use to compute projection */
  14305. defaultProjectionMatrix: Matrix;
  14306. /**
  14307. * Gets the maximum number of particles active at the same time.
  14308. * @returns The max number of active particles.
  14309. */
  14310. getCapacity(): number;
  14311. /**
  14312. * Gets the number of particles active at the same time.
  14313. * @returns The number of active particles.
  14314. */
  14315. getActiveCount(): number;
  14316. /**
  14317. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14318. * @returns True if it has been started, otherwise false.
  14319. */
  14320. isStarted(): boolean;
  14321. /**
  14322. * Animates the particle system for this frame.
  14323. */
  14324. animate(): void;
  14325. /**
  14326. * Renders the particle system in its current state.
  14327. * @returns the current number of particles
  14328. */
  14329. render(): number;
  14330. /**
  14331. * Dispose the particle system and frees its associated resources.
  14332. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14333. */
  14334. dispose(disposeTexture?: boolean): void;
  14335. /**
  14336. * An event triggered when the system is disposed
  14337. */
  14338. onDisposeObservable: Observable<IParticleSystem>;
  14339. /**
  14340. * An event triggered when the system is stopped
  14341. */
  14342. onStoppedObservable: Observable<IParticleSystem>;
  14343. /**
  14344. * Clones the particle system.
  14345. * @param name The name of the cloned object
  14346. * @param newEmitter The new emitter to use
  14347. * @returns the cloned particle system
  14348. */
  14349. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14350. /**
  14351. * Serializes the particle system to a JSON object
  14352. * @param serializeTexture defines if the texture must be serialized as well
  14353. * @returns the JSON object
  14354. */
  14355. serialize(serializeTexture: boolean): any;
  14356. /**
  14357. * Rebuild the particle system
  14358. */
  14359. rebuild(): void;
  14360. /** Force the system to rebuild all gradients that need to be resync */
  14361. forceRefreshGradients(): void;
  14362. /**
  14363. * Starts the particle system and begins to emit
  14364. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14365. */
  14366. start(delay?: number): void;
  14367. /**
  14368. * Stops the particle system.
  14369. */
  14370. stop(): void;
  14371. /**
  14372. * Remove all active particles
  14373. */
  14374. reset(): void;
  14375. /**
  14376. * Gets a boolean indicating that the system is stopping
  14377. * @returns true if the system is currently stopping
  14378. */
  14379. isStopping(): boolean;
  14380. /**
  14381. * Is this system ready to be used/rendered
  14382. * @return true if the system is ready
  14383. */
  14384. isReady(): boolean;
  14385. /**
  14386. * Returns the string "ParticleSystem"
  14387. * @returns a string containing the class name
  14388. */
  14389. getClassName(): string;
  14390. /**
  14391. * Gets the custom effect used to render the particles
  14392. * @param blendMode Blend mode for which the effect should be retrieved
  14393. * @returns The effect
  14394. */
  14395. getCustomEffect(blendMode: number): Nullable<Effect>;
  14396. /**
  14397. * Sets the custom effect used to render the particles
  14398. * @param effect The effect to set
  14399. * @param blendMode Blend mode for which the effect should be set
  14400. */
  14401. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14402. /**
  14403. * Fill the defines array according to the current settings of the particle system
  14404. * @param defines Array to be updated
  14405. * @param blendMode blend mode to take into account when updating the array
  14406. */
  14407. fillDefines(defines: Array<string>, blendMode: number): void;
  14408. /**
  14409. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14410. * @param uniforms Uniforms array to fill
  14411. * @param attributes Attributes array to fill
  14412. * @param samplers Samplers array to fill
  14413. */
  14414. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14415. /**
  14416. * Observable that will be called just before the particles are drawn
  14417. */
  14418. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14419. /**
  14420. * Gets the name of the particle vertex shader
  14421. */
  14422. vertexShaderName: string;
  14423. /**
  14424. * Adds a new color gradient
  14425. * @param gradient defines the gradient to use (between 0 and 1)
  14426. * @param color1 defines the color to affect to the specified gradient
  14427. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14428. * @returns the current particle system
  14429. */
  14430. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14431. /**
  14432. * Remove a specific color gradient
  14433. * @param gradient defines the gradient to remove
  14434. * @returns the current particle system
  14435. */
  14436. removeColorGradient(gradient: number): IParticleSystem;
  14437. /**
  14438. * Adds a new size gradient
  14439. * @param gradient defines the gradient to use (between 0 and 1)
  14440. * @param factor defines the size factor to affect to the specified gradient
  14441. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14442. * @returns the current particle system
  14443. */
  14444. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14445. /**
  14446. * Remove a specific size gradient
  14447. * @param gradient defines the gradient to remove
  14448. * @returns the current particle system
  14449. */
  14450. removeSizeGradient(gradient: number): IParticleSystem;
  14451. /**
  14452. * Gets the current list of color gradients.
  14453. * You must use addColorGradient and removeColorGradient to udpate this list
  14454. * @returns the list of color gradients
  14455. */
  14456. getColorGradients(): Nullable<Array<ColorGradient>>;
  14457. /**
  14458. * Gets the current list of size gradients.
  14459. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14460. * @returns the list of size gradients
  14461. */
  14462. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14463. /**
  14464. * Gets the current list of angular speed gradients.
  14465. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14466. * @returns the list of angular speed gradients
  14467. */
  14468. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14469. /**
  14470. * Adds a new angular speed gradient
  14471. * @param gradient defines the gradient to use (between 0 and 1)
  14472. * @param factor defines the angular speed to affect to the specified gradient
  14473. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14474. * @returns the current particle system
  14475. */
  14476. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14477. /**
  14478. * Remove a specific angular speed gradient
  14479. * @param gradient defines the gradient to remove
  14480. * @returns the current particle system
  14481. */
  14482. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14483. /**
  14484. * Gets the current list of velocity gradients.
  14485. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14486. * @returns the list of velocity gradients
  14487. */
  14488. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14489. /**
  14490. * Adds a new velocity gradient
  14491. * @param gradient defines the gradient to use (between 0 and 1)
  14492. * @param factor defines the velocity to affect to the specified gradient
  14493. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14494. * @returns the current particle system
  14495. */
  14496. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14497. /**
  14498. * Remove a specific velocity gradient
  14499. * @param gradient defines the gradient to remove
  14500. * @returns the current particle system
  14501. */
  14502. removeVelocityGradient(gradient: number): IParticleSystem;
  14503. /**
  14504. * Gets the current list of limit velocity gradients.
  14505. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14506. * @returns the list of limit velocity gradients
  14507. */
  14508. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14509. /**
  14510. * Adds a new limit velocity gradient
  14511. * @param gradient defines the gradient to use (between 0 and 1)
  14512. * @param factor defines the limit velocity to affect to the specified gradient
  14513. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14514. * @returns the current particle system
  14515. */
  14516. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14517. /**
  14518. * Remove a specific limit velocity gradient
  14519. * @param gradient defines the gradient to remove
  14520. * @returns the current particle system
  14521. */
  14522. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14523. /**
  14524. * Adds a new drag gradient
  14525. * @param gradient defines the gradient to use (between 0 and 1)
  14526. * @param factor defines the drag to affect to the specified gradient
  14527. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14528. * @returns the current particle system
  14529. */
  14530. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14531. /**
  14532. * Remove a specific drag gradient
  14533. * @param gradient defines the gradient to remove
  14534. * @returns the current particle system
  14535. */
  14536. removeDragGradient(gradient: number): IParticleSystem;
  14537. /**
  14538. * Gets the current list of drag gradients.
  14539. * You must use addDragGradient and removeDragGradient to udpate this list
  14540. * @returns the list of drag gradients
  14541. */
  14542. getDragGradients(): Nullable<Array<FactorGradient>>;
  14543. /**
  14544. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14545. * @param gradient defines the gradient to use (between 0 and 1)
  14546. * @param factor defines the emit rate to affect to the specified gradient
  14547. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14548. * @returns the current particle system
  14549. */
  14550. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14551. /**
  14552. * Remove a specific emit rate gradient
  14553. * @param gradient defines the gradient to remove
  14554. * @returns the current particle system
  14555. */
  14556. removeEmitRateGradient(gradient: number): IParticleSystem;
  14557. /**
  14558. * Gets the current list of emit rate gradients.
  14559. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14560. * @returns the list of emit rate gradients
  14561. */
  14562. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14563. /**
  14564. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14565. * @param gradient defines the gradient to use (between 0 and 1)
  14566. * @param factor defines the start size to affect to the specified gradient
  14567. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14568. * @returns the current particle system
  14569. */
  14570. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14571. /**
  14572. * Remove a specific start size gradient
  14573. * @param gradient defines the gradient to remove
  14574. * @returns the current particle system
  14575. */
  14576. removeStartSizeGradient(gradient: number): IParticleSystem;
  14577. /**
  14578. * Gets the current list of start size gradients.
  14579. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14580. * @returns the list of start size gradients
  14581. */
  14582. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14583. /**
  14584. * Adds a new life time gradient
  14585. * @param gradient defines the gradient to use (between 0 and 1)
  14586. * @param factor defines the life time factor to affect to the specified gradient
  14587. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14588. * @returns the current particle system
  14589. */
  14590. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14591. /**
  14592. * Remove a specific life time gradient
  14593. * @param gradient defines the gradient to remove
  14594. * @returns the current particle system
  14595. */
  14596. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14597. /**
  14598. * Gets the current list of life time gradients.
  14599. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14600. * @returns the list of life time gradients
  14601. */
  14602. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14603. /**
  14604. * Gets the current list of color gradients.
  14605. * You must use addColorGradient and removeColorGradient to udpate this list
  14606. * @returns the list of color gradients
  14607. */
  14608. getColorGradients(): Nullable<Array<ColorGradient>>;
  14609. /**
  14610. * Adds a new ramp gradient used to remap particle colors
  14611. * @param gradient defines the gradient to use (between 0 and 1)
  14612. * @param color defines the color to affect to the specified gradient
  14613. * @returns the current particle system
  14614. */
  14615. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14616. /**
  14617. * Gets the current list of ramp gradients.
  14618. * You must use addRampGradient and removeRampGradient to udpate this list
  14619. * @returns the list of ramp gradients
  14620. */
  14621. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14622. /** Gets or sets a boolean indicating that ramp gradients must be used
  14623. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14624. */
  14625. useRampGradients: boolean;
  14626. /**
  14627. * Adds a new color remap gradient
  14628. * @param gradient defines the gradient to use (between 0 and 1)
  14629. * @param min defines the color remap minimal range
  14630. * @param max defines the color remap maximal range
  14631. * @returns the current particle system
  14632. */
  14633. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14634. /**
  14635. * Gets the current list of color remap gradients.
  14636. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14637. * @returns the list of color remap gradients
  14638. */
  14639. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14640. /**
  14641. * Adds a new alpha remap gradient
  14642. * @param gradient defines the gradient to use (between 0 and 1)
  14643. * @param min defines the alpha remap minimal range
  14644. * @param max defines the alpha remap maximal range
  14645. * @returns the current particle system
  14646. */
  14647. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14648. /**
  14649. * Gets the current list of alpha remap gradients.
  14650. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14651. * @returns the list of alpha remap gradients
  14652. */
  14653. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14654. /**
  14655. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14656. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14657. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14658. * @returns the emitter
  14659. */
  14660. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14661. /**
  14662. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14663. * @param radius The radius of the hemisphere to emit from
  14664. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14665. * @returns the emitter
  14666. */
  14667. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14668. /**
  14669. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14670. * @param radius The radius of the sphere to emit from
  14671. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14672. * @returns the emitter
  14673. */
  14674. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14675. /**
  14676. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14677. * @param radius The radius of the sphere to emit from
  14678. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14679. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14680. * @returns the emitter
  14681. */
  14682. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14683. /**
  14684. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14685. * @param radius The radius of the emission cylinder
  14686. * @param height The height of the emission cylinder
  14687. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14688. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14689. * @returns the emitter
  14690. */
  14691. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14692. /**
  14693. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14694. * @param radius The radius of the cylinder to emit from
  14695. * @param height The height of the emission cylinder
  14696. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14697. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14698. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14699. * @returns the emitter
  14700. */
  14701. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14702. /**
  14703. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14704. * @param radius The radius of the cone to emit from
  14705. * @param angle The base angle of the cone
  14706. * @returns the emitter
  14707. */
  14708. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14709. /**
  14710. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14711. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14712. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14713. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14714. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14715. * @returns the emitter
  14716. */
  14717. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14718. /**
  14719. * Get hosting scene
  14720. * @returns the scene
  14721. */
  14722. getScene(): Nullable<Scene>;
  14723. }
  14724. }
  14725. declare module BABYLON {
  14726. /**
  14727. * 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.
  14728. * @see https://doc.babylonjs.com/how_to/transformnode
  14729. */
  14730. export class TransformNode extends Node {
  14731. /**
  14732. * Object will not rotate to face the camera
  14733. */
  14734. static BILLBOARDMODE_NONE: number;
  14735. /**
  14736. * Object will rotate to face the camera but only on the x axis
  14737. */
  14738. static BILLBOARDMODE_X: number;
  14739. /**
  14740. * Object will rotate to face the camera but only on the y axis
  14741. */
  14742. static BILLBOARDMODE_Y: number;
  14743. /**
  14744. * Object will rotate to face the camera but only on the z axis
  14745. */
  14746. static BILLBOARDMODE_Z: number;
  14747. /**
  14748. * Object will rotate to face the camera
  14749. */
  14750. static BILLBOARDMODE_ALL: number;
  14751. /**
  14752. * Object will rotate to face the camera's position instead of orientation
  14753. */
  14754. static BILLBOARDMODE_USE_POSITION: number;
  14755. private static _TmpRotation;
  14756. private static _TmpScaling;
  14757. private static _TmpTranslation;
  14758. private _forward;
  14759. private _forwardInverted;
  14760. private _up;
  14761. private _right;
  14762. private _rightInverted;
  14763. private _position;
  14764. private _rotation;
  14765. private _rotationQuaternion;
  14766. protected _scaling: Vector3;
  14767. protected _isDirty: boolean;
  14768. private _transformToBoneReferal;
  14769. private _isAbsoluteSynced;
  14770. private _billboardMode;
  14771. /**
  14772. * Gets or sets the billboard mode. Default is 0.
  14773. *
  14774. * | Value | Type | Description |
  14775. * | --- | --- | --- |
  14776. * | 0 | BILLBOARDMODE_NONE | |
  14777. * | 1 | BILLBOARDMODE_X | |
  14778. * | 2 | BILLBOARDMODE_Y | |
  14779. * | 4 | BILLBOARDMODE_Z | |
  14780. * | 7 | BILLBOARDMODE_ALL | |
  14781. *
  14782. */
  14783. get billboardMode(): number;
  14784. set billboardMode(value: number);
  14785. private _preserveParentRotationForBillboard;
  14786. /**
  14787. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14788. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14789. */
  14790. get preserveParentRotationForBillboard(): boolean;
  14791. set preserveParentRotationForBillboard(value: boolean);
  14792. /**
  14793. * 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
  14794. */
  14795. scalingDeterminant: number;
  14796. private _infiniteDistance;
  14797. /**
  14798. * Gets or sets the distance of the object to max, often used by skybox
  14799. */
  14800. get infiniteDistance(): boolean;
  14801. set infiniteDistance(value: boolean);
  14802. /**
  14803. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14804. * By default the system will update normals to compensate
  14805. */
  14806. ignoreNonUniformScaling: boolean;
  14807. /**
  14808. * 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
  14809. */
  14810. reIntegrateRotationIntoRotationQuaternion: boolean;
  14811. /** @hidden */
  14812. _poseMatrix: Nullable<Matrix>;
  14813. /** @hidden */
  14814. _localMatrix: Matrix;
  14815. private _usePivotMatrix;
  14816. private _absolutePosition;
  14817. private _absoluteScaling;
  14818. private _absoluteRotationQuaternion;
  14819. private _pivotMatrix;
  14820. private _pivotMatrixInverse;
  14821. /** @hidden */
  14822. _postMultiplyPivotMatrix: boolean;
  14823. protected _isWorldMatrixFrozen: boolean;
  14824. /** @hidden */
  14825. _indexInSceneTransformNodesArray: number;
  14826. /**
  14827. * An event triggered after the world matrix is updated
  14828. */
  14829. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14830. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14831. /**
  14832. * Gets a string identifying the name of the class
  14833. * @returns "TransformNode" string
  14834. */
  14835. getClassName(): string;
  14836. /**
  14837. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14838. */
  14839. get position(): Vector3;
  14840. set position(newPosition: Vector3);
  14841. /**
  14842. * 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)).
  14843. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14844. */
  14845. get rotation(): Vector3;
  14846. set rotation(newRotation: Vector3);
  14847. /**
  14848. * 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)).
  14849. */
  14850. get scaling(): Vector3;
  14851. set scaling(newScaling: Vector3);
  14852. /**
  14853. * 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).
  14854. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14855. */
  14856. get rotationQuaternion(): Nullable<Quaternion>;
  14857. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14858. /**
  14859. * The forward direction of that transform in world space.
  14860. */
  14861. get forward(): Vector3;
  14862. /**
  14863. * The up direction of that transform in world space.
  14864. */
  14865. get up(): Vector3;
  14866. /**
  14867. * The right direction of that transform in world space.
  14868. */
  14869. get right(): Vector3;
  14870. /**
  14871. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14872. * @param matrix the matrix to copy the pose from
  14873. * @returns this TransformNode.
  14874. */
  14875. updatePoseMatrix(matrix: Matrix): TransformNode;
  14876. /**
  14877. * Returns the mesh Pose matrix.
  14878. * @returns the pose matrix
  14879. */
  14880. getPoseMatrix(): Matrix;
  14881. /** @hidden */
  14882. _isSynchronized(): boolean;
  14883. /** @hidden */
  14884. _initCache(): void;
  14885. /**
  14886. * Flag the transform node as dirty (Forcing it to update everything)
  14887. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14888. * @returns this transform node
  14889. */
  14890. markAsDirty(property: string): TransformNode;
  14891. /**
  14892. * Returns the current mesh absolute position.
  14893. * Returns a Vector3.
  14894. */
  14895. get absolutePosition(): Vector3;
  14896. /**
  14897. * Returns the current mesh absolute scaling.
  14898. * Returns a Vector3.
  14899. */
  14900. get absoluteScaling(): Vector3;
  14901. /**
  14902. * Returns the current mesh absolute rotation.
  14903. * Returns a Quaternion.
  14904. */
  14905. get absoluteRotationQuaternion(): Quaternion;
  14906. /**
  14907. * Sets a new matrix to apply before all other transformation
  14908. * @param matrix defines the transform matrix
  14909. * @returns the current TransformNode
  14910. */
  14911. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14912. /**
  14913. * Sets a new pivot matrix to the current node
  14914. * @param matrix defines the new pivot matrix to use
  14915. * @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
  14916. * @returns the current TransformNode
  14917. */
  14918. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14919. /**
  14920. * Returns the mesh pivot matrix.
  14921. * Default : Identity.
  14922. * @returns the matrix
  14923. */
  14924. getPivotMatrix(): Matrix;
  14925. /**
  14926. * Instantiate (when possible) or clone that node with its hierarchy
  14927. * @param newParent defines the new parent to use for the instance (or clone)
  14928. * @param options defines options to configure how copy is done
  14929. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14930. * @returns an instance (or a clone) of the current node with its hiearchy
  14931. */
  14932. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14933. doNotInstantiate: boolean;
  14934. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14935. /**
  14936. * Prevents the World matrix to be computed any longer
  14937. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14938. * @returns the TransformNode.
  14939. */
  14940. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14941. /**
  14942. * Allows back the World matrix computation.
  14943. * @returns the TransformNode.
  14944. */
  14945. unfreezeWorldMatrix(): this;
  14946. /**
  14947. * True if the World matrix has been frozen.
  14948. */
  14949. get isWorldMatrixFrozen(): boolean;
  14950. /**
  14951. * Retuns the mesh absolute position in the World.
  14952. * @returns a Vector3.
  14953. */
  14954. getAbsolutePosition(): Vector3;
  14955. /**
  14956. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14957. * @param absolutePosition the absolute position to set
  14958. * @returns the TransformNode.
  14959. */
  14960. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14961. /**
  14962. * Sets the mesh position in its local space.
  14963. * @param vector3 the position to set in localspace
  14964. * @returns the TransformNode.
  14965. */
  14966. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14967. /**
  14968. * Returns the mesh position in the local space from the current World matrix values.
  14969. * @returns a new Vector3.
  14970. */
  14971. getPositionExpressedInLocalSpace(): Vector3;
  14972. /**
  14973. * Translates the mesh along the passed Vector3 in its local space.
  14974. * @param vector3 the distance to translate in localspace
  14975. * @returns the TransformNode.
  14976. */
  14977. locallyTranslate(vector3: Vector3): TransformNode;
  14978. private static _lookAtVectorCache;
  14979. /**
  14980. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14981. * @param targetPoint the position (must be in same space as current mesh) to look at
  14982. * @param yawCor optional yaw (y-axis) correction in radians
  14983. * @param pitchCor optional pitch (x-axis) correction in radians
  14984. * @param rollCor optional roll (z-axis) correction in radians
  14985. * @param space the choosen space of the target
  14986. * @returns the TransformNode.
  14987. */
  14988. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14989. /**
  14990. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14991. * This Vector3 is expressed in the World space.
  14992. * @param localAxis axis to rotate
  14993. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14994. */
  14995. getDirection(localAxis: Vector3): Vector3;
  14996. /**
  14997. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14998. * localAxis is expressed in the mesh local space.
  14999. * result is computed in the Wordl space from the mesh World matrix.
  15000. * @param localAxis axis to rotate
  15001. * @param result the resulting transformnode
  15002. * @returns this TransformNode.
  15003. */
  15004. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15005. /**
  15006. * Sets this transform node rotation to the given local axis.
  15007. * @param localAxis the axis in local space
  15008. * @param yawCor optional yaw (y-axis) correction in radians
  15009. * @param pitchCor optional pitch (x-axis) correction in radians
  15010. * @param rollCor optional roll (z-axis) correction in radians
  15011. * @returns this TransformNode
  15012. */
  15013. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15014. /**
  15015. * Sets a new pivot point to the current node
  15016. * @param point defines the new pivot point to use
  15017. * @param space defines if the point is in world or local space (local by default)
  15018. * @returns the current TransformNode
  15019. */
  15020. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15021. /**
  15022. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15023. * @returns the pivot point
  15024. */
  15025. getPivotPoint(): Vector3;
  15026. /**
  15027. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15028. * @param result the vector3 to store the result
  15029. * @returns this TransformNode.
  15030. */
  15031. getPivotPointToRef(result: Vector3): TransformNode;
  15032. /**
  15033. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15034. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15035. */
  15036. getAbsolutePivotPoint(): Vector3;
  15037. /**
  15038. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15039. * @param result vector3 to store the result
  15040. * @returns this TransformNode.
  15041. */
  15042. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15043. /**
  15044. * Defines the passed node as the parent of the current node.
  15045. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15046. * @see https://doc.babylonjs.com/how_to/parenting
  15047. * @param node the node ot set as the parent
  15048. * @returns this TransformNode.
  15049. */
  15050. setParent(node: Nullable<Node>): TransformNode;
  15051. private _nonUniformScaling;
  15052. /**
  15053. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15054. */
  15055. get nonUniformScaling(): boolean;
  15056. /** @hidden */
  15057. _updateNonUniformScalingState(value: boolean): boolean;
  15058. /**
  15059. * Attach the current TransformNode to another TransformNode associated with a bone
  15060. * @param bone Bone affecting the TransformNode
  15061. * @param affectedTransformNode TransformNode associated with the bone
  15062. * @returns this object
  15063. */
  15064. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15065. /**
  15066. * Detach the transform node if its associated with a bone
  15067. * @returns this object
  15068. */
  15069. detachFromBone(): TransformNode;
  15070. private static _rotationAxisCache;
  15071. /**
  15072. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15073. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15074. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15075. * The passed axis is also normalized.
  15076. * @param axis the axis to rotate around
  15077. * @param amount the amount to rotate in radians
  15078. * @param space Space to rotate in (Default: local)
  15079. * @returns the TransformNode.
  15080. */
  15081. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15082. /**
  15083. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15084. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15085. * The passed axis is also normalized. .
  15086. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15087. * @param point the point to rotate around
  15088. * @param axis the axis to rotate around
  15089. * @param amount the amount to rotate in radians
  15090. * @returns the TransformNode
  15091. */
  15092. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15093. /**
  15094. * Translates the mesh along the axis vector for the passed distance in the given space.
  15095. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15096. * @param axis the axis to translate in
  15097. * @param distance the distance to translate
  15098. * @param space Space to rotate in (Default: local)
  15099. * @returns the TransformNode.
  15100. */
  15101. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15102. /**
  15103. * Adds a rotation step to the mesh current rotation.
  15104. * x, y, z are Euler angles expressed in radians.
  15105. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15106. * This means this rotation is made in the mesh local space only.
  15107. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15108. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15109. * ```javascript
  15110. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15111. * ```
  15112. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15113. * 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.
  15114. * @param x Rotation to add
  15115. * @param y Rotation to add
  15116. * @param z Rotation to add
  15117. * @returns the TransformNode.
  15118. */
  15119. addRotation(x: number, y: number, z: number): TransformNode;
  15120. /**
  15121. * @hidden
  15122. */
  15123. protected _getEffectiveParent(): Nullable<Node>;
  15124. /**
  15125. * Computes the world matrix of the node
  15126. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15127. * @returns the world matrix
  15128. */
  15129. computeWorldMatrix(force?: boolean): Matrix;
  15130. /**
  15131. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15132. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15133. */
  15134. resetLocalMatrix(independentOfChildren?: boolean): void;
  15135. protected _afterComputeWorldMatrix(): void;
  15136. /**
  15137. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15138. * @param func callback function to add
  15139. *
  15140. * @returns the TransformNode.
  15141. */
  15142. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15143. /**
  15144. * Removes a registered callback function.
  15145. * @param func callback function to remove
  15146. * @returns the TransformNode.
  15147. */
  15148. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15149. /**
  15150. * Gets the position of the current mesh in camera space
  15151. * @param camera defines the camera to use
  15152. * @returns a position
  15153. */
  15154. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15155. /**
  15156. * Returns the distance from the mesh to the active camera
  15157. * @param camera defines the camera to use
  15158. * @returns the distance
  15159. */
  15160. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15161. /**
  15162. * Clone the current transform node
  15163. * @param name Name of the new clone
  15164. * @param newParent New parent for the clone
  15165. * @param doNotCloneChildren Do not clone children hierarchy
  15166. * @returns the new transform node
  15167. */
  15168. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15169. /**
  15170. * Serializes the objects information.
  15171. * @param currentSerializationObject defines the object to serialize in
  15172. * @returns the serialized object
  15173. */
  15174. serialize(currentSerializationObject?: any): any;
  15175. /**
  15176. * Returns a new TransformNode object parsed from the source provided.
  15177. * @param parsedTransformNode is the source.
  15178. * @param scene the scne the object belongs to
  15179. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15180. * @returns a new TransformNode object parsed from the source provided.
  15181. */
  15182. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15183. /**
  15184. * Get all child-transformNodes of this node
  15185. * @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
  15186. * @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
  15187. * @returns an array of TransformNode
  15188. */
  15189. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15190. /**
  15191. * Releases resources associated with this transform node.
  15192. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15193. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15194. */
  15195. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15196. /**
  15197. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15198. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15199. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15200. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15201. * @returns the current mesh
  15202. */
  15203. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15204. private _syncAbsoluteScalingAndRotation;
  15205. }
  15206. }
  15207. declare module BABYLON {
  15208. /**
  15209. * Class used to override all child animations of a given target
  15210. */
  15211. export class AnimationPropertiesOverride {
  15212. /**
  15213. * Gets or sets a value indicating if animation blending must be used
  15214. */
  15215. enableBlending: boolean;
  15216. /**
  15217. * Gets or sets the blending speed to use when enableBlending is true
  15218. */
  15219. blendingSpeed: number;
  15220. /**
  15221. * Gets or sets the default loop mode to use
  15222. */
  15223. loopMode: number;
  15224. }
  15225. }
  15226. declare module BABYLON {
  15227. /**
  15228. * Class used to store bone information
  15229. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15230. */
  15231. export class Bone extends Node {
  15232. /**
  15233. * defines the bone name
  15234. */
  15235. name: string;
  15236. private static _tmpVecs;
  15237. private static _tmpQuat;
  15238. private static _tmpMats;
  15239. /**
  15240. * Gets the list of child bones
  15241. */
  15242. children: Bone[];
  15243. /** Gets the animations associated with this bone */
  15244. animations: Animation[];
  15245. /**
  15246. * Gets or sets bone length
  15247. */
  15248. length: number;
  15249. /**
  15250. * @hidden Internal only
  15251. * Set this value to map this bone to a different index in the transform matrices
  15252. * Set this value to -1 to exclude the bone from the transform matrices
  15253. */
  15254. _index: Nullable<number>;
  15255. private _skeleton;
  15256. private _localMatrix;
  15257. private _restPose;
  15258. private _bindPose;
  15259. private _baseMatrix;
  15260. private _absoluteTransform;
  15261. private _invertedAbsoluteTransform;
  15262. private _parent;
  15263. private _scalingDeterminant;
  15264. private _worldTransform;
  15265. private _localScaling;
  15266. private _localRotation;
  15267. private _localPosition;
  15268. private _needToDecompose;
  15269. private _needToCompose;
  15270. /** @hidden */
  15271. _linkedTransformNode: Nullable<TransformNode>;
  15272. /** @hidden */
  15273. _waitingTransformNodeId: Nullable<string>;
  15274. /** @hidden */
  15275. get _matrix(): Matrix;
  15276. /** @hidden */
  15277. set _matrix(value: Matrix);
  15278. /**
  15279. * Create a new bone
  15280. * @param name defines the bone name
  15281. * @param skeleton defines the parent skeleton
  15282. * @param parentBone defines the parent (can be null if the bone is the root)
  15283. * @param localMatrix defines the local matrix
  15284. * @param restPose defines the rest pose matrix
  15285. * @param baseMatrix defines the base matrix
  15286. * @param index defines index of the bone in the hiearchy
  15287. */
  15288. constructor(
  15289. /**
  15290. * defines the bone name
  15291. */
  15292. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15293. /**
  15294. * Gets the current object class name.
  15295. * @return the class name
  15296. */
  15297. getClassName(): string;
  15298. /**
  15299. * Gets the parent skeleton
  15300. * @returns a skeleton
  15301. */
  15302. getSkeleton(): Skeleton;
  15303. /**
  15304. * Gets parent bone
  15305. * @returns a bone or null if the bone is the root of the bone hierarchy
  15306. */
  15307. getParent(): Nullable<Bone>;
  15308. /**
  15309. * Returns an array containing the root bones
  15310. * @returns an array containing the root bones
  15311. */
  15312. getChildren(): Array<Bone>;
  15313. /**
  15314. * Gets the node index in matrix array generated for rendering
  15315. * @returns the node index
  15316. */
  15317. getIndex(): number;
  15318. /**
  15319. * Sets the parent bone
  15320. * @param parent defines the parent (can be null if the bone is the root)
  15321. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15322. */
  15323. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15324. /**
  15325. * Gets the local matrix
  15326. * @returns a matrix
  15327. */
  15328. getLocalMatrix(): Matrix;
  15329. /**
  15330. * Gets the base matrix (initial matrix which remains unchanged)
  15331. * @returns a matrix
  15332. */
  15333. getBaseMatrix(): Matrix;
  15334. /**
  15335. * Gets the rest pose matrix
  15336. * @returns a matrix
  15337. */
  15338. getRestPose(): Matrix;
  15339. /**
  15340. * Sets the rest pose matrix
  15341. * @param matrix the local-space rest pose to set for this bone
  15342. */
  15343. setRestPose(matrix: Matrix): void;
  15344. /**
  15345. * Gets the bind pose matrix
  15346. * @returns the bind pose matrix
  15347. */
  15348. getBindPose(): Matrix;
  15349. /**
  15350. * Sets the bind pose matrix
  15351. * @param matrix the local-space bind pose to set for this bone
  15352. */
  15353. setBindPose(matrix: Matrix): void;
  15354. /**
  15355. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15356. */
  15357. getWorldMatrix(): Matrix;
  15358. /**
  15359. * Sets the local matrix to rest pose matrix
  15360. */
  15361. returnToRest(): void;
  15362. /**
  15363. * Gets the inverse of the absolute transform matrix.
  15364. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15365. * @returns a matrix
  15366. */
  15367. getInvertedAbsoluteTransform(): Matrix;
  15368. /**
  15369. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15370. * @returns a matrix
  15371. */
  15372. getAbsoluteTransform(): Matrix;
  15373. /**
  15374. * Links with the given transform node.
  15375. * The local matrix of this bone is copied from the transform node every frame.
  15376. * @param transformNode defines the transform node to link to
  15377. */
  15378. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15379. /**
  15380. * Gets the node used to drive the bone's transformation
  15381. * @returns a transform node or null
  15382. */
  15383. getTransformNode(): Nullable<TransformNode>;
  15384. /** Gets or sets current position (in local space) */
  15385. get position(): Vector3;
  15386. set position(newPosition: Vector3);
  15387. /** Gets or sets current rotation (in local space) */
  15388. get rotation(): Vector3;
  15389. set rotation(newRotation: Vector3);
  15390. /** Gets or sets current rotation quaternion (in local space) */
  15391. get rotationQuaternion(): Quaternion;
  15392. set rotationQuaternion(newRotation: Quaternion);
  15393. /** Gets or sets current scaling (in local space) */
  15394. get scaling(): Vector3;
  15395. set scaling(newScaling: Vector3);
  15396. /**
  15397. * Gets the animation properties override
  15398. */
  15399. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15400. private _decompose;
  15401. private _compose;
  15402. /**
  15403. * Update the base and local matrices
  15404. * @param matrix defines the new base or local matrix
  15405. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15406. * @param updateLocalMatrix defines if the local matrix should be updated
  15407. */
  15408. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15409. /** @hidden */
  15410. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15411. /**
  15412. * Flag the bone as dirty (Forcing it to update everything)
  15413. */
  15414. markAsDirty(): void;
  15415. /** @hidden */
  15416. _markAsDirtyAndCompose(): void;
  15417. private _markAsDirtyAndDecompose;
  15418. /**
  15419. * Translate the bone in local or world space
  15420. * @param vec The amount to translate the bone
  15421. * @param space The space that the translation is in
  15422. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15423. */
  15424. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15425. /**
  15426. * Set the postion of the bone in local or world space
  15427. * @param position The position to set the bone
  15428. * @param space The space that the position is in
  15429. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15430. */
  15431. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15432. /**
  15433. * Set the absolute position of the bone (world space)
  15434. * @param position The position to set the bone
  15435. * @param mesh The mesh that this bone is attached to
  15436. */
  15437. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15438. /**
  15439. * Scale the bone on the x, y and z axes (in local space)
  15440. * @param x The amount to scale the bone on the x axis
  15441. * @param y The amount to scale the bone on the y axis
  15442. * @param z The amount to scale the bone on the z axis
  15443. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15444. */
  15445. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15446. /**
  15447. * Set the bone scaling in local space
  15448. * @param scale defines the scaling vector
  15449. */
  15450. setScale(scale: Vector3): void;
  15451. /**
  15452. * Gets the current scaling in local space
  15453. * @returns the current scaling vector
  15454. */
  15455. getScale(): Vector3;
  15456. /**
  15457. * Gets the current scaling in local space and stores it in a target vector
  15458. * @param result defines the target vector
  15459. */
  15460. getScaleToRef(result: Vector3): void;
  15461. /**
  15462. * Set the yaw, pitch, and roll of the bone in local or world space
  15463. * @param yaw The rotation of the bone on the y axis
  15464. * @param pitch The rotation of the bone on the x axis
  15465. * @param roll The rotation of the bone on the z axis
  15466. * @param space The space that the axes of rotation are in
  15467. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15468. */
  15469. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15470. /**
  15471. * Add a rotation to the bone on an axis in local or world space
  15472. * @param axis The axis to rotate the bone on
  15473. * @param amount The amount to rotate the bone
  15474. * @param space The space that the axis is in
  15475. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15476. */
  15477. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15478. /**
  15479. * Set the rotation of the bone to a particular axis angle in local or world space
  15480. * @param axis The axis to rotate the bone on
  15481. * @param angle The angle that the bone should be rotated to
  15482. * @param space The space that the axis is in
  15483. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15484. */
  15485. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15486. /**
  15487. * Set the euler rotation of the bone in local or world space
  15488. * @param rotation The euler rotation that the bone should be set to
  15489. * @param space The space that the rotation is in
  15490. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15491. */
  15492. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15493. /**
  15494. * Set the quaternion rotation of the bone in local or world space
  15495. * @param quat The quaternion rotation that the bone should be set to
  15496. * @param space The space that the rotation is in
  15497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15498. */
  15499. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15500. /**
  15501. * Set the rotation matrix of the bone in local or world space
  15502. * @param rotMat The rotation matrix that the bone should be set to
  15503. * @param space The space that the rotation is in
  15504. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15505. */
  15506. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15507. private _rotateWithMatrix;
  15508. private _getNegativeRotationToRef;
  15509. /**
  15510. * Get the position of the bone in local or world space
  15511. * @param space The space that the returned position is in
  15512. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15513. * @returns The position of the bone
  15514. */
  15515. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15516. /**
  15517. * Copy the position of the bone to a vector3 in local or world space
  15518. * @param space The space that the returned position is in
  15519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15520. * @param result The vector3 to copy the position to
  15521. */
  15522. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15523. /**
  15524. * Get the absolute position of the bone (world space)
  15525. * @param mesh The mesh that this bone is attached to
  15526. * @returns The absolute position of the bone
  15527. */
  15528. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15529. /**
  15530. * Copy the absolute position of the bone (world space) to the result param
  15531. * @param mesh The mesh that this bone is attached to
  15532. * @param result The vector3 to copy the absolute position to
  15533. */
  15534. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15535. /**
  15536. * Compute the absolute transforms of this bone and its children
  15537. */
  15538. computeAbsoluteTransforms(): void;
  15539. /**
  15540. * Get the world direction from an axis that is in the local space of the bone
  15541. * @param localAxis The local direction that is used to compute the world direction
  15542. * @param mesh The mesh that this bone is attached to
  15543. * @returns The world direction
  15544. */
  15545. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15546. /**
  15547. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15548. * @param localAxis The local direction that is used to compute the world direction
  15549. * @param mesh The mesh that this bone is attached to
  15550. * @param result The vector3 that the world direction will be copied to
  15551. */
  15552. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15553. /**
  15554. * Get the euler rotation of the bone in local or world space
  15555. * @param space The space that the rotation should be in
  15556. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15557. * @returns The euler rotation
  15558. */
  15559. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15560. /**
  15561. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15562. * @param space The space that the rotation should be in
  15563. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15564. * @param result The vector3 that the rotation should be copied to
  15565. */
  15566. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15567. /**
  15568. * Get the quaternion rotation of the bone in either local or world space
  15569. * @param space The space that the rotation should be in
  15570. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15571. * @returns The quaternion rotation
  15572. */
  15573. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15574. /**
  15575. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15576. * @param space The space that the rotation should be in
  15577. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15578. * @param result The quaternion that the rotation should be copied to
  15579. */
  15580. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15581. /**
  15582. * Get the rotation matrix of the bone in local or world space
  15583. * @param space The space that the rotation should be in
  15584. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15585. * @returns The rotation matrix
  15586. */
  15587. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15588. /**
  15589. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15590. * @param space The space that the rotation should be in
  15591. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15592. * @param result The quaternion that the rotation should be copied to
  15593. */
  15594. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15595. /**
  15596. * Get the world position of a point that is in the local space of the bone
  15597. * @param position The local position
  15598. * @param mesh The mesh that this bone is attached to
  15599. * @returns The world position
  15600. */
  15601. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15602. /**
  15603. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15604. * @param position The local position
  15605. * @param mesh The mesh that this bone is attached to
  15606. * @param result The vector3 that the world position should be copied to
  15607. */
  15608. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15609. /**
  15610. * Get the local position of a point that is in world space
  15611. * @param position The world position
  15612. * @param mesh The mesh that this bone is attached to
  15613. * @returns The local position
  15614. */
  15615. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15616. /**
  15617. * Get the local position of a point that is in world space and copy it to the result param
  15618. * @param position The world position
  15619. * @param mesh The mesh that this bone is attached to
  15620. * @param result The vector3 that the local position should be copied to
  15621. */
  15622. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15623. /**
  15624. * Set the current local matrix as the restPose for this bone.
  15625. */
  15626. setCurrentPoseAsRest(): void;
  15627. }
  15628. }
  15629. declare module BABYLON {
  15630. /**
  15631. * Defines a runtime animation
  15632. */
  15633. export class RuntimeAnimation {
  15634. private _events;
  15635. /**
  15636. * The current frame of the runtime animation
  15637. */
  15638. private _currentFrame;
  15639. /**
  15640. * The animation used by the runtime animation
  15641. */
  15642. private _animation;
  15643. /**
  15644. * The target of the runtime animation
  15645. */
  15646. private _target;
  15647. /**
  15648. * The initiating animatable
  15649. */
  15650. private _host;
  15651. /**
  15652. * The original value of the runtime animation
  15653. */
  15654. private _originalValue;
  15655. /**
  15656. * The original blend value of the runtime animation
  15657. */
  15658. private _originalBlendValue;
  15659. /**
  15660. * The offsets cache of the runtime animation
  15661. */
  15662. private _offsetsCache;
  15663. /**
  15664. * The high limits cache of the runtime animation
  15665. */
  15666. private _highLimitsCache;
  15667. /**
  15668. * Specifies if the runtime animation has been stopped
  15669. */
  15670. private _stopped;
  15671. /**
  15672. * The blending factor of the runtime animation
  15673. */
  15674. private _blendingFactor;
  15675. /**
  15676. * The BabylonJS scene
  15677. */
  15678. private _scene;
  15679. /**
  15680. * The current value of the runtime animation
  15681. */
  15682. private _currentValue;
  15683. /** @hidden */
  15684. _animationState: _IAnimationState;
  15685. /**
  15686. * The active target of the runtime animation
  15687. */
  15688. private _activeTargets;
  15689. private _currentActiveTarget;
  15690. private _directTarget;
  15691. /**
  15692. * The target path of the runtime animation
  15693. */
  15694. private _targetPath;
  15695. /**
  15696. * The weight of the runtime animation
  15697. */
  15698. private _weight;
  15699. /**
  15700. * The ratio offset of the runtime animation
  15701. */
  15702. private _ratioOffset;
  15703. /**
  15704. * The previous delay of the runtime animation
  15705. */
  15706. private _previousDelay;
  15707. /**
  15708. * The previous ratio of the runtime animation
  15709. */
  15710. private _previousRatio;
  15711. private _enableBlending;
  15712. private _keys;
  15713. private _minFrame;
  15714. private _maxFrame;
  15715. private _minValue;
  15716. private _maxValue;
  15717. private _targetIsArray;
  15718. /**
  15719. * Gets the current frame of the runtime animation
  15720. */
  15721. get currentFrame(): number;
  15722. /**
  15723. * Gets the weight of the runtime animation
  15724. */
  15725. get weight(): number;
  15726. /**
  15727. * Gets the current value of the runtime animation
  15728. */
  15729. get currentValue(): any;
  15730. /**
  15731. * Gets the target path of the runtime animation
  15732. */
  15733. get targetPath(): string;
  15734. /**
  15735. * Gets the actual target of the runtime animation
  15736. */
  15737. get target(): any;
  15738. /**
  15739. * Gets the additive state of the runtime animation
  15740. */
  15741. get isAdditive(): boolean;
  15742. /** @hidden */
  15743. _onLoop: () => void;
  15744. /**
  15745. * Create a new RuntimeAnimation object
  15746. * @param target defines the target of the animation
  15747. * @param animation defines the source animation object
  15748. * @param scene defines the hosting scene
  15749. * @param host defines the initiating Animatable
  15750. */
  15751. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15752. private _preparePath;
  15753. /**
  15754. * Gets the animation from the runtime animation
  15755. */
  15756. get animation(): Animation;
  15757. /**
  15758. * Resets the runtime animation to the beginning
  15759. * @param restoreOriginal defines whether to restore the target property to the original value
  15760. */
  15761. reset(restoreOriginal?: boolean): void;
  15762. /**
  15763. * Specifies if the runtime animation is stopped
  15764. * @returns Boolean specifying if the runtime animation is stopped
  15765. */
  15766. isStopped(): boolean;
  15767. /**
  15768. * Disposes of the runtime animation
  15769. */
  15770. dispose(): void;
  15771. /**
  15772. * Apply the interpolated value to the target
  15773. * @param currentValue defines the value computed by the animation
  15774. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15775. */
  15776. setValue(currentValue: any, weight: number): void;
  15777. private _getOriginalValues;
  15778. private _setValue;
  15779. /**
  15780. * Gets the loop pmode of the runtime animation
  15781. * @returns Loop Mode
  15782. */
  15783. private _getCorrectLoopMode;
  15784. /**
  15785. * Move the current animation to a given frame
  15786. * @param frame defines the frame to move to
  15787. */
  15788. goToFrame(frame: number): void;
  15789. /**
  15790. * @hidden Internal use only
  15791. */
  15792. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15793. /**
  15794. * Execute the current animation
  15795. * @param delay defines the delay to add to the current frame
  15796. * @param from defines the lower bound of the animation range
  15797. * @param to defines the upper bound of the animation range
  15798. * @param loop defines if the current animation must loop
  15799. * @param speedRatio defines the current speed ratio
  15800. * @param weight defines the weight of the animation (default is -1 so no weight)
  15801. * @param onLoop optional callback called when animation loops
  15802. * @returns a boolean indicating if the animation is running
  15803. */
  15804. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15805. }
  15806. }
  15807. declare module BABYLON {
  15808. /**
  15809. * Class used to store an actual running animation
  15810. */
  15811. export class Animatable {
  15812. /** defines the target object */
  15813. target: any;
  15814. /** defines the starting frame number (default is 0) */
  15815. fromFrame: number;
  15816. /** defines the ending frame number (default is 100) */
  15817. toFrame: number;
  15818. /** defines if the animation must loop (default is false) */
  15819. loopAnimation: boolean;
  15820. /** defines a callback to call when animation ends if it is not looping */
  15821. onAnimationEnd?: (() => void) | null | undefined;
  15822. /** defines a callback to call when animation loops */
  15823. onAnimationLoop?: (() => void) | null | undefined;
  15824. /** defines whether the animation should be evaluated additively */
  15825. isAdditive: boolean;
  15826. private _localDelayOffset;
  15827. private _pausedDelay;
  15828. private _runtimeAnimations;
  15829. private _paused;
  15830. private _scene;
  15831. private _speedRatio;
  15832. private _weight;
  15833. private _syncRoot;
  15834. /**
  15835. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15836. * This will only apply for non looping animation (default is true)
  15837. */
  15838. disposeOnEnd: boolean;
  15839. /**
  15840. * Gets a boolean indicating if the animation has started
  15841. */
  15842. animationStarted: boolean;
  15843. /**
  15844. * Observer raised when the animation ends
  15845. */
  15846. onAnimationEndObservable: Observable<Animatable>;
  15847. /**
  15848. * Observer raised when the animation loops
  15849. */
  15850. onAnimationLoopObservable: Observable<Animatable>;
  15851. /**
  15852. * Gets the root Animatable used to synchronize and normalize animations
  15853. */
  15854. get syncRoot(): Nullable<Animatable>;
  15855. /**
  15856. * Gets the current frame of the first RuntimeAnimation
  15857. * Used to synchronize Animatables
  15858. */
  15859. get masterFrame(): number;
  15860. /**
  15861. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15862. */
  15863. get weight(): number;
  15864. set weight(value: number);
  15865. /**
  15866. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15867. */
  15868. get speedRatio(): number;
  15869. set speedRatio(value: number);
  15870. /**
  15871. * Creates a new Animatable
  15872. * @param scene defines the hosting scene
  15873. * @param target defines the target object
  15874. * @param fromFrame defines the starting frame number (default is 0)
  15875. * @param toFrame defines the ending frame number (default is 100)
  15876. * @param loopAnimation defines if the animation must loop (default is false)
  15877. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15878. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15879. * @param animations defines a group of animation to add to the new Animatable
  15880. * @param onAnimationLoop defines a callback to call when animation loops
  15881. * @param isAdditive defines whether the animation should be evaluated additively
  15882. */
  15883. constructor(scene: Scene,
  15884. /** defines the target object */
  15885. target: any,
  15886. /** defines the starting frame number (default is 0) */
  15887. fromFrame?: number,
  15888. /** defines the ending frame number (default is 100) */
  15889. toFrame?: number,
  15890. /** defines if the animation must loop (default is false) */
  15891. loopAnimation?: boolean, speedRatio?: number,
  15892. /** defines a callback to call when animation ends if it is not looping */
  15893. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15894. /** defines a callback to call when animation loops */
  15895. onAnimationLoop?: (() => void) | null | undefined,
  15896. /** defines whether the animation should be evaluated additively */
  15897. isAdditive?: boolean);
  15898. /**
  15899. * Synchronize and normalize current Animatable with a source Animatable
  15900. * This is useful when using animation weights and when animations are not of the same length
  15901. * @param root defines the root Animatable to synchronize with
  15902. * @returns the current Animatable
  15903. */
  15904. syncWith(root: Animatable): Animatable;
  15905. /**
  15906. * Gets the list of runtime animations
  15907. * @returns an array of RuntimeAnimation
  15908. */
  15909. getAnimations(): RuntimeAnimation[];
  15910. /**
  15911. * Adds more animations to the current animatable
  15912. * @param target defines the target of the animations
  15913. * @param animations defines the new animations to add
  15914. */
  15915. appendAnimations(target: any, animations: Animation[]): void;
  15916. /**
  15917. * Gets the source animation for a specific property
  15918. * @param property defines the propertyu to look for
  15919. * @returns null or the source animation for the given property
  15920. */
  15921. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15922. /**
  15923. * Gets the runtime animation for a specific property
  15924. * @param property defines the propertyu to look for
  15925. * @returns null or the runtime animation for the given property
  15926. */
  15927. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15928. /**
  15929. * Resets the animatable to its original state
  15930. */
  15931. reset(): void;
  15932. /**
  15933. * Allows the animatable to blend with current running animations
  15934. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15935. * @param blendingSpeed defines the blending speed to use
  15936. */
  15937. enableBlending(blendingSpeed: number): void;
  15938. /**
  15939. * Disable animation blending
  15940. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15941. */
  15942. disableBlending(): void;
  15943. /**
  15944. * Jump directly to a given frame
  15945. * @param frame defines the frame to jump to
  15946. */
  15947. goToFrame(frame: number): void;
  15948. /**
  15949. * Pause the animation
  15950. */
  15951. pause(): void;
  15952. /**
  15953. * Restart the animation
  15954. */
  15955. restart(): void;
  15956. private _raiseOnAnimationEnd;
  15957. /**
  15958. * Stop and delete the current animation
  15959. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15960. * @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)
  15961. */
  15962. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15963. /**
  15964. * Wait asynchronously for the animation to end
  15965. * @returns a promise which will be fullfilled when the animation ends
  15966. */
  15967. waitAsync(): Promise<Animatable>;
  15968. /** @hidden */
  15969. _animate(delay: number): boolean;
  15970. }
  15971. interface Scene {
  15972. /** @hidden */
  15973. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15974. /** @hidden */
  15975. _processLateAnimationBindingsForMatrices(holder: {
  15976. totalWeight: number;
  15977. totalAdditiveWeight: number;
  15978. animations: RuntimeAnimation[];
  15979. additiveAnimations: RuntimeAnimation[];
  15980. originalValue: Matrix;
  15981. }): any;
  15982. /** @hidden */
  15983. _processLateAnimationBindingsForQuaternions(holder: {
  15984. totalWeight: number;
  15985. totalAdditiveWeight: number;
  15986. animations: RuntimeAnimation[];
  15987. additiveAnimations: RuntimeAnimation[];
  15988. originalValue: Quaternion;
  15989. }, refQuaternion: Quaternion): Quaternion;
  15990. /** @hidden */
  15991. _processLateAnimationBindings(): void;
  15992. /**
  15993. * Will start the animation sequence of a given target
  15994. * @param target defines the target
  15995. * @param from defines from which frame should animation start
  15996. * @param to defines until which frame should animation run.
  15997. * @param weight defines the weight to apply to the animation (1.0 by default)
  15998. * @param loop defines if the animation loops
  15999. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16000. * @param onAnimationEnd defines the function to be executed when the animation ends
  16001. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16002. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16003. * @param onAnimationLoop defines the callback to call when an animation loops
  16004. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16005. * @returns the animatable object created for this animation
  16006. */
  16007. 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;
  16008. /**
  16009. * Will start the animation sequence of a given target
  16010. * @param target defines the target
  16011. * @param from defines from which frame should animation start
  16012. * @param to defines until which frame should animation run.
  16013. * @param loop defines if the animation loops
  16014. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16015. * @param onAnimationEnd defines the function to be executed when the animation ends
  16016. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16017. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16018. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16019. * @param onAnimationLoop defines the callback to call when an animation loops
  16020. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16021. * @returns the animatable object created for this animation
  16022. */
  16023. 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;
  16024. /**
  16025. * Will start the animation sequence of a given target and its hierarchy
  16026. * @param target defines the target
  16027. * @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.
  16028. * @param from defines from which frame should animation start
  16029. * @param to defines until which frame should animation run.
  16030. * @param loop defines if the animation loops
  16031. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16032. * @param onAnimationEnd defines the function to be executed when the animation ends
  16033. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16034. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16035. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16036. * @param onAnimationLoop defines the callback to call when an animation loops
  16037. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16038. * @returns the list of created animatables
  16039. */
  16040. 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[];
  16041. /**
  16042. * Begin a new animation on a given node
  16043. * @param target defines the target where the animation will take place
  16044. * @param animations defines the list of animations to start
  16045. * @param from defines the initial value
  16046. * @param to defines the final value
  16047. * @param loop defines if you want animation to loop (off by default)
  16048. * @param speedRatio defines the speed ratio to apply to all animations
  16049. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16050. * @param onAnimationLoop defines the callback to call when an animation loops
  16051. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16052. * @returns the list of created animatables
  16053. */
  16054. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16055. /**
  16056. * Begin a new animation on a given node and its hierarchy
  16057. * @param target defines the root node where the animation will take place
  16058. * @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.
  16059. * @param animations defines the list of animations to start
  16060. * @param from defines the initial value
  16061. * @param to defines the final value
  16062. * @param loop defines if you want animation to loop (off by default)
  16063. * @param speedRatio defines the speed ratio to apply to all animations
  16064. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16065. * @param onAnimationLoop defines the callback to call when an animation loops
  16066. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16067. * @returns the list of animatables created for all nodes
  16068. */
  16069. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16070. /**
  16071. * Gets the animatable associated with a specific target
  16072. * @param target defines the target of the animatable
  16073. * @returns the required animatable if found
  16074. */
  16075. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16076. /**
  16077. * Gets all animatables associated with a given target
  16078. * @param target defines the target to look animatables for
  16079. * @returns an array of Animatables
  16080. */
  16081. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16082. /**
  16083. * Stops and removes all animations that have been applied to the scene
  16084. */
  16085. stopAllAnimations(): void;
  16086. /**
  16087. * Gets the current delta time used by animation engine
  16088. */
  16089. deltaTime: number;
  16090. }
  16091. interface Bone {
  16092. /**
  16093. * Copy an animation range from another bone
  16094. * @param source defines the source bone
  16095. * @param rangeName defines the range name to copy
  16096. * @param frameOffset defines the frame offset
  16097. * @param rescaleAsRequired defines if rescaling must be applied if required
  16098. * @param skelDimensionsRatio defines the scaling ratio
  16099. * @returns true if operation was successful
  16100. */
  16101. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16102. }
  16103. }
  16104. declare module BABYLON {
  16105. /**
  16106. * Class used to handle skinning animations
  16107. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16108. */
  16109. export class Skeleton implements IAnimatable {
  16110. /** defines the skeleton name */
  16111. name: string;
  16112. /** defines the skeleton Id */
  16113. id: string;
  16114. /**
  16115. * Defines the list of child bones
  16116. */
  16117. bones: Bone[];
  16118. /**
  16119. * Defines an estimate of the dimension of the skeleton at rest
  16120. */
  16121. dimensionsAtRest: Vector3;
  16122. /**
  16123. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16124. */
  16125. needInitialSkinMatrix: boolean;
  16126. /**
  16127. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16128. */
  16129. overrideMesh: Nullable<AbstractMesh>;
  16130. /**
  16131. * Gets the list of animations attached to this skeleton
  16132. */
  16133. animations: Array<Animation>;
  16134. private _scene;
  16135. private _isDirty;
  16136. private _transformMatrices;
  16137. private _transformMatrixTexture;
  16138. private _meshesWithPoseMatrix;
  16139. private _animatables;
  16140. private _identity;
  16141. private _synchronizedWithMesh;
  16142. private _ranges;
  16143. private _lastAbsoluteTransformsUpdateId;
  16144. private _canUseTextureForBones;
  16145. private _uniqueId;
  16146. /** @hidden */
  16147. _numBonesWithLinkedTransformNode: number;
  16148. /** @hidden */
  16149. _hasWaitingData: Nullable<boolean>;
  16150. /** @hidden */
  16151. _waitingOverrideMeshId: Nullable<string>;
  16152. /**
  16153. * Specifies if the skeleton should be serialized
  16154. */
  16155. doNotSerialize: boolean;
  16156. private _useTextureToStoreBoneMatrices;
  16157. /**
  16158. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16159. * Please note that this option is not available if the hardware does not support it
  16160. */
  16161. get useTextureToStoreBoneMatrices(): boolean;
  16162. set useTextureToStoreBoneMatrices(value: boolean);
  16163. private _animationPropertiesOverride;
  16164. /**
  16165. * Gets or sets the animation properties override
  16166. */
  16167. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16168. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16169. /**
  16170. * List of inspectable custom properties (used by the Inspector)
  16171. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16172. */
  16173. inspectableCustomProperties: IInspectable[];
  16174. /**
  16175. * An observable triggered before computing the skeleton's matrices
  16176. */
  16177. onBeforeComputeObservable: Observable<Skeleton>;
  16178. /**
  16179. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16180. */
  16181. get isUsingTextureForMatrices(): boolean;
  16182. /**
  16183. * Gets the unique ID of this skeleton
  16184. */
  16185. get uniqueId(): number;
  16186. /**
  16187. * Creates a new skeleton
  16188. * @param name defines the skeleton name
  16189. * @param id defines the skeleton Id
  16190. * @param scene defines the hosting scene
  16191. */
  16192. constructor(
  16193. /** defines the skeleton name */
  16194. name: string,
  16195. /** defines the skeleton Id */
  16196. id: string, scene: Scene);
  16197. /**
  16198. * Gets the current object class name.
  16199. * @return the class name
  16200. */
  16201. getClassName(): string;
  16202. /**
  16203. * Returns an array containing the root bones
  16204. * @returns an array containing the root bones
  16205. */
  16206. getChildren(): Array<Bone>;
  16207. /**
  16208. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16209. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16210. * @returns a Float32Array containing matrices data
  16211. */
  16212. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16213. /**
  16214. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16215. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16216. * @returns a raw texture containing the data
  16217. */
  16218. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16219. /**
  16220. * Gets the current hosting scene
  16221. * @returns a scene object
  16222. */
  16223. getScene(): Scene;
  16224. /**
  16225. * Gets a string representing the current skeleton data
  16226. * @param fullDetails defines a boolean indicating if we want a verbose version
  16227. * @returns a string representing the current skeleton data
  16228. */
  16229. toString(fullDetails?: boolean): string;
  16230. /**
  16231. * Get bone's index searching by name
  16232. * @param name defines bone's name to search for
  16233. * @return the indice of the bone. Returns -1 if not found
  16234. */
  16235. getBoneIndexByName(name: string): number;
  16236. /**
  16237. * Creater a new animation range
  16238. * @param name defines the name of the range
  16239. * @param from defines the start key
  16240. * @param to defines the end key
  16241. */
  16242. createAnimationRange(name: string, from: number, to: number): void;
  16243. /**
  16244. * Delete a specific animation range
  16245. * @param name defines the name of the range
  16246. * @param deleteFrames defines if frames must be removed as well
  16247. */
  16248. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16249. /**
  16250. * Gets a specific animation range
  16251. * @param name defines the name of the range to look for
  16252. * @returns the requested animation range or null if not found
  16253. */
  16254. getAnimationRange(name: string): Nullable<AnimationRange>;
  16255. /**
  16256. * Gets the list of all animation ranges defined on this skeleton
  16257. * @returns an array
  16258. */
  16259. getAnimationRanges(): Nullable<AnimationRange>[];
  16260. /**
  16261. * Copy animation range from a source skeleton.
  16262. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16263. * @param source defines the source skeleton
  16264. * @param name defines the name of the range to copy
  16265. * @param rescaleAsRequired defines if rescaling must be applied if required
  16266. * @returns true if operation was successful
  16267. */
  16268. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16269. /**
  16270. * Forces the skeleton to go to rest pose
  16271. */
  16272. returnToRest(): void;
  16273. private _getHighestAnimationFrame;
  16274. /**
  16275. * Begin a specific animation range
  16276. * @param name defines the name of the range to start
  16277. * @param loop defines if looping must be turned on (false by default)
  16278. * @param speedRatio defines the speed ratio to apply (1 by default)
  16279. * @param onAnimationEnd defines a callback which will be called when animation will end
  16280. * @returns a new animatable
  16281. */
  16282. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16283. /**
  16284. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16285. * @param skeleton defines the Skeleton containing the animation range to convert
  16286. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16287. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16288. * @returns the original skeleton
  16289. */
  16290. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16291. /** @hidden */
  16292. _markAsDirty(): void;
  16293. /** @hidden */
  16294. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16295. /** @hidden */
  16296. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16297. private _computeTransformMatrices;
  16298. /**
  16299. * Build all resources required to render a skeleton
  16300. */
  16301. prepare(): void;
  16302. /**
  16303. * Gets the list of animatables currently running for this skeleton
  16304. * @returns an array of animatables
  16305. */
  16306. getAnimatables(): IAnimatable[];
  16307. /**
  16308. * Clone the current skeleton
  16309. * @param name defines the name of the new skeleton
  16310. * @param id defines the id of the new skeleton
  16311. * @returns the new skeleton
  16312. */
  16313. clone(name: string, id?: string): Skeleton;
  16314. /**
  16315. * Enable animation blending for this skeleton
  16316. * @param blendingSpeed defines the blending speed to apply
  16317. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16318. */
  16319. enableBlending(blendingSpeed?: number): void;
  16320. /**
  16321. * Releases all resources associated with the current skeleton
  16322. */
  16323. dispose(): void;
  16324. /**
  16325. * Serialize the skeleton in a JSON object
  16326. * @returns a JSON object
  16327. */
  16328. serialize(): any;
  16329. /**
  16330. * Creates a new skeleton from serialized data
  16331. * @param parsedSkeleton defines the serialized data
  16332. * @param scene defines the hosting scene
  16333. * @returns a new skeleton
  16334. */
  16335. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16336. /**
  16337. * Compute all node absolute transforms
  16338. * @param forceUpdate defines if computation must be done even if cache is up to date
  16339. */
  16340. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16341. /**
  16342. * Gets the root pose matrix
  16343. * @returns a matrix
  16344. */
  16345. getPoseMatrix(): Nullable<Matrix>;
  16346. /**
  16347. * Sorts bones per internal index
  16348. */
  16349. sortBones(): void;
  16350. private _sortBones;
  16351. /**
  16352. * Set the current local matrix as the restPose for all bones in the skeleton.
  16353. */
  16354. setCurrentPoseAsRest(): void;
  16355. }
  16356. }
  16357. declare module BABYLON {
  16358. /**
  16359. * Creates an instance based on a source mesh.
  16360. */
  16361. export class InstancedMesh extends AbstractMesh {
  16362. private _sourceMesh;
  16363. private _currentLOD;
  16364. /** @hidden */
  16365. _indexInSourceMeshInstanceArray: number;
  16366. constructor(name: string, source: Mesh);
  16367. /**
  16368. * Returns the string "InstancedMesh".
  16369. */
  16370. getClassName(): string;
  16371. /** Gets the list of lights affecting that mesh */
  16372. get lightSources(): Light[];
  16373. _resyncLightSources(): void;
  16374. _resyncLightSource(light: Light): void;
  16375. _removeLightSource(light: Light, dispose: boolean): void;
  16376. /**
  16377. * If the source mesh receives shadows
  16378. */
  16379. get receiveShadows(): boolean;
  16380. /**
  16381. * The material of the source mesh
  16382. */
  16383. get material(): Nullable<Material>;
  16384. /**
  16385. * Visibility of the source mesh
  16386. */
  16387. get visibility(): number;
  16388. /**
  16389. * Skeleton of the source mesh
  16390. */
  16391. get skeleton(): Nullable<Skeleton>;
  16392. /**
  16393. * Rendering ground id of the source mesh
  16394. */
  16395. get renderingGroupId(): number;
  16396. set renderingGroupId(value: number);
  16397. /**
  16398. * Returns the total number of vertices (integer).
  16399. */
  16400. getTotalVertices(): number;
  16401. /**
  16402. * Returns a positive integer : the total number of indices in this mesh geometry.
  16403. * @returns the numner of indices or zero if the mesh has no geometry.
  16404. */
  16405. getTotalIndices(): number;
  16406. /**
  16407. * The source mesh of the instance
  16408. */
  16409. get sourceMesh(): Mesh;
  16410. /**
  16411. * Creates a new InstancedMesh object from the mesh model.
  16412. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16413. * @param name defines the name of the new instance
  16414. * @returns a new InstancedMesh
  16415. */
  16416. createInstance(name: string): InstancedMesh;
  16417. /**
  16418. * Is this node ready to be used/rendered
  16419. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16420. * @return {boolean} is it ready
  16421. */
  16422. isReady(completeCheck?: boolean): boolean;
  16423. /**
  16424. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16425. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16426. * @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.
  16427. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16428. */
  16429. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16430. /**
  16431. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16432. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16433. * The `data` are either a numeric array either a Float32Array.
  16434. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16435. * 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).
  16436. * Note that a new underlying VertexBuffer object is created each call.
  16437. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16438. *
  16439. * Possible `kind` values :
  16440. * - VertexBuffer.PositionKind
  16441. * - VertexBuffer.UVKind
  16442. * - VertexBuffer.UV2Kind
  16443. * - VertexBuffer.UV3Kind
  16444. * - VertexBuffer.UV4Kind
  16445. * - VertexBuffer.UV5Kind
  16446. * - VertexBuffer.UV6Kind
  16447. * - VertexBuffer.ColorKind
  16448. * - VertexBuffer.MatricesIndicesKind
  16449. * - VertexBuffer.MatricesIndicesExtraKind
  16450. * - VertexBuffer.MatricesWeightsKind
  16451. * - VertexBuffer.MatricesWeightsExtraKind
  16452. *
  16453. * Returns the Mesh.
  16454. */
  16455. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16456. /**
  16457. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16458. * If the mesh has no geometry, it is simply returned as it is.
  16459. * The `data` are either a numeric array either a Float32Array.
  16460. * No new underlying VertexBuffer object is created.
  16461. * 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.
  16462. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16463. *
  16464. * Possible `kind` values :
  16465. * - VertexBuffer.PositionKind
  16466. * - VertexBuffer.UVKind
  16467. * - VertexBuffer.UV2Kind
  16468. * - VertexBuffer.UV3Kind
  16469. * - VertexBuffer.UV4Kind
  16470. * - VertexBuffer.UV5Kind
  16471. * - VertexBuffer.UV6Kind
  16472. * - VertexBuffer.ColorKind
  16473. * - VertexBuffer.MatricesIndicesKind
  16474. * - VertexBuffer.MatricesIndicesExtraKind
  16475. * - VertexBuffer.MatricesWeightsKind
  16476. * - VertexBuffer.MatricesWeightsExtraKind
  16477. *
  16478. * Returns the Mesh.
  16479. */
  16480. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16481. /**
  16482. * Sets the mesh indices.
  16483. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16484. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16485. * This method creates a new index buffer each call.
  16486. * Returns the Mesh.
  16487. */
  16488. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16489. /**
  16490. * Boolean : True if the mesh owns the requested kind of data.
  16491. */
  16492. isVerticesDataPresent(kind: string): boolean;
  16493. /**
  16494. * Returns an array of indices (IndicesArray).
  16495. */
  16496. getIndices(): Nullable<IndicesArray>;
  16497. get _positions(): Nullable<Vector3[]>;
  16498. /**
  16499. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16500. * This means the mesh underlying bounding box and sphere are recomputed.
  16501. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16502. * @returns the current mesh
  16503. */
  16504. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16505. /** @hidden */
  16506. _preActivate(): InstancedMesh;
  16507. /** @hidden */
  16508. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16509. /** @hidden */
  16510. _postActivate(): void;
  16511. getWorldMatrix(): Matrix;
  16512. get isAnInstance(): boolean;
  16513. /**
  16514. * Returns the current associated LOD AbstractMesh.
  16515. */
  16516. getLOD(camera: Camera): AbstractMesh;
  16517. /** @hidden */
  16518. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16519. /** @hidden */
  16520. _syncSubMeshes(): InstancedMesh;
  16521. /** @hidden */
  16522. _generatePointsArray(): boolean;
  16523. /** @hidden */
  16524. _updateBoundingInfo(): AbstractMesh;
  16525. /**
  16526. * Creates a new InstancedMesh from the current mesh.
  16527. * - name (string) : the cloned mesh name
  16528. * - newParent (optional Node) : the optional Node to parent the clone to.
  16529. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16530. *
  16531. * Returns the clone.
  16532. */
  16533. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16534. /**
  16535. * Disposes the InstancedMesh.
  16536. * Returns nothing.
  16537. */
  16538. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16539. }
  16540. interface Mesh {
  16541. /**
  16542. * Register a custom buffer that will be instanced
  16543. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16544. * @param kind defines the buffer kind
  16545. * @param stride defines the stride in floats
  16546. */
  16547. registerInstancedBuffer(kind: string, stride: number): void;
  16548. /**
  16549. * true to use the edge renderer for all instances of this mesh
  16550. */
  16551. edgesShareWithInstances: boolean;
  16552. /** @hidden */
  16553. _userInstancedBuffersStorage: {
  16554. data: {
  16555. [key: string]: Float32Array;
  16556. };
  16557. sizes: {
  16558. [key: string]: number;
  16559. };
  16560. vertexBuffers: {
  16561. [key: string]: Nullable<VertexBuffer>;
  16562. };
  16563. strides: {
  16564. [key: string]: number;
  16565. };
  16566. };
  16567. }
  16568. interface AbstractMesh {
  16569. /**
  16570. * Object used to store instanced buffers defined by user
  16571. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16572. */
  16573. instancedBuffers: {
  16574. [key: string]: any;
  16575. };
  16576. }
  16577. }
  16578. declare module BABYLON {
  16579. /**
  16580. * Defines the options associated with the creation of a shader material.
  16581. */
  16582. export interface IShaderMaterialOptions {
  16583. /**
  16584. * Does the material work in alpha blend mode
  16585. */
  16586. needAlphaBlending: boolean;
  16587. /**
  16588. * Does the material work in alpha test mode
  16589. */
  16590. needAlphaTesting: boolean;
  16591. /**
  16592. * The list of attribute names used in the shader
  16593. */
  16594. attributes: string[];
  16595. /**
  16596. * The list of unifrom names used in the shader
  16597. */
  16598. uniforms: string[];
  16599. /**
  16600. * The list of UBO names used in the shader
  16601. */
  16602. uniformBuffers: string[];
  16603. /**
  16604. * The list of sampler names used in the shader
  16605. */
  16606. samplers: string[];
  16607. /**
  16608. * The list of defines used in the shader
  16609. */
  16610. defines: string[];
  16611. }
  16612. /**
  16613. * 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.
  16614. *
  16615. * This returned material effects how the mesh will look based on the code in the shaders.
  16616. *
  16617. * @see https://doc.babylonjs.com/how_to/shader_material
  16618. */
  16619. export class ShaderMaterial extends Material {
  16620. private _shaderPath;
  16621. private _options;
  16622. private _textures;
  16623. private _textureArrays;
  16624. private _floats;
  16625. private _ints;
  16626. private _floatsArrays;
  16627. private _colors3;
  16628. private _colors3Arrays;
  16629. private _colors4;
  16630. private _colors4Arrays;
  16631. private _vectors2;
  16632. private _vectors3;
  16633. private _vectors4;
  16634. private _matrices;
  16635. private _matrixArrays;
  16636. private _matrices3x3;
  16637. private _matrices2x2;
  16638. private _vectors2Arrays;
  16639. private _vectors3Arrays;
  16640. private _vectors4Arrays;
  16641. private _cachedWorldViewMatrix;
  16642. private _cachedWorldViewProjectionMatrix;
  16643. private _renderId;
  16644. private _multiview;
  16645. private _cachedDefines;
  16646. /** Define the Url to load snippets */
  16647. static SnippetUrl: string;
  16648. /** Snippet ID if the material was created from the snippet server */
  16649. snippetId: string;
  16650. /**
  16651. * Instantiate a new shader material.
  16652. * 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.
  16653. * This returned material effects how the mesh will look based on the code in the shaders.
  16654. * @see https://doc.babylonjs.com/how_to/shader_material
  16655. * @param name Define the name of the material in the scene
  16656. * @param scene Define the scene the material belongs to
  16657. * @param shaderPath Defines the route to the shader code in one of three ways:
  16658. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16659. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16660. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16661. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16662. * @param options Define the options used to create the shader
  16663. */
  16664. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16665. /**
  16666. * Gets the shader path used to define the shader code
  16667. * It can be modified to trigger a new compilation
  16668. */
  16669. get shaderPath(): any;
  16670. /**
  16671. * Sets the shader path used to define the shader code
  16672. * It can be modified to trigger a new compilation
  16673. */
  16674. set shaderPath(shaderPath: any);
  16675. /**
  16676. * Gets the options used to compile the shader.
  16677. * They can be modified to trigger a new compilation
  16678. */
  16679. get options(): IShaderMaterialOptions;
  16680. /**
  16681. * Gets the current class name of the material e.g. "ShaderMaterial"
  16682. * Mainly use in serialization.
  16683. * @returns the class name
  16684. */
  16685. getClassName(): string;
  16686. /**
  16687. * Specifies if the material will require alpha blending
  16688. * @returns a boolean specifying if alpha blending is needed
  16689. */
  16690. needAlphaBlending(): boolean;
  16691. /**
  16692. * Specifies if this material should be rendered in alpha test mode
  16693. * @returns a boolean specifying if an alpha test is needed.
  16694. */
  16695. needAlphaTesting(): boolean;
  16696. private _checkUniform;
  16697. /**
  16698. * Set a texture in the shader.
  16699. * @param name Define the name of the uniform samplers as defined in the shader
  16700. * @param texture Define the texture to bind to this sampler
  16701. * @return the material itself allowing "fluent" like uniform updates
  16702. */
  16703. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16704. /**
  16705. * Set a texture array in the shader.
  16706. * @param name Define the name of the uniform sampler array as defined in the shader
  16707. * @param textures Define the list of textures to bind to this sampler
  16708. * @return the material itself allowing "fluent" like uniform updates
  16709. */
  16710. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16711. /**
  16712. * Set a float in the shader.
  16713. * @param name Define the name of the uniform as defined in the shader
  16714. * @param value Define the value to give to the uniform
  16715. * @return the material itself allowing "fluent" like uniform updates
  16716. */
  16717. setFloat(name: string, value: number): ShaderMaterial;
  16718. /**
  16719. * Set a int in the shader.
  16720. * @param name Define the name of the uniform as defined in the shader
  16721. * @param value Define the value to give to the uniform
  16722. * @return the material itself allowing "fluent" like uniform updates
  16723. */
  16724. setInt(name: string, value: number): ShaderMaterial;
  16725. /**
  16726. * Set an array of floats in the shader.
  16727. * @param name Define the name of the uniform as defined in the shader
  16728. * @param value Define the value to give to the uniform
  16729. * @return the material itself allowing "fluent" like uniform updates
  16730. */
  16731. setFloats(name: string, value: number[]): ShaderMaterial;
  16732. /**
  16733. * Set a vec3 in the shader from a Color3.
  16734. * @param name Define the name of the uniform as defined in the shader
  16735. * @param value Define the value to give to the uniform
  16736. * @return the material itself allowing "fluent" like uniform updates
  16737. */
  16738. setColor3(name: string, value: Color3): ShaderMaterial;
  16739. /**
  16740. * Set a vec3 array in the shader from a Color3 array.
  16741. * @param name Define the name of the uniform as defined in the shader
  16742. * @param value Define the value to give to the uniform
  16743. * @return the material itself allowing "fluent" like uniform updates
  16744. */
  16745. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16746. /**
  16747. * Set a vec4 in the shader from a Color4.
  16748. * @param name Define the name of the uniform as defined in the shader
  16749. * @param value Define the value to give to the uniform
  16750. * @return the material itself allowing "fluent" like uniform updates
  16751. */
  16752. setColor4(name: string, value: Color4): ShaderMaterial;
  16753. /**
  16754. * Set a vec4 array in the shader from a Color4 array.
  16755. * @param name Define the name of the uniform as defined in the shader
  16756. * @param value Define the value to give to the uniform
  16757. * @return the material itself allowing "fluent" like uniform updates
  16758. */
  16759. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16760. /**
  16761. * Set a vec2 in the shader from a Vector2.
  16762. * @param name Define the name of the uniform as defined in the shader
  16763. * @param value Define the value to give to the uniform
  16764. * @return the material itself allowing "fluent" like uniform updates
  16765. */
  16766. setVector2(name: string, value: Vector2): ShaderMaterial;
  16767. /**
  16768. * Set a vec3 in the shader from a Vector3.
  16769. * @param name Define the name of the uniform as defined in the shader
  16770. * @param value Define the value to give to the uniform
  16771. * @return the material itself allowing "fluent" like uniform updates
  16772. */
  16773. setVector3(name: string, value: Vector3): ShaderMaterial;
  16774. /**
  16775. * Set a vec4 in the shader from a Vector4.
  16776. * @param name Define the name of the uniform as defined in the shader
  16777. * @param value Define the value to give to the uniform
  16778. * @return the material itself allowing "fluent" like uniform updates
  16779. */
  16780. setVector4(name: string, value: Vector4): ShaderMaterial;
  16781. /**
  16782. * Set a mat4 in the shader from a Matrix.
  16783. * @param name Define the name of the uniform as defined in the shader
  16784. * @param value Define the value to give to the uniform
  16785. * @return the material itself allowing "fluent" like uniform updates
  16786. */
  16787. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16788. /**
  16789. * Set a float32Array in the shader from a matrix array.
  16790. * @param name Define the name of the uniform as defined in the shader
  16791. * @param value Define the value to give to the uniform
  16792. * @return the material itself allowing "fluent" like uniform updates
  16793. */
  16794. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16795. /**
  16796. * Set a mat3 in the shader from a Float32Array.
  16797. * @param name Define the name of the uniform as defined in the shader
  16798. * @param value Define the value to give to the uniform
  16799. * @return the material itself allowing "fluent" like uniform updates
  16800. */
  16801. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16802. /**
  16803. * Set a mat2 in the shader from a Float32Array.
  16804. * @param name Define the name of the uniform as defined in the shader
  16805. * @param value Define the value to give to the uniform
  16806. * @return the material itself allowing "fluent" like uniform updates
  16807. */
  16808. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16809. /**
  16810. * Set a vec2 array in the shader from a number array.
  16811. * @param name Define the name of the uniform as defined in the shader
  16812. * @param value Define the value to give to the uniform
  16813. * @return the material itself allowing "fluent" like uniform updates
  16814. */
  16815. setArray2(name: string, value: number[]): ShaderMaterial;
  16816. /**
  16817. * Set a vec3 array in the shader from a number array.
  16818. * @param name Define the name of the uniform as defined in the shader
  16819. * @param value Define the value to give to the uniform
  16820. * @return the material itself allowing "fluent" like uniform updates
  16821. */
  16822. setArray3(name: string, value: number[]): ShaderMaterial;
  16823. /**
  16824. * Set a vec4 array in the shader from a number array.
  16825. * @param name Define the name of the uniform as defined in the shader
  16826. * @param value Define the value to give to the uniform
  16827. * @return the material itself allowing "fluent" like uniform updates
  16828. */
  16829. setArray4(name: string, value: number[]): ShaderMaterial;
  16830. private _checkCache;
  16831. /**
  16832. * Specifies that the submesh is ready to be used
  16833. * @param mesh defines the mesh to check
  16834. * @param subMesh defines which submesh to check
  16835. * @param useInstances specifies that instances should be used
  16836. * @returns a boolean indicating that the submesh is ready or not
  16837. */
  16838. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16839. /**
  16840. * Checks if the material is ready to render the requested mesh
  16841. * @param mesh Define the mesh to render
  16842. * @param useInstances Define whether or not the material is used with instances
  16843. * @returns true if ready, otherwise false
  16844. */
  16845. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16846. /**
  16847. * Binds the world matrix to the material
  16848. * @param world defines the world transformation matrix
  16849. * @param effectOverride - If provided, use this effect instead of internal effect
  16850. */
  16851. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16852. /**
  16853. * Binds the submesh to this material by preparing the effect and shader to draw
  16854. * @param world defines the world transformation matrix
  16855. * @param mesh defines the mesh containing the submesh
  16856. * @param subMesh defines the submesh to bind the material to
  16857. */
  16858. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16859. /**
  16860. * Binds the material to the mesh
  16861. * @param world defines the world transformation matrix
  16862. * @param mesh defines the mesh to bind the material to
  16863. * @param effectOverride - If provided, use this effect instead of internal effect
  16864. */
  16865. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16866. protected _afterBind(mesh?: Mesh): void;
  16867. /**
  16868. * Gets the active textures from the material
  16869. * @returns an array of textures
  16870. */
  16871. getActiveTextures(): BaseTexture[];
  16872. /**
  16873. * Specifies if the material uses a texture
  16874. * @param texture defines the texture to check against the material
  16875. * @returns a boolean specifying if the material uses the texture
  16876. */
  16877. hasTexture(texture: BaseTexture): boolean;
  16878. /**
  16879. * Makes a duplicate of the material, and gives it a new name
  16880. * @param name defines the new name for the duplicated material
  16881. * @returns the cloned material
  16882. */
  16883. clone(name: string): ShaderMaterial;
  16884. /**
  16885. * Disposes the material
  16886. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16887. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16888. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16889. */
  16890. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16891. /**
  16892. * Serializes this material in a JSON representation
  16893. * @returns the serialized material object
  16894. */
  16895. serialize(): any;
  16896. /**
  16897. * Creates a shader material from parsed shader material data
  16898. * @param source defines the JSON represnetation of the material
  16899. * @param scene defines the hosting scene
  16900. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16901. * @returns a new material
  16902. */
  16903. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16904. /**
  16905. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16906. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16907. * @param url defines the url to load from
  16908. * @param scene defines the hosting scene
  16909. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16910. * @returns a promise that will resolve to the new ShaderMaterial
  16911. */
  16912. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16913. /**
  16914. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16915. * @param snippetId defines the snippet to load
  16916. * @param scene defines the hosting scene
  16917. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16918. * @returns a promise that will resolve to the new ShaderMaterial
  16919. */
  16920. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16921. }
  16922. }
  16923. declare module BABYLON {
  16924. /** @hidden */
  16925. export var colorPixelShader: {
  16926. name: string;
  16927. shader: string;
  16928. };
  16929. }
  16930. declare module BABYLON {
  16931. /** @hidden */
  16932. export var colorVertexShader: {
  16933. name: string;
  16934. shader: string;
  16935. };
  16936. }
  16937. declare module BABYLON {
  16938. /**
  16939. * Line mesh
  16940. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16941. */
  16942. export class LinesMesh extends Mesh {
  16943. /**
  16944. * If vertex color should be applied to the mesh
  16945. */
  16946. readonly useVertexColor?: boolean | undefined;
  16947. /**
  16948. * If vertex alpha should be applied to the mesh
  16949. */
  16950. readonly useVertexAlpha?: boolean | undefined;
  16951. /**
  16952. * Color of the line (Default: White)
  16953. */
  16954. color: Color3;
  16955. /**
  16956. * Alpha of the line (Default: 1)
  16957. */
  16958. alpha: number;
  16959. /**
  16960. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16961. * This margin is expressed in world space coordinates, so its value may vary.
  16962. * Default value is 0.1
  16963. */
  16964. intersectionThreshold: number;
  16965. private _colorShader;
  16966. private color4;
  16967. /**
  16968. * Creates a new LinesMesh
  16969. * @param name defines the name
  16970. * @param scene defines the hosting scene
  16971. * @param parent defines the parent mesh if any
  16972. * @param source defines the optional source LinesMesh used to clone data from
  16973. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16974. * When false, achieved by calling a clone(), also passing False.
  16975. * This will make creation of children, recursive.
  16976. * @param useVertexColor defines if this LinesMesh supports vertex color
  16977. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16978. */
  16979. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16980. /**
  16981. * If vertex color should be applied to the mesh
  16982. */
  16983. useVertexColor?: boolean | undefined,
  16984. /**
  16985. * If vertex alpha should be applied to the mesh
  16986. */
  16987. useVertexAlpha?: boolean | undefined);
  16988. private _addClipPlaneDefine;
  16989. private _removeClipPlaneDefine;
  16990. isReady(): boolean;
  16991. /**
  16992. * Returns the string "LineMesh"
  16993. */
  16994. getClassName(): string;
  16995. /**
  16996. * @hidden
  16997. */
  16998. get material(): Material;
  16999. /**
  17000. * @hidden
  17001. */
  17002. set material(value: Material);
  17003. /**
  17004. * @hidden
  17005. */
  17006. get checkCollisions(): boolean;
  17007. /** @hidden */
  17008. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17009. /** @hidden */
  17010. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17011. /**
  17012. * Disposes of the line mesh
  17013. * @param doNotRecurse If children should be disposed
  17014. */
  17015. dispose(doNotRecurse?: boolean): void;
  17016. /**
  17017. * Returns a new LineMesh object cloned from the current one.
  17018. */
  17019. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17020. /**
  17021. * Creates a new InstancedLinesMesh object from the mesh model.
  17022. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17023. * @param name defines the name of the new instance
  17024. * @returns a new InstancedLinesMesh
  17025. */
  17026. createInstance(name: string): InstancedLinesMesh;
  17027. }
  17028. /**
  17029. * Creates an instance based on a source LinesMesh
  17030. */
  17031. export class InstancedLinesMesh extends InstancedMesh {
  17032. /**
  17033. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17034. * This margin is expressed in world space coordinates, so its value may vary.
  17035. * Initilized with the intersectionThreshold value of the source LinesMesh
  17036. */
  17037. intersectionThreshold: number;
  17038. constructor(name: string, source: LinesMesh);
  17039. /**
  17040. * Returns the string "InstancedLinesMesh".
  17041. */
  17042. getClassName(): string;
  17043. }
  17044. }
  17045. declare module BABYLON {
  17046. /** @hidden */
  17047. export var linePixelShader: {
  17048. name: string;
  17049. shader: string;
  17050. };
  17051. }
  17052. declare module BABYLON {
  17053. /** @hidden */
  17054. export var lineVertexShader: {
  17055. name: string;
  17056. shader: string;
  17057. };
  17058. }
  17059. declare module BABYLON {
  17060. interface Scene {
  17061. /** @hidden */
  17062. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17063. }
  17064. interface AbstractMesh {
  17065. /**
  17066. * Gets the edgesRenderer associated with the mesh
  17067. */
  17068. edgesRenderer: Nullable<EdgesRenderer>;
  17069. }
  17070. interface LinesMesh {
  17071. /**
  17072. * Enables the edge rendering mode on the mesh.
  17073. * This mode makes the mesh edges visible
  17074. * @param epsilon defines the maximal distance between two angles to detect a face
  17075. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17076. * @returns the currentAbstractMesh
  17077. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17078. */
  17079. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17080. }
  17081. interface InstancedLinesMesh {
  17082. /**
  17083. * Enables the edge rendering mode on the mesh.
  17084. * This mode makes the mesh edges visible
  17085. * @param epsilon defines the maximal distance between two angles to detect a face
  17086. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17087. * @returns the current InstancedLinesMesh
  17088. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17089. */
  17090. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17091. }
  17092. /**
  17093. * Defines the minimum contract an Edges renderer should follow.
  17094. */
  17095. export interface IEdgesRenderer extends IDisposable {
  17096. /**
  17097. * Gets or sets a boolean indicating if the edgesRenderer is active
  17098. */
  17099. isEnabled: boolean;
  17100. /**
  17101. * Renders the edges of the attached mesh,
  17102. */
  17103. render(): void;
  17104. /**
  17105. * Checks wether or not the edges renderer is ready to render.
  17106. * @return true if ready, otherwise false.
  17107. */
  17108. isReady(): boolean;
  17109. /**
  17110. * List of instances to render in case the source mesh has instances
  17111. */
  17112. customInstances: SmartArray<Matrix>;
  17113. }
  17114. /**
  17115. * Defines the additional options of the edges renderer
  17116. */
  17117. export interface IEdgesRendererOptions {
  17118. /**
  17119. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17120. * If not defined, the default value is true
  17121. */
  17122. useAlternateEdgeFinder?: boolean;
  17123. /**
  17124. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17125. * If not defined, the default value is true.
  17126. * 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)
  17127. * This option is used only if useAlternateEdgeFinder = true
  17128. */
  17129. useFastVertexMerger?: boolean;
  17130. /**
  17131. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17132. * The default value is 1e-6
  17133. * This option is used only if useAlternateEdgeFinder = true
  17134. */
  17135. epsilonVertexMerge?: number;
  17136. /**
  17137. * 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
  17138. * 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.
  17139. * This option is used only if useAlternateEdgeFinder = true
  17140. */
  17141. applyTessellation?: boolean;
  17142. /**
  17143. * 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
  17144. * The default value is 1e-6
  17145. * This option is used only if useAlternateEdgeFinder = true
  17146. */
  17147. epsilonVertexAligned?: number;
  17148. }
  17149. /**
  17150. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17151. */
  17152. export class EdgesRenderer implements IEdgesRenderer {
  17153. /**
  17154. * Define the size of the edges with an orthographic camera
  17155. */
  17156. edgesWidthScalerForOrthographic: number;
  17157. /**
  17158. * Define the size of the edges with a perspective camera
  17159. */
  17160. edgesWidthScalerForPerspective: number;
  17161. protected _source: AbstractMesh;
  17162. protected _linesPositions: number[];
  17163. protected _linesNormals: number[];
  17164. protected _linesIndices: number[];
  17165. protected _epsilon: number;
  17166. protected _indicesCount: number;
  17167. protected _lineShader: ShaderMaterial;
  17168. protected _ib: DataBuffer;
  17169. protected _buffers: {
  17170. [key: string]: Nullable<VertexBuffer>;
  17171. };
  17172. protected _buffersForInstances: {
  17173. [key: string]: Nullable<VertexBuffer>;
  17174. };
  17175. protected _checkVerticesInsteadOfIndices: boolean;
  17176. protected _options: Nullable<IEdgesRendererOptions>;
  17177. private _meshRebuildObserver;
  17178. private _meshDisposeObserver;
  17179. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17180. isEnabled: boolean;
  17181. /**
  17182. * List of instances to render in case the source mesh has instances
  17183. */
  17184. customInstances: SmartArray<Matrix>;
  17185. private static GetShader;
  17186. /**
  17187. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17188. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17189. * @param source Mesh used to create edges
  17190. * @param epsilon sum of angles in adjacency to check for edge
  17191. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17192. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17193. * @param options The options to apply when generating the edges
  17194. */
  17195. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17196. protected _prepareRessources(): void;
  17197. /** @hidden */
  17198. _rebuild(): void;
  17199. /**
  17200. * Releases the required resources for the edges renderer
  17201. */
  17202. dispose(): void;
  17203. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17204. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17205. /**
  17206. * Checks if the pair of p0 and p1 is en edge
  17207. * @param faceIndex
  17208. * @param edge
  17209. * @param faceNormals
  17210. * @param p0
  17211. * @param p1
  17212. * @private
  17213. */
  17214. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17215. /**
  17216. * push line into the position, normal and index buffer
  17217. * @protected
  17218. */
  17219. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17220. /**
  17221. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17222. */
  17223. private _tessellateTriangle;
  17224. private _generateEdgesLinesAlternate;
  17225. /**
  17226. * Generates lines edges from adjacencjes
  17227. * @private
  17228. */
  17229. _generateEdgesLines(): void;
  17230. /**
  17231. * Checks wether or not the edges renderer is ready to render.
  17232. * @return true if ready, otherwise false.
  17233. */
  17234. isReady(): boolean;
  17235. /**
  17236. * Renders the edges of the attached mesh,
  17237. */
  17238. render(): void;
  17239. }
  17240. /**
  17241. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17242. */
  17243. export class LineEdgesRenderer extends EdgesRenderer {
  17244. /**
  17245. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17246. * @param source LineMesh used to generate edges
  17247. * @param epsilon not important (specified angle for edge detection)
  17248. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17249. */
  17250. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17251. /**
  17252. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17253. */
  17254. _generateEdgesLines(): void;
  17255. }
  17256. }
  17257. declare module BABYLON {
  17258. /**
  17259. * This represents the object necessary to create a rendering group.
  17260. * This is exclusively used and created by the rendering manager.
  17261. * To modify the behavior, you use the available helpers in your scene or meshes.
  17262. * @hidden
  17263. */
  17264. export class RenderingGroup {
  17265. index: number;
  17266. private static _zeroVector;
  17267. private _scene;
  17268. private _opaqueSubMeshes;
  17269. private _transparentSubMeshes;
  17270. private _alphaTestSubMeshes;
  17271. private _depthOnlySubMeshes;
  17272. private _particleSystems;
  17273. private _spriteManagers;
  17274. private _opaqueSortCompareFn;
  17275. private _alphaTestSortCompareFn;
  17276. private _transparentSortCompareFn;
  17277. private _renderOpaque;
  17278. private _renderAlphaTest;
  17279. private _renderTransparent;
  17280. /** @hidden */
  17281. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17282. onBeforeTransparentRendering: () => void;
  17283. /**
  17284. * Set the opaque sort comparison function.
  17285. * If null the sub meshes will be render in the order they were created
  17286. */
  17287. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17288. /**
  17289. * Set the alpha test sort comparison function.
  17290. * If null the sub meshes will be render in the order they were created
  17291. */
  17292. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17293. /**
  17294. * Set the transparent sort comparison function.
  17295. * If null the sub meshes will be render in the order they were created
  17296. */
  17297. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17298. /**
  17299. * Creates a new rendering group.
  17300. * @param index The rendering group index
  17301. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17302. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17303. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17304. */
  17305. 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>);
  17306. /**
  17307. * Render all the sub meshes contained in the group.
  17308. * @param customRenderFunction Used to override the default render behaviour of the group.
  17309. * @returns true if rendered some submeshes.
  17310. */
  17311. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17312. /**
  17313. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17314. * @param subMeshes The submeshes to render
  17315. */
  17316. private renderOpaqueSorted;
  17317. /**
  17318. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17319. * @param subMeshes The submeshes to render
  17320. */
  17321. private renderAlphaTestSorted;
  17322. /**
  17323. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17324. * @param subMeshes The submeshes to render
  17325. */
  17326. private renderTransparentSorted;
  17327. /**
  17328. * Renders the submeshes in a specified order.
  17329. * @param subMeshes The submeshes to sort before render
  17330. * @param sortCompareFn The comparison function use to sort
  17331. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17332. * @param transparent Specifies to activate blending if true
  17333. */
  17334. private static renderSorted;
  17335. /**
  17336. * Renders the submeshes in the order they were dispatched (no sort applied).
  17337. * @param subMeshes The submeshes to render
  17338. */
  17339. private static renderUnsorted;
  17340. /**
  17341. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17342. * are rendered back to front if in the same alpha index.
  17343. *
  17344. * @param a The first submesh
  17345. * @param b The second submesh
  17346. * @returns The result of the comparison
  17347. */
  17348. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17349. /**
  17350. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17351. * are rendered back to front.
  17352. *
  17353. * @param a The first submesh
  17354. * @param b The second submesh
  17355. * @returns The result of the comparison
  17356. */
  17357. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17358. /**
  17359. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17360. * are rendered front to back (prevent overdraw).
  17361. *
  17362. * @param a The first submesh
  17363. * @param b The second submesh
  17364. * @returns The result of the comparison
  17365. */
  17366. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17367. /**
  17368. * Resets the different lists of submeshes to prepare a new frame.
  17369. */
  17370. prepare(): void;
  17371. dispose(): void;
  17372. /**
  17373. * Inserts the submesh in its correct queue depending on its material.
  17374. * @param subMesh The submesh to dispatch
  17375. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17376. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17377. */
  17378. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17379. dispatchSprites(spriteManager: ISpriteManager): void;
  17380. dispatchParticles(particleSystem: IParticleSystem): void;
  17381. private _renderParticles;
  17382. private _renderSprites;
  17383. }
  17384. }
  17385. declare module BABYLON {
  17386. /**
  17387. * Interface describing the different options available in the rendering manager
  17388. * regarding Auto Clear between groups.
  17389. */
  17390. export interface IRenderingManagerAutoClearSetup {
  17391. /**
  17392. * Defines whether or not autoclear is enable.
  17393. */
  17394. autoClear: boolean;
  17395. /**
  17396. * Defines whether or not to autoclear the depth buffer.
  17397. */
  17398. depth: boolean;
  17399. /**
  17400. * Defines whether or not to autoclear the stencil buffer.
  17401. */
  17402. stencil: boolean;
  17403. }
  17404. /**
  17405. * This class is used by the onRenderingGroupObservable
  17406. */
  17407. export class RenderingGroupInfo {
  17408. /**
  17409. * The Scene that being rendered
  17410. */
  17411. scene: Scene;
  17412. /**
  17413. * The camera currently used for the rendering pass
  17414. */
  17415. camera: Nullable<Camera>;
  17416. /**
  17417. * The ID of the renderingGroup being processed
  17418. */
  17419. renderingGroupId: number;
  17420. }
  17421. /**
  17422. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17423. * It is enable to manage the different groups as well as the different necessary sort functions.
  17424. * This should not be used directly aside of the few static configurations
  17425. */
  17426. export class RenderingManager {
  17427. /**
  17428. * The max id used for rendering groups (not included)
  17429. */
  17430. static MAX_RENDERINGGROUPS: number;
  17431. /**
  17432. * The min id used for rendering groups (included)
  17433. */
  17434. static MIN_RENDERINGGROUPS: number;
  17435. /**
  17436. * Used to globally prevent autoclearing scenes.
  17437. */
  17438. static AUTOCLEAR: boolean;
  17439. /**
  17440. * @hidden
  17441. */
  17442. _useSceneAutoClearSetup: boolean;
  17443. private _scene;
  17444. private _renderingGroups;
  17445. private _depthStencilBufferAlreadyCleaned;
  17446. private _autoClearDepthStencil;
  17447. private _customOpaqueSortCompareFn;
  17448. private _customAlphaTestSortCompareFn;
  17449. private _customTransparentSortCompareFn;
  17450. private _renderingGroupInfo;
  17451. /**
  17452. * Instantiates a new rendering group for a particular scene
  17453. * @param scene Defines the scene the groups belongs to
  17454. */
  17455. constructor(scene: Scene);
  17456. private _clearDepthStencilBuffer;
  17457. /**
  17458. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17459. * @hidden
  17460. */
  17461. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17462. /**
  17463. * Resets the different information of the group to prepare a new frame
  17464. * @hidden
  17465. */
  17466. reset(): void;
  17467. /**
  17468. * Dispose and release the group and its associated resources.
  17469. * @hidden
  17470. */
  17471. dispose(): void;
  17472. /**
  17473. * Clear the info related to rendering groups preventing retention points during dispose.
  17474. */
  17475. freeRenderingGroups(): void;
  17476. private _prepareRenderingGroup;
  17477. /**
  17478. * Add a sprite manager to the rendering manager in order to render it this frame.
  17479. * @param spriteManager Define the sprite manager to render
  17480. */
  17481. dispatchSprites(spriteManager: ISpriteManager): void;
  17482. /**
  17483. * Add a particle system to the rendering manager in order to render it this frame.
  17484. * @param particleSystem Define the particle system to render
  17485. */
  17486. dispatchParticles(particleSystem: IParticleSystem): void;
  17487. /**
  17488. * Add a submesh to the manager in order to render it this frame
  17489. * @param subMesh The submesh to dispatch
  17490. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17491. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17492. */
  17493. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17494. /**
  17495. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17496. * This allowed control for front to back rendering or reversly depending of the special needs.
  17497. *
  17498. * @param renderingGroupId The rendering group id corresponding to its index
  17499. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17500. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17501. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17502. */
  17503. 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;
  17504. /**
  17505. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17506. *
  17507. * @param renderingGroupId The rendering group id corresponding to its index
  17508. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17509. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17510. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17511. */
  17512. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17513. /**
  17514. * Gets the current auto clear configuration for one rendering group of the rendering
  17515. * manager.
  17516. * @param index the rendering group index to get the information for
  17517. * @returns The auto clear setup for the requested rendering group
  17518. */
  17519. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17520. }
  17521. }
  17522. declare module BABYLON {
  17523. /**
  17524. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17525. */
  17526. export interface ICustomShaderOptions {
  17527. /**
  17528. * Gets or sets the custom shader name to use
  17529. */
  17530. shaderName: string;
  17531. /**
  17532. * The list of attribute names used in the shader
  17533. */
  17534. attributes?: string[];
  17535. /**
  17536. * The list of unifrom names used in the shader
  17537. */
  17538. uniforms?: string[];
  17539. /**
  17540. * The list of sampler names used in the shader
  17541. */
  17542. samplers?: string[];
  17543. /**
  17544. * The list of defines used in the shader
  17545. */
  17546. defines?: string[];
  17547. }
  17548. /**
  17549. * Interface to implement to create a shadow generator compatible with BJS.
  17550. */
  17551. export interface IShadowGenerator {
  17552. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17553. id: string;
  17554. /**
  17555. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17556. * @returns The render target texture if present otherwise, null
  17557. */
  17558. getShadowMap(): Nullable<RenderTargetTexture>;
  17559. /**
  17560. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17561. * @param subMesh The submesh we want to render in the shadow map
  17562. * @param useInstances Defines wether will draw in the map using instances
  17563. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17564. * @returns true if ready otherwise, false
  17565. */
  17566. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17567. /**
  17568. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17569. * @param defines Defines of the material we want to update
  17570. * @param lightIndex Index of the light in the enabled light list of the material
  17571. */
  17572. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17573. /**
  17574. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17575. * defined in the generator but impacting the effect).
  17576. * It implies the unifroms available on the materials are the standard BJS ones.
  17577. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17578. * @param effect The effect we are binfing the information for
  17579. */
  17580. bindShadowLight(lightIndex: string, effect: Effect): void;
  17581. /**
  17582. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17583. * (eq to shadow prjection matrix * light transform matrix)
  17584. * @returns The transform matrix used to create the shadow map
  17585. */
  17586. getTransformMatrix(): Matrix;
  17587. /**
  17588. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17589. * Cube and 2D textures for instance.
  17590. */
  17591. recreateShadowMap(): void;
  17592. /**
  17593. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17594. * @param onCompiled Callback triggered at the and of the effects compilation
  17595. * @param options Sets of optional options forcing the compilation with different modes
  17596. */
  17597. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17598. useInstances: boolean;
  17599. }>): void;
  17600. /**
  17601. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17602. * @param options Sets of optional options forcing the compilation with different modes
  17603. * @returns A promise that resolves when the compilation completes
  17604. */
  17605. forceCompilationAsync(options?: Partial<{
  17606. useInstances: boolean;
  17607. }>): Promise<void>;
  17608. /**
  17609. * Serializes the shadow generator setup to a json object.
  17610. * @returns The serialized JSON object
  17611. */
  17612. serialize(): any;
  17613. /**
  17614. * Disposes the Shadow map and related Textures and effects.
  17615. */
  17616. dispose(): void;
  17617. }
  17618. /**
  17619. * Default implementation IShadowGenerator.
  17620. * This is the main object responsible of generating shadows in the framework.
  17621. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17622. */
  17623. export class ShadowGenerator implements IShadowGenerator {
  17624. /**
  17625. * Name of the shadow generator class
  17626. */
  17627. static CLASSNAME: string;
  17628. /**
  17629. * Shadow generator mode None: no filtering applied.
  17630. */
  17631. static readonly FILTER_NONE: number;
  17632. /**
  17633. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17634. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17635. */
  17636. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17637. /**
  17638. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17639. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17640. */
  17641. static readonly FILTER_POISSONSAMPLING: number;
  17642. /**
  17643. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17644. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17645. */
  17646. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17647. /**
  17648. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17649. * edge artifacts on steep falloff.
  17650. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17651. */
  17652. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17653. /**
  17654. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17655. * edge artifacts on steep falloff.
  17656. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17657. */
  17658. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17659. /**
  17660. * Shadow generator mode PCF: Percentage Closer Filtering
  17661. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17662. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17663. */
  17664. static readonly FILTER_PCF: number;
  17665. /**
  17666. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17667. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17668. * Contact Hardening
  17669. */
  17670. static readonly FILTER_PCSS: number;
  17671. /**
  17672. * Reserved for PCF and PCSS
  17673. * Highest Quality.
  17674. *
  17675. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17676. *
  17677. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17678. */
  17679. static readonly QUALITY_HIGH: number;
  17680. /**
  17681. * Reserved for PCF and PCSS
  17682. * Good tradeoff for quality/perf cross devices
  17683. *
  17684. * Execute PCF on a 3*3 kernel.
  17685. *
  17686. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17687. */
  17688. static readonly QUALITY_MEDIUM: number;
  17689. /**
  17690. * Reserved for PCF and PCSS
  17691. * The lowest quality but the fastest.
  17692. *
  17693. * Execute PCF on a 1*1 kernel.
  17694. *
  17695. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17696. */
  17697. static readonly QUALITY_LOW: number;
  17698. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17699. id: string;
  17700. /** Gets or sets the custom shader name to use */
  17701. customShaderOptions: ICustomShaderOptions;
  17702. /**
  17703. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17704. */
  17705. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17706. /**
  17707. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17708. */
  17709. onAfterShadowMapRenderObservable: Observable<Effect>;
  17710. /**
  17711. * Observable triggered before a mesh is rendered in the shadow map.
  17712. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17713. */
  17714. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17715. /**
  17716. * Observable triggered after a mesh is rendered in the shadow map.
  17717. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17718. */
  17719. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17720. protected _bias: number;
  17721. /**
  17722. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17723. */
  17724. get bias(): number;
  17725. /**
  17726. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17727. */
  17728. set bias(bias: number);
  17729. protected _normalBias: number;
  17730. /**
  17731. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17732. */
  17733. get normalBias(): number;
  17734. /**
  17735. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17736. */
  17737. set normalBias(normalBias: number);
  17738. protected _blurBoxOffset: number;
  17739. /**
  17740. * Gets the blur box offset: offset applied during the blur pass.
  17741. * Only useful if useKernelBlur = false
  17742. */
  17743. get blurBoxOffset(): number;
  17744. /**
  17745. * Sets the blur box offset: offset applied during the blur pass.
  17746. * Only useful if useKernelBlur = false
  17747. */
  17748. set blurBoxOffset(value: number);
  17749. protected _blurScale: number;
  17750. /**
  17751. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17752. * 2 means half of the size.
  17753. */
  17754. get blurScale(): number;
  17755. /**
  17756. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17757. * 2 means half of the size.
  17758. */
  17759. set blurScale(value: number);
  17760. protected _blurKernel: number;
  17761. /**
  17762. * Gets the blur kernel: kernel size of the blur pass.
  17763. * Only useful if useKernelBlur = true
  17764. */
  17765. get blurKernel(): number;
  17766. /**
  17767. * Sets the blur kernel: kernel size of the blur pass.
  17768. * Only useful if useKernelBlur = true
  17769. */
  17770. set blurKernel(value: number);
  17771. protected _useKernelBlur: boolean;
  17772. /**
  17773. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17774. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17775. */
  17776. get useKernelBlur(): boolean;
  17777. /**
  17778. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17779. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17780. */
  17781. set useKernelBlur(value: boolean);
  17782. protected _depthScale: number;
  17783. /**
  17784. * Gets the depth scale used in ESM mode.
  17785. */
  17786. get depthScale(): number;
  17787. /**
  17788. * Sets the depth scale used in ESM mode.
  17789. * This can override the scale stored on the light.
  17790. */
  17791. set depthScale(value: number);
  17792. protected _validateFilter(filter: number): number;
  17793. protected _filter: number;
  17794. /**
  17795. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17796. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17797. */
  17798. get filter(): number;
  17799. /**
  17800. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17801. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17802. */
  17803. set filter(value: number);
  17804. /**
  17805. * Gets if the current filter is set to Poisson Sampling.
  17806. */
  17807. get usePoissonSampling(): boolean;
  17808. /**
  17809. * Sets the current filter to Poisson Sampling.
  17810. */
  17811. set usePoissonSampling(value: boolean);
  17812. /**
  17813. * Gets if the current filter is set to ESM.
  17814. */
  17815. get useExponentialShadowMap(): boolean;
  17816. /**
  17817. * Sets the current filter is to ESM.
  17818. */
  17819. set useExponentialShadowMap(value: boolean);
  17820. /**
  17821. * Gets if the current filter is set to filtered ESM.
  17822. */
  17823. get useBlurExponentialShadowMap(): boolean;
  17824. /**
  17825. * Gets if the current filter is set to filtered ESM.
  17826. */
  17827. set useBlurExponentialShadowMap(value: boolean);
  17828. /**
  17829. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17830. * exponential to prevent steep falloff artifacts).
  17831. */
  17832. get useCloseExponentialShadowMap(): boolean;
  17833. /**
  17834. * Sets the current filter to "close ESM" (using the inverse of the
  17835. * exponential to prevent steep falloff artifacts).
  17836. */
  17837. set useCloseExponentialShadowMap(value: boolean);
  17838. /**
  17839. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17840. * exponential to prevent steep falloff artifacts).
  17841. */
  17842. get useBlurCloseExponentialShadowMap(): boolean;
  17843. /**
  17844. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17845. * exponential to prevent steep falloff artifacts).
  17846. */
  17847. set useBlurCloseExponentialShadowMap(value: boolean);
  17848. /**
  17849. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17850. */
  17851. get usePercentageCloserFiltering(): boolean;
  17852. /**
  17853. * Sets the current filter to "PCF" (percentage closer filtering).
  17854. */
  17855. set usePercentageCloserFiltering(value: boolean);
  17856. protected _filteringQuality: number;
  17857. /**
  17858. * Gets the PCF or PCSS Quality.
  17859. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17860. */
  17861. get filteringQuality(): number;
  17862. /**
  17863. * Sets the PCF or PCSS Quality.
  17864. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17865. */
  17866. set filteringQuality(filteringQuality: number);
  17867. /**
  17868. * Gets if the current filter is set to "PCSS" (contact hardening).
  17869. */
  17870. get useContactHardeningShadow(): boolean;
  17871. /**
  17872. * Sets the current filter to "PCSS" (contact hardening).
  17873. */
  17874. set useContactHardeningShadow(value: boolean);
  17875. protected _contactHardeningLightSizeUVRatio: number;
  17876. /**
  17877. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17878. * Using a ratio helps keeping shape stability independently of the map size.
  17879. *
  17880. * It does not account for the light projection as it was having too much
  17881. * instability during the light setup or during light position changes.
  17882. *
  17883. * Only valid if useContactHardeningShadow is true.
  17884. */
  17885. get contactHardeningLightSizeUVRatio(): number;
  17886. /**
  17887. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17888. * Using a ratio helps keeping shape stability independently of the map size.
  17889. *
  17890. * It does not account for the light projection as it was having too much
  17891. * instability during the light setup or during light position changes.
  17892. *
  17893. * Only valid if useContactHardeningShadow is true.
  17894. */
  17895. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17896. protected _darkness: number;
  17897. /** Gets or sets the actual darkness of a shadow */
  17898. get darkness(): number;
  17899. set darkness(value: number);
  17900. /**
  17901. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17902. * 0 means strongest and 1 would means no shadow.
  17903. * @returns the darkness.
  17904. */
  17905. getDarkness(): number;
  17906. /**
  17907. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17908. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17909. * @returns the shadow generator allowing fluent coding.
  17910. */
  17911. setDarkness(darkness: number): ShadowGenerator;
  17912. protected _transparencyShadow: boolean;
  17913. /** Gets or sets the ability to have transparent shadow */
  17914. get transparencyShadow(): boolean;
  17915. set transparencyShadow(value: boolean);
  17916. /**
  17917. * Sets the ability to have transparent shadow (boolean).
  17918. * @param transparent True if transparent else False
  17919. * @returns the shadow generator allowing fluent coding
  17920. */
  17921. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17922. /**
  17923. * Enables or disables shadows with varying strength based on the transparency
  17924. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17925. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17926. * mesh.visibility * alphaTexture.a
  17927. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17928. */
  17929. enableSoftTransparentShadow: boolean;
  17930. protected _shadowMap: Nullable<RenderTargetTexture>;
  17931. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17932. /**
  17933. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17934. * @returns The render target texture if present otherwise, null
  17935. */
  17936. getShadowMap(): Nullable<RenderTargetTexture>;
  17937. /**
  17938. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17939. * @returns The render target texture if the shadow map is present otherwise, null
  17940. */
  17941. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17942. /**
  17943. * Gets the class name of that object
  17944. * @returns "ShadowGenerator"
  17945. */
  17946. getClassName(): string;
  17947. /**
  17948. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17949. * @param mesh Mesh to add
  17950. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17951. * @returns the Shadow Generator itself
  17952. */
  17953. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17954. /**
  17955. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17956. * @param mesh Mesh to remove
  17957. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17958. * @returns the Shadow Generator itself
  17959. */
  17960. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17961. /**
  17962. * Controls the extent to which the shadows fade out at the edge of the frustum
  17963. */
  17964. frustumEdgeFalloff: number;
  17965. protected _light: IShadowLight;
  17966. /**
  17967. * Returns the associated light object.
  17968. * @returns the light generating the shadow
  17969. */
  17970. getLight(): IShadowLight;
  17971. /**
  17972. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17973. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17974. * It might on the other hand introduce peter panning.
  17975. */
  17976. forceBackFacesOnly: boolean;
  17977. protected _scene: Scene;
  17978. protected _lightDirection: Vector3;
  17979. protected _effect: Effect;
  17980. protected _viewMatrix: Matrix;
  17981. protected _projectionMatrix: Matrix;
  17982. protected _transformMatrix: Matrix;
  17983. protected _cachedPosition: Vector3;
  17984. protected _cachedDirection: Vector3;
  17985. protected _cachedDefines: string;
  17986. protected _currentRenderID: number;
  17987. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17988. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17989. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17990. protected _blurPostProcesses: PostProcess[];
  17991. protected _mapSize: number;
  17992. protected _currentFaceIndex: number;
  17993. protected _currentFaceIndexCache: number;
  17994. protected _textureType: number;
  17995. protected _defaultTextureMatrix: Matrix;
  17996. protected _storedUniqueId: Nullable<number>;
  17997. /** @hidden */
  17998. static _SceneComponentInitialization: (scene: Scene) => void;
  17999. /**
  18000. * Gets or sets the size of the texture what stores the shadows
  18001. */
  18002. get mapSize(): number;
  18003. set mapSize(size: number);
  18004. /**
  18005. * Creates a ShadowGenerator object.
  18006. * A ShadowGenerator is the required tool to use the shadows.
  18007. * Each light casting shadows needs to use its own ShadowGenerator.
  18008. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18009. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18010. * @param light The light object generating the shadows.
  18011. * @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.
  18012. */
  18013. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18014. protected _initializeGenerator(): void;
  18015. protected _createTargetRenderTexture(): void;
  18016. protected _initializeShadowMap(): void;
  18017. protected _initializeBlurRTTAndPostProcesses(): void;
  18018. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18019. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18020. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18021. protected _applyFilterValues(): void;
  18022. /**
  18023. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18024. * @param onCompiled Callback triggered at the and of the effects compilation
  18025. * @param options Sets of optional options forcing the compilation with different modes
  18026. */
  18027. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18028. useInstances: boolean;
  18029. }>): void;
  18030. /**
  18031. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18032. * @param options Sets of optional options forcing the compilation with different modes
  18033. * @returns A promise that resolves when the compilation completes
  18034. */
  18035. forceCompilationAsync(options?: Partial<{
  18036. useInstances: boolean;
  18037. }>): Promise<void>;
  18038. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18039. private _prepareShadowDefines;
  18040. /**
  18041. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18042. * @param subMesh The submesh we want to render in the shadow map
  18043. * @param useInstances Defines wether will draw in the map using instances
  18044. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18045. * @returns true if ready otherwise, false
  18046. */
  18047. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18048. /**
  18049. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18050. * @param defines Defines of the material we want to update
  18051. * @param lightIndex Index of the light in the enabled light list of the material
  18052. */
  18053. prepareDefines(defines: any, lightIndex: number): void;
  18054. /**
  18055. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18056. * defined in the generator but impacting the effect).
  18057. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18058. * @param effect The effect we are binfing the information for
  18059. */
  18060. bindShadowLight(lightIndex: string, effect: Effect): void;
  18061. /**
  18062. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18063. * (eq to shadow prjection matrix * light transform matrix)
  18064. * @returns The transform matrix used to create the shadow map
  18065. */
  18066. getTransformMatrix(): Matrix;
  18067. /**
  18068. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18069. * Cube and 2D textures for instance.
  18070. */
  18071. recreateShadowMap(): void;
  18072. protected _disposeBlurPostProcesses(): void;
  18073. protected _disposeRTTandPostProcesses(): void;
  18074. /**
  18075. * Disposes the ShadowGenerator.
  18076. * Returns nothing.
  18077. */
  18078. dispose(): void;
  18079. /**
  18080. * Serializes the shadow generator setup to a json object.
  18081. * @returns The serialized JSON object
  18082. */
  18083. serialize(): any;
  18084. /**
  18085. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18086. * @param parsedShadowGenerator The JSON object to parse
  18087. * @param scene The scene to create the shadow map for
  18088. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18089. * @returns The parsed shadow generator
  18090. */
  18091. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18092. }
  18093. }
  18094. declare module BABYLON {
  18095. /**
  18096. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18097. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18098. * 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.
  18099. */
  18100. export abstract class Light extends Node {
  18101. /**
  18102. * Falloff Default: light is falling off following the material specification:
  18103. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18104. */
  18105. static readonly FALLOFF_DEFAULT: number;
  18106. /**
  18107. * Falloff Physical: light is falling off following the inverse squared distance law.
  18108. */
  18109. static readonly FALLOFF_PHYSICAL: number;
  18110. /**
  18111. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18112. * to enhance interoperability with other engines.
  18113. */
  18114. static readonly FALLOFF_GLTF: number;
  18115. /**
  18116. * Falloff Standard: light is falling off like in the standard material
  18117. * to enhance interoperability with other materials.
  18118. */
  18119. static readonly FALLOFF_STANDARD: number;
  18120. /**
  18121. * If every light affecting the material is in this lightmapMode,
  18122. * material.lightmapTexture adds or multiplies
  18123. * (depends on material.useLightmapAsShadowmap)
  18124. * after every other light calculations.
  18125. */
  18126. static readonly LIGHTMAP_DEFAULT: number;
  18127. /**
  18128. * material.lightmapTexture as only diffuse lighting from this light
  18129. * adds only specular lighting from this light
  18130. * adds dynamic shadows
  18131. */
  18132. static readonly LIGHTMAP_SPECULAR: number;
  18133. /**
  18134. * material.lightmapTexture as only lighting
  18135. * no light calculation from this light
  18136. * only adds dynamic shadows from this light
  18137. */
  18138. static readonly LIGHTMAP_SHADOWSONLY: number;
  18139. /**
  18140. * Each light type uses the default quantity according to its type:
  18141. * point/spot lights use luminous intensity
  18142. * directional lights use illuminance
  18143. */
  18144. static readonly INTENSITYMODE_AUTOMATIC: number;
  18145. /**
  18146. * lumen (lm)
  18147. */
  18148. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18149. /**
  18150. * candela (lm/sr)
  18151. */
  18152. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18153. /**
  18154. * lux (lm/m^2)
  18155. */
  18156. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18157. /**
  18158. * nit (cd/m^2)
  18159. */
  18160. static readonly INTENSITYMODE_LUMINANCE: number;
  18161. /**
  18162. * Light type const id of the point light.
  18163. */
  18164. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18165. /**
  18166. * Light type const id of the directional light.
  18167. */
  18168. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18169. /**
  18170. * Light type const id of the spot light.
  18171. */
  18172. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18173. /**
  18174. * Light type const id of the hemispheric light.
  18175. */
  18176. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18177. /**
  18178. * Diffuse gives the basic color to an object.
  18179. */
  18180. diffuse: Color3;
  18181. /**
  18182. * Specular produces a highlight color on an object.
  18183. * Note: This is note affecting PBR materials.
  18184. */
  18185. specular: Color3;
  18186. /**
  18187. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18188. * falling off base on range or angle.
  18189. * This can be set to any values in Light.FALLOFF_x.
  18190. *
  18191. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18192. * other types of materials.
  18193. */
  18194. falloffType: number;
  18195. /**
  18196. * Strength of the light.
  18197. * Note: By default it is define in the framework own unit.
  18198. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18199. */
  18200. intensity: number;
  18201. private _range;
  18202. protected _inverseSquaredRange: number;
  18203. /**
  18204. * Defines how far from the source the light is impacting in scene units.
  18205. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18206. */
  18207. get range(): number;
  18208. /**
  18209. * Defines how far from the source the light is impacting in scene units.
  18210. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18211. */
  18212. set range(value: number);
  18213. /**
  18214. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18215. * of light.
  18216. */
  18217. private _photometricScale;
  18218. private _intensityMode;
  18219. /**
  18220. * Gets the photometric scale used to interpret the intensity.
  18221. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18222. */
  18223. get intensityMode(): number;
  18224. /**
  18225. * Sets the photometric scale used to interpret the intensity.
  18226. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18227. */
  18228. set intensityMode(value: number);
  18229. private _radius;
  18230. /**
  18231. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18232. */
  18233. get radius(): number;
  18234. /**
  18235. * sets the light radius used by PBR Materials to simulate soft area lights.
  18236. */
  18237. set radius(value: number);
  18238. private _renderPriority;
  18239. /**
  18240. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18241. * exceeding the number allowed of the materials.
  18242. */
  18243. renderPriority: number;
  18244. private _shadowEnabled;
  18245. /**
  18246. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18247. * the current shadow generator.
  18248. */
  18249. get shadowEnabled(): boolean;
  18250. /**
  18251. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18252. * the current shadow generator.
  18253. */
  18254. set shadowEnabled(value: boolean);
  18255. private _includedOnlyMeshes;
  18256. /**
  18257. * Gets the only meshes impacted by this light.
  18258. */
  18259. get includedOnlyMeshes(): AbstractMesh[];
  18260. /**
  18261. * Sets the only meshes impacted by this light.
  18262. */
  18263. set includedOnlyMeshes(value: AbstractMesh[]);
  18264. private _excludedMeshes;
  18265. /**
  18266. * Gets the meshes not impacted by this light.
  18267. */
  18268. get excludedMeshes(): AbstractMesh[];
  18269. /**
  18270. * Sets the meshes not impacted by this light.
  18271. */
  18272. set excludedMeshes(value: AbstractMesh[]);
  18273. private _excludeWithLayerMask;
  18274. /**
  18275. * Gets the layer id use to find what meshes are not impacted by the light.
  18276. * Inactive if 0
  18277. */
  18278. get excludeWithLayerMask(): number;
  18279. /**
  18280. * Sets the layer id use to find what meshes are not impacted by the light.
  18281. * Inactive if 0
  18282. */
  18283. set excludeWithLayerMask(value: number);
  18284. private _includeOnlyWithLayerMask;
  18285. /**
  18286. * Gets the layer id use to find what meshes are impacted by the light.
  18287. * Inactive if 0
  18288. */
  18289. get includeOnlyWithLayerMask(): number;
  18290. /**
  18291. * Sets the layer id use to find what meshes are impacted by the light.
  18292. * Inactive if 0
  18293. */
  18294. set includeOnlyWithLayerMask(value: number);
  18295. private _lightmapMode;
  18296. /**
  18297. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18298. */
  18299. get lightmapMode(): number;
  18300. /**
  18301. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18302. */
  18303. set lightmapMode(value: number);
  18304. /**
  18305. * Shadow generator associted to the light.
  18306. * @hidden Internal use only.
  18307. */
  18308. _shadowGenerator: Nullable<IShadowGenerator>;
  18309. /**
  18310. * @hidden Internal use only.
  18311. */
  18312. _excludedMeshesIds: string[];
  18313. /**
  18314. * @hidden Internal use only.
  18315. */
  18316. _includedOnlyMeshesIds: string[];
  18317. /**
  18318. * The current light unifom buffer.
  18319. * @hidden Internal use only.
  18320. */
  18321. _uniformBuffer: UniformBuffer;
  18322. /** @hidden */
  18323. _renderId: number;
  18324. /**
  18325. * Creates a Light object in the scene.
  18326. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18327. * @param name The firendly name of the light
  18328. * @param scene The scene the light belongs too
  18329. */
  18330. constructor(name: string, scene: Scene);
  18331. protected abstract _buildUniformLayout(): void;
  18332. /**
  18333. * Sets the passed Effect "effect" with the Light information.
  18334. * @param effect The effect to update
  18335. * @param lightIndex The index of the light in the effect to update
  18336. * @returns The light
  18337. */
  18338. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18339. /**
  18340. * Sets the passed Effect "effect" with the Light textures.
  18341. * @param effect The effect to update
  18342. * @param lightIndex The index of the light in the effect to update
  18343. * @returns The light
  18344. */
  18345. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18346. /**
  18347. * Binds the lights information from the scene to the effect for the given mesh.
  18348. * @param lightIndex Light index
  18349. * @param scene The scene where the light belongs to
  18350. * @param effect The effect we are binding the data to
  18351. * @param useSpecular Defines if specular is supported
  18352. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18353. */
  18354. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18355. /**
  18356. * Sets the passed Effect "effect" with the Light information.
  18357. * @param effect The effect to update
  18358. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18359. * @returns The light
  18360. */
  18361. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18362. /**
  18363. * Returns the string "Light".
  18364. * @returns the class name
  18365. */
  18366. getClassName(): string;
  18367. /** @hidden */
  18368. readonly _isLight: boolean;
  18369. /**
  18370. * Converts the light information to a readable string for debug purpose.
  18371. * @param fullDetails Supports for multiple levels of logging within scene loading
  18372. * @returns the human readable light info
  18373. */
  18374. toString(fullDetails?: boolean): string;
  18375. /** @hidden */
  18376. protected _syncParentEnabledState(): void;
  18377. /**
  18378. * Set the enabled state of this node.
  18379. * @param value - the new enabled state
  18380. */
  18381. setEnabled(value: boolean): void;
  18382. /**
  18383. * Returns the Light associated shadow generator if any.
  18384. * @return the associated shadow generator.
  18385. */
  18386. getShadowGenerator(): Nullable<IShadowGenerator>;
  18387. /**
  18388. * Returns a Vector3, the absolute light position in the World.
  18389. * @returns the world space position of the light
  18390. */
  18391. getAbsolutePosition(): Vector3;
  18392. /**
  18393. * Specifies if the light will affect the passed mesh.
  18394. * @param mesh The mesh to test against the light
  18395. * @return true the mesh is affected otherwise, false.
  18396. */
  18397. canAffectMesh(mesh: AbstractMesh): boolean;
  18398. /**
  18399. * Sort function to order lights for rendering.
  18400. * @param a First Light object to compare to second.
  18401. * @param b Second Light object to compare first.
  18402. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18403. */
  18404. static CompareLightsPriority(a: Light, b: Light): number;
  18405. /**
  18406. * Releases resources associated with this node.
  18407. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18408. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18409. */
  18410. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18411. /**
  18412. * Returns the light type ID (integer).
  18413. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18414. */
  18415. getTypeID(): number;
  18416. /**
  18417. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18418. * @returns the scaled intensity in intensity mode unit
  18419. */
  18420. getScaledIntensity(): number;
  18421. /**
  18422. * Returns a new Light object, named "name", from the current one.
  18423. * @param name The name of the cloned light
  18424. * @param newParent The parent of this light, if it has one
  18425. * @returns the new created light
  18426. */
  18427. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18428. /**
  18429. * Serializes the current light into a Serialization object.
  18430. * @returns the serialized object.
  18431. */
  18432. serialize(): any;
  18433. /**
  18434. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18435. * This new light is named "name" and added to the passed scene.
  18436. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18437. * @param name The friendly name of the light
  18438. * @param scene The scene the new light will belong to
  18439. * @returns the constructor function
  18440. */
  18441. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18442. /**
  18443. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18444. * @param parsedLight The JSON representation of the light
  18445. * @param scene The scene to create the parsed light in
  18446. * @returns the created light after parsing
  18447. */
  18448. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18449. private _hookArrayForExcluded;
  18450. private _hookArrayForIncludedOnly;
  18451. private _resyncMeshes;
  18452. /**
  18453. * Forces the meshes to update their light related information in their rendering used effects
  18454. * @hidden Internal Use Only
  18455. */
  18456. _markMeshesAsLightDirty(): void;
  18457. /**
  18458. * Recomputes the cached photometric scale if needed.
  18459. */
  18460. private _computePhotometricScale;
  18461. /**
  18462. * Returns the Photometric Scale according to the light type and intensity mode.
  18463. */
  18464. private _getPhotometricScale;
  18465. /**
  18466. * Reorder the light in the scene according to their defined priority.
  18467. * @hidden Internal Use Only
  18468. */
  18469. _reorderLightsInScene(): void;
  18470. /**
  18471. * Prepares the list of defines specific to the light type.
  18472. * @param defines the list of defines
  18473. * @param lightIndex defines the index of the light for the effect
  18474. */
  18475. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18476. }
  18477. }
  18478. declare module BABYLON {
  18479. /**
  18480. * Configuration needed for prepass-capable materials
  18481. */
  18482. export class PrePassConfiguration {
  18483. /**
  18484. * Previous world matrices of meshes carrying this material
  18485. * Used for computing velocity
  18486. */
  18487. previousWorldMatrices: {
  18488. [index: number]: Matrix;
  18489. };
  18490. /**
  18491. * Previous view project matrix
  18492. * Used for computing velocity
  18493. */
  18494. previousViewProjection: Matrix;
  18495. /**
  18496. * Previous bones of meshes carrying this material
  18497. * Used for computing velocity
  18498. */
  18499. previousBones: {
  18500. [index: number]: Float32Array;
  18501. };
  18502. /**
  18503. * Add the required uniforms to the current list.
  18504. * @param uniforms defines the current uniform list.
  18505. */
  18506. static AddUniforms(uniforms: string[]): void;
  18507. /**
  18508. * Add the required samplers to the current list.
  18509. * @param samplers defines the current sampler list.
  18510. */
  18511. static AddSamplers(samplers: string[]): void;
  18512. /**
  18513. * Binds the material data.
  18514. * @param effect defines the effect to update
  18515. * @param scene defines the scene the material belongs to.
  18516. * @param mesh The mesh
  18517. * @param world World matrix of this mesh
  18518. * @param isFrozen Is the material frozen
  18519. */
  18520. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  18521. }
  18522. }
  18523. declare module BABYLON {
  18524. /**
  18525. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18526. * This is the base of the follow, arc rotate cameras and Free camera
  18527. * @see https://doc.babylonjs.com/features/cameras
  18528. */
  18529. export class TargetCamera extends Camera {
  18530. private static _RigCamTransformMatrix;
  18531. private static _TargetTransformMatrix;
  18532. private static _TargetFocalPoint;
  18533. private _tmpUpVector;
  18534. private _tmpTargetVector;
  18535. /**
  18536. * Define the current direction the camera is moving to
  18537. */
  18538. cameraDirection: Vector3;
  18539. /**
  18540. * Define the current rotation the camera is rotating to
  18541. */
  18542. cameraRotation: Vector2;
  18543. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18544. ignoreParentScaling: boolean;
  18545. /**
  18546. * When set, the up vector of the camera will be updated by the rotation of the camera
  18547. */
  18548. updateUpVectorFromRotation: boolean;
  18549. private _tmpQuaternion;
  18550. /**
  18551. * Define the current rotation of the camera
  18552. */
  18553. rotation: Vector3;
  18554. /**
  18555. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18556. */
  18557. rotationQuaternion: Quaternion;
  18558. /**
  18559. * Define the current speed of the camera
  18560. */
  18561. speed: number;
  18562. /**
  18563. * Add constraint to the camera to prevent it to move freely in all directions and
  18564. * around all axis.
  18565. */
  18566. noRotationConstraint: boolean;
  18567. /**
  18568. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18569. * panning
  18570. */
  18571. invertRotation: boolean;
  18572. /**
  18573. * Speed multiplier for inverse camera panning
  18574. */
  18575. inverseRotationSpeed: number;
  18576. /**
  18577. * Define the current target of the camera as an object or a position.
  18578. */
  18579. lockedTarget: any;
  18580. /** @hidden */
  18581. _currentTarget: Vector3;
  18582. /** @hidden */
  18583. _initialFocalDistance: number;
  18584. /** @hidden */
  18585. _viewMatrix: Matrix;
  18586. /** @hidden */
  18587. _camMatrix: Matrix;
  18588. /** @hidden */
  18589. _cameraTransformMatrix: Matrix;
  18590. /** @hidden */
  18591. _cameraRotationMatrix: Matrix;
  18592. /** @hidden */
  18593. _referencePoint: Vector3;
  18594. /** @hidden */
  18595. _transformedReferencePoint: Vector3;
  18596. /** @hidden */
  18597. _reset: () => void;
  18598. private _defaultUp;
  18599. /**
  18600. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18601. * This is the base of the follow, arc rotate cameras and Free camera
  18602. * @see https://doc.babylonjs.com/features/cameras
  18603. * @param name Defines the name of the camera in the scene
  18604. * @param position Defines the start position of the camera in the scene
  18605. * @param scene Defines the scene the camera belongs to
  18606. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18607. */
  18608. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18609. /**
  18610. * Gets the position in front of the camera at a given distance.
  18611. * @param distance The distance from the camera we want the position to be
  18612. * @returns the position
  18613. */
  18614. getFrontPosition(distance: number): Vector3;
  18615. /** @hidden */
  18616. _getLockedTargetPosition(): Nullable<Vector3>;
  18617. private _storedPosition;
  18618. private _storedRotation;
  18619. private _storedRotationQuaternion;
  18620. /**
  18621. * Store current camera state of the camera (fov, position, rotation, etc..)
  18622. * @returns the camera
  18623. */
  18624. storeState(): Camera;
  18625. /**
  18626. * Restored camera state. You must call storeState() first
  18627. * @returns whether it was successful or not
  18628. * @hidden
  18629. */
  18630. _restoreStateValues(): boolean;
  18631. /** @hidden */
  18632. _initCache(): void;
  18633. /** @hidden */
  18634. _updateCache(ignoreParentClass?: boolean): void;
  18635. /** @hidden */
  18636. _isSynchronizedViewMatrix(): boolean;
  18637. /** @hidden */
  18638. _computeLocalCameraSpeed(): number;
  18639. /**
  18640. * Defines the target the camera should look at.
  18641. * @param target Defines the new target as a Vector or a mesh
  18642. */
  18643. setTarget(target: Vector3): void;
  18644. /**
  18645. * Defines the target point of the camera.
  18646. * The camera looks towards it form the radius distance.
  18647. */
  18648. get target(): Vector3;
  18649. set target(value: Vector3);
  18650. /**
  18651. * Return the current target position of the camera. This value is expressed in local space.
  18652. * @returns the target position
  18653. */
  18654. getTarget(): Vector3;
  18655. /** @hidden */
  18656. _decideIfNeedsToMove(): boolean;
  18657. /** @hidden */
  18658. _updatePosition(): void;
  18659. /** @hidden */
  18660. _checkInputs(): void;
  18661. protected _updateCameraRotationMatrix(): void;
  18662. /**
  18663. * 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)
  18664. * @returns the current camera
  18665. */
  18666. private _rotateUpVectorWithCameraRotationMatrix;
  18667. private _cachedRotationZ;
  18668. private _cachedQuaternionRotationZ;
  18669. /** @hidden */
  18670. _getViewMatrix(): Matrix;
  18671. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18672. /**
  18673. * @hidden
  18674. */
  18675. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18676. /**
  18677. * @hidden
  18678. */
  18679. _updateRigCameras(): void;
  18680. private _getRigCamPositionAndTarget;
  18681. /**
  18682. * Gets the current object class name.
  18683. * @return the class name
  18684. */
  18685. getClassName(): string;
  18686. }
  18687. }
  18688. declare module BABYLON {
  18689. /**
  18690. * Gather the list of keyboard event types as constants.
  18691. */
  18692. export class KeyboardEventTypes {
  18693. /**
  18694. * The keydown event is fired when a key becomes active (pressed).
  18695. */
  18696. static readonly KEYDOWN: number;
  18697. /**
  18698. * The keyup event is fired when a key has been released.
  18699. */
  18700. static readonly KEYUP: number;
  18701. }
  18702. /**
  18703. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18704. */
  18705. export class KeyboardInfo {
  18706. /**
  18707. * Defines the type of event (KeyboardEventTypes)
  18708. */
  18709. type: number;
  18710. /**
  18711. * Defines the related dom event
  18712. */
  18713. event: KeyboardEvent;
  18714. /**
  18715. * Instantiates a new keyboard info.
  18716. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18717. * @param type Defines the type of event (KeyboardEventTypes)
  18718. * @param event Defines the related dom event
  18719. */
  18720. constructor(
  18721. /**
  18722. * Defines the type of event (KeyboardEventTypes)
  18723. */
  18724. type: number,
  18725. /**
  18726. * Defines the related dom event
  18727. */
  18728. event: KeyboardEvent);
  18729. }
  18730. /**
  18731. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18732. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18733. */
  18734. export class KeyboardInfoPre extends KeyboardInfo {
  18735. /**
  18736. * Defines the type of event (KeyboardEventTypes)
  18737. */
  18738. type: number;
  18739. /**
  18740. * Defines the related dom event
  18741. */
  18742. event: KeyboardEvent;
  18743. /**
  18744. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18745. */
  18746. skipOnPointerObservable: boolean;
  18747. /**
  18748. * Instantiates a new keyboard pre info.
  18749. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18750. * @param type Defines the type of event (KeyboardEventTypes)
  18751. * @param event Defines the related dom event
  18752. */
  18753. constructor(
  18754. /**
  18755. * Defines the type of event (KeyboardEventTypes)
  18756. */
  18757. type: number,
  18758. /**
  18759. * Defines the related dom event
  18760. */
  18761. event: KeyboardEvent);
  18762. }
  18763. }
  18764. declare module BABYLON {
  18765. /**
  18766. * Manage the keyboard inputs to control the movement of a free camera.
  18767. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18768. */
  18769. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18770. /**
  18771. * Defines the camera the input is attached to.
  18772. */
  18773. camera: FreeCamera;
  18774. /**
  18775. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18776. */
  18777. keysUp: number[];
  18778. /**
  18779. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18780. */
  18781. keysUpward: number[];
  18782. /**
  18783. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18784. */
  18785. keysDown: number[];
  18786. /**
  18787. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18788. */
  18789. keysDownward: number[];
  18790. /**
  18791. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18792. */
  18793. keysLeft: number[];
  18794. /**
  18795. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18796. */
  18797. keysRight: number[];
  18798. private _keys;
  18799. private _onCanvasBlurObserver;
  18800. private _onKeyboardObserver;
  18801. private _engine;
  18802. private _scene;
  18803. /**
  18804. * Attach the input controls to a specific dom element to get the input from.
  18805. * @param element Defines the element the controls should be listened from
  18806. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18807. */
  18808. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18809. /**
  18810. * Detach the current controls from the specified dom element.
  18811. * @param element Defines the element to stop listening the inputs from
  18812. */
  18813. detachControl(element: Nullable<HTMLElement>): void;
  18814. /**
  18815. * Update the current camera state depending on the inputs that have been used this frame.
  18816. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18817. */
  18818. checkInputs(): void;
  18819. /**
  18820. * Gets the class name of the current intput.
  18821. * @returns the class name
  18822. */
  18823. getClassName(): string;
  18824. /** @hidden */
  18825. _onLostFocus(): void;
  18826. /**
  18827. * Get the friendly name associated with the input class.
  18828. * @returns the input friendly name
  18829. */
  18830. getSimpleName(): string;
  18831. }
  18832. }
  18833. declare module BABYLON {
  18834. /**
  18835. * Gather the list of pointer event types as constants.
  18836. */
  18837. export class PointerEventTypes {
  18838. /**
  18839. * 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.
  18840. */
  18841. static readonly POINTERDOWN: number;
  18842. /**
  18843. * The pointerup event is fired when a pointer is no longer active.
  18844. */
  18845. static readonly POINTERUP: number;
  18846. /**
  18847. * The pointermove event is fired when a pointer changes coordinates.
  18848. */
  18849. static readonly POINTERMOVE: number;
  18850. /**
  18851. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18852. */
  18853. static readonly POINTERWHEEL: number;
  18854. /**
  18855. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18856. */
  18857. static readonly POINTERPICK: number;
  18858. /**
  18859. * The pointertap event is fired when a the object has been touched and released without drag.
  18860. */
  18861. static readonly POINTERTAP: number;
  18862. /**
  18863. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18864. */
  18865. static readonly POINTERDOUBLETAP: number;
  18866. }
  18867. /**
  18868. * Base class of pointer info types.
  18869. */
  18870. export class PointerInfoBase {
  18871. /**
  18872. * Defines the type of event (PointerEventTypes)
  18873. */
  18874. type: number;
  18875. /**
  18876. * Defines the related dom event
  18877. */
  18878. event: PointerEvent | MouseWheelEvent;
  18879. /**
  18880. * Instantiates the base class of pointers info.
  18881. * @param type Defines the type of event (PointerEventTypes)
  18882. * @param event Defines the related dom event
  18883. */
  18884. constructor(
  18885. /**
  18886. * Defines the type of event (PointerEventTypes)
  18887. */
  18888. type: number,
  18889. /**
  18890. * Defines the related dom event
  18891. */
  18892. event: PointerEvent | MouseWheelEvent);
  18893. }
  18894. /**
  18895. * This class is used to store pointer related info for the onPrePointerObservable event.
  18896. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18897. */
  18898. export class PointerInfoPre extends PointerInfoBase {
  18899. /**
  18900. * Ray from a pointer if availible (eg. 6dof controller)
  18901. */
  18902. ray: Nullable<Ray>;
  18903. /**
  18904. * Defines the local position of the pointer on the canvas.
  18905. */
  18906. localPosition: Vector2;
  18907. /**
  18908. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18909. */
  18910. skipOnPointerObservable: boolean;
  18911. /**
  18912. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18913. * @param type Defines the type of event (PointerEventTypes)
  18914. * @param event Defines the related dom event
  18915. * @param localX Defines the local x coordinates of the pointer when the event occured
  18916. * @param localY Defines the local y coordinates of the pointer when the event occured
  18917. */
  18918. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18919. }
  18920. /**
  18921. * This type contains all the data related to a pointer event in Babylon.js.
  18922. * 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.
  18923. */
  18924. export class PointerInfo extends PointerInfoBase {
  18925. /**
  18926. * Defines the picking info associated to the info (if any)\
  18927. */
  18928. pickInfo: Nullable<PickingInfo>;
  18929. /**
  18930. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18931. * @param type Defines the type of event (PointerEventTypes)
  18932. * @param event Defines the related dom event
  18933. * @param pickInfo Defines the picking info associated to the info (if any)\
  18934. */
  18935. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18936. /**
  18937. * Defines the picking info associated to the info (if any)\
  18938. */
  18939. pickInfo: Nullable<PickingInfo>);
  18940. }
  18941. /**
  18942. * Data relating to a touch event on the screen.
  18943. */
  18944. export interface PointerTouch {
  18945. /**
  18946. * X coordinate of touch.
  18947. */
  18948. x: number;
  18949. /**
  18950. * Y coordinate of touch.
  18951. */
  18952. y: number;
  18953. /**
  18954. * Id of touch. Unique for each finger.
  18955. */
  18956. pointerId: number;
  18957. /**
  18958. * Event type passed from DOM.
  18959. */
  18960. type: any;
  18961. }
  18962. }
  18963. declare module BABYLON {
  18964. /**
  18965. * Manage the mouse inputs to control the movement of a free camera.
  18966. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18967. */
  18968. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18969. /**
  18970. * Define if touch is enabled in the mouse input
  18971. */
  18972. touchEnabled: boolean;
  18973. /**
  18974. * Defines the camera the input is attached to.
  18975. */
  18976. camera: FreeCamera;
  18977. /**
  18978. * Defines the buttons associated with the input to handle camera move.
  18979. */
  18980. buttons: number[];
  18981. /**
  18982. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18983. */
  18984. angularSensibility: number;
  18985. private _pointerInput;
  18986. private _onMouseMove;
  18987. private _observer;
  18988. private previousPosition;
  18989. /**
  18990. * Observable for when a pointer move event occurs containing the move offset
  18991. */
  18992. onPointerMovedObservable: Observable<{
  18993. offsetX: number;
  18994. offsetY: number;
  18995. }>;
  18996. /**
  18997. * @hidden
  18998. * If the camera should be rotated automatically based on pointer movement
  18999. */
  19000. _allowCameraRotation: boolean;
  19001. /**
  19002. * Manage the mouse inputs to control the movement of a free camera.
  19003. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19004. * @param touchEnabled Defines if touch is enabled or not
  19005. */
  19006. constructor(
  19007. /**
  19008. * Define if touch is enabled in the mouse input
  19009. */
  19010. touchEnabled?: boolean);
  19011. /**
  19012. * Attach the input controls to a specific dom element to get the input from.
  19013. * @param element Defines the element the controls should be listened from
  19014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19015. */
  19016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19017. /**
  19018. * Called on JS contextmenu event.
  19019. * Override this method to provide functionality.
  19020. */
  19021. protected onContextMenu(evt: PointerEvent): void;
  19022. /**
  19023. * Detach the current controls from the specified dom element.
  19024. * @param element Defines the element to stop listening the inputs from
  19025. */
  19026. detachControl(element: Nullable<HTMLElement>): void;
  19027. /**
  19028. * Gets the class name of the current intput.
  19029. * @returns the class name
  19030. */
  19031. getClassName(): string;
  19032. /**
  19033. * Get the friendly name associated with the input class.
  19034. * @returns the input friendly name
  19035. */
  19036. getSimpleName(): string;
  19037. }
  19038. }
  19039. declare module BABYLON {
  19040. /**
  19041. * Base class for mouse wheel input..
  19042. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  19043. * for example usage.
  19044. */
  19045. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  19046. /**
  19047. * Defines the camera the input is attached to.
  19048. */
  19049. abstract camera: Camera;
  19050. /**
  19051. * How fast is the camera moves in relation to X axis mouseWheel events.
  19052. * Use negative value to reverse direction.
  19053. */
  19054. wheelPrecisionX: number;
  19055. /**
  19056. * How fast is the camera moves in relation to Y axis mouseWheel events.
  19057. * Use negative value to reverse direction.
  19058. */
  19059. wheelPrecisionY: number;
  19060. /**
  19061. * How fast is the camera moves in relation to Z axis mouseWheel events.
  19062. * Use negative value to reverse direction.
  19063. */
  19064. wheelPrecisionZ: number;
  19065. /**
  19066. * Observable for when a mouse wheel move event occurs.
  19067. */
  19068. onChangedObservable: Observable<{
  19069. wheelDeltaX: number;
  19070. wheelDeltaY: number;
  19071. wheelDeltaZ: number;
  19072. }>;
  19073. private _wheel;
  19074. private _observer;
  19075. /**
  19076. * Attach the input controls to a specific dom element to get the input from.
  19077. * @param element Defines the element the controls should be listened from
  19078. * @param noPreventDefault Defines whether event caught by the controls
  19079. * should call preventdefault().
  19080. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19081. */
  19082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19083. /**
  19084. * Detach the current controls from the specified dom element.
  19085. * @param element Defines the element to stop listening the inputs from
  19086. */
  19087. detachControl(element: Nullable<HTMLElement>): void;
  19088. /**
  19089. * Called for each rendered frame.
  19090. */
  19091. checkInputs(): void;
  19092. /**
  19093. * Gets the class name of the current intput.
  19094. * @returns the class name
  19095. */
  19096. getClassName(): string;
  19097. /**
  19098. * Get the friendly name associated with the input class.
  19099. * @returns the input friendly name
  19100. */
  19101. getSimpleName(): string;
  19102. /**
  19103. * Incremental value of multiple mouse wheel movements of the X axis.
  19104. * Should be zero-ed when read.
  19105. */
  19106. protected _wheelDeltaX: number;
  19107. /**
  19108. * Incremental value of multiple mouse wheel movements of the Y axis.
  19109. * Should be zero-ed when read.
  19110. */
  19111. protected _wheelDeltaY: number;
  19112. /**
  19113. * Incremental value of multiple mouse wheel movements of the Z axis.
  19114. * Should be zero-ed when read.
  19115. */
  19116. protected _wheelDeltaZ: number;
  19117. /**
  19118. * Firefox uses a different scheme to report scroll distances to other
  19119. * browsers. Rather than use complicated methods to calculate the exact
  19120. * multiple we need to apply, let's just cheat and use a constant.
  19121. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  19122. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  19123. */
  19124. private readonly _ffMultiplier;
  19125. /**
  19126. * Different event attributes for wheel data fall into a few set ranges.
  19127. * Some relevant but dated date here:
  19128. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  19129. */
  19130. private readonly _normalize;
  19131. }
  19132. }
  19133. declare module BABYLON {
  19134. /**
  19135. * Manage the mouse wheel inputs to control a free camera.
  19136. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19137. */
  19138. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  19139. /**
  19140. * Defines the camera the input is attached to.
  19141. */
  19142. camera: FreeCamera;
  19143. /**
  19144. * Gets the class name of the current input.
  19145. * @returns the class name
  19146. */
  19147. getClassName(): string;
  19148. /**
  19149. * Set which movement axis (relative to camera's orientation) the mouse
  19150. * wheel's X axis controls.
  19151. * @param axis The axis to be moved. Set null to clear.
  19152. */
  19153. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  19154. /**
  19155. * Get the configured movement axis (relative to camera's orientation) the
  19156. * mouse wheel's X axis controls.
  19157. * @returns The configured axis or null if none.
  19158. */
  19159. get wheelXMoveRelative(): Nullable<Coordinate>;
  19160. /**
  19161. * Set which movement axis (relative to camera's orientation) the mouse
  19162. * wheel's Y axis controls.
  19163. * @param axis The axis to be moved. Set null to clear.
  19164. */
  19165. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  19166. /**
  19167. * Get the configured movement axis (relative to camera's orientation) the
  19168. * mouse wheel's Y axis controls.
  19169. * @returns The configured axis or null if none.
  19170. */
  19171. get wheelYMoveRelative(): Nullable<Coordinate>;
  19172. /**
  19173. * Set which movement axis (relative to camera's orientation) the mouse
  19174. * wheel's Z axis controls.
  19175. * @param axis The axis to be moved. Set null to clear.
  19176. */
  19177. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  19178. /**
  19179. * Get the configured movement axis (relative to camera's orientation) the
  19180. * mouse wheel's Z axis controls.
  19181. * @returns The configured axis or null if none.
  19182. */
  19183. get wheelZMoveRelative(): Nullable<Coordinate>;
  19184. /**
  19185. * Set which rotation axis (relative to camera's orientation) the mouse
  19186. * wheel's X axis controls.
  19187. * @param axis The axis to be moved. Set null to clear.
  19188. */
  19189. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  19190. /**
  19191. * Get the configured rotation axis (relative to camera's orientation) the
  19192. * mouse wheel's X axis controls.
  19193. * @returns The configured axis or null if none.
  19194. */
  19195. get wheelXRotateRelative(): Nullable<Coordinate>;
  19196. /**
  19197. * Set which rotation axis (relative to camera's orientation) the mouse
  19198. * wheel's Y axis controls.
  19199. * @param axis The axis to be moved. Set null to clear.
  19200. */
  19201. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  19202. /**
  19203. * Get the configured rotation axis (relative to camera's orientation) the
  19204. * mouse wheel's Y axis controls.
  19205. * @returns The configured axis or null if none.
  19206. */
  19207. get wheelYRotateRelative(): Nullable<Coordinate>;
  19208. /**
  19209. * Set which rotation axis (relative to camera's orientation) the mouse
  19210. * wheel's Z axis controls.
  19211. * @param axis The axis to be moved. Set null to clear.
  19212. */
  19213. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  19214. /**
  19215. * Get the configured rotation axis (relative to camera's orientation) the
  19216. * mouse wheel's Z axis controls.
  19217. * @returns The configured axis or null if none.
  19218. */
  19219. get wheelZRotateRelative(): Nullable<Coordinate>;
  19220. /**
  19221. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  19222. * controls.
  19223. * @param axis The axis to be moved. Set null to clear.
  19224. */
  19225. set wheelXMoveScene(axis: Nullable<Coordinate>);
  19226. /**
  19227. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19228. * X axis controls.
  19229. * @returns The configured axis or null if none.
  19230. */
  19231. get wheelXMoveScene(): Nullable<Coordinate>;
  19232. /**
  19233. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  19234. * controls.
  19235. * @param axis The axis to be moved. Set null to clear.
  19236. */
  19237. set wheelYMoveScene(axis: Nullable<Coordinate>);
  19238. /**
  19239. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19240. * Y axis controls.
  19241. * @returns The configured axis or null if none.
  19242. */
  19243. get wheelYMoveScene(): Nullable<Coordinate>;
  19244. /**
  19245. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  19246. * controls.
  19247. * @param axis The axis to be moved. Set null to clear.
  19248. */
  19249. set wheelZMoveScene(axis: Nullable<Coordinate>);
  19250. /**
  19251. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19252. * Z axis controls.
  19253. * @returns The configured axis or null if none.
  19254. */
  19255. get wheelZMoveScene(): Nullable<Coordinate>;
  19256. /**
  19257. * Called for each rendered frame.
  19258. */
  19259. checkInputs(): void;
  19260. private _moveRelative;
  19261. private _rotateRelative;
  19262. private _moveScene;
  19263. /**
  19264. * These are set to the desired default behaviour.
  19265. */
  19266. private _wheelXAction;
  19267. private _wheelXActionCoordinate;
  19268. private _wheelYAction;
  19269. private _wheelYActionCoordinate;
  19270. private _wheelZAction;
  19271. private _wheelZActionCoordinate;
  19272. /**
  19273. * Update the camera according to any configured properties for the 3
  19274. * mouse-wheel axis.
  19275. */
  19276. private _updateCamera;
  19277. }
  19278. }
  19279. declare module BABYLON {
  19280. /**
  19281. * Manage the touch inputs to control the movement of a free camera.
  19282. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19283. */
  19284. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19285. /**
  19286. * Define if mouse events can be treated as touch events
  19287. */
  19288. allowMouse: boolean;
  19289. /**
  19290. * Defines the camera the input is attached to.
  19291. */
  19292. camera: FreeCamera;
  19293. /**
  19294. * Defines the touch sensibility for rotation.
  19295. * The higher the faster.
  19296. */
  19297. touchAngularSensibility: number;
  19298. /**
  19299. * Defines the touch sensibility for move.
  19300. * The higher the faster.
  19301. */
  19302. touchMoveSensibility: number;
  19303. private _offsetX;
  19304. private _offsetY;
  19305. private _pointerPressed;
  19306. private _pointerInput;
  19307. private _observer;
  19308. private _onLostFocus;
  19309. /**
  19310. * Manage the touch inputs to control the movement of a free camera.
  19311. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19312. * @param allowMouse Defines if mouse events can be treated as touch events
  19313. */
  19314. constructor(
  19315. /**
  19316. * Define if mouse events can be treated as touch events
  19317. */
  19318. allowMouse?: boolean);
  19319. /**
  19320. * Attach the input controls to a specific dom element to get the input from.
  19321. * @param element Defines the element the controls should be listened from
  19322. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19323. */
  19324. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19325. /**
  19326. * Detach the current controls from the specified dom element.
  19327. * @param element Defines the element to stop listening the inputs from
  19328. */
  19329. detachControl(element: Nullable<HTMLElement>): void;
  19330. /**
  19331. * Update the current camera state depending on the inputs that have been used this frame.
  19332. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19333. */
  19334. checkInputs(): void;
  19335. /**
  19336. * Gets the class name of the current intput.
  19337. * @returns the class name
  19338. */
  19339. getClassName(): string;
  19340. /**
  19341. * Get the friendly name associated with the input class.
  19342. * @returns the input friendly name
  19343. */
  19344. getSimpleName(): string;
  19345. }
  19346. }
  19347. declare module BABYLON {
  19348. /**
  19349. * Default Inputs manager for the FreeCamera.
  19350. * It groups all the default supported inputs for ease of use.
  19351. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19352. */
  19353. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19354. /**
  19355. * @hidden
  19356. */
  19357. _mouseInput: Nullable<FreeCameraMouseInput>;
  19358. /**
  19359. * @hidden
  19360. */
  19361. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  19362. /**
  19363. * Instantiates a new FreeCameraInputsManager.
  19364. * @param camera Defines the camera the inputs belong to
  19365. */
  19366. constructor(camera: FreeCamera);
  19367. /**
  19368. * Add keyboard input support to the input manager.
  19369. * @returns the current input manager
  19370. */
  19371. addKeyboard(): FreeCameraInputsManager;
  19372. /**
  19373. * Add mouse input support to the input manager.
  19374. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19375. * @returns the current input manager
  19376. */
  19377. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19378. /**
  19379. * Removes the mouse input support from the manager
  19380. * @returns the current input manager
  19381. */
  19382. removeMouse(): FreeCameraInputsManager;
  19383. /**
  19384. * Add mouse wheel input support to the input manager.
  19385. * @returns the current input manager
  19386. */
  19387. addMouseWheel(): FreeCameraInputsManager;
  19388. /**
  19389. * Removes the mouse wheel input support from the manager
  19390. * @returns the current input manager
  19391. */
  19392. removeMouseWheel(): FreeCameraInputsManager;
  19393. /**
  19394. * Add touch input support to the input manager.
  19395. * @returns the current input manager
  19396. */
  19397. addTouch(): FreeCameraInputsManager;
  19398. /**
  19399. * Remove all attached input methods from a camera
  19400. */
  19401. clear(): void;
  19402. }
  19403. }
  19404. declare module BABYLON {
  19405. /**
  19406. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19407. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19408. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19409. */
  19410. export class FreeCamera extends TargetCamera {
  19411. /**
  19412. * Define the collision ellipsoid of the camera.
  19413. * This is helpful to simulate a camera body like the player body around the camera
  19414. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19415. */
  19416. ellipsoid: Vector3;
  19417. /**
  19418. * Define an offset for the position of the ellipsoid around the camera.
  19419. * This can be helpful to determine the center of the body near the gravity center of the body
  19420. * instead of its head.
  19421. */
  19422. ellipsoidOffset: Vector3;
  19423. /**
  19424. * Enable or disable collisions of the camera with the rest of the scene objects.
  19425. */
  19426. checkCollisions: boolean;
  19427. /**
  19428. * Enable or disable gravity on the camera.
  19429. */
  19430. applyGravity: boolean;
  19431. /**
  19432. * Define the input manager associated to the camera.
  19433. */
  19434. inputs: FreeCameraInputsManager;
  19435. /**
  19436. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19437. * Higher values reduce sensitivity.
  19438. */
  19439. get angularSensibility(): number;
  19440. /**
  19441. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19442. * Higher values reduce sensitivity.
  19443. */
  19444. set angularSensibility(value: number);
  19445. /**
  19446. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19447. */
  19448. get keysUp(): number[];
  19449. set keysUp(value: number[]);
  19450. /**
  19451. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19452. */
  19453. get keysUpward(): number[];
  19454. set keysUpward(value: number[]);
  19455. /**
  19456. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19457. */
  19458. get keysDown(): number[];
  19459. set keysDown(value: number[]);
  19460. /**
  19461. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19462. */
  19463. get keysDownward(): number[];
  19464. set keysDownward(value: number[]);
  19465. /**
  19466. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19467. */
  19468. get keysLeft(): number[];
  19469. set keysLeft(value: number[]);
  19470. /**
  19471. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19472. */
  19473. get keysRight(): number[];
  19474. set keysRight(value: number[]);
  19475. /**
  19476. * Event raised when the camera collide with a mesh in the scene.
  19477. */
  19478. onCollide: (collidedMesh: AbstractMesh) => void;
  19479. private _collider;
  19480. private _needMoveForGravity;
  19481. private _oldPosition;
  19482. private _diffPosition;
  19483. private _newPosition;
  19484. /** @hidden */
  19485. _localDirection: Vector3;
  19486. /** @hidden */
  19487. _transformedDirection: Vector3;
  19488. /**
  19489. * Instantiates a Free Camera.
  19490. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19491. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19492. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19493. * @param name Define the name of the camera in the scene
  19494. * @param position Define the start position of the camera in the scene
  19495. * @param scene Define the scene the camera belongs to
  19496. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19497. */
  19498. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19499. /**
  19500. * Attached controls to the current camera.
  19501. * @param element Defines the element the controls should be listened from
  19502. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19503. */
  19504. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19505. /**
  19506. * Detach the current controls from the camera.
  19507. * The camera will stop reacting to inputs.
  19508. * @param element Defines the element to stop listening the inputs from
  19509. */
  19510. detachControl(element: HTMLElement): void;
  19511. private _collisionMask;
  19512. /**
  19513. * Define a collision mask to limit the list of object the camera can collide with
  19514. */
  19515. get collisionMask(): number;
  19516. set collisionMask(mask: number);
  19517. /** @hidden */
  19518. _collideWithWorld(displacement: Vector3): void;
  19519. private _onCollisionPositionChange;
  19520. /** @hidden */
  19521. _checkInputs(): void;
  19522. /** @hidden */
  19523. _decideIfNeedsToMove(): boolean;
  19524. /** @hidden */
  19525. _updatePosition(): void;
  19526. /**
  19527. * Destroy the camera and release the current resources hold by it.
  19528. */
  19529. dispose(): void;
  19530. /**
  19531. * Gets the current object class name.
  19532. * @return the class name
  19533. */
  19534. getClassName(): string;
  19535. }
  19536. }
  19537. declare module BABYLON {
  19538. /**
  19539. * Represents a gamepad control stick position
  19540. */
  19541. export class StickValues {
  19542. /**
  19543. * The x component of the control stick
  19544. */
  19545. x: number;
  19546. /**
  19547. * The y component of the control stick
  19548. */
  19549. y: number;
  19550. /**
  19551. * Initializes the gamepad x and y control stick values
  19552. * @param x The x component of the gamepad control stick value
  19553. * @param y The y component of the gamepad control stick value
  19554. */
  19555. constructor(
  19556. /**
  19557. * The x component of the control stick
  19558. */
  19559. x: number,
  19560. /**
  19561. * The y component of the control stick
  19562. */
  19563. y: number);
  19564. }
  19565. /**
  19566. * An interface which manages callbacks for gamepad button changes
  19567. */
  19568. export interface GamepadButtonChanges {
  19569. /**
  19570. * Called when a gamepad has been changed
  19571. */
  19572. changed: boolean;
  19573. /**
  19574. * Called when a gamepad press event has been triggered
  19575. */
  19576. pressChanged: boolean;
  19577. /**
  19578. * Called when a touch event has been triggered
  19579. */
  19580. touchChanged: boolean;
  19581. /**
  19582. * Called when a value has changed
  19583. */
  19584. valueChanged: boolean;
  19585. }
  19586. /**
  19587. * Represents a gamepad
  19588. */
  19589. export class Gamepad {
  19590. /**
  19591. * The id of the gamepad
  19592. */
  19593. id: string;
  19594. /**
  19595. * The index of the gamepad
  19596. */
  19597. index: number;
  19598. /**
  19599. * The browser gamepad
  19600. */
  19601. browserGamepad: any;
  19602. /**
  19603. * Specifies what type of gamepad this represents
  19604. */
  19605. type: number;
  19606. private _leftStick;
  19607. private _rightStick;
  19608. /** @hidden */
  19609. _isConnected: boolean;
  19610. private _leftStickAxisX;
  19611. private _leftStickAxisY;
  19612. private _rightStickAxisX;
  19613. private _rightStickAxisY;
  19614. /**
  19615. * Triggered when the left control stick has been changed
  19616. */
  19617. private _onleftstickchanged;
  19618. /**
  19619. * Triggered when the right control stick has been changed
  19620. */
  19621. private _onrightstickchanged;
  19622. /**
  19623. * Represents a gamepad controller
  19624. */
  19625. static GAMEPAD: number;
  19626. /**
  19627. * Represents a generic controller
  19628. */
  19629. static GENERIC: number;
  19630. /**
  19631. * Represents an XBox controller
  19632. */
  19633. static XBOX: number;
  19634. /**
  19635. * Represents a pose-enabled controller
  19636. */
  19637. static POSE_ENABLED: number;
  19638. /**
  19639. * Represents an Dual Shock controller
  19640. */
  19641. static DUALSHOCK: number;
  19642. /**
  19643. * Specifies whether the left control stick should be Y-inverted
  19644. */
  19645. protected _invertLeftStickY: boolean;
  19646. /**
  19647. * Specifies if the gamepad has been connected
  19648. */
  19649. get isConnected(): boolean;
  19650. /**
  19651. * Initializes the gamepad
  19652. * @param id The id of the gamepad
  19653. * @param index The index of the gamepad
  19654. * @param browserGamepad The browser gamepad
  19655. * @param leftStickX The x component of the left joystick
  19656. * @param leftStickY The y component of the left joystick
  19657. * @param rightStickX The x component of the right joystick
  19658. * @param rightStickY The y component of the right joystick
  19659. */
  19660. constructor(
  19661. /**
  19662. * The id of the gamepad
  19663. */
  19664. id: string,
  19665. /**
  19666. * The index of the gamepad
  19667. */
  19668. index: number,
  19669. /**
  19670. * The browser gamepad
  19671. */
  19672. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19673. /**
  19674. * Callback triggered when the left joystick has changed
  19675. * @param callback
  19676. */
  19677. onleftstickchanged(callback: (values: StickValues) => void): void;
  19678. /**
  19679. * Callback triggered when the right joystick has changed
  19680. * @param callback
  19681. */
  19682. onrightstickchanged(callback: (values: StickValues) => void): void;
  19683. /**
  19684. * Gets the left joystick
  19685. */
  19686. get leftStick(): StickValues;
  19687. /**
  19688. * Sets the left joystick values
  19689. */
  19690. set leftStick(newValues: StickValues);
  19691. /**
  19692. * Gets the right joystick
  19693. */
  19694. get rightStick(): StickValues;
  19695. /**
  19696. * Sets the right joystick value
  19697. */
  19698. set rightStick(newValues: StickValues);
  19699. /**
  19700. * Updates the gamepad joystick positions
  19701. */
  19702. update(): void;
  19703. /**
  19704. * Disposes the gamepad
  19705. */
  19706. dispose(): void;
  19707. }
  19708. /**
  19709. * Represents a generic gamepad
  19710. */
  19711. export class GenericPad extends Gamepad {
  19712. private _buttons;
  19713. private _onbuttondown;
  19714. private _onbuttonup;
  19715. /**
  19716. * Observable triggered when a button has been pressed
  19717. */
  19718. onButtonDownObservable: Observable<number>;
  19719. /**
  19720. * Observable triggered when a button has been released
  19721. */
  19722. onButtonUpObservable: Observable<number>;
  19723. /**
  19724. * Callback triggered when a button has been pressed
  19725. * @param callback Called when a button has been pressed
  19726. */
  19727. onbuttondown(callback: (buttonPressed: number) => void): void;
  19728. /**
  19729. * Callback triggered when a button has been released
  19730. * @param callback Called when a button has been released
  19731. */
  19732. onbuttonup(callback: (buttonReleased: number) => void): void;
  19733. /**
  19734. * Initializes the generic gamepad
  19735. * @param id The id of the generic gamepad
  19736. * @param index The index of the generic gamepad
  19737. * @param browserGamepad The browser gamepad
  19738. */
  19739. constructor(id: string, index: number, browserGamepad: any);
  19740. private _setButtonValue;
  19741. /**
  19742. * Updates the generic gamepad
  19743. */
  19744. update(): void;
  19745. /**
  19746. * Disposes the generic gamepad
  19747. */
  19748. dispose(): void;
  19749. }
  19750. }
  19751. declare module BABYLON {
  19752. /**
  19753. * Defines the types of pose enabled controllers that are supported
  19754. */
  19755. export enum PoseEnabledControllerType {
  19756. /**
  19757. * HTC Vive
  19758. */
  19759. VIVE = 0,
  19760. /**
  19761. * Oculus Rift
  19762. */
  19763. OCULUS = 1,
  19764. /**
  19765. * Windows mixed reality
  19766. */
  19767. WINDOWS = 2,
  19768. /**
  19769. * Samsung gear VR
  19770. */
  19771. GEAR_VR = 3,
  19772. /**
  19773. * Google Daydream
  19774. */
  19775. DAYDREAM = 4,
  19776. /**
  19777. * Generic
  19778. */
  19779. GENERIC = 5
  19780. }
  19781. /**
  19782. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19783. */
  19784. export interface MutableGamepadButton {
  19785. /**
  19786. * Value of the button/trigger
  19787. */
  19788. value: number;
  19789. /**
  19790. * If the button/trigger is currently touched
  19791. */
  19792. touched: boolean;
  19793. /**
  19794. * If the button/trigger is currently pressed
  19795. */
  19796. pressed: boolean;
  19797. }
  19798. /**
  19799. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19800. * @hidden
  19801. */
  19802. export interface ExtendedGamepadButton extends GamepadButton {
  19803. /**
  19804. * If the button/trigger is currently pressed
  19805. */
  19806. readonly pressed: boolean;
  19807. /**
  19808. * If the button/trigger is currently touched
  19809. */
  19810. readonly touched: boolean;
  19811. /**
  19812. * Value of the button/trigger
  19813. */
  19814. readonly value: number;
  19815. }
  19816. /** @hidden */
  19817. export interface _GamePadFactory {
  19818. /**
  19819. * Returns whether or not the current gamepad can be created for this type of controller.
  19820. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19821. * @returns true if it can be created, otherwise false
  19822. */
  19823. canCreate(gamepadInfo: any): boolean;
  19824. /**
  19825. * Creates a new instance of the Gamepad.
  19826. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19827. * @returns the new gamepad instance
  19828. */
  19829. create(gamepadInfo: any): Gamepad;
  19830. }
  19831. /**
  19832. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19833. */
  19834. export class PoseEnabledControllerHelper {
  19835. /** @hidden */
  19836. static _ControllerFactories: _GamePadFactory[];
  19837. /** @hidden */
  19838. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19839. /**
  19840. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19841. * @param vrGamepad the gamepad to initialized
  19842. * @returns a vr controller of the type the gamepad identified as
  19843. */
  19844. static InitiateController(vrGamepad: any): Gamepad;
  19845. }
  19846. /**
  19847. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19848. */
  19849. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19850. /**
  19851. * If the controller is used in a webXR session
  19852. */
  19853. isXR: boolean;
  19854. private _deviceRoomPosition;
  19855. private _deviceRoomRotationQuaternion;
  19856. /**
  19857. * The device position in babylon space
  19858. */
  19859. devicePosition: Vector3;
  19860. /**
  19861. * The device rotation in babylon space
  19862. */
  19863. deviceRotationQuaternion: Quaternion;
  19864. /**
  19865. * The scale factor of the device in babylon space
  19866. */
  19867. deviceScaleFactor: number;
  19868. /**
  19869. * (Likely devicePosition should be used instead) The device position in its room space
  19870. */
  19871. position: Vector3;
  19872. /**
  19873. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19874. */
  19875. rotationQuaternion: Quaternion;
  19876. /**
  19877. * The type of controller (Eg. Windows mixed reality)
  19878. */
  19879. controllerType: PoseEnabledControllerType;
  19880. protected _calculatedPosition: Vector3;
  19881. private _calculatedRotation;
  19882. /**
  19883. * The raw pose from the device
  19884. */
  19885. rawPose: DevicePose;
  19886. private _trackPosition;
  19887. private _maxRotationDistFromHeadset;
  19888. private _draggedRoomRotation;
  19889. /**
  19890. * @hidden
  19891. */
  19892. _disableTrackPosition(fixedPosition: Vector3): void;
  19893. /**
  19894. * Internal, the mesh attached to the controller
  19895. * @hidden
  19896. */
  19897. _mesh: Nullable<AbstractMesh>;
  19898. private _poseControlledCamera;
  19899. private _leftHandSystemQuaternion;
  19900. /**
  19901. * Internal, matrix used to convert room space to babylon space
  19902. * @hidden
  19903. */
  19904. _deviceToWorld: Matrix;
  19905. /**
  19906. * Node to be used when casting a ray from the controller
  19907. * @hidden
  19908. */
  19909. _pointingPoseNode: Nullable<TransformNode>;
  19910. /**
  19911. * Name of the child mesh that can be used to cast a ray from the controller
  19912. */
  19913. static readonly POINTING_POSE: string;
  19914. /**
  19915. * Creates a new PoseEnabledController from a gamepad
  19916. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19917. */
  19918. constructor(browserGamepad: any);
  19919. private _workingMatrix;
  19920. /**
  19921. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19922. */
  19923. update(): void;
  19924. /**
  19925. * Updates only the pose device and mesh without doing any button event checking
  19926. */
  19927. protected _updatePoseAndMesh(): void;
  19928. /**
  19929. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19930. * @param poseData raw pose fromthe device
  19931. */
  19932. updateFromDevice(poseData: DevicePose): void;
  19933. /**
  19934. * @hidden
  19935. */
  19936. _meshAttachedObservable: Observable<AbstractMesh>;
  19937. /**
  19938. * Attaches a mesh to the controller
  19939. * @param mesh the mesh to be attached
  19940. */
  19941. attachToMesh(mesh: AbstractMesh): void;
  19942. /**
  19943. * Attaches the controllers mesh to a camera
  19944. * @param camera the camera the mesh should be attached to
  19945. */
  19946. attachToPoseControlledCamera(camera: TargetCamera): void;
  19947. /**
  19948. * Disposes of the controller
  19949. */
  19950. dispose(): void;
  19951. /**
  19952. * The mesh that is attached to the controller
  19953. */
  19954. get mesh(): Nullable<AbstractMesh>;
  19955. /**
  19956. * Gets the ray of the controller in the direction the controller is pointing
  19957. * @param length the length the resulting ray should be
  19958. * @returns a ray in the direction the controller is pointing
  19959. */
  19960. getForwardRay(length?: number): Ray;
  19961. }
  19962. }
  19963. declare module BABYLON {
  19964. /**
  19965. * Defines the WebVRController object that represents controllers tracked in 3D space
  19966. */
  19967. export abstract class WebVRController extends PoseEnabledController {
  19968. /**
  19969. * Internal, the default controller model for the controller
  19970. */
  19971. protected _defaultModel: Nullable<AbstractMesh>;
  19972. /**
  19973. * Fired when the trigger state has changed
  19974. */
  19975. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19976. /**
  19977. * Fired when the main button state has changed
  19978. */
  19979. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19980. /**
  19981. * Fired when the secondary button state has changed
  19982. */
  19983. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19984. /**
  19985. * Fired when the pad state has changed
  19986. */
  19987. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19988. /**
  19989. * Fired when controllers stick values have changed
  19990. */
  19991. onPadValuesChangedObservable: Observable<StickValues>;
  19992. /**
  19993. * Array of button availible on the controller
  19994. */
  19995. protected _buttons: Array<MutableGamepadButton>;
  19996. private _onButtonStateChange;
  19997. /**
  19998. * Fired when a controller button's state has changed
  19999. * @param callback the callback containing the button that was modified
  20000. */
  20001. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20002. /**
  20003. * X and Y axis corresponding to the controllers joystick
  20004. */
  20005. pad: StickValues;
  20006. /**
  20007. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20008. */
  20009. hand: string;
  20010. /**
  20011. * The default controller model for the controller
  20012. */
  20013. get defaultModel(): Nullable<AbstractMesh>;
  20014. /**
  20015. * Creates a new WebVRController from a gamepad
  20016. * @param vrGamepad the gamepad that the WebVRController should be created from
  20017. */
  20018. constructor(vrGamepad: any);
  20019. /**
  20020. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20021. */
  20022. update(): void;
  20023. /**
  20024. * Function to be called when a button is modified
  20025. */
  20026. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20027. /**
  20028. * Loads a mesh and attaches it to the controller
  20029. * @param scene the scene the mesh should be added to
  20030. * @param meshLoaded callback for when the mesh has been loaded
  20031. */
  20032. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20033. private _setButtonValue;
  20034. private _changes;
  20035. private _checkChanges;
  20036. /**
  20037. * Disposes of th webVRCOntroller
  20038. */
  20039. dispose(): void;
  20040. }
  20041. }
  20042. declare module BABYLON {
  20043. /**
  20044. * The HemisphericLight simulates the ambient environment light,
  20045. * so the passed direction is the light reflection direction, not the incoming direction.
  20046. */
  20047. export class HemisphericLight extends Light {
  20048. /**
  20049. * The groundColor is the light in the opposite direction to the one specified during creation.
  20050. * 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.
  20051. */
  20052. groundColor: Color3;
  20053. /**
  20054. * The light reflection direction, not the incoming direction.
  20055. */
  20056. direction: Vector3;
  20057. /**
  20058. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20059. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20060. * The HemisphericLight can't cast shadows.
  20061. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20062. * @param name The friendly name of the light
  20063. * @param direction The direction of the light reflection
  20064. * @param scene The scene the light belongs to
  20065. */
  20066. constructor(name: string, direction: Vector3, scene: Scene);
  20067. protected _buildUniformLayout(): void;
  20068. /**
  20069. * Returns the string "HemisphericLight".
  20070. * @return The class name
  20071. */
  20072. getClassName(): string;
  20073. /**
  20074. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20075. * Returns the updated direction.
  20076. * @param target The target the direction should point to
  20077. * @return The computed direction
  20078. */
  20079. setDirectionToTarget(target: Vector3): Vector3;
  20080. /**
  20081. * Returns the shadow generator associated to the light.
  20082. * @returns Always null for hemispheric lights because it does not support shadows.
  20083. */
  20084. getShadowGenerator(): Nullable<IShadowGenerator>;
  20085. /**
  20086. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20087. * @param effect The effect to update
  20088. * @param lightIndex The index of the light in the effect to update
  20089. * @returns The hemispheric light
  20090. */
  20091. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20092. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20093. /**
  20094. * Computes the world matrix of the node
  20095. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20096. * @param useWasUpdatedFlag defines a reserved property
  20097. * @returns the world matrix
  20098. */
  20099. computeWorldMatrix(): Matrix;
  20100. /**
  20101. * Returns the integer 3.
  20102. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20103. */
  20104. getTypeID(): number;
  20105. /**
  20106. * Prepares the list of defines specific to the light type.
  20107. * @param defines the list of defines
  20108. * @param lightIndex defines the index of the light for the effect
  20109. */
  20110. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20111. }
  20112. }
  20113. declare module BABYLON {
  20114. /** @hidden */
  20115. export var vrMultiviewToSingleviewPixelShader: {
  20116. name: string;
  20117. shader: string;
  20118. };
  20119. }
  20120. declare module BABYLON {
  20121. /**
  20122. * Renders to multiple views with a single draw call
  20123. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20124. */
  20125. export class MultiviewRenderTarget extends RenderTargetTexture {
  20126. /**
  20127. * Creates a multiview render target
  20128. * @param scene scene used with the render target
  20129. * @param size the size of the render target (used for each view)
  20130. */
  20131. constructor(scene: Scene, size?: number | {
  20132. width: number;
  20133. height: number;
  20134. } | {
  20135. ratio: number;
  20136. });
  20137. /**
  20138. * @hidden
  20139. * @param faceIndex the face index, if its a cube texture
  20140. */
  20141. _bindFrameBuffer(faceIndex?: number): void;
  20142. /**
  20143. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20144. * @returns the view count
  20145. */
  20146. getViewCount(): number;
  20147. }
  20148. }
  20149. declare module BABYLON {
  20150. interface Engine {
  20151. /**
  20152. * Creates a new multiview render target
  20153. * @param width defines the width of the texture
  20154. * @param height defines the height of the texture
  20155. * @returns the created multiview texture
  20156. */
  20157. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20158. /**
  20159. * Binds a multiview framebuffer to be drawn to
  20160. * @param multiviewTexture texture to bind
  20161. */
  20162. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20163. }
  20164. interface Camera {
  20165. /**
  20166. * @hidden
  20167. * 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)
  20168. */
  20169. _useMultiviewToSingleView: boolean;
  20170. /**
  20171. * @hidden
  20172. * 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)
  20173. */
  20174. _multiviewTexture: Nullable<RenderTargetTexture>;
  20175. /**
  20176. * @hidden
  20177. * ensures the multiview texture of the camera exists and has the specified width/height
  20178. * @param width height to set on the multiview texture
  20179. * @param height width to set on the multiview texture
  20180. */
  20181. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20182. }
  20183. interface Scene {
  20184. /** @hidden */
  20185. _transformMatrixR: Matrix;
  20186. /** @hidden */
  20187. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20188. /** @hidden */
  20189. _createMultiviewUbo(): void;
  20190. /** @hidden */
  20191. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20192. /** @hidden */
  20193. _renderMultiviewToSingleView(camera: Camera): void;
  20194. }
  20195. }
  20196. declare module BABYLON {
  20197. /**
  20198. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20199. * This will not be used for webXR as it supports displaying texture arrays directly
  20200. */
  20201. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20202. /**
  20203. * Gets a string identifying the name of the class
  20204. * @returns "VRMultiviewToSingleviewPostProcess" string
  20205. */
  20206. getClassName(): string;
  20207. /**
  20208. * Initializes a VRMultiviewToSingleview
  20209. * @param name name of the post process
  20210. * @param camera camera to be applied to
  20211. * @param scaleFactor scaling factor to the size of the output texture
  20212. */
  20213. constructor(name: string, camera: Camera, scaleFactor: number);
  20214. }
  20215. }
  20216. declare module BABYLON {
  20217. /**
  20218. * Interface used to define additional presentation attributes
  20219. */
  20220. export interface IVRPresentationAttributes {
  20221. /**
  20222. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20223. */
  20224. highRefreshRate: boolean;
  20225. /**
  20226. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20227. */
  20228. foveationLevel: number;
  20229. }
  20230. interface Engine {
  20231. /** @hidden */
  20232. _vrDisplay: any;
  20233. /** @hidden */
  20234. _vrSupported: boolean;
  20235. /** @hidden */
  20236. _oldSize: Size;
  20237. /** @hidden */
  20238. _oldHardwareScaleFactor: number;
  20239. /** @hidden */
  20240. _vrExclusivePointerMode: boolean;
  20241. /** @hidden */
  20242. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20243. /** @hidden */
  20244. _onVRDisplayPointerRestricted: () => void;
  20245. /** @hidden */
  20246. _onVRDisplayPointerUnrestricted: () => void;
  20247. /** @hidden */
  20248. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20249. /** @hidden */
  20250. _onVrDisplayDisconnect: Nullable<() => void>;
  20251. /** @hidden */
  20252. _onVrDisplayPresentChange: Nullable<() => void>;
  20253. /**
  20254. * Observable signaled when VR display mode changes
  20255. */
  20256. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20257. /**
  20258. * Observable signaled when VR request present is complete
  20259. */
  20260. onVRRequestPresentComplete: Observable<boolean>;
  20261. /**
  20262. * Observable signaled when VR request present starts
  20263. */
  20264. onVRRequestPresentStart: Observable<Engine>;
  20265. /**
  20266. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20267. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20268. */
  20269. isInVRExclusivePointerMode: boolean;
  20270. /**
  20271. * Gets a boolean indicating if a webVR device was detected
  20272. * @returns true if a webVR device was detected
  20273. */
  20274. isVRDevicePresent(): boolean;
  20275. /**
  20276. * Gets the current webVR device
  20277. * @returns the current webVR device (or null)
  20278. */
  20279. getVRDevice(): any;
  20280. /**
  20281. * Initializes a webVR display and starts listening to display change events
  20282. * The onVRDisplayChangedObservable will be notified upon these changes
  20283. * @returns A promise containing a VRDisplay and if vr is supported
  20284. */
  20285. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20286. /** @hidden */
  20287. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20288. /**
  20289. * Gets or sets the presentation attributes used to configure VR rendering
  20290. */
  20291. vrPresentationAttributes?: IVRPresentationAttributes;
  20292. /**
  20293. * Call this function to switch to webVR mode
  20294. * Will do nothing if webVR is not supported or if there is no webVR device
  20295. * @param options the webvr options provided to the camera. mainly used for multiview
  20296. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20297. */
  20298. enableVR(options: WebVROptions): void;
  20299. /** @hidden */
  20300. _onVRFullScreenTriggered(): void;
  20301. }
  20302. }
  20303. declare module BABYLON {
  20304. /**
  20305. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20306. * IMPORTANT!! The data is right-hand data.
  20307. * @export
  20308. * @interface DevicePose
  20309. */
  20310. export interface DevicePose {
  20311. /**
  20312. * The position of the device, values in array are [x,y,z].
  20313. */
  20314. readonly position: Nullable<Float32Array>;
  20315. /**
  20316. * The linearVelocity of the device, values in array are [x,y,z].
  20317. */
  20318. readonly linearVelocity: Nullable<Float32Array>;
  20319. /**
  20320. * The linearAcceleration of the device, values in array are [x,y,z].
  20321. */
  20322. readonly linearAcceleration: Nullable<Float32Array>;
  20323. /**
  20324. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20325. */
  20326. readonly orientation: Nullable<Float32Array>;
  20327. /**
  20328. * The angularVelocity of the device, values in array are [x,y,z].
  20329. */
  20330. readonly angularVelocity: Nullable<Float32Array>;
  20331. /**
  20332. * The angularAcceleration of the device, values in array are [x,y,z].
  20333. */
  20334. readonly angularAcceleration: Nullable<Float32Array>;
  20335. }
  20336. /**
  20337. * Interface representing a pose controlled object in Babylon.
  20338. * A pose controlled object has both regular pose values as well as pose values
  20339. * from an external device such as a VR head mounted display
  20340. */
  20341. export interface PoseControlled {
  20342. /**
  20343. * The position of the object in babylon space.
  20344. */
  20345. position: Vector3;
  20346. /**
  20347. * The rotation quaternion of the object in babylon space.
  20348. */
  20349. rotationQuaternion: Quaternion;
  20350. /**
  20351. * The position of the device in babylon space.
  20352. */
  20353. devicePosition?: Vector3;
  20354. /**
  20355. * The rotation quaternion of the device in babylon space.
  20356. */
  20357. deviceRotationQuaternion: Quaternion;
  20358. /**
  20359. * The raw pose coming from the device.
  20360. */
  20361. rawPose: Nullable<DevicePose>;
  20362. /**
  20363. * The scale of the device to be used when translating from device space to babylon space.
  20364. */
  20365. deviceScaleFactor: number;
  20366. /**
  20367. * Updates the poseControlled values based on the input device pose.
  20368. * @param poseData the pose data to update the object with
  20369. */
  20370. updateFromDevice(poseData: DevicePose): void;
  20371. }
  20372. /**
  20373. * Set of options to customize the webVRCamera
  20374. */
  20375. export interface WebVROptions {
  20376. /**
  20377. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20378. */
  20379. trackPosition?: boolean;
  20380. /**
  20381. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20382. */
  20383. positionScale?: number;
  20384. /**
  20385. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20386. */
  20387. displayName?: string;
  20388. /**
  20389. * Should the native controller meshes be initialized. (default: true)
  20390. */
  20391. controllerMeshes?: boolean;
  20392. /**
  20393. * Creating a default HemiLight only on controllers. (default: true)
  20394. */
  20395. defaultLightingOnControllers?: boolean;
  20396. /**
  20397. * If you don't want to use the default VR button of the helper. (default: false)
  20398. */
  20399. useCustomVRButton?: boolean;
  20400. /**
  20401. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20402. */
  20403. customVRButton?: HTMLButtonElement;
  20404. /**
  20405. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20406. */
  20407. rayLength?: number;
  20408. /**
  20409. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20410. */
  20411. defaultHeight?: number;
  20412. /**
  20413. * If multiview should be used if availible (default: false)
  20414. */
  20415. useMultiview?: boolean;
  20416. }
  20417. /**
  20418. * This represents a WebVR camera.
  20419. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20420. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20421. */
  20422. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20423. private webVROptions;
  20424. /**
  20425. * @hidden
  20426. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20427. */
  20428. _vrDevice: any;
  20429. /**
  20430. * The rawPose of the vrDevice.
  20431. */
  20432. rawPose: Nullable<DevicePose>;
  20433. private _onVREnabled;
  20434. private _specsVersion;
  20435. private _attached;
  20436. private _frameData;
  20437. protected _descendants: Array<Node>;
  20438. private _deviceRoomPosition;
  20439. /** @hidden */
  20440. _deviceRoomRotationQuaternion: Quaternion;
  20441. private _standingMatrix;
  20442. /**
  20443. * Represents device position in babylon space.
  20444. */
  20445. devicePosition: Vector3;
  20446. /**
  20447. * Represents device rotation in babylon space.
  20448. */
  20449. deviceRotationQuaternion: Quaternion;
  20450. /**
  20451. * The scale of the device to be used when translating from device space to babylon space.
  20452. */
  20453. deviceScaleFactor: number;
  20454. private _deviceToWorld;
  20455. private _worldToDevice;
  20456. /**
  20457. * References to the webVR controllers for the vrDevice.
  20458. */
  20459. controllers: Array<WebVRController>;
  20460. /**
  20461. * Emits an event when a controller is attached.
  20462. */
  20463. onControllersAttachedObservable: Observable<WebVRController[]>;
  20464. /**
  20465. * Emits an event when a controller's mesh has been loaded;
  20466. */
  20467. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20468. /**
  20469. * Emits an event when the HMD's pose has been updated.
  20470. */
  20471. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20472. private _poseSet;
  20473. /**
  20474. * If the rig cameras be used as parent instead of this camera.
  20475. */
  20476. rigParenting: boolean;
  20477. private _lightOnControllers;
  20478. private _defaultHeight?;
  20479. /**
  20480. * Instantiates a WebVRFreeCamera.
  20481. * @param name The name of the WebVRFreeCamera
  20482. * @param position The starting anchor position for the camera
  20483. * @param scene The scene the camera belongs to
  20484. * @param webVROptions a set of customizable options for the webVRCamera
  20485. */
  20486. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20487. /**
  20488. * Gets the device distance from the ground in meters.
  20489. * @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.
  20490. */
  20491. deviceDistanceToRoomGround(): number;
  20492. /**
  20493. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20494. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20495. */
  20496. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20497. /**
  20498. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20499. * @returns A promise with a boolean set to if the standing matrix is supported.
  20500. */
  20501. useStandingMatrixAsync(): Promise<boolean>;
  20502. /**
  20503. * Disposes the camera
  20504. */
  20505. dispose(): void;
  20506. /**
  20507. * Gets a vrController by name.
  20508. * @param name The name of the controller to retreive
  20509. * @returns the controller matching the name specified or null if not found
  20510. */
  20511. getControllerByName(name: string): Nullable<WebVRController>;
  20512. private _leftController;
  20513. /**
  20514. * The controller corresponding to the users left hand.
  20515. */
  20516. get leftController(): Nullable<WebVRController>;
  20517. private _rightController;
  20518. /**
  20519. * The controller corresponding to the users right hand.
  20520. */
  20521. get rightController(): Nullable<WebVRController>;
  20522. /**
  20523. * Casts a ray forward from the vrCamera's gaze.
  20524. * @param length Length of the ray (default: 100)
  20525. * @returns the ray corresponding to the gaze
  20526. */
  20527. getForwardRay(length?: number): Ray;
  20528. /**
  20529. * @hidden
  20530. * Updates the camera based on device's frame data
  20531. */
  20532. _checkInputs(): void;
  20533. /**
  20534. * Updates the poseControlled values based on the input device pose.
  20535. * @param poseData Pose coming from the device
  20536. */
  20537. updateFromDevice(poseData: DevicePose): void;
  20538. private _htmlElementAttached;
  20539. private _detachIfAttached;
  20540. /**
  20541. * WebVR's attach control will start broadcasting frames to the device.
  20542. * Note that in certain browsers (chrome for example) this function must be called
  20543. * within a user-interaction callback. Example:
  20544. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20545. *
  20546. * @param element html element to attach the vrDevice to
  20547. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20548. */
  20549. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20550. /**
  20551. * Detaches the camera from the html element and disables VR
  20552. *
  20553. * @param element html element to detach from
  20554. */
  20555. detachControl(element: HTMLElement): void;
  20556. /**
  20557. * @returns the name of this class
  20558. */
  20559. getClassName(): string;
  20560. /**
  20561. * Calls resetPose on the vrDisplay
  20562. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20563. */
  20564. resetToCurrentRotation(): void;
  20565. /**
  20566. * @hidden
  20567. * Updates the rig cameras (left and right eye)
  20568. */
  20569. _updateRigCameras(): void;
  20570. private _workingVector;
  20571. private _oneVector;
  20572. private _workingMatrix;
  20573. private updateCacheCalled;
  20574. private _correctPositionIfNotTrackPosition;
  20575. /**
  20576. * @hidden
  20577. * Updates the cached values of the camera
  20578. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20579. */
  20580. _updateCache(ignoreParentClass?: boolean): void;
  20581. /**
  20582. * @hidden
  20583. * Get current device position in babylon world
  20584. */
  20585. _computeDevicePosition(): void;
  20586. /**
  20587. * Updates the current device position and rotation in the babylon world
  20588. */
  20589. update(): void;
  20590. /**
  20591. * @hidden
  20592. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20593. * @returns an identity matrix
  20594. */
  20595. _getViewMatrix(): Matrix;
  20596. private _tmpMatrix;
  20597. /**
  20598. * This function is called by the two RIG cameras.
  20599. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20600. * @hidden
  20601. */
  20602. _getWebVRViewMatrix(): Matrix;
  20603. /** @hidden */
  20604. _getWebVRProjectionMatrix(): Matrix;
  20605. private _onGamepadConnectedObserver;
  20606. private _onGamepadDisconnectedObserver;
  20607. private _updateCacheWhenTrackingDisabledObserver;
  20608. /**
  20609. * Initializes the controllers and their meshes
  20610. */
  20611. initControllers(): void;
  20612. }
  20613. }
  20614. declare module BABYLON {
  20615. /**
  20616. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20617. *
  20618. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20619. *
  20620. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20621. */
  20622. export class MaterialHelper {
  20623. /**
  20624. * Bind the current view position to an effect.
  20625. * @param effect The effect to be bound
  20626. * @param scene The scene the eyes position is used from
  20627. * @param variableName name of the shader variable that will hold the eye position
  20628. */
  20629. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20630. /**
  20631. * Helps preparing the defines values about the UVs in used in the effect.
  20632. * UVs are shared as much as we can accross channels in the shaders.
  20633. * @param texture The texture we are preparing the UVs for
  20634. * @param defines The defines to update
  20635. * @param key The channel key "diffuse", "specular"... used in the shader
  20636. */
  20637. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20638. /**
  20639. * Binds a texture matrix value to its corrsponding uniform
  20640. * @param texture The texture to bind the matrix for
  20641. * @param uniformBuffer The uniform buffer receivin the data
  20642. * @param key The channel key "diffuse", "specular"... used in the shader
  20643. */
  20644. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20645. /**
  20646. * Gets the current status of the fog (should it be enabled?)
  20647. * @param mesh defines the mesh to evaluate for fog support
  20648. * @param scene defines the hosting scene
  20649. * @returns true if fog must be enabled
  20650. */
  20651. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20652. /**
  20653. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20654. * @param mesh defines the current mesh
  20655. * @param scene defines the current scene
  20656. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20657. * @param pointsCloud defines if point cloud rendering has to be turned on
  20658. * @param fogEnabled defines if fog has to be turned on
  20659. * @param alphaTest defines if alpha testing has to be turned on
  20660. * @param defines defines the current list of defines
  20661. */
  20662. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20663. /**
  20664. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20665. * @param scene defines the current scene
  20666. * @param engine defines the current engine
  20667. * @param defines specifies the list of active defines
  20668. * @param useInstances defines if instances have to be turned on
  20669. * @param useClipPlane defines if clip plane have to be turned on
  20670. * @param useInstances defines if instances have to be turned on
  20671. * @param useThinInstances defines if thin instances have to be turned on
  20672. */
  20673. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20674. /**
  20675. * Prepares the defines for bones
  20676. * @param mesh The mesh containing the geometry data we will draw
  20677. * @param defines The defines to update
  20678. */
  20679. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20680. /**
  20681. * Prepares the defines for morph targets
  20682. * @param mesh The mesh containing the geometry data we will draw
  20683. * @param defines The defines to update
  20684. */
  20685. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20686. /**
  20687. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20688. * @param mesh The mesh containing the geometry data we will draw
  20689. * @param defines The defines to update
  20690. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20691. * @param useBones Precise whether bones should be used or not (override mesh info)
  20692. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20693. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20694. * @returns false if defines are considered not dirty and have not been checked
  20695. */
  20696. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20697. /**
  20698. * Prepares the defines related to multiview
  20699. * @param scene The scene we are intending to draw
  20700. * @param defines The defines to update
  20701. */
  20702. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20703. /**
  20704. * Prepares the defines related to the prepass
  20705. * @param scene The scene we are intending to draw
  20706. * @param defines The defines to update
  20707. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20708. */
  20709. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20710. /**
  20711. * Prepares the defines related to the light information passed in parameter
  20712. * @param scene The scene we are intending to draw
  20713. * @param mesh The mesh the effect is compiling for
  20714. * @param light The light the effect is compiling for
  20715. * @param lightIndex The index of the light
  20716. * @param defines The defines to update
  20717. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20718. * @param state Defines the current state regarding what is needed (normals, etc...)
  20719. */
  20720. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20721. needNormals: boolean;
  20722. needRebuild: boolean;
  20723. shadowEnabled: boolean;
  20724. specularEnabled: boolean;
  20725. lightmapMode: boolean;
  20726. }): void;
  20727. /**
  20728. * Prepares the defines related to the light information passed in parameter
  20729. * @param scene The scene we are intending to draw
  20730. * @param mesh The mesh the effect is compiling for
  20731. * @param defines The defines to update
  20732. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20733. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20734. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20735. * @returns true if normals will be required for the rest of the effect
  20736. */
  20737. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20738. /**
  20739. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20740. * @param lightIndex defines the light index
  20741. * @param uniformsList The uniform list
  20742. * @param samplersList The sampler list
  20743. * @param projectedLightTexture defines if projected texture must be used
  20744. * @param uniformBuffersList defines an optional list of uniform buffers
  20745. */
  20746. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20747. /**
  20748. * Prepares the uniforms and samplers list to be used in the effect
  20749. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20750. * @param samplersList The sampler list
  20751. * @param defines The defines helping in the list generation
  20752. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20753. */
  20754. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20755. /**
  20756. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20757. * @param defines The defines to update while falling back
  20758. * @param fallbacks The authorized effect fallbacks
  20759. * @param maxSimultaneousLights The maximum number of lights allowed
  20760. * @param rank the current rank of the Effect
  20761. * @returns The newly affected rank
  20762. */
  20763. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20764. private static _TmpMorphInfluencers;
  20765. /**
  20766. * Prepares the list of attributes required for morph targets according to the effect defines.
  20767. * @param attribs The current list of supported attribs
  20768. * @param mesh The mesh to prepare the morph targets attributes for
  20769. * @param influencers The number of influencers
  20770. */
  20771. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20772. /**
  20773. * Prepares the list of attributes required for morph targets according to the effect defines.
  20774. * @param attribs The current list of supported attribs
  20775. * @param mesh The mesh to prepare the morph targets attributes for
  20776. * @param defines The current Defines of the effect
  20777. */
  20778. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20779. /**
  20780. * Prepares the list of attributes required for bones according to the effect defines.
  20781. * @param attribs The current list of supported attribs
  20782. * @param mesh The mesh to prepare the bones attributes for
  20783. * @param defines The current Defines of the effect
  20784. * @param fallbacks The current efffect fallback strategy
  20785. */
  20786. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20787. /**
  20788. * Check and prepare the list of attributes required for instances according to the effect defines.
  20789. * @param attribs The current list of supported attribs
  20790. * @param defines The current MaterialDefines of the effect
  20791. */
  20792. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20793. /**
  20794. * Add the list of attributes required for instances to the attribs array.
  20795. * @param attribs The current list of supported attribs
  20796. */
  20797. static PushAttributesForInstances(attribs: string[]): void;
  20798. /**
  20799. * Binds the light information to the effect.
  20800. * @param light The light containing the generator
  20801. * @param effect The effect we are binding the data to
  20802. * @param lightIndex The light index in the effect used to render
  20803. */
  20804. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20805. /**
  20806. * Binds the lights information from the scene to the effect for the given mesh.
  20807. * @param light Light to bind
  20808. * @param lightIndex Light index
  20809. * @param scene The scene where the light belongs to
  20810. * @param effect The effect we are binding the data to
  20811. * @param useSpecular Defines if specular is supported
  20812. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20813. */
  20814. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20815. /**
  20816. * Binds the lights information from the scene to the effect for the given mesh.
  20817. * @param scene The scene the lights belongs to
  20818. * @param mesh The mesh we are binding the information to render
  20819. * @param effect The effect we are binding the data to
  20820. * @param defines The generated defines for the effect
  20821. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20822. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20823. */
  20824. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20825. private static _tempFogColor;
  20826. /**
  20827. * Binds the fog information from the scene to the effect for the given mesh.
  20828. * @param scene The scene the lights belongs to
  20829. * @param mesh The mesh we are binding the information to render
  20830. * @param effect The effect we are binding the data to
  20831. * @param linearSpace Defines if the fog effect is applied in linear space
  20832. */
  20833. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20834. /**
  20835. * Binds the bones information from the mesh to the effect.
  20836. * @param mesh The mesh we are binding the information to render
  20837. * @param effect The effect we are binding the data to
  20838. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  20839. */
  20840. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  20841. private static _CopyBonesTransformationMatrices;
  20842. /**
  20843. * Binds the morph targets information from the mesh to the effect.
  20844. * @param abstractMesh The mesh we are binding the information to render
  20845. * @param effect The effect we are binding the data to
  20846. */
  20847. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20848. /**
  20849. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20850. * @param defines The generated defines used in the effect
  20851. * @param effect The effect we are binding the data to
  20852. * @param scene The scene we are willing to render with logarithmic scale for
  20853. */
  20854. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20855. /**
  20856. * Binds the clip plane information from the scene to the effect.
  20857. * @param scene The scene the clip plane information are extracted from
  20858. * @param effect The effect we are binding the data to
  20859. */
  20860. static BindClipPlane(effect: Effect, scene: Scene): void;
  20861. }
  20862. }
  20863. declare module BABYLON {
  20864. /**
  20865. * Block used to expose an input value
  20866. */
  20867. export class InputBlock extends NodeMaterialBlock {
  20868. private _mode;
  20869. private _associatedVariableName;
  20870. private _storedValue;
  20871. private _valueCallback;
  20872. private _type;
  20873. private _animationType;
  20874. /** Gets or set a value used to limit the range of float values */
  20875. min: number;
  20876. /** Gets or set a value used to limit the range of float values */
  20877. max: number;
  20878. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20879. isBoolean: boolean;
  20880. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20881. matrixMode: number;
  20882. /** @hidden */
  20883. _systemValue: Nullable<NodeMaterialSystemValues>;
  20884. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20885. isConstant: boolean;
  20886. /** Gets or sets the group to use to display this block in the Inspector */
  20887. groupInInspector: string;
  20888. /** Gets an observable raised when the value is changed */
  20889. onValueChangedObservable: Observable<InputBlock>;
  20890. /**
  20891. * Gets or sets the connection point type (default is float)
  20892. */
  20893. get type(): NodeMaterialBlockConnectionPointTypes;
  20894. /**
  20895. * Creates a new InputBlock
  20896. * @param name defines the block name
  20897. * @param target defines the target of that block (Vertex by default)
  20898. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20899. */
  20900. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20901. /**
  20902. * Validates if a name is a reserve word.
  20903. * @param newName the new name to be given to the node.
  20904. * @returns false if the name is a reserve word, else true.
  20905. */
  20906. validateBlockName(newName: string): boolean;
  20907. /**
  20908. * Gets the output component
  20909. */
  20910. get output(): NodeMaterialConnectionPoint;
  20911. /**
  20912. * Set the source of this connection point to a vertex attribute
  20913. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20914. * @returns the current connection point
  20915. */
  20916. setAsAttribute(attributeName?: string): InputBlock;
  20917. /**
  20918. * Set the source of this connection point to a system value
  20919. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20920. * @returns the current connection point
  20921. */
  20922. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20923. /**
  20924. * Gets or sets the value of that point.
  20925. * Please note that this value will be ignored if valueCallback is defined
  20926. */
  20927. get value(): any;
  20928. set value(value: any);
  20929. /**
  20930. * Gets or sets a callback used to get the value of that point.
  20931. * Please note that setting this value will force the connection point to ignore the value property
  20932. */
  20933. get valueCallback(): () => any;
  20934. set valueCallback(value: () => any);
  20935. /**
  20936. * Gets or sets the associated variable name in the shader
  20937. */
  20938. get associatedVariableName(): string;
  20939. set associatedVariableName(value: string);
  20940. /** Gets or sets the type of animation applied to the input */
  20941. get animationType(): AnimatedInputBlockTypes;
  20942. set animationType(value: AnimatedInputBlockTypes);
  20943. /**
  20944. * Gets a boolean indicating that this connection point not defined yet
  20945. */
  20946. get isUndefined(): boolean;
  20947. /**
  20948. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20949. * In this case the connection point name must be the name of the uniform to use.
  20950. * Can only be set on inputs
  20951. */
  20952. get isUniform(): boolean;
  20953. set isUniform(value: boolean);
  20954. /**
  20955. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20956. * In this case the connection point name must be the name of the attribute to use
  20957. * Can only be set on inputs
  20958. */
  20959. get isAttribute(): boolean;
  20960. set isAttribute(value: boolean);
  20961. /**
  20962. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20963. * Can only be set on exit points
  20964. */
  20965. get isVarying(): boolean;
  20966. set isVarying(value: boolean);
  20967. /**
  20968. * Gets a boolean indicating that the current connection point is a system value
  20969. */
  20970. get isSystemValue(): boolean;
  20971. /**
  20972. * Gets or sets the current well known value or null if not defined as a system value
  20973. */
  20974. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20975. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20976. /**
  20977. * Gets the current class name
  20978. * @returns the class name
  20979. */
  20980. getClassName(): string;
  20981. /**
  20982. * Animate the input if animationType !== None
  20983. * @param scene defines the rendering scene
  20984. */
  20985. animate(scene: Scene): void;
  20986. private _emitDefine;
  20987. initialize(state: NodeMaterialBuildState): void;
  20988. /**
  20989. * Set the input block to its default value (based on its type)
  20990. */
  20991. setDefaultValue(): void;
  20992. private _emitConstant;
  20993. /** @hidden */
  20994. get _noContextSwitch(): boolean;
  20995. private _emit;
  20996. /** @hidden */
  20997. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20998. /** @hidden */
  20999. _transmit(effect: Effect, scene: Scene): void;
  21000. protected _buildBlock(state: NodeMaterialBuildState): void;
  21001. protected _dumpPropertiesCode(): string;
  21002. dispose(): void;
  21003. serialize(): any;
  21004. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21005. }
  21006. }
  21007. declare module BABYLON {
  21008. /**
  21009. * Enum used to define the compatibility state between two connection points
  21010. */
  21011. export enum NodeMaterialConnectionPointCompatibilityStates {
  21012. /** Points are compatibles */
  21013. Compatible = 0,
  21014. /** Points are incompatible because of their types */
  21015. TypeIncompatible = 1,
  21016. /** Points are incompatible because of their targets (vertex vs fragment) */
  21017. TargetIncompatible = 2
  21018. }
  21019. /**
  21020. * Defines the direction of a connection point
  21021. */
  21022. export enum NodeMaterialConnectionPointDirection {
  21023. /** Input */
  21024. Input = 0,
  21025. /** Output */
  21026. Output = 1
  21027. }
  21028. /**
  21029. * Defines a connection point for a block
  21030. */
  21031. export class NodeMaterialConnectionPoint {
  21032. /** @hidden */
  21033. _ownerBlock: NodeMaterialBlock;
  21034. /** @hidden */
  21035. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21036. private _endpoints;
  21037. private _associatedVariableName;
  21038. private _direction;
  21039. /** @hidden */
  21040. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21041. /** @hidden */
  21042. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21043. private _type;
  21044. /** @hidden */
  21045. _enforceAssociatedVariableName: boolean;
  21046. /** Gets the direction of the point */
  21047. get direction(): NodeMaterialConnectionPointDirection;
  21048. /** Indicates that this connection point needs dual validation before being connected to another point */
  21049. needDualDirectionValidation: boolean;
  21050. /**
  21051. * Gets or sets the additional types supported by this connection point
  21052. */
  21053. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21054. /**
  21055. * Gets or sets the additional types excluded by this connection point
  21056. */
  21057. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21058. /**
  21059. * Observable triggered when this point is connected
  21060. */
  21061. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21062. /**
  21063. * Gets or sets the associated variable name in the shader
  21064. */
  21065. get associatedVariableName(): string;
  21066. set associatedVariableName(value: string);
  21067. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21068. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21069. /**
  21070. * Gets or sets the connection point type (default is float)
  21071. */
  21072. get type(): NodeMaterialBlockConnectionPointTypes;
  21073. set type(value: NodeMaterialBlockConnectionPointTypes);
  21074. /**
  21075. * Gets or sets the connection point name
  21076. */
  21077. name: string;
  21078. /**
  21079. * Gets or sets the connection point name
  21080. */
  21081. displayName: string;
  21082. /**
  21083. * Gets or sets a boolean indicating that this connection point can be omitted
  21084. */
  21085. isOptional: boolean;
  21086. /**
  21087. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21088. */
  21089. isExposedOnFrame: boolean;
  21090. /**
  21091. * Gets or sets number indicating the position that the port is exposed to on a frame
  21092. */
  21093. exposedPortPosition: number;
  21094. /**
  21095. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21096. */
  21097. define: string;
  21098. /** @hidden */
  21099. _prioritizeVertex: boolean;
  21100. private _target;
  21101. /** Gets or sets the target of that connection point */
  21102. get target(): NodeMaterialBlockTargets;
  21103. set target(value: NodeMaterialBlockTargets);
  21104. /**
  21105. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21106. */
  21107. get isConnected(): boolean;
  21108. /**
  21109. * Gets a boolean indicating that the current point is connected to an input block
  21110. */
  21111. get isConnectedToInputBlock(): boolean;
  21112. /**
  21113. * Gets a the connected input block (if any)
  21114. */
  21115. get connectInputBlock(): Nullable<InputBlock>;
  21116. /** Get the other side of the connection (if any) */
  21117. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21118. /** Get the block that owns this connection point */
  21119. get ownerBlock(): NodeMaterialBlock;
  21120. /** Get the block connected on the other side of this connection (if any) */
  21121. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21122. /** Get the block connected on the endpoints of this connection (if any) */
  21123. get connectedBlocks(): Array<NodeMaterialBlock>;
  21124. /** Gets the list of connected endpoints */
  21125. get endpoints(): NodeMaterialConnectionPoint[];
  21126. /** Gets a boolean indicating if that output point is connected to at least one input */
  21127. get hasEndpoints(): boolean;
  21128. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21129. get isConnectedInVertexShader(): boolean;
  21130. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21131. get isConnectedInFragmentShader(): boolean;
  21132. /**
  21133. * Creates a block suitable to be used as an input for this input point.
  21134. * If null is returned, a block based on the point type will be created.
  21135. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  21136. */
  21137. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21138. /**
  21139. * Creates a new connection point
  21140. * @param name defines the connection point name
  21141. * @param ownerBlock defines the block hosting this connection point
  21142. * @param direction defines the direction of the connection point
  21143. */
  21144. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21145. /**
  21146. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21147. * @returns the class name
  21148. */
  21149. getClassName(): string;
  21150. /**
  21151. * Gets a boolean indicating if the current point can be connected to another point
  21152. * @param connectionPoint defines the other connection point
  21153. * @returns a boolean
  21154. */
  21155. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21156. /**
  21157. * Gets a number indicating if the current point can be connected to another point
  21158. * @param connectionPoint defines the other connection point
  21159. * @returns a number defining the compatibility state
  21160. */
  21161. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21162. /**
  21163. * Connect this point to another connection point
  21164. * @param connectionPoint defines the other connection point
  21165. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21166. * @returns the current connection point
  21167. */
  21168. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21169. /**
  21170. * Disconnect this point from one of his endpoint
  21171. * @param endpoint defines the other connection point
  21172. * @returns the current connection point
  21173. */
  21174. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21175. /**
  21176. * Serializes this point in a JSON representation
  21177. * @param isInput defines if the connection point is an input (default is true)
  21178. * @returns the serialized point object
  21179. */
  21180. serialize(isInput?: boolean): any;
  21181. /**
  21182. * Release resources
  21183. */
  21184. dispose(): void;
  21185. }
  21186. }
  21187. declare module BABYLON {
  21188. /**
  21189. * Enum used to define the material modes
  21190. */
  21191. export enum NodeMaterialModes {
  21192. /** Regular material */
  21193. Material = 0,
  21194. /** For post process */
  21195. PostProcess = 1,
  21196. /** For particle system */
  21197. Particle = 2,
  21198. /** For procedural texture */
  21199. ProceduralTexture = 3
  21200. }
  21201. }
  21202. declare module BABYLON {
  21203. /**
  21204. * Block used to read a texture from a sampler
  21205. */
  21206. export class TextureBlock extends NodeMaterialBlock {
  21207. private _defineName;
  21208. private _linearDefineName;
  21209. private _gammaDefineName;
  21210. private _tempTextureRead;
  21211. private _samplerName;
  21212. private _transformedUVName;
  21213. private _textureTransformName;
  21214. private _textureInfoName;
  21215. private _mainUVName;
  21216. private _mainUVDefineName;
  21217. private _fragmentOnly;
  21218. /**
  21219. * Gets or sets the texture associated with the node
  21220. */
  21221. texture: Nullable<Texture>;
  21222. /**
  21223. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21224. */
  21225. convertToGammaSpace: boolean;
  21226. /**
  21227. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21228. */
  21229. convertToLinearSpace: boolean;
  21230. /**
  21231. * Create a new TextureBlock
  21232. * @param name defines the block name
  21233. */
  21234. constructor(name: string, fragmentOnly?: boolean);
  21235. /**
  21236. * Gets the current class name
  21237. * @returns the class name
  21238. */
  21239. getClassName(): string;
  21240. /**
  21241. * Gets the uv input component
  21242. */
  21243. get uv(): NodeMaterialConnectionPoint;
  21244. /**
  21245. * Gets the rgba output component
  21246. */
  21247. get rgba(): NodeMaterialConnectionPoint;
  21248. /**
  21249. * Gets the rgb output component
  21250. */
  21251. get rgb(): NodeMaterialConnectionPoint;
  21252. /**
  21253. * Gets the r output component
  21254. */
  21255. get r(): NodeMaterialConnectionPoint;
  21256. /**
  21257. * Gets the g output component
  21258. */
  21259. get g(): NodeMaterialConnectionPoint;
  21260. /**
  21261. * Gets the b output component
  21262. */
  21263. get b(): NodeMaterialConnectionPoint;
  21264. /**
  21265. * Gets the a output component
  21266. */
  21267. get a(): NodeMaterialConnectionPoint;
  21268. get target(): NodeMaterialBlockTargets;
  21269. autoConfigure(material: NodeMaterial): void;
  21270. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21271. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21272. isReady(): boolean;
  21273. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21274. private get _isMixed();
  21275. private _injectVertexCode;
  21276. private _writeTextureRead;
  21277. private _writeOutput;
  21278. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21279. protected _dumpPropertiesCode(): string;
  21280. serialize(): any;
  21281. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21282. }
  21283. }
  21284. declare module BABYLON {
  21285. /** @hidden */
  21286. export var reflectionFunction: {
  21287. name: string;
  21288. shader: string;
  21289. };
  21290. }
  21291. declare module BABYLON {
  21292. /**
  21293. * Base block used to read a reflection texture from a sampler
  21294. */
  21295. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21296. /** @hidden */
  21297. _define3DName: string;
  21298. /** @hidden */
  21299. _defineCubicName: string;
  21300. /** @hidden */
  21301. _defineExplicitName: string;
  21302. /** @hidden */
  21303. _defineProjectionName: string;
  21304. /** @hidden */
  21305. _defineLocalCubicName: string;
  21306. /** @hidden */
  21307. _defineSphericalName: string;
  21308. /** @hidden */
  21309. _definePlanarName: string;
  21310. /** @hidden */
  21311. _defineEquirectangularName: string;
  21312. /** @hidden */
  21313. _defineMirroredEquirectangularFixedName: string;
  21314. /** @hidden */
  21315. _defineEquirectangularFixedName: string;
  21316. /** @hidden */
  21317. _defineSkyboxName: string;
  21318. /** @hidden */
  21319. _defineOppositeZ: string;
  21320. /** @hidden */
  21321. _cubeSamplerName: string;
  21322. /** @hidden */
  21323. _2DSamplerName: string;
  21324. protected _positionUVWName: string;
  21325. protected _directionWName: string;
  21326. protected _reflectionVectorName: string;
  21327. /** @hidden */
  21328. _reflectionCoordsName: string;
  21329. /** @hidden */
  21330. _reflectionMatrixName: string;
  21331. protected _reflectionColorName: string;
  21332. /**
  21333. * Gets or sets the texture associated with the node
  21334. */
  21335. texture: Nullable<BaseTexture>;
  21336. /**
  21337. * Create a new ReflectionTextureBaseBlock
  21338. * @param name defines the block name
  21339. */
  21340. constructor(name: string);
  21341. /**
  21342. * Gets the current class name
  21343. * @returns the class name
  21344. */
  21345. getClassName(): string;
  21346. /**
  21347. * Gets the world position input component
  21348. */
  21349. abstract get position(): NodeMaterialConnectionPoint;
  21350. /**
  21351. * Gets the world position input component
  21352. */
  21353. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21354. /**
  21355. * Gets the world normal input component
  21356. */
  21357. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21358. /**
  21359. * Gets the world input component
  21360. */
  21361. abstract get world(): NodeMaterialConnectionPoint;
  21362. /**
  21363. * Gets the camera (or eye) position component
  21364. */
  21365. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21366. /**
  21367. * Gets the view input component
  21368. */
  21369. abstract get view(): NodeMaterialConnectionPoint;
  21370. protected _getTexture(): Nullable<BaseTexture>;
  21371. autoConfigure(material: NodeMaterial): void;
  21372. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21373. isReady(): boolean;
  21374. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21375. /**
  21376. * Gets the code to inject in the vertex shader
  21377. * @param state current state of the node material building
  21378. * @returns the shader code
  21379. */
  21380. handleVertexSide(state: NodeMaterialBuildState): string;
  21381. /**
  21382. * Handles the inits for the fragment code path
  21383. * @param state node material build state
  21384. */
  21385. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21386. /**
  21387. * Generates the reflection coords code for the fragment code path
  21388. * @param worldNormalVarName name of the world normal variable
  21389. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21390. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21391. * @returns the shader code
  21392. */
  21393. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21394. /**
  21395. * Generates the reflection color code for the fragment code path
  21396. * @param lodVarName name of the lod variable
  21397. * @param swizzleLookupTexture swizzle to use for the final color variable
  21398. * @returns the shader code
  21399. */
  21400. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21401. /**
  21402. * Generates the code corresponding to the connected output points
  21403. * @param state node material build state
  21404. * @param varName name of the variable to output
  21405. * @returns the shader code
  21406. */
  21407. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21408. protected _buildBlock(state: NodeMaterialBuildState): this;
  21409. protected _dumpPropertiesCode(): string;
  21410. serialize(): any;
  21411. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21412. }
  21413. }
  21414. declare module BABYLON {
  21415. /**
  21416. * Defines a connection point to be used for points with a custom object type
  21417. */
  21418. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21419. private _blockType;
  21420. private _blockName;
  21421. private _nameForCheking?;
  21422. /**
  21423. * Creates a new connection point
  21424. * @param name defines the connection point name
  21425. * @param ownerBlock defines the block hosting this connection point
  21426. * @param direction defines the direction of the connection point
  21427. */
  21428. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21429. /**
  21430. * Gets a number indicating if the current point can be connected to another point
  21431. * @param connectionPoint defines the other connection point
  21432. * @returns a number defining the compatibility state
  21433. */
  21434. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21435. /**
  21436. * Creates a block suitable to be used as an input for this input point.
  21437. * If null is returned, a block based on the point type will be created.
  21438. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  21439. */
  21440. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21441. }
  21442. }
  21443. declare module BABYLON {
  21444. /**
  21445. * Enum defining the type of properties that can be edited in the property pages in the NME
  21446. */
  21447. export enum PropertyTypeForEdition {
  21448. /** property is a boolean */
  21449. Boolean = 0,
  21450. /** property is a float */
  21451. Float = 1,
  21452. /** property is a Vector2 */
  21453. Vector2 = 2,
  21454. /** property is a list of values */
  21455. List = 3
  21456. }
  21457. /**
  21458. * Interface that defines an option in a variable of type list
  21459. */
  21460. export interface IEditablePropertyListOption {
  21461. /** label of the option */
  21462. "label": string;
  21463. /** value of the option */
  21464. "value": number;
  21465. }
  21466. /**
  21467. * Interface that defines the options available for an editable property
  21468. */
  21469. export interface IEditablePropertyOption {
  21470. /** min value */
  21471. "min"?: number;
  21472. /** max value */
  21473. "max"?: number;
  21474. /** notifiers: indicates which actions to take when the property is changed */
  21475. "notifiers"?: {
  21476. /** the material should be rebuilt */
  21477. "rebuild"?: boolean;
  21478. /** the preview should be updated */
  21479. "update"?: boolean;
  21480. };
  21481. /** list of the options for a variable of type list */
  21482. "options"?: IEditablePropertyListOption[];
  21483. }
  21484. /**
  21485. * Interface that describes an editable property
  21486. */
  21487. export interface IPropertyDescriptionForEdition {
  21488. /** name of the property */
  21489. "propertyName": string;
  21490. /** display name of the property */
  21491. "displayName": string;
  21492. /** type of the property */
  21493. "type": PropertyTypeForEdition;
  21494. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21495. "groupName": string;
  21496. /** options for the property */
  21497. "options": IEditablePropertyOption;
  21498. }
  21499. /**
  21500. * Decorator that flags a property in a node material block as being editable
  21501. */
  21502. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21503. }
  21504. declare module BABYLON {
  21505. /**
  21506. * Block used to implement the refraction part of the sub surface module of the PBR material
  21507. */
  21508. export class RefractionBlock extends NodeMaterialBlock {
  21509. /** @hidden */
  21510. _define3DName: string;
  21511. /** @hidden */
  21512. _refractionMatrixName: string;
  21513. /** @hidden */
  21514. _defineLODRefractionAlpha: string;
  21515. /** @hidden */
  21516. _defineLinearSpecularRefraction: string;
  21517. /** @hidden */
  21518. _defineOppositeZ: string;
  21519. /** @hidden */
  21520. _cubeSamplerName: string;
  21521. /** @hidden */
  21522. _2DSamplerName: string;
  21523. /** @hidden */
  21524. _vRefractionMicrosurfaceInfosName: string;
  21525. /** @hidden */
  21526. _vRefractionInfosName: string;
  21527. private _scene;
  21528. /**
  21529. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21530. * Materials half opaque for instance using refraction could benefit from this control.
  21531. */
  21532. linkRefractionWithTransparency: boolean;
  21533. /**
  21534. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21535. */
  21536. invertRefractionY: boolean;
  21537. /**
  21538. * Gets or sets the texture associated with the node
  21539. */
  21540. texture: Nullable<BaseTexture>;
  21541. /**
  21542. * Create a new RefractionBlock
  21543. * @param name defines the block name
  21544. */
  21545. constructor(name: string);
  21546. /**
  21547. * Gets the current class name
  21548. * @returns the class name
  21549. */
  21550. getClassName(): string;
  21551. /**
  21552. * Gets the intensity input component
  21553. */
  21554. get intensity(): NodeMaterialConnectionPoint;
  21555. /**
  21556. * Gets the index of refraction input component
  21557. */
  21558. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21559. /**
  21560. * Gets the tint at distance input component
  21561. */
  21562. get tintAtDistance(): NodeMaterialConnectionPoint;
  21563. /**
  21564. * Gets the view input component
  21565. */
  21566. get view(): NodeMaterialConnectionPoint;
  21567. /**
  21568. * Gets the refraction object output component
  21569. */
  21570. get refraction(): NodeMaterialConnectionPoint;
  21571. /**
  21572. * Returns true if the block has a texture
  21573. */
  21574. get hasTexture(): boolean;
  21575. protected _getTexture(): Nullable<BaseTexture>;
  21576. autoConfigure(material: NodeMaterial): void;
  21577. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21578. isReady(): boolean;
  21579. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21580. /**
  21581. * Gets the main code of the block (fragment side)
  21582. * @param state current state of the node material building
  21583. * @returns the shader code
  21584. */
  21585. getCode(state: NodeMaterialBuildState): string;
  21586. protected _buildBlock(state: NodeMaterialBuildState): this;
  21587. protected _dumpPropertiesCode(): string;
  21588. serialize(): any;
  21589. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21590. }
  21591. }
  21592. declare module BABYLON {
  21593. /**
  21594. * Base block used as input for post process
  21595. */
  21596. export class CurrentScreenBlock extends NodeMaterialBlock {
  21597. private _samplerName;
  21598. private _linearDefineName;
  21599. private _gammaDefineName;
  21600. private _mainUVName;
  21601. private _tempTextureRead;
  21602. /**
  21603. * Gets or sets the texture associated with the node
  21604. */
  21605. texture: Nullable<BaseTexture>;
  21606. /**
  21607. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21608. */
  21609. convertToGammaSpace: boolean;
  21610. /**
  21611. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21612. */
  21613. convertToLinearSpace: boolean;
  21614. /**
  21615. * Create a new CurrentScreenBlock
  21616. * @param name defines the block name
  21617. */
  21618. constructor(name: string);
  21619. /**
  21620. * Gets the current class name
  21621. * @returns the class name
  21622. */
  21623. getClassName(): string;
  21624. /**
  21625. * Gets the uv input component
  21626. */
  21627. get uv(): NodeMaterialConnectionPoint;
  21628. /**
  21629. * Gets the rgba output component
  21630. */
  21631. get rgba(): NodeMaterialConnectionPoint;
  21632. /**
  21633. * Gets the rgb output component
  21634. */
  21635. get rgb(): NodeMaterialConnectionPoint;
  21636. /**
  21637. * Gets the r output component
  21638. */
  21639. get r(): NodeMaterialConnectionPoint;
  21640. /**
  21641. * Gets the g output component
  21642. */
  21643. get g(): NodeMaterialConnectionPoint;
  21644. /**
  21645. * Gets the b output component
  21646. */
  21647. get b(): NodeMaterialConnectionPoint;
  21648. /**
  21649. * Gets the a output component
  21650. */
  21651. get a(): NodeMaterialConnectionPoint;
  21652. /**
  21653. * Initialize the block and prepare the context for build
  21654. * @param state defines the state that will be used for the build
  21655. */
  21656. initialize(state: NodeMaterialBuildState): void;
  21657. get target(): NodeMaterialBlockTargets;
  21658. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21659. isReady(): boolean;
  21660. private _injectVertexCode;
  21661. private _writeTextureRead;
  21662. private _writeOutput;
  21663. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21664. serialize(): any;
  21665. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21666. }
  21667. }
  21668. declare module BABYLON {
  21669. /**
  21670. * Base block used for the particle texture
  21671. */
  21672. export class ParticleTextureBlock extends NodeMaterialBlock {
  21673. private _samplerName;
  21674. private _linearDefineName;
  21675. private _gammaDefineName;
  21676. private _tempTextureRead;
  21677. /**
  21678. * Gets or sets the texture associated with the node
  21679. */
  21680. texture: Nullable<BaseTexture>;
  21681. /**
  21682. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21683. */
  21684. convertToGammaSpace: boolean;
  21685. /**
  21686. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21687. */
  21688. convertToLinearSpace: boolean;
  21689. /**
  21690. * Create a new ParticleTextureBlock
  21691. * @param name defines the block name
  21692. */
  21693. constructor(name: string);
  21694. /**
  21695. * Gets the current class name
  21696. * @returns the class name
  21697. */
  21698. getClassName(): string;
  21699. /**
  21700. * Gets the uv input component
  21701. */
  21702. get uv(): NodeMaterialConnectionPoint;
  21703. /**
  21704. * Gets the rgba output component
  21705. */
  21706. get rgba(): NodeMaterialConnectionPoint;
  21707. /**
  21708. * Gets the rgb output component
  21709. */
  21710. get rgb(): NodeMaterialConnectionPoint;
  21711. /**
  21712. * Gets the r output component
  21713. */
  21714. get r(): NodeMaterialConnectionPoint;
  21715. /**
  21716. * Gets the g output component
  21717. */
  21718. get g(): NodeMaterialConnectionPoint;
  21719. /**
  21720. * Gets the b output component
  21721. */
  21722. get b(): NodeMaterialConnectionPoint;
  21723. /**
  21724. * Gets the a output component
  21725. */
  21726. get a(): NodeMaterialConnectionPoint;
  21727. /**
  21728. * Initialize the block and prepare the context for build
  21729. * @param state defines the state that will be used for the build
  21730. */
  21731. initialize(state: NodeMaterialBuildState): void;
  21732. autoConfigure(material: NodeMaterial): void;
  21733. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21734. isReady(): boolean;
  21735. private _writeOutput;
  21736. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21737. serialize(): any;
  21738. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21739. }
  21740. }
  21741. declare module BABYLON {
  21742. /**
  21743. * Class used to store shared data between 2 NodeMaterialBuildState
  21744. */
  21745. export class NodeMaterialBuildStateSharedData {
  21746. /**
  21747. * Gets the list of emitted varyings
  21748. */
  21749. temps: string[];
  21750. /**
  21751. * Gets the list of emitted varyings
  21752. */
  21753. varyings: string[];
  21754. /**
  21755. * Gets the varying declaration string
  21756. */
  21757. varyingDeclaration: string;
  21758. /**
  21759. * Input blocks
  21760. */
  21761. inputBlocks: InputBlock[];
  21762. /**
  21763. * Input blocks
  21764. */
  21765. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21766. /**
  21767. * Bindable blocks (Blocks that need to set data to the effect)
  21768. */
  21769. bindableBlocks: NodeMaterialBlock[];
  21770. /**
  21771. * List of blocks that can provide a compilation fallback
  21772. */
  21773. blocksWithFallbacks: NodeMaterialBlock[];
  21774. /**
  21775. * List of blocks that can provide a define update
  21776. */
  21777. blocksWithDefines: NodeMaterialBlock[];
  21778. /**
  21779. * List of blocks that can provide a repeatable content
  21780. */
  21781. repeatableContentBlocks: NodeMaterialBlock[];
  21782. /**
  21783. * List of blocks that can provide a dynamic list of uniforms
  21784. */
  21785. dynamicUniformBlocks: NodeMaterialBlock[];
  21786. /**
  21787. * List of blocks that can block the isReady function for the material
  21788. */
  21789. blockingBlocks: NodeMaterialBlock[];
  21790. /**
  21791. * Gets the list of animated inputs
  21792. */
  21793. animatedInputs: InputBlock[];
  21794. /**
  21795. * Build Id used to avoid multiple recompilations
  21796. */
  21797. buildId: number;
  21798. /** List of emitted variables */
  21799. variableNames: {
  21800. [key: string]: number;
  21801. };
  21802. /** List of emitted defines */
  21803. defineNames: {
  21804. [key: string]: number;
  21805. };
  21806. /** Should emit comments? */
  21807. emitComments: boolean;
  21808. /** Emit build activity */
  21809. verbose: boolean;
  21810. /** Gets or sets the hosting scene */
  21811. scene: Scene;
  21812. /**
  21813. * Gets the compilation hints emitted at compilation time
  21814. */
  21815. hints: {
  21816. needWorldViewMatrix: boolean;
  21817. needWorldViewProjectionMatrix: boolean;
  21818. needAlphaBlending: boolean;
  21819. needAlphaTesting: boolean;
  21820. };
  21821. /**
  21822. * List of compilation checks
  21823. */
  21824. checks: {
  21825. emitVertex: boolean;
  21826. emitFragment: boolean;
  21827. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21828. };
  21829. /**
  21830. * Is vertex program allowed to be empty?
  21831. */
  21832. allowEmptyVertexProgram: boolean;
  21833. /** Creates a new shared data */
  21834. constructor();
  21835. /**
  21836. * Emits console errors and exceptions if there is a failing check
  21837. */
  21838. emitErrors(): void;
  21839. }
  21840. }
  21841. declare module BABYLON {
  21842. /**
  21843. * Class used to store node based material build state
  21844. */
  21845. export class NodeMaterialBuildState {
  21846. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21847. supportUniformBuffers: boolean;
  21848. /**
  21849. * Gets the list of emitted attributes
  21850. */
  21851. attributes: string[];
  21852. /**
  21853. * Gets the list of emitted uniforms
  21854. */
  21855. uniforms: string[];
  21856. /**
  21857. * Gets the list of emitted constants
  21858. */
  21859. constants: string[];
  21860. /**
  21861. * Gets the list of emitted samplers
  21862. */
  21863. samplers: string[];
  21864. /**
  21865. * Gets the list of emitted functions
  21866. */
  21867. functions: {
  21868. [key: string]: string;
  21869. };
  21870. /**
  21871. * Gets the list of emitted extensions
  21872. */
  21873. extensions: {
  21874. [key: string]: string;
  21875. };
  21876. /**
  21877. * Gets the target of the compilation state
  21878. */
  21879. target: NodeMaterialBlockTargets;
  21880. /**
  21881. * Gets the list of emitted counters
  21882. */
  21883. counters: {
  21884. [key: string]: number;
  21885. };
  21886. /**
  21887. * Shared data between multiple NodeMaterialBuildState instances
  21888. */
  21889. sharedData: NodeMaterialBuildStateSharedData;
  21890. /** @hidden */
  21891. _vertexState: NodeMaterialBuildState;
  21892. /** @hidden */
  21893. _attributeDeclaration: string;
  21894. /** @hidden */
  21895. _uniformDeclaration: string;
  21896. /** @hidden */
  21897. _constantDeclaration: string;
  21898. /** @hidden */
  21899. _samplerDeclaration: string;
  21900. /** @hidden */
  21901. _varyingTransfer: string;
  21902. /** @hidden */
  21903. _injectAtEnd: string;
  21904. private _repeatableContentAnchorIndex;
  21905. /** @hidden */
  21906. _builtCompilationString: string;
  21907. /**
  21908. * Gets the emitted compilation strings
  21909. */
  21910. compilationString: string;
  21911. /**
  21912. * Finalize the compilation strings
  21913. * @param state defines the current compilation state
  21914. */
  21915. finalize(state: NodeMaterialBuildState): void;
  21916. /** @hidden */
  21917. get _repeatableContentAnchor(): string;
  21918. /** @hidden */
  21919. _getFreeVariableName(prefix: string): string;
  21920. /** @hidden */
  21921. _getFreeDefineName(prefix: string): string;
  21922. /** @hidden */
  21923. _excludeVariableName(name: string): void;
  21924. /** @hidden */
  21925. _emit2DSampler(name: string): void;
  21926. /** @hidden */
  21927. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21928. /** @hidden */
  21929. _emitExtension(name: string, extension: string, define?: string): void;
  21930. /** @hidden */
  21931. _emitFunction(name: string, code: string, comments: string): void;
  21932. /** @hidden */
  21933. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21934. replaceStrings?: {
  21935. search: RegExp;
  21936. replace: string;
  21937. }[];
  21938. repeatKey?: string;
  21939. }): string;
  21940. /** @hidden */
  21941. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21942. repeatKey?: string;
  21943. removeAttributes?: boolean;
  21944. removeUniforms?: boolean;
  21945. removeVaryings?: boolean;
  21946. removeIfDef?: boolean;
  21947. replaceStrings?: {
  21948. search: RegExp;
  21949. replace: string;
  21950. }[];
  21951. }, storeKey?: string): void;
  21952. /** @hidden */
  21953. _registerTempVariable(name: string): boolean;
  21954. /** @hidden */
  21955. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21956. /** @hidden */
  21957. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21958. /** @hidden */
  21959. _emitFloat(value: number): string;
  21960. }
  21961. }
  21962. declare module BABYLON {
  21963. /**
  21964. * Helper class used to generate session unique ID
  21965. */
  21966. export class UniqueIdGenerator {
  21967. private static _UniqueIdCounter;
  21968. /**
  21969. * Gets an unique (relatively to the current scene) Id
  21970. */
  21971. static get UniqueId(): number;
  21972. }
  21973. }
  21974. declare module BABYLON {
  21975. /**
  21976. * Defines a block that can be used inside a node based material
  21977. */
  21978. export class NodeMaterialBlock {
  21979. private _buildId;
  21980. private _buildTarget;
  21981. private _target;
  21982. private _isFinalMerger;
  21983. private _isInput;
  21984. private _name;
  21985. protected _isUnique: boolean;
  21986. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21987. inputsAreExclusive: boolean;
  21988. /** @hidden */
  21989. _codeVariableName: string;
  21990. /** @hidden */
  21991. _inputs: NodeMaterialConnectionPoint[];
  21992. /** @hidden */
  21993. _outputs: NodeMaterialConnectionPoint[];
  21994. /** @hidden */
  21995. _preparationId: number;
  21996. /**
  21997. * Gets the name of the block
  21998. */
  21999. get name(): string;
  22000. /**
  22001. * Sets the name of the block. Will check if the name is valid.
  22002. */
  22003. set name(newName: string);
  22004. /**
  22005. * Gets or sets the unique id of the node
  22006. */
  22007. uniqueId: number;
  22008. /**
  22009. * Gets or sets the comments associated with this block
  22010. */
  22011. comments: string;
  22012. /**
  22013. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22014. */
  22015. get isUnique(): boolean;
  22016. /**
  22017. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22018. */
  22019. get isFinalMerger(): boolean;
  22020. /**
  22021. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22022. */
  22023. get isInput(): boolean;
  22024. /**
  22025. * Gets or sets the build Id
  22026. */
  22027. get buildId(): number;
  22028. set buildId(value: number);
  22029. /**
  22030. * Gets or sets the target of the block
  22031. */
  22032. get target(): NodeMaterialBlockTargets;
  22033. set target(value: NodeMaterialBlockTargets);
  22034. /**
  22035. * Gets the list of input points
  22036. */
  22037. get inputs(): NodeMaterialConnectionPoint[];
  22038. /** Gets the list of output points */
  22039. get outputs(): NodeMaterialConnectionPoint[];
  22040. /**
  22041. * Find an input by its name
  22042. * @param name defines the name of the input to look for
  22043. * @returns the input or null if not found
  22044. */
  22045. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22046. /**
  22047. * Find an output by its name
  22048. * @param name defines the name of the outputto look for
  22049. * @returns the output or null if not found
  22050. */
  22051. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22052. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22053. visibleInInspector: boolean;
  22054. /**
  22055. * Creates a new NodeMaterialBlock
  22056. * @param name defines the block name
  22057. * @param target defines the target of that block (Vertex by default)
  22058. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22059. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22060. */
  22061. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22062. /**
  22063. * Initialize the block and prepare the context for build
  22064. * @param state defines the state that will be used for the build
  22065. */
  22066. initialize(state: NodeMaterialBuildState): void;
  22067. /**
  22068. * Bind data to effect. Will only be called for blocks with isBindable === true
  22069. * @param effect defines the effect to bind data to
  22070. * @param nodeMaterial defines the hosting NodeMaterial
  22071. * @param mesh defines the mesh that will be rendered
  22072. * @param subMesh defines the submesh that will be rendered
  22073. */
  22074. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22075. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22076. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22077. protected _writeFloat(value: number): string;
  22078. /**
  22079. * Gets the current class name e.g. "NodeMaterialBlock"
  22080. * @returns the class name
  22081. */
  22082. getClassName(): string;
  22083. /**
  22084. * Register a new input. Must be called inside a block constructor
  22085. * @param name defines the connection point name
  22086. * @param type defines the connection point type
  22087. * @param isOptional defines a boolean indicating that this input can be omitted
  22088. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22089. * @param point an already created connection point. If not provided, create a new one
  22090. * @returns the current block
  22091. */
  22092. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22093. /**
  22094. * Register a new output. Must be called inside a block constructor
  22095. * @param name defines the connection point name
  22096. * @param type defines the connection point type
  22097. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22098. * @param point an already created connection point. If not provided, create a new one
  22099. * @returns the current block
  22100. */
  22101. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22102. /**
  22103. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22104. * @param forOutput defines an optional connection point to check compatibility with
  22105. * @returns the first available input or null
  22106. */
  22107. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22108. /**
  22109. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22110. * @param forBlock defines an optional block to check compatibility with
  22111. * @returns the first available input or null
  22112. */
  22113. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22114. /**
  22115. * Gets the sibling of the given output
  22116. * @param current defines the current output
  22117. * @returns the next output in the list or null
  22118. */
  22119. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22120. /**
  22121. * Connect current block with another block
  22122. * @param other defines the block to connect with
  22123. * @param options define the various options to help pick the right connections
  22124. * @returns the current block
  22125. */
  22126. connectTo(other: NodeMaterialBlock, options?: {
  22127. input?: string;
  22128. output?: string;
  22129. outputSwizzle?: string;
  22130. }): this | undefined;
  22131. protected _buildBlock(state: NodeMaterialBuildState): void;
  22132. /**
  22133. * Add uniforms, samplers and uniform buffers at compilation time
  22134. * @param state defines the state to update
  22135. * @param nodeMaterial defines the node material requesting the update
  22136. * @param defines defines the material defines to update
  22137. * @param uniformBuffers defines the list of uniform buffer names
  22138. */
  22139. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22140. /**
  22141. * Add potential fallbacks if shader compilation fails
  22142. * @param mesh defines the mesh to be rendered
  22143. * @param fallbacks defines the current prioritized list of fallbacks
  22144. */
  22145. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22146. /**
  22147. * Initialize defines for shader compilation
  22148. * @param mesh defines the mesh to be rendered
  22149. * @param nodeMaterial defines the node material requesting the update
  22150. * @param defines defines the material defines to update
  22151. * @param useInstances specifies that instances should be used
  22152. */
  22153. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22154. /**
  22155. * Update defines for shader compilation
  22156. * @param mesh defines the mesh to be rendered
  22157. * @param nodeMaterial defines the node material requesting the update
  22158. * @param defines defines the material defines to update
  22159. * @param useInstances specifies that instances should be used
  22160. * @param subMesh defines which submesh to render
  22161. */
  22162. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22163. /**
  22164. * Lets the block try to connect some inputs automatically
  22165. * @param material defines the hosting NodeMaterial
  22166. */
  22167. autoConfigure(material: NodeMaterial): void;
  22168. /**
  22169. * Function called when a block is declared as repeatable content generator
  22170. * @param vertexShaderState defines the current compilation state for the vertex shader
  22171. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22172. * @param mesh defines the mesh to be rendered
  22173. * @param defines defines the material defines to update
  22174. */
  22175. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22176. /**
  22177. * Checks if the block is ready
  22178. * @param mesh defines the mesh to be rendered
  22179. * @param nodeMaterial defines the node material requesting the update
  22180. * @param defines defines the material defines to update
  22181. * @param useInstances specifies that instances should be used
  22182. * @returns true if the block is ready
  22183. */
  22184. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22185. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22186. private _processBuild;
  22187. /**
  22188. * Validates the new name for the block node.
  22189. * @param newName the new name to be given to the node.
  22190. * @returns false if the name is a reserve word, else true.
  22191. */
  22192. validateBlockName(newName: string): boolean;
  22193. /**
  22194. * Compile the current node and generate the shader code
  22195. * @param state defines the current compilation state (uniforms, samplers, current string)
  22196. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22197. * @returns true if already built
  22198. */
  22199. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22200. protected _inputRename(name: string): string;
  22201. protected _outputRename(name: string): string;
  22202. protected _dumpPropertiesCode(): string;
  22203. /** @hidden */
  22204. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22205. /** @hidden */
  22206. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22207. /**
  22208. * Clone the current block to a new identical block
  22209. * @param scene defines the hosting scene
  22210. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22211. * @returns a copy of the current block
  22212. */
  22213. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22214. /**
  22215. * Serializes this block in a JSON representation
  22216. * @returns the serialized block object
  22217. */
  22218. serialize(): any;
  22219. /** @hidden */
  22220. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22221. private _deserializePortDisplayNamesAndExposedOnFrame;
  22222. /**
  22223. * Release resources
  22224. */
  22225. dispose(): void;
  22226. }
  22227. }
  22228. declare module BABYLON {
  22229. /**
  22230. * Base class of materials working in push mode in babylon JS
  22231. * @hidden
  22232. */
  22233. export class PushMaterial extends Material {
  22234. protected _activeEffect: Effect;
  22235. protected _normalMatrix: Matrix;
  22236. constructor(name: string, scene: Scene);
  22237. getEffect(): Effect;
  22238. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22239. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22240. /**
  22241. * Binds the given world matrix to the active effect
  22242. *
  22243. * @param world the matrix to bind
  22244. */
  22245. bindOnlyWorldMatrix(world: Matrix): void;
  22246. /**
  22247. * Binds the given normal matrix to the active effect
  22248. *
  22249. * @param normalMatrix the matrix to bind
  22250. */
  22251. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22252. bind(world: Matrix, mesh?: Mesh): void;
  22253. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22254. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22255. }
  22256. }
  22257. declare module BABYLON {
  22258. /**
  22259. * Root class for all node material optimizers
  22260. */
  22261. export class NodeMaterialOptimizer {
  22262. /**
  22263. * Function used to optimize a NodeMaterial graph
  22264. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22265. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22266. */
  22267. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22268. }
  22269. }
  22270. declare module BABYLON {
  22271. /**
  22272. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22273. */
  22274. export class TransformBlock extends NodeMaterialBlock {
  22275. /**
  22276. * Defines the value to use to complement W value to transform it to a Vector4
  22277. */
  22278. complementW: number;
  22279. /**
  22280. * Defines the value to use to complement z value to transform it to a Vector4
  22281. */
  22282. complementZ: number;
  22283. /**
  22284. * Creates a new TransformBlock
  22285. * @param name defines the block name
  22286. */
  22287. constructor(name: string);
  22288. /**
  22289. * Gets the current class name
  22290. * @returns the class name
  22291. */
  22292. getClassName(): string;
  22293. /**
  22294. * Gets the vector input
  22295. */
  22296. get vector(): NodeMaterialConnectionPoint;
  22297. /**
  22298. * Gets the output component
  22299. */
  22300. get output(): NodeMaterialConnectionPoint;
  22301. /**
  22302. * Gets the xyz output component
  22303. */
  22304. get xyz(): NodeMaterialConnectionPoint;
  22305. /**
  22306. * Gets the matrix transform input
  22307. */
  22308. get transform(): NodeMaterialConnectionPoint;
  22309. protected _buildBlock(state: NodeMaterialBuildState): this;
  22310. /**
  22311. * Update defines for shader compilation
  22312. * @param mesh defines the mesh to be rendered
  22313. * @param nodeMaterial defines the node material requesting the update
  22314. * @param defines defines the material defines to update
  22315. * @param useInstances specifies that instances should be used
  22316. * @param subMesh defines which submesh to render
  22317. */
  22318. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22319. serialize(): any;
  22320. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22321. protected _dumpPropertiesCode(): string;
  22322. }
  22323. }
  22324. declare module BABYLON {
  22325. /**
  22326. * Block used to output the vertex position
  22327. */
  22328. export class VertexOutputBlock extends NodeMaterialBlock {
  22329. /**
  22330. * Creates a new VertexOutputBlock
  22331. * @param name defines the block name
  22332. */
  22333. constructor(name: string);
  22334. /**
  22335. * Gets the current class name
  22336. * @returns the class name
  22337. */
  22338. getClassName(): string;
  22339. /**
  22340. * Gets the vector input component
  22341. */
  22342. get vector(): NodeMaterialConnectionPoint;
  22343. protected _buildBlock(state: NodeMaterialBuildState): this;
  22344. }
  22345. }
  22346. declare module BABYLON {
  22347. /**
  22348. * Block used to output the final color
  22349. */
  22350. export class FragmentOutputBlock extends NodeMaterialBlock {
  22351. /**
  22352. * Create a new FragmentOutputBlock
  22353. * @param name defines the block name
  22354. */
  22355. constructor(name: string);
  22356. /**
  22357. * Gets the current class name
  22358. * @returns the class name
  22359. */
  22360. getClassName(): string;
  22361. /**
  22362. * Gets the rgba input component
  22363. */
  22364. get rgba(): NodeMaterialConnectionPoint;
  22365. /**
  22366. * Gets the rgb input component
  22367. */
  22368. get rgb(): NodeMaterialConnectionPoint;
  22369. /**
  22370. * Gets the a input component
  22371. */
  22372. get a(): NodeMaterialConnectionPoint;
  22373. protected _buildBlock(state: NodeMaterialBuildState): this;
  22374. }
  22375. }
  22376. declare module BABYLON {
  22377. /**
  22378. * Block used for the particle ramp gradient section
  22379. */
  22380. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22381. /**
  22382. * Create a new ParticleRampGradientBlock
  22383. * @param name defines the block name
  22384. */
  22385. constructor(name: string);
  22386. /**
  22387. * Gets the current class name
  22388. * @returns the class name
  22389. */
  22390. getClassName(): string;
  22391. /**
  22392. * Gets the color input component
  22393. */
  22394. get color(): NodeMaterialConnectionPoint;
  22395. /**
  22396. * Gets the rampColor output component
  22397. */
  22398. get rampColor(): NodeMaterialConnectionPoint;
  22399. /**
  22400. * Initialize the block and prepare the context for build
  22401. * @param state defines the state that will be used for the build
  22402. */
  22403. initialize(state: NodeMaterialBuildState): void;
  22404. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22405. }
  22406. }
  22407. declare module BABYLON {
  22408. /**
  22409. * Block used for the particle blend multiply section
  22410. */
  22411. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22412. /**
  22413. * Create a new ParticleBlendMultiplyBlock
  22414. * @param name defines the block name
  22415. */
  22416. constructor(name: string);
  22417. /**
  22418. * Gets the current class name
  22419. * @returns the class name
  22420. */
  22421. getClassName(): string;
  22422. /**
  22423. * Gets the color input component
  22424. */
  22425. get color(): NodeMaterialConnectionPoint;
  22426. /**
  22427. * Gets the alphaTexture input component
  22428. */
  22429. get alphaTexture(): NodeMaterialConnectionPoint;
  22430. /**
  22431. * Gets the alphaColor input component
  22432. */
  22433. get alphaColor(): NodeMaterialConnectionPoint;
  22434. /**
  22435. * Gets the blendColor output component
  22436. */
  22437. get blendColor(): NodeMaterialConnectionPoint;
  22438. /**
  22439. * Initialize the block and prepare the context for build
  22440. * @param state defines the state that will be used for the build
  22441. */
  22442. initialize(state: NodeMaterialBuildState): void;
  22443. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22444. }
  22445. }
  22446. declare module BABYLON {
  22447. /**
  22448. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22449. */
  22450. export class VectorMergerBlock extends NodeMaterialBlock {
  22451. /**
  22452. * Create a new VectorMergerBlock
  22453. * @param name defines the block name
  22454. */
  22455. constructor(name: string);
  22456. /**
  22457. * Gets the current class name
  22458. * @returns the class name
  22459. */
  22460. getClassName(): string;
  22461. /**
  22462. * Gets the xyz component (input)
  22463. */
  22464. get xyzIn(): NodeMaterialConnectionPoint;
  22465. /**
  22466. * Gets the xy component (input)
  22467. */
  22468. get xyIn(): NodeMaterialConnectionPoint;
  22469. /**
  22470. * Gets the x component (input)
  22471. */
  22472. get x(): NodeMaterialConnectionPoint;
  22473. /**
  22474. * Gets the y component (input)
  22475. */
  22476. get y(): NodeMaterialConnectionPoint;
  22477. /**
  22478. * Gets the z component (input)
  22479. */
  22480. get z(): NodeMaterialConnectionPoint;
  22481. /**
  22482. * Gets the w component (input)
  22483. */
  22484. get w(): NodeMaterialConnectionPoint;
  22485. /**
  22486. * Gets the xyzw component (output)
  22487. */
  22488. get xyzw(): NodeMaterialConnectionPoint;
  22489. /**
  22490. * Gets the xyz component (output)
  22491. */
  22492. get xyzOut(): NodeMaterialConnectionPoint;
  22493. /**
  22494. * Gets the xy component (output)
  22495. */
  22496. get xyOut(): NodeMaterialConnectionPoint;
  22497. /**
  22498. * Gets the xy component (output)
  22499. * @deprecated Please use xyOut instead.
  22500. */
  22501. get xy(): NodeMaterialConnectionPoint;
  22502. /**
  22503. * Gets the xyz component (output)
  22504. * @deprecated Please use xyzOut instead.
  22505. */
  22506. get xyz(): NodeMaterialConnectionPoint;
  22507. protected _buildBlock(state: NodeMaterialBuildState): this;
  22508. }
  22509. }
  22510. declare module BABYLON {
  22511. /**
  22512. * Block used to remap a float from a range to a new one
  22513. */
  22514. export class RemapBlock extends NodeMaterialBlock {
  22515. /**
  22516. * Gets or sets the source range
  22517. */
  22518. sourceRange: Vector2;
  22519. /**
  22520. * Gets or sets the target range
  22521. */
  22522. targetRange: Vector2;
  22523. /**
  22524. * Creates a new RemapBlock
  22525. * @param name defines the block name
  22526. */
  22527. constructor(name: string);
  22528. /**
  22529. * Gets the current class name
  22530. * @returns the class name
  22531. */
  22532. getClassName(): string;
  22533. /**
  22534. * Gets the input component
  22535. */
  22536. get input(): NodeMaterialConnectionPoint;
  22537. /**
  22538. * Gets the source min input component
  22539. */
  22540. get sourceMin(): NodeMaterialConnectionPoint;
  22541. /**
  22542. * Gets the source max input component
  22543. */
  22544. get sourceMax(): NodeMaterialConnectionPoint;
  22545. /**
  22546. * Gets the target min input component
  22547. */
  22548. get targetMin(): NodeMaterialConnectionPoint;
  22549. /**
  22550. * Gets the target max input component
  22551. */
  22552. get targetMax(): NodeMaterialConnectionPoint;
  22553. /**
  22554. * Gets the output component
  22555. */
  22556. get output(): NodeMaterialConnectionPoint;
  22557. protected _buildBlock(state: NodeMaterialBuildState): this;
  22558. protected _dumpPropertiesCode(): string;
  22559. serialize(): any;
  22560. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22561. }
  22562. }
  22563. declare module BABYLON {
  22564. /**
  22565. * Block used to multiply 2 values
  22566. */
  22567. export class MultiplyBlock extends NodeMaterialBlock {
  22568. /**
  22569. * Creates a new MultiplyBlock
  22570. * @param name defines the block name
  22571. */
  22572. constructor(name: string);
  22573. /**
  22574. * Gets the current class name
  22575. * @returns the class name
  22576. */
  22577. getClassName(): string;
  22578. /**
  22579. * Gets the left operand input component
  22580. */
  22581. get left(): NodeMaterialConnectionPoint;
  22582. /**
  22583. * Gets the right operand input component
  22584. */
  22585. get right(): NodeMaterialConnectionPoint;
  22586. /**
  22587. * Gets the output component
  22588. */
  22589. get output(): NodeMaterialConnectionPoint;
  22590. protected _buildBlock(state: NodeMaterialBuildState): this;
  22591. }
  22592. }
  22593. declare module BABYLON {
  22594. /**
  22595. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22596. */
  22597. export class ColorSplitterBlock extends NodeMaterialBlock {
  22598. /**
  22599. * Create a new ColorSplitterBlock
  22600. * @param name defines the block name
  22601. */
  22602. constructor(name: string);
  22603. /**
  22604. * Gets the current class name
  22605. * @returns the class name
  22606. */
  22607. getClassName(): string;
  22608. /**
  22609. * Gets the rgba component (input)
  22610. */
  22611. get rgba(): NodeMaterialConnectionPoint;
  22612. /**
  22613. * Gets the rgb component (input)
  22614. */
  22615. get rgbIn(): NodeMaterialConnectionPoint;
  22616. /**
  22617. * Gets the rgb component (output)
  22618. */
  22619. get rgbOut(): NodeMaterialConnectionPoint;
  22620. /**
  22621. * Gets the r component (output)
  22622. */
  22623. get r(): NodeMaterialConnectionPoint;
  22624. /**
  22625. * Gets the g component (output)
  22626. */
  22627. get g(): NodeMaterialConnectionPoint;
  22628. /**
  22629. * Gets the b component (output)
  22630. */
  22631. get b(): NodeMaterialConnectionPoint;
  22632. /**
  22633. * Gets the a component (output)
  22634. */
  22635. get a(): NodeMaterialConnectionPoint;
  22636. protected _inputRename(name: string): string;
  22637. protected _outputRename(name: string): string;
  22638. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22639. }
  22640. }
  22641. declare module BABYLON {
  22642. /**
  22643. * Operations supported by the Trigonometry block
  22644. */
  22645. export enum TrigonometryBlockOperations {
  22646. /** Cos */
  22647. Cos = 0,
  22648. /** Sin */
  22649. Sin = 1,
  22650. /** Abs */
  22651. Abs = 2,
  22652. /** Exp */
  22653. Exp = 3,
  22654. /** Exp2 */
  22655. Exp2 = 4,
  22656. /** Round */
  22657. Round = 5,
  22658. /** Floor */
  22659. Floor = 6,
  22660. /** Ceiling */
  22661. Ceiling = 7,
  22662. /** Square root */
  22663. Sqrt = 8,
  22664. /** Log */
  22665. Log = 9,
  22666. /** Tangent */
  22667. Tan = 10,
  22668. /** Arc tangent */
  22669. ArcTan = 11,
  22670. /** Arc cosinus */
  22671. ArcCos = 12,
  22672. /** Arc sinus */
  22673. ArcSin = 13,
  22674. /** Fraction */
  22675. Fract = 14,
  22676. /** Sign */
  22677. Sign = 15,
  22678. /** To radians (from degrees) */
  22679. Radians = 16,
  22680. /** To degrees (from radians) */
  22681. Degrees = 17
  22682. }
  22683. /**
  22684. * Block used to apply trigonometry operation to floats
  22685. */
  22686. export class TrigonometryBlock extends NodeMaterialBlock {
  22687. /**
  22688. * Gets or sets the operation applied by the block
  22689. */
  22690. operation: TrigonometryBlockOperations;
  22691. /**
  22692. * Creates a new TrigonometryBlock
  22693. * @param name defines the block name
  22694. */
  22695. constructor(name: string);
  22696. /**
  22697. * Gets the current class name
  22698. * @returns the class name
  22699. */
  22700. getClassName(): string;
  22701. /**
  22702. * Gets the input component
  22703. */
  22704. get input(): NodeMaterialConnectionPoint;
  22705. /**
  22706. * Gets the output component
  22707. */
  22708. get output(): NodeMaterialConnectionPoint;
  22709. protected _buildBlock(state: NodeMaterialBuildState): this;
  22710. serialize(): any;
  22711. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22712. protected _dumpPropertiesCode(): string;
  22713. }
  22714. }
  22715. declare module BABYLON {
  22716. /**
  22717. * Interface used to configure the node material editor
  22718. */
  22719. export interface INodeMaterialEditorOptions {
  22720. /** Define the URl to load node editor script */
  22721. editorURL?: string;
  22722. }
  22723. /** @hidden */
  22724. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22725. NORMAL: boolean;
  22726. TANGENT: boolean;
  22727. UV1: boolean;
  22728. /** BONES */
  22729. NUM_BONE_INFLUENCERS: number;
  22730. BonesPerMesh: number;
  22731. BONETEXTURE: boolean;
  22732. /** MORPH TARGETS */
  22733. MORPHTARGETS: boolean;
  22734. MORPHTARGETS_NORMAL: boolean;
  22735. MORPHTARGETS_TANGENT: boolean;
  22736. MORPHTARGETS_UV: boolean;
  22737. NUM_MORPH_INFLUENCERS: number;
  22738. /** IMAGE PROCESSING */
  22739. IMAGEPROCESSING: boolean;
  22740. VIGNETTE: boolean;
  22741. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22742. VIGNETTEBLENDMODEOPAQUE: boolean;
  22743. TONEMAPPING: boolean;
  22744. TONEMAPPING_ACES: boolean;
  22745. CONTRAST: boolean;
  22746. EXPOSURE: boolean;
  22747. COLORCURVES: boolean;
  22748. COLORGRADING: boolean;
  22749. COLORGRADING3D: boolean;
  22750. SAMPLER3DGREENDEPTH: boolean;
  22751. SAMPLER3DBGRMAP: boolean;
  22752. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22753. /** MISC. */
  22754. BUMPDIRECTUV: number;
  22755. constructor();
  22756. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22757. }
  22758. /**
  22759. * Class used to configure NodeMaterial
  22760. */
  22761. export interface INodeMaterialOptions {
  22762. /**
  22763. * Defines if blocks should emit comments
  22764. */
  22765. emitComments: boolean;
  22766. }
  22767. /**
  22768. * Class used to create a node based material built by assembling shader blocks
  22769. */
  22770. export class NodeMaterial extends PushMaterial {
  22771. private static _BuildIdGenerator;
  22772. private _options;
  22773. private _vertexCompilationState;
  22774. private _fragmentCompilationState;
  22775. private _sharedData;
  22776. private _buildId;
  22777. private _buildWasSuccessful;
  22778. private _cachedWorldViewMatrix;
  22779. private _cachedWorldViewProjectionMatrix;
  22780. private _optimizers;
  22781. private _animationFrame;
  22782. /** Define the Url to load node editor script */
  22783. static EditorURL: string;
  22784. /** Define the Url to load snippets */
  22785. static SnippetUrl: string;
  22786. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22787. static IgnoreTexturesAtLoadTime: boolean;
  22788. private BJSNODEMATERIALEDITOR;
  22789. /** Get the inspector from bundle or global */
  22790. private _getGlobalNodeMaterialEditor;
  22791. /**
  22792. * Snippet ID if the material was created from the snippet server
  22793. */
  22794. snippetId: string;
  22795. /**
  22796. * Gets or sets data used by visual editor
  22797. * @see https://nme.babylonjs.com
  22798. */
  22799. editorData: any;
  22800. /**
  22801. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  22802. */
  22803. ignoreAlpha: boolean;
  22804. /**
  22805. * Defines the maximum number of lights that can be used in the material
  22806. */
  22807. maxSimultaneousLights: number;
  22808. /**
  22809. * Observable raised when the material is built
  22810. */
  22811. onBuildObservable: Observable<NodeMaterial>;
  22812. /**
  22813. * Gets or sets the root nodes of the material vertex shader
  22814. */
  22815. _vertexOutputNodes: NodeMaterialBlock[];
  22816. /**
  22817. * Gets or sets the root nodes of the material fragment (pixel) shader
  22818. */
  22819. _fragmentOutputNodes: NodeMaterialBlock[];
  22820. /** Gets or sets options to control the node material overall behavior */
  22821. get options(): INodeMaterialOptions;
  22822. set options(options: INodeMaterialOptions);
  22823. /**
  22824. * Default configuration related to image processing available in the standard Material.
  22825. */
  22826. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22827. /**
  22828. * Gets the image processing configuration used either in this material.
  22829. */
  22830. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22831. /**
  22832. * Sets the Default image processing configuration used either in the this material.
  22833. *
  22834. * If sets to null, the scene one is in use.
  22835. */
  22836. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22837. /**
  22838. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22839. */
  22840. attachedBlocks: NodeMaterialBlock[];
  22841. /**
  22842. * Specifies the mode of the node material
  22843. * @hidden
  22844. */
  22845. _mode: NodeMaterialModes;
  22846. /**
  22847. * Gets the mode property
  22848. */
  22849. get mode(): NodeMaterialModes;
  22850. /**
  22851. * A free comment about the material
  22852. */
  22853. comment: string;
  22854. /**
  22855. * Create a new node based material
  22856. * @param name defines the material name
  22857. * @param scene defines the hosting scene
  22858. * @param options defines creation option
  22859. */
  22860. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22861. /**
  22862. * Gets the current class name of the material e.g. "NodeMaterial"
  22863. * @returns the class name
  22864. */
  22865. getClassName(): string;
  22866. /**
  22867. * Keep track of the image processing observer to allow dispose and replace.
  22868. */
  22869. private _imageProcessingObserver;
  22870. /**
  22871. * Attaches a new image processing configuration to the Standard Material.
  22872. * @param configuration
  22873. */
  22874. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22875. /**
  22876. * Get a block by its name
  22877. * @param name defines the name of the block to retrieve
  22878. * @returns the required block or null if not found
  22879. */
  22880. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22881. /**
  22882. * Get a block by its name
  22883. * @param predicate defines the predicate used to find the good candidate
  22884. * @returns the required block or null if not found
  22885. */
  22886. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22887. /**
  22888. * Get an input block by its name
  22889. * @param predicate defines the predicate used to find the good candidate
  22890. * @returns the required input block or null if not found
  22891. */
  22892. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22893. /**
  22894. * Gets the list of input blocks attached to this material
  22895. * @returns an array of InputBlocks
  22896. */
  22897. getInputBlocks(): InputBlock[];
  22898. /**
  22899. * Adds a new optimizer to the list of optimizers
  22900. * @param optimizer defines the optimizers to add
  22901. * @returns the current material
  22902. */
  22903. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22904. /**
  22905. * Remove an optimizer from the list of optimizers
  22906. * @param optimizer defines the optimizers to remove
  22907. * @returns the current material
  22908. */
  22909. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22910. /**
  22911. * Add a new block to the list of output nodes
  22912. * @param node defines the node to add
  22913. * @returns the current material
  22914. */
  22915. addOutputNode(node: NodeMaterialBlock): this;
  22916. /**
  22917. * Remove a block from the list of root nodes
  22918. * @param node defines the node to remove
  22919. * @returns the current material
  22920. */
  22921. removeOutputNode(node: NodeMaterialBlock): this;
  22922. private _addVertexOutputNode;
  22923. private _removeVertexOutputNode;
  22924. private _addFragmentOutputNode;
  22925. private _removeFragmentOutputNode;
  22926. /**
  22927. * Specifies if the material will require alpha blending
  22928. * @returns a boolean specifying if alpha blending is needed
  22929. */
  22930. needAlphaBlending(): boolean;
  22931. /**
  22932. * Specifies if this material should be rendered in alpha test mode
  22933. * @returns a boolean specifying if an alpha test is needed.
  22934. */
  22935. needAlphaTesting(): boolean;
  22936. private _initializeBlock;
  22937. private _resetDualBlocks;
  22938. /**
  22939. * Remove a block from the current node material
  22940. * @param block defines the block to remove
  22941. */
  22942. removeBlock(block: NodeMaterialBlock): void;
  22943. /**
  22944. * Build the material and generates the inner effect
  22945. * @param verbose defines if the build should log activity
  22946. */
  22947. build(verbose?: boolean): void;
  22948. /**
  22949. * Runs an otpimization phase to try to improve the shader code
  22950. */
  22951. optimize(): void;
  22952. private _prepareDefinesForAttributes;
  22953. /**
  22954. * Create a post process from the material
  22955. * @param camera The camera to apply the render pass to.
  22956. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22958. * @param engine The engine which the post process will be applied. (default: current engine)
  22959. * @param reusable If the post process can be reused on the same frame. (default: false)
  22960. * @param textureType Type of textures used when performing the post process. (default: 0)
  22961. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22962. * @returns the post process created
  22963. */
  22964. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22965. /**
  22966. * Create the post process effect from the material
  22967. * @param postProcess The post process to create the effect for
  22968. */
  22969. createEffectForPostProcess(postProcess: PostProcess): void;
  22970. private _createEffectForPostProcess;
  22971. /**
  22972. * Create a new procedural texture based on this node material
  22973. * @param size defines the size of the texture
  22974. * @param scene defines the hosting scene
  22975. * @returns the new procedural texture attached to this node material
  22976. */
  22977. createProceduralTexture(size: number | {
  22978. width: number;
  22979. height: number;
  22980. layers?: number;
  22981. }, scene: Scene): Nullable<ProceduralTexture>;
  22982. private _createEffectForParticles;
  22983. private _checkInternals;
  22984. /**
  22985. * Create the effect to be used as the custom effect for a particle system
  22986. * @param particleSystem Particle system to create the effect for
  22987. * @param onCompiled defines a function to call when the effect creation is successful
  22988. * @param onError defines a function to call when the effect creation has failed
  22989. */
  22990. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22991. private _processDefines;
  22992. /**
  22993. * Get if the submesh is ready to be used and all its information available.
  22994. * Child classes can use it to update shaders
  22995. * @param mesh defines the mesh to check
  22996. * @param subMesh defines which submesh to check
  22997. * @param useInstances specifies that instances should be used
  22998. * @returns a boolean indicating that the submesh is ready or not
  22999. */
  23000. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23001. /**
  23002. * Get a string representing the shaders built by the current node graph
  23003. */
  23004. get compiledShaders(): string;
  23005. /**
  23006. * Binds the world matrix to the material
  23007. * @param world defines the world transformation matrix
  23008. */
  23009. bindOnlyWorldMatrix(world: Matrix): void;
  23010. /**
  23011. * Binds the submesh to this material by preparing the effect and shader to draw
  23012. * @param world defines the world transformation matrix
  23013. * @param mesh defines the mesh containing the submesh
  23014. * @param subMesh defines the submesh to bind the material to
  23015. */
  23016. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23017. /**
  23018. * Gets the active textures from the material
  23019. * @returns an array of textures
  23020. */
  23021. getActiveTextures(): BaseTexture[];
  23022. /**
  23023. * Gets the list of texture blocks
  23024. * @returns an array of texture blocks
  23025. */
  23026. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23027. /**
  23028. * Specifies if the material uses a texture
  23029. * @param texture defines the texture to check against the material
  23030. * @returns a boolean specifying if the material uses the texture
  23031. */
  23032. hasTexture(texture: BaseTexture): boolean;
  23033. /**
  23034. * Disposes the material
  23035. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23036. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23037. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23038. */
  23039. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23040. /** Creates the node editor window. */
  23041. private _createNodeEditor;
  23042. /**
  23043. * Launch the node material editor
  23044. * @param config Define the configuration of the editor
  23045. * @return a promise fulfilled when the node editor is visible
  23046. */
  23047. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23048. /**
  23049. * Clear the current material
  23050. */
  23051. clear(): void;
  23052. /**
  23053. * Clear the current material and set it to a default state
  23054. */
  23055. setToDefault(): void;
  23056. /**
  23057. * Clear the current material and set it to a default state for post process
  23058. */
  23059. setToDefaultPostProcess(): void;
  23060. /**
  23061. * Clear the current material and set it to a default state for procedural texture
  23062. */
  23063. setToDefaultProceduralTexture(): void;
  23064. /**
  23065. * Clear the current material and set it to a default state for particle
  23066. */
  23067. setToDefaultParticle(): void;
  23068. /**
  23069. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23070. * @param url defines the url to load from
  23071. * @returns a promise that will fullfil when the material is fully loaded
  23072. */
  23073. loadAsync(url: string): Promise<void>;
  23074. private _gatherBlocks;
  23075. /**
  23076. * Generate a string containing the code declaration required to create an equivalent of this material
  23077. * @returns a string
  23078. */
  23079. generateCode(): string;
  23080. /**
  23081. * Serializes this material in a JSON representation
  23082. * @returns the serialized material object
  23083. */
  23084. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23085. private _restoreConnections;
  23086. /**
  23087. * Clear the current graph and load a new one from a serialization object
  23088. * @param source defines the JSON representation of the material
  23089. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23090. * @param merge defines whether or not the source must be merged or replace the current content
  23091. */
  23092. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23093. /**
  23094. * Makes a duplicate of the current material.
  23095. * @param name - name to use for the new material.
  23096. */
  23097. clone(name: string): NodeMaterial;
  23098. /**
  23099. * Creates a node material from parsed material data
  23100. * @param source defines the JSON representation of the material
  23101. * @param scene defines the hosting scene
  23102. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23103. * @returns a new node material
  23104. */
  23105. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23106. /**
  23107. * Creates a node material from a snippet saved in a remote file
  23108. * @param name defines the name of the material to create
  23109. * @param url defines the url to load from
  23110. * @param scene defines the hosting scene
  23111. * @returns a promise that will resolve to the new node material
  23112. */
  23113. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23114. /**
  23115. * Creates a node material from a snippet saved by the node material editor
  23116. * @param snippetId defines the snippet to load
  23117. * @param scene defines the hosting scene
  23118. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23119. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23120. * @returns a promise that will resolve to the new node material
  23121. */
  23122. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23123. /**
  23124. * Creates a new node material set to default basic configuration
  23125. * @param name defines the name of the material
  23126. * @param scene defines the hosting scene
  23127. * @returns a new NodeMaterial
  23128. */
  23129. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23130. }
  23131. }
  23132. declare module BABYLON {
  23133. interface ThinEngine {
  23134. /**
  23135. * Unbind a list of render target textures from the webGL context
  23136. * This is used only when drawBuffer extension or webGL2 are active
  23137. * @param textures defines the render target textures to unbind
  23138. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23139. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23140. */
  23141. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23142. /**
  23143. * Create a multi render target texture
  23144. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23145. * @param size defines the size of the texture
  23146. * @param options defines the creation options
  23147. * @returns the cube texture as an InternalTexture
  23148. */
  23149. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23150. /**
  23151. * Update the sample count for a given multiple render target texture
  23152. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23153. * @param textures defines the textures to update
  23154. * @param samples defines the sample count to set
  23155. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23156. */
  23157. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23158. /**
  23159. * Select a subsets of attachments to draw to.
  23160. * @param attachments gl attachments
  23161. */
  23162. bindAttachments(attachments: number[]): void;
  23163. /**
  23164. * Creates a layout object to draw/clear on specific textures in a MRT
  23165. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23166. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23167. */
  23168. buildTextureLayout(textureStatus: boolean[]): number[];
  23169. /**
  23170. * Restores the webgl state to only draw on the main color attachment
  23171. */
  23172. restoreSingleAttachment(): void;
  23173. }
  23174. }
  23175. declare module BABYLON {
  23176. /**
  23177. * Creation options of the multi render target texture.
  23178. */
  23179. export interface IMultiRenderTargetOptions {
  23180. /**
  23181. * Define if the texture needs to create mip maps after render.
  23182. */
  23183. generateMipMaps?: boolean;
  23184. /**
  23185. * Define the types of all the draw buffers we want to create
  23186. */
  23187. types?: number[];
  23188. /**
  23189. * Define the sampling modes of all the draw buffers we want to create
  23190. */
  23191. samplingModes?: number[];
  23192. /**
  23193. * Define if a depth buffer is required
  23194. */
  23195. generateDepthBuffer?: boolean;
  23196. /**
  23197. * Define if a stencil buffer is required
  23198. */
  23199. generateStencilBuffer?: boolean;
  23200. /**
  23201. * Define if a depth texture is required instead of a depth buffer
  23202. */
  23203. generateDepthTexture?: boolean;
  23204. /**
  23205. * Define the number of desired draw buffers
  23206. */
  23207. textureCount?: number;
  23208. /**
  23209. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23210. */
  23211. doNotChangeAspectRatio?: boolean;
  23212. /**
  23213. * Define the default type of the buffers we are creating
  23214. */
  23215. defaultType?: number;
  23216. }
  23217. /**
  23218. * A multi render target, like a render target provides the ability to render to a texture.
  23219. * Unlike the render target, it can render to several draw buffers in one draw.
  23220. * This is specially interesting in deferred rendering or for any effects requiring more than
  23221. * just one color from a single pass.
  23222. */
  23223. export class MultiRenderTarget extends RenderTargetTexture {
  23224. private _internalTextures;
  23225. private _textures;
  23226. private _multiRenderTargetOptions;
  23227. private _count;
  23228. /**
  23229. * Get if draw buffers are currently supported by the used hardware and browser.
  23230. */
  23231. get isSupported(): boolean;
  23232. /**
  23233. * Get the list of textures generated by the multi render target.
  23234. */
  23235. get textures(): Texture[];
  23236. /**
  23237. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23238. */
  23239. get count(): number;
  23240. /**
  23241. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23242. */
  23243. get depthTexture(): Texture;
  23244. /**
  23245. * Set the wrapping mode on U of all the textures we are rendering to.
  23246. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23247. */
  23248. set wrapU(wrap: number);
  23249. /**
  23250. * Set the wrapping mode on V of all the textures we are rendering to.
  23251. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23252. */
  23253. set wrapV(wrap: number);
  23254. /**
  23255. * Instantiate a new multi render target texture.
  23256. * A multi render target, like a render target provides the ability to render to a texture.
  23257. * Unlike the render target, it can render to several draw buffers in one draw.
  23258. * This is specially interesting in deferred rendering or for any effects requiring more than
  23259. * just one color from a single pass.
  23260. * @param name Define the name of the texture
  23261. * @param size Define the size of the buffers to render to
  23262. * @param count Define the number of target we are rendering into
  23263. * @param scene Define the scene the texture belongs to
  23264. * @param options Define the options used to create the multi render target
  23265. */
  23266. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23267. private _initTypes;
  23268. /** @hidden */
  23269. _rebuild(forceFullRebuild?: boolean): void;
  23270. private _createInternalTextures;
  23271. private _createTextures;
  23272. /**
  23273. * Replaces a texture within the MRT.
  23274. * @param texture The new texture to insert in the MRT
  23275. * @param index The index of the texture to replace
  23276. */
  23277. replaceTexture(texture: Texture, index: number): void;
  23278. /**
  23279. * Define the number of samples used if MSAA is enabled.
  23280. */
  23281. get samples(): number;
  23282. set samples(value: number);
  23283. /**
  23284. * Resize all the textures in the multi render target.
  23285. * Be careful as it will recreate all the data in the new texture.
  23286. * @param size Define the new size
  23287. */
  23288. resize(size: any): void;
  23289. /**
  23290. * Changes the number of render targets in this MRT
  23291. * Be careful as it will recreate all the data in the new texture.
  23292. * @param count new texture count
  23293. * @param options Specifies texture types and sampling modes for new textures
  23294. */
  23295. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23296. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23297. /**
  23298. * Dispose the render targets and their associated resources
  23299. */
  23300. dispose(): void;
  23301. /**
  23302. * Release all the underlying texture used as draw buffers.
  23303. */
  23304. releaseInternalTextures(): void;
  23305. }
  23306. }
  23307. declare module BABYLON {
  23308. /** @hidden */
  23309. export var imageProcessingPixelShader: {
  23310. name: string;
  23311. shader: string;
  23312. };
  23313. }
  23314. declare module BABYLON {
  23315. /**
  23316. * ImageProcessingPostProcess
  23317. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23318. */
  23319. export class ImageProcessingPostProcess extends PostProcess {
  23320. /**
  23321. * Default configuration related to image processing available in the PBR Material.
  23322. */
  23323. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23324. /**
  23325. * Gets the image processing configuration used either in this material.
  23326. */
  23327. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23328. /**
  23329. * Sets the Default image processing configuration used either in the this material.
  23330. *
  23331. * If sets to null, the scene one is in use.
  23332. */
  23333. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23334. /**
  23335. * Keep track of the image processing observer to allow dispose and replace.
  23336. */
  23337. private _imageProcessingObserver;
  23338. /**
  23339. * Attaches a new image processing configuration to the PBR Material.
  23340. * @param configuration
  23341. */
  23342. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23343. /**
  23344. * If the post process is supported.
  23345. */
  23346. get isSupported(): boolean;
  23347. /**
  23348. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23349. */
  23350. get colorCurves(): Nullable<ColorCurves>;
  23351. /**
  23352. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23353. */
  23354. set colorCurves(value: Nullable<ColorCurves>);
  23355. /**
  23356. * Gets wether the color curves effect is enabled.
  23357. */
  23358. get colorCurvesEnabled(): boolean;
  23359. /**
  23360. * Sets wether the color curves effect is enabled.
  23361. */
  23362. set colorCurvesEnabled(value: boolean);
  23363. /**
  23364. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23365. */
  23366. get colorGradingTexture(): Nullable<BaseTexture>;
  23367. /**
  23368. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23369. */
  23370. set colorGradingTexture(value: Nullable<BaseTexture>);
  23371. /**
  23372. * Gets wether the color grading effect is enabled.
  23373. */
  23374. get colorGradingEnabled(): boolean;
  23375. /**
  23376. * Gets wether the color grading effect is enabled.
  23377. */
  23378. set colorGradingEnabled(value: boolean);
  23379. /**
  23380. * Gets exposure used in the effect.
  23381. */
  23382. get exposure(): number;
  23383. /**
  23384. * Sets exposure used in the effect.
  23385. */
  23386. set exposure(value: number);
  23387. /**
  23388. * Gets wether tonemapping is enabled or not.
  23389. */
  23390. get toneMappingEnabled(): boolean;
  23391. /**
  23392. * Sets wether tonemapping is enabled or not
  23393. */
  23394. set toneMappingEnabled(value: boolean);
  23395. /**
  23396. * Gets the type of tone mapping effect.
  23397. */
  23398. get toneMappingType(): number;
  23399. /**
  23400. * Sets the type of tone mapping effect.
  23401. */
  23402. set toneMappingType(value: number);
  23403. /**
  23404. * Gets contrast used in the effect.
  23405. */
  23406. get contrast(): number;
  23407. /**
  23408. * Sets contrast used in the effect.
  23409. */
  23410. set contrast(value: number);
  23411. /**
  23412. * Gets Vignette stretch size.
  23413. */
  23414. get vignetteStretch(): number;
  23415. /**
  23416. * Sets Vignette stretch size.
  23417. */
  23418. set vignetteStretch(value: number);
  23419. /**
  23420. * Gets Vignette centre X Offset.
  23421. */
  23422. get vignetteCentreX(): number;
  23423. /**
  23424. * Sets Vignette centre X Offset.
  23425. */
  23426. set vignetteCentreX(value: number);
  23427. /**
  23428. * Gets Vignette centre Y Offset.
  23429. */
  23430. get vignetteCentreY(): number;
  23431. /**
  23432. * Sets Vignette centre Y Offset.
  23433. */
  23434. set vignetteCentreY(value: number);
  23435. /**
  23436. * Gets Vignette weight or intensity of the vignette effect.
  23437. */
  23438. get vignetteWeight(): number;
  23439. /**
  23440. * Sets Vignette weight or intensity of the vignette effect.
  23441. */
  23442. set vignetteWeight(value: number);
  23443. /**
  23444. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23445. * if vignetteEnabled is set to true.
  23446. */
  23447. get vignetteColor(): Color4;
  23448. /**
  23449. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23450. * if vignetteEnabled is set to true.
  23451. */
  23452. set vignetteColor(value: Color4);
  23453. /**
  23454. * Gets Camera field of view used by the Vignette effect.
  23455. */
  23456. get vignetteCameraFov(): number;
  23457. /**
  23458. * Sets Camera field of view used by the Vignette effect.
  23459. */
  23460. set vignetteCameraFov(value: number);
  23461. /**
  23462. * Gets the vignette blend mode allowing different kind of effect.
  23463. */
  23464. get vignetteBlendMode(): number;
  23465. /**
  23466. * Sets the vignette blend mode allowing different kind of effect.
  23467. */
  23468. set vignetteBlendMode(value: number);
  23469. /**
  23470. * Gets wether the vignette effect is enabled.
  23471. */
  23472. get vignetteEnabled(): boolean;
  23473. /**
  23474. * Sets wether the vignette effect is enabled.
  23475. */
  23476. set vignetteEnabled(value: boolean);
  23477. private _fromLinearSpace;
  23478. /**
  23479. * Gets wether the input of the processing is in Gamma or Linear Space.
  23480. */
  23481. get fromLinearSpace(): boolean;
  23482. /**
  23483. * Sets wether the input of the processing is in Gamma or Linear Space.
  23484. */
  23485. set fromLinearSpace(value: boolean);
  23486. /**
  23487. * Defines cache preventing GC.
  23488. */
  23489. private _defines;
  23490. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  23491. /**
  23492. * "ImageProcessingPostProcess"
  23493. * @returns "ImageProcessingPostProcess"
  23494. */
  23495. getClassName(): string;
  23496. /**
  23497. * @hidden
  23498. */
  23499. _updateParameters(): void;
  23500. dispose(camera?: Camera): void;
  23501. }
  23502. }
  23503. declare module BABYLON {
  23504. /**
  23505. * Interface for defining prepass effects in the prepass post-process pipeline
  23506. */
  23507. export interface PrePassEffectConfiguration {
  23508. /**
  23509. * Name of the effect
  23510. */
  23511. name: string;
  23512. /**
  23513. * Post process to attach for this effect
  23514. */
  23515. postProcess?: PostProcess;
  23516. /**
  23517. * Textures required in the MRT
  23518. */
  23519. texturesRequired: number[];
  23520. /**
  23521. * Is the effect enabled
  23522. */
  23523. enabled: boolean;
  23524. /**
  23525. * Disposes the effect configuration
  23526. */
  23527. dispose?: () => void;
  23528. /**
  23529. * Creates the associated post process
  23530. */
  23531. createPostProcess?: () => PostProcess;
  23532. }
  23533. }
  23534. declare module BABYLON {
  23535. /**
  23536. * Options to be used when creating a FresnelParameters.
  23537. */
  23538. export type IFresnelParametersCreationOptions = {
  23539. /**
  23540. * Define the color used on edges (grazing angle)
  23541. */
  23542. leftColor?: Color3;
  23543. /**
  23544. * Define the color used on center
  23545. */
  23546. rightColor?: Color3;
  23547. /**
  23548. * Define bias applied to computed fresnel term
  23549. */
  23550. bias?: number;
  23551. /**
  23552. * Defined the power exponent applied to fresnel term
  23553. */
  23554. power?: number;
  23555. /**
  23556. * Define if the fresnel effect is enable or not.
  23557. */
  23558. isEnabled?: boolean;
  23559. };
  23560. /**
  23561. * Serialized format for FresnelParameters.
  23562. */
  23563. export type IFresnelParametersSerialized = {
  23564. /**
  23565. * Define the color used on edges (grazing angle) [as an array]
  23566. */
  23567. leftColor: number[];
  23568. /**
  23569. * Define the color used on center [as an array]
  23570. */
  23571. rightColor: number[];
  23572. /**
  23573. * Define bias applied to computed fresnel term
  23574. */
  23575. bias: number;
  23576. /**
  23577. * Defined the power exponent applied to fresnel term
  23578. */
  23579. power?: number;
  23580. /**
  23581. * Define if the fresnel effect is enable or not.
  23582. */
  23583. isEnabled: boolean;
  23584. };
  23585. /**
  23586. * This represents all the required information to add a fresnel effect on a material:
  23587. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23588. */
  23589. export class FresnelParameters {
  23590. private _isEnabled;
  23591. /**
  23592. * Define if the fresnel effect is enable or not.
  23593. */
  23594. get isEnabled(): boolean;
  23595. set isEnabled(value: boolean);
  23596. /**
  23597. * Define the color used on edges (grazing angle)
  23598. */
  23599. leftColor: Color3;
  23600. /**
  23601. * Define the color used on center
  23602. */
  23603. rightColor: Color3;
  23604. /**
  23605. * Define bias applied to computed fresnel term
  23606. */
  23607. bias: number;
  23608. /**
  23609. * Defined the power exponent applied to fresnel term
  23610. */
  23611. power: number;
  23612. /**
  23613. * Creates a new FresnelParameters object.
  23614. *
  23615. * @param options provide your own settings to optionally to override defaults
  23616. */
  23617. constructor(options?: IFresnelParametersCreationOptions);
  23618. /**
  23619. * Clones the current fresnel and its valuues
  23620. * @returns a clone fresnel configuration
  23621. */
  23622. clone(): FresnelParameters;
  23623. /**
  23624. * Determines equality between FresnelParameters objects
  23625. * @param otherFresnelParameters defines the second operand
  23626. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  23627. */
  23628. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  23629. /**
  23630. * Serializes the current fresnel parameters to a JSON representation.
  23631. * @return the JSON serialization
  23632. */
  23633. serialize(): IFresnelParametersSerialized;
  23634. /**
  23635. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  23636. * @param parsedFresnelParameters Define the JSON representation
  23637. * @returns the parsed parameters
  23638. */
  23639. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  23640. }
  23641. }
  23642. declare module BABYLON {
  23643. /**
  23644. * This groups all the flags used to control the materials channel.
  23645. */
  23646. export class MaterialFlags {
  23647. private static _DiffuseTextureEnabled;
  23648. /**
  23649. * Are diffuse textures enabled in the application.
  23650. */
  23651. static get DiffuseTextureEnabled(): boolean;
  23652. static set DiffuseTextureEnabled(value: boolean);
  23653. private static _DetailTextureEnabled;
  23654. /**
  23655. * Are detail textures enabled in the application.
  23656. */
  23657. static get DetailTextureEnabled(): boolean;
  23658. static set DetailTextureEnabled(value: boolean);
  23659. private static _AmbientTextureEnabled;
  23660. /**
  23661. * Are ambient textures enabled in the application.
  23662. */
  23663. static get AmbientTextureEnabled(): boolean;
  23664. static set AmbientTextureEnabled(value: boolean);
  23665. private static _OpacityTextureEnabled;
  23666. /**
  23667. * Are opacity textures enabled in the application.
  23668. */
  23669. static get OpacityTextureEnabled(): boolean;
  23670. static set OpacityTextureEnabled(value: boolean);
  23671. private static _ReflectionTextureEnabled;
  23672. /**
  23673. * Are reflection textures enabled in the application.
  23674. */
  23675. static get ReflectionTextureEnabled(): boolean;
  23676. static set ReflectionTextureEnabled(value: boolean);
  23677. private static _EmissiveTextureEnabled;
  23678. /**
  23679. * Are emissive textures enabled in the application.
  23680. */
  23681. static get EmissiveTextureEnabled(): boolean;
  23682. static set EmissiveTextureEnabled(value: boolean);
  23683. private static _SpecularTextureEnabled;
  23684. /**
  23685. * Are specular textures enabled in the application.
  23686. */
  23687. static get SpecularTextureEnabled(): boolean;
  23688. static set SpecularTextureEnabled(value: boolean);
  23689. private static _BumpTextureEnabled;
  23690. /**
  23691. * Are bump textures enabled in the application.
  23692. */
  23693. static get BumpTextureEnabled(): boolean;
  23694. static set BumpTextureEnabled(value: boolean);
  23695. private static _LightmapTextureEnabled;
  23696. /**
  23697. * Are lightmap textures enabled in the application.
  23698. */
  23699. static get LightmapTextureEnabled(): boolean;
  23700. static set LightmapTextureEnabled(value: boolean);
  23701. private static _RefractionTextureEnabled;
  23702. /**
  23703. * Are refraction textures enabled in the application.
  23704. */
  23705. static get RefractionTextureEnabled(): boolean;
  23706. static set RefractionTextureEnabled(value: boolean);
  23707. private static _ColorGradingTextureEnabled;
  23708. /**
  23709. * Are color grading textures enabled in the application.
  23710. */
  23711. static get ColorGradingTextureEnabled(): boolean;
  23712. static set ColorGradingTextureEnabled(value: boolean);
  23713. private static _FresnelEnabled;
  23714. /**
  23715. * Are fresnels enabled in the application.
  23716. */
  23717. static get FresnelEnabled(): boolean;
  23718. static set FresnelEnabled(value: boolean);
  23719. private static _ClearCoatTextureEnabled;
  23720. /**
  23721. * Are clear coat textures enabled in the application.
  23722. */
  23723. static get ClearCoatTextureEnabled(): boolean;
  23724. static set ClearCoatTextureEnabled(value: boolean);
  23725. private static _ClearCoatBumpTextureEnabled;
  23726. /**
  23727. * Are clear coat bump textures enabled in the application.
  23728. */
  23729. static get ClearCoatBumpTextureEnabled(): boolean;
  23730. static set ClearCoatBumpTextureEnabled(value: boolean);
  23731. private static _ClearCoatTintTextureEnabled;
  23732. /**
  23733. * Are clear coat tint textures enabled in the application.
  23734. */
  23735. static get ClearCoatTintTextureEnabled(): boolean;
  23736. static set ClearCoatTintTextureEnabled(value: boolean);
  23737. private static _SheenTextureEnabled;
  23738. /**
  23739. * Are sheen textures enabled in the application.
  23740. */
  23741. static get SheenTextureEnabled(): boolean;
  23742. static set SheenTextureEnabled(value: boolean);
  23743. private static _AnisotropicTextureEnabled;
  23744. /**
  23745. * Are anisotropic textures enabled in the application.
  23746. */
  23747. static get AnisotropicTextureEnabled(): boolean;
  23748. static set AnisotropicTextureEnabled(value: boolean);
  23749. private static _ThicknessTextureEnabled;
  23750. /**
  23751. * Are thickness textures enabled in the application.
  23752. */
  23753. static get ThicknessTextureEnabled(): boolean;
  23754. static set ThicknessTextureEnabled(value: boolean);
  23755. }
  23756. }
  23757. declare module BABYLON {
  23758. /** @hidden */
  23759. export var defaultFragmentDeclaration: {
  23760. name: string;
  23761. shader: string;
  23762. };
  23763. }
  23764. declare module BABYLON {
  23765. /** @hidden */
  23766. export var defaultUboDeclaration: {
  23767. name: string;
  23768. shader: string;
  23769. };
  23770. }
  23771. declare module BABYLON {
  23772. /** @hidden */
  23773. export var prePassDeclaration: {
  23774. name: string;
  23775. shader: string;
  23776. };
  23777. }
  23778. declare module BABYLON {
  23779. /** @hidden */
  23780. export var lightFragmentDeclaration: {
  23781. name: string;
  23782. shader: string;
  23783. };
  23784. }
  23785. declare module BABYLON {
  23786. /** @hidden */
  23787. export var lightUboDeclaration: {
  23788. name: string;
  23789. shader: string;
  23790. };
  23791. }
  23792. declare module BABYLON {
  23793. /** @hidden */
  23794. export var lightsFragmentFunctions: {
  23795. name: string;
  23796. shader: string;
  23797. };
  23798. }
  23799. declare module BABYLON {
  23800. /** @hidden */
  23801. export var shadowsFragmentFunctions: {
  23802. name: string;
  23803. shader: string;
  23804. };
  23805. }
  23806. declare module BABYLON {
  23807. /** @hidden */
  23808. export var fresnelFunction: {
  23809. name: string;
  23810. shader: string;
  23811. };
  23812. }
  23813. declare module BABYLON {
  23814. /** @hidden */
  23815. export var bumpFragmentMainFunctions: {
  23816. name: string;
  23817. shader: string;
  23818. };
  23819. }
  23820. declare module BABYLON {
  23821. /** @hidden */
  23822. export var bumpFragmentFunctions: {
  23823. name: string;
  23824. shader: string;
  23825. };
  23826. }
  23827. declare module BABYLON {
  23828. /** @hidden */
  23829. export var logDepthDeclaration: {
  23830. name: string;
  23831. shader: string;
  23832. };
  23833. }
  23834. declare module BABYLON {
  23835. /** @hidden */
  23836. export var bumpFragment: {
  23837. name: string;
  23838. shader: string;
  23839. };
  23840. }
  23841. declare module BABYLON {
  23842. /** @hidden */
  23843. export var depthPrePass: {
  23844. name: string;
  23845. shader: string;
  23846. };
  23847. }
  23848. declare module BABYLON {
  23849. /** @hidden */
  23850. export var lightFragment: {
  23851. name: string;
  23852. shader: string;
  23853. };
  23854. }
  23855. declare module BABYLON {
  23856. /** @hidden */
  23857. export var logDepthFragment: {
  23858. name: string;
  23859. shader: string;
  23860. };
  23861. }
  23862. declare module BABYLON {
  23863. /** @hidden */
  23864. export var defaultPixelShader: {
  23865. name: string;
  23866. shader: string;
  23867. };
  23868. }
  23869. declare module BABYLON {
  23870. /** @hidden */
  23871. export var defaultVertexDeclaration: {
  23872. name: string;
  23873. shader: string;
  23874. };
  23875. }
  23876. declare module BABYLON {
  23877. /** @hidden */
  23878. export var prePassVertexDeclaration: {
  23879. name: string;
  23880. shader: string;
  23881. };
  23882. }
  23883. declare module BABYLON {
  23884. /** @hidden */
  23885. export var bumpVertexDeclaration: {
  23886. name: string;
  23887. shader: string;
  23888. };
  23889. }
  23890. declare module BABYLON {
  23891. /** @hidden */
  23892. export var prePassVertex: {
  23893. name: string;
  23894. shader: string;
  23895. };
  23896. }
  23897. declare module BABYLON {
  23898. /** @hidden */
  23899. export var bumpVertex: {
  23900. name: string;
  23901. shader: string;
  23902. };
  23903. }
  23904. declare module BABYLON {
  23905. /** @hidden */
  23906. export var fogVertex: {
  23907. name: string;
  23908. shader: string;
  23909. };
  23910. }
  23911. declare module BABYLON {
  23912. /** @hidden */
  23913. export var shadowsVertex: {
  23914. name: string;
  23915. shader: string;
  23916. };
  23917. }
  23918. declare module BABYLON {
  23919. /** @hidden */
  23920. export var pointCloudVertex: {
  23921. name: string;
  23922. shader: string;
  23923. };
  23924. }
  23925. declare module BABYLON {
  23926. /** @hidden */
  23927. export var logDepthVertex: {
  23928. name: string;
  23929. shader: string;
  23930. };
  23931. }
  23932. declare module BABYLON {
  23933. /** @hidden */
  23934. export var defaultVertexShader: {
  23935. name: string;
  23936. shader: string;
  23937. };
  23938. }
  23939. declare module BABYLON {
  23940. /**
  23941. * @hidden
  23942. */
  23943. export interface IMaterialDetailMapDefines {
  23944. DETAIL: boolean;
  23945. DETAILDIRECTUV: number;
  23946. DETAIL_NORMALBLENDMETHOD: number;
  23947. /** @hidden */
  23948. _areTexturesDirty: boolean;
  23949. }
  23950. /**
  23951. * Define the code related to the detail map parameters of a material
  23952. *
  23953. * Inspired from:
  23954. * Unity: https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@9.0/manual/Mask-Map-and-Detail-Map.html and https://docs.unity3d.com/Manual/StandardShaderMaterialParameterDetail.html
  23955. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  23956. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  23957. */
  23958. export class DetailMapConfiguration {
  23959. private _texture;
  23960. /**
  23961. * The detail texture of the material.
  23962. */
  23963. texture: Nullable<BaseTexture>;
  23964. /**
  23965. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  23966. * Bigger values mean stronger blending
  23967. */
  23968. diffuseBlendLevel: number;
  23969. /**
  23970. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  23971. * Bigger values mean stronger blending. Only used with PBR materials
  23972. */
  23973. roughnessBlendLevel: number;
  23974. /**
  23975. * Defines how strong the bump effect from the detail map is
  23976. * Bigger values mean stronger effect
  23977. */
  23978. bumpLevel: number;
  23979. private _normalBlendMethod;
  23980. /**
  23981. * The method used to blend the bump and detail normals together
  23982. */
  23983. normalBlendMethod: number;
  23984. private _isEnabled;
  23985. /**
  23986. * Enable or disable the detail map on this material
  23987. */
  23988. isEnabled: boolean;
  23989. /** @hidden */
  23990. private _internalMarkAllSubMeshesAsTexturesDirty;
  23991. /** @hidden */
  23992. _markAllSubMeshesAsTexturesDirty(): void;
  23993. /**
  23994. * Instantiate a new detail map
  23995. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  23996. */
  23997. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  23998. /**
  23999. * Gets whether the submesh is ready to be used or not.
  24000. * @param defines the list of "defines" to update.
  24001. * @param scene defines the scene the material belongs to.
  24002. * @returns - boolean indicating that the submesh is ready or not.
  24003. */
  24004. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  24005. /**
  24006. * Update the defines for detail map usage
  24007. * @param defines the list of "defines" to update.
  24008. * @param scene defines the scene the material belongs to.
  24009. */
  24010. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  24011. /**
  24012. * Binds the material data.
  24013. * @param uniformBuffer defines the Uniform buffer to fill in.
  24014. * @param scene defines the scene the material belongs to.
  24015. * @param isFrozen defines whether the material is frozen or not.
  24016. */
  24017. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24018. /**
  24019. * Checks to see if a texture is used in the material.
  24020. * @param texture - Base texture to use.
  24021. * @returns - Boolean specifying if a texture is used in the material.
  24022. */
  24023. hasTexture(texture: BaseTexture): boolean;
  24024. /**
  24025. * Returns an array of the actively used textures.
  24026. * @param activeTextures Array of BaseTextures
  24027. */
  24028. getActiveTextures(activeTextures: BaseTexture[]): void;
  24029. /**
  24030. * Returns the animatable textures.
  24031. * @param animatables Array of animatable textures.
  24032. */
  24033. getAnimatables(animatables: IAnimatable[]): void;
  24034. /**
  24035. * Disposes the resources of the material.
  24036. * @param forceDisposeTextures - Forces the disposal of all textures.
  24037. */
  24038. dispose(forceDisposeTextures?: boolean): void;
  24039. /**
  24040. * Get the current class name useful for serialization or dynamic coding.
  24041. * @returns "DetailMap"
  24042. */
  24043. getClassName(): string;
  24044. /**
  24045. * Add the required uniforms to the current list.
  24046. * @param uniforms defines the current uniform list.
  24047. */
  24048. static AddUniforms(uniforms: string[]): void;
  24049. /**
  24050. * Add the required samplers to the current list.
  24051. * @param samplers defines the current sampler list.
  24052. */
  24053. static AddSamplers(samplers: string[]): void;
  24054. /**
  24055. * Add the required uniforms to the current buffer.
  24056. * @param uniformBuffer defines the current uniform buffer.
  24057. */
  24058. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24059. /**
  24060. * Makes a duplicate of the current instance into another one.
  24061. * @param detailMap define the instance where to copy the info
  24062. */
  24063. copyTo(detailMap: DetailMapConfiguration): void;
  24064. /**
  24065. * Serializes this detail map instance
  24066. * @returns - An object with the serialized instance.
  24067. */
  24068. serialize(): any;
  24069. /**
  24070. * Parses a detail map setting from a serialized object.
  24071. * @param source - Serialized object.
  24072. * @param scene Defines the scene we are parsing for
  24073. * @param rootUrl Defines the rootUrl to load from
  24074. */
  24075. parse(source: any, scene: Scene, rootUrl: string): void;
  24076. }
  24077. }
  24078. declare module BABYLON {
  24079. /** @hidden */
  24080. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24081. MAINUV1: boolean;
  24082. MAINUV2: boolean;
  24083. DIFFUSE: boolean;
  24084. DIFFUSEDIRECTUV: number;
  24085. DETAIL: boolean;
  24086. DETAILDIRECTUV: number;
  24087. DETAIL_NORMALBLENDMETHOD: number;
  24088. AMBIENT: boolean;
  24089. AMBIENTDIRECTUV: number;
  24090. OPACITY: boolean;
  24091. OPACITYDIRECTUV: number;
  24092. OPACITYRGB: boolean;
  24093. REFLECTION: boolean;
  24094. EMISSIVE: boolean;
  24095. EMISSIVEDIRECTUV: number;
  24096. SPECULAR: boolean;
  24097. SPECULARDIRECTUV: number;
  24098. BUMP: boolean;
  24099. BUMPDIRECTUV: number;
  24100. PARALLAX: boolean;
  24101. PARALLAXOCCLUSION: boolean;
  24102. SPECULAROVERALPHA: boolean;
  24103. CLIPPLANE: boolean;
  24104. CLIPPLANE2: boolean;
  24105. CLIPPLANE3: boolean;
  24106. CLIPPLANE4: boolean;
  24107. CLIPPLANE5: boolean;
  24108. CLIPPLANE6: boolean;
  24109. ALPHATEST: boolean;
  24110. DEPTHPREPASS: boolean;
  24111. ALPHAFROMDIFFUSE: boolean;
  24112. POINTSIZE: boolean;
  24113. FOG: boolean;
  24114. SPECULARTERM: boolean;
  24115. DIFFUSEFRESNEL: boolean;
  24116. OPACITYFRESNEL: boolean;
  24117. REFLECTIONFRESNEL: boolean;
  24118. REFRACTIONFRESNEL: boolean;
  24119. EMISSIVEFRESNEL: boolean;
  24120. FRESNEL: boolean;
  24121. NORMAL: boolean;
  24122. UV1: boolean;
  24123. UV2: boolean;
  24124. VERTEXCOLOR: boolean;
  24125. VERTEXALPHA: boolean;
  24126. NUM_BONE_INFLUENCERS: number;
  24127. BonesPerMesh: number;
  24128. BONETEXTURE: boolean;
  24129. BONES_VELOCITY_ENABLED: boolean;
  24130. INSTANCES: boolean;
  24131. THIN_INSTANCES: boolean;
  24132. GLOSSINESS: boolean;
  24133. ROUGHNESS: boolean;
  24134. EMISSIVEASILLUMINATION: boolean;
  24135. LINKEMISSIVEWITHDIFFUSE: boolean;
  24136. REFLECTIONFRESNELFROMSPECULAR: boolean;
  24137. LIGHTMAP: boolean;
  24138. LIGHTMAPDIRECTUV: number;
  24139. OBJECTSPACE_NORMALMAP: boolean;
  24140. USELIGHTMAPASSHADOWMAP: boolean;
  24141. REFLECTIONMAP_3D: boolean;
  24142. REFLECTIONMAP_SPHERICAL: boolean;
  24143. REFLECTIONMAP_PLANAR: boolean;
  24144. REFLECTIONMAP_CUBIC: boolean;
  24145. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  24146. REFLECTIONMAP_PROJECTION: boolean;
  24147. REFLECTIONMAP_SKYBOX: boolean;
  24148. REFLECTIONMAP_EXPLICIT: boolean;
  24149. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  24150. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  24151. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  24152. INVERTCUBICMAP: boolean;
  24153. LOGARITHMICDEPTH: boolean;
  24154. REFRACTION: boolean;
  24155. REFRACTIONMAP_3D: boolean;
  24156. REFLECTIONOVERALPHA: boolean;
  24157. TWOSIDEDLIGHTING: boolean;
  24158. SHADOWFLOAT: boolean;
  24159. MORPHTARGETS: boolean;
  24160. MORPHTARGETS_NORMAL: boolean;
  24161. MORPHTARGETS_TANGENT: boolean;
  24162. MORPHTARGETS_UV: boolean;
  24163. NUM_MORPH_INFLUENCERS: number;
  24164. NONUNIFORMSCALING: boolean;
  24165. PREMULTIPLYALPHA: boolean;
  24166. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  24167. ALPHABLEND: boolean;
  24168. PREPASS: boolean;
  24169. PREPASS_IRRADIANCE: boolean;
  24170. PREPASS_IRRADIANCE_INDEX: number;
  24171. PREPASS_ALBEDO: boolean;
  24172. PREPASS_ALBEDO_INDEX: number;
  24173. PREPASS_DEPTHNORMAL: boolean;
  24174. PREPASS_DEPTHNORMAL_INDEX: number;
  24175. PREPASS_POSITION: boolean;
  24176. PREPASS_POSITION_INDEX: number;
  24177. PREPASS_VELOCITY: boolean;
  24178. PREPASS_VELOCITY_INDEX: number;
  24179. PREPASS_REFLECTIVITY: boolean;
  24180. PREPASS_REFLECTIVITY_INDEX: number;
  24181. SCENE_MRT_COUNT: number;
  24182. RGBDLIGHTMAP: boolean;
  24183. RGBDREFLECTION: boolean;
  24184. RGBDREFRACTION: boolean;
  24185. IMAGEPROCESSING: boolean;
  24186. VIGNETTE: boolean;
  24187. VIGNETTEBLENDMODEMULTIPLY: boolean;
  24188. VIGNETTEBLENDMODEOPAQUE: boolean;
  24189. TONEMAPPING: boolean;
  24190. TONEMAPPING_ACES: boolean;
  24191. CONTRAST: boolean;
  24192. COLORCURVES: boolean;
  24193. COLORGRADING: boolean;
  24194. COLORGRADING3D: boolean;
  24195. SAMPLER3DGREENDEPTH: boolean;
  24196. SAMPLER3DBGRMAP: boolean;
  24197. IMAGEPROCESSINGPOSTPROCESS: boolean;
  24198. MULTIVIEW: boolean;
  24199. /**
  24200. * If the reflection texture on this material is in linear color space
  24201. * @hidden
  24202. */
  24203. IS_REFLECTION_LINEAR: boolean;
  24204. /**
  24205. * If the refraction texture on this material is in linear color space
  24206. * @hidden
  24207. */
  24208. IS_REFRACTION_LINEAR: boolean;
  24209. EXPOSURE: boolean;
  24210. constructor();
  24211. setReflectionMode(modeToEnable: string): void;
  24212. }
  24213. /**
  24214. * This is the default material used in Babylon. It is the best trade off between quality
  24215. * and performances.
  24216. * @see https://doc.babylonjs.com/babylon101/materials
  24217. */
  24218. export class StandardMaterial extends PushMaterial {
  24219. private _diffuseTexture;
  24220. /**
  24221. * The basic texture of the material as viewed under a light.
  24222. */
  24223. diffuseTexture: Nullable<BaseTexture>;
  24224. private _ambientTexture;
  24225. /**
  24226. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  24227. */
  24228. ambientTexture: Nullable<BaseTexture>;
  24229. private _opacityTexture;
  24230. /**
  24231. * Define the transparency of the material from a texture.
  24232. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  24233. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  24234. */
  24235. opacityTexture: Nullable<BaseTexture>;
  24236. private _reflectionTexture;
  24237. /**
  24238. * Define the texture used to display the reflection.
  24239. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24240. */
  24241. reflectionTexture: Nullable<BaseTexture>;
  24242. private _emissiveTexture;
  24243. /**
  24244. * Define texture of the material as if self lit.
  24245. * This will be mixed in the final result even in the absence of light.
  24246. */
  24247. emissiveTexture: Nullable<BaseTexture>;
  24248. private _specularTexture;
  24249. /**
  24250. * Define how the color and intensity of the highlight given by the light in the material.
  24251. */
  24252. specularTexture: Nullable<BaseTexture>;
  24253. private _bumpTexture;
  24254. /**
  24255. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  24256. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  24257. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  24258. */
  24259. bumpTexture: Nullable<BaseTexture>;
  24260. private _lightmapTexture;
  24261. /**
  24262. * Complex lighting can be computationally expensive to compute at runtime.
  24263. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  24264. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  24265. */
  24266. lightmapTexture: Nullable<BaseTexture>;
  24267. private _refractionTexture;
  24268. /**
  24269. * Define the texture used to display the refraction.
  24270. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24271. */
  24272. refractionTexture: Nullable<BaseTexture>;
  24273. /**
  24274. * The color of the material lit by the environmental background lighting.
  24275. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  24276. */
  24277. ambientColor: Color3;
  24278. /**
  24279. * The basic color of the material as viewed under a light.
  24280. */
  24281. diffuseColor: Color3;
  24282. /**
  24283. * Define how the color and intensity of the highlight given by the light in the material.
  24284. */
  24285. specularColor: Color3;
  24286. /**
  24287. * Define the color of the material as if self lit.
  24288. * This will be mixed in the final result even in the absence of light.
  24289. */
  24290. emissiveColor: Color3;
  24291. /**
  24292. * Defines how sharp are the highlights in the material.
  24293. * The bigger the value the sharper giving a more glossy feeling to the result.
  24294. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24295. */
  24296. specularPower: number;
  24297. private _useAlphaFromDiffuseTexture;
  24298. /**
  24299. * Does the transparency come from the diffuse texture alpha channel.
  24300. */
  24301. useAlphaFromDiffuseTexture: boolean;
  24302. private _useEmissiveAsIllumination;
  24303. /**
  24304. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24305. */
  24306. useEmissiveAsIllumination: boolean;
  24307. private _linkEmissiveWithDiffuse;
  24308. /**
  24309. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24310. * the emissive level when the final color is close to one.
  24311. */
  24312. linkEmissiveWithDiffuse: boolean;
  24313. private _useSpecularOverAlpha;
  24314. /**
  24315. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24316. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24317. */
  24318. useSpecularOverAlpha: boolean;
  24319. private _useReflectionOverAlpha;
  24320. /**
  24321. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24322. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24323. */
  24324. useReflectionOverAlpha: boolean;
  24325. private _disableLighting;
  24326. /**
  24327. * Does lights from the scene impacts this material.
  24328. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24329. */
  24330. disableLighting: boolean;
  24331. private _useObjectSpaceNormalMap;
  24332. /**
  24333. * Allows using an object space normal map (instead of tangent space).
  24334. */
  24335. useObjectSpaceNormalMap: boolean;
  24336. private _useParallax;
  24337. /**
  24338. * Is parallax enabled or not.
  24339. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24340. */
  24341. useParallax: boolean;
  24342. private _useParallaxOcclusion;
  24343. /**
  24344. * Is parallax occlusion enabled or not.
  24345. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24346. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24347. */
  24348. useParallaxOcclusion: boolean;
  24349. /**
  24350. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  24351. */
  24352. parallaxScaleBias: number;
  24353. private _roughness;
  24354. /**
  24355. * Helps to define how blurry the reflections should appears in the material.
  24356. */
  24357. roughness: number;
  24358. /**
  24359. * In case of refraction, define the value of the index of refraction.
  24360. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24361. */
  24362. indexOfRefraction: number;
  24363. /**
  24364. * Invert the refraction texture alongside the y axis.
  24365. * It can be useful with procedural textures or probe for instance.
  24366. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24367. */
  24368. invertRefractionY: boolean;
  24369. /**
  24370. * Defines the alpha limits in alpha test mode.
  24371. */
  24372. alphaCutOff: number;
  24373. private _useLightmapAsShadowmap;
  24374. /**
  24375. * In case of light mapping, define whether the map contains light or shadow informations.
  24376. */
  24377. useLightmapAsShadowmap: boolean;
  24378. private _diffuseFresnelParameters;
  24379. /**
  24380. * Define the diffuse fresnel parameters of the material.
  24381. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24382. */
  24383. diffuseFresnelParameters: FresnelParameters;
  24384. private _opacityFresnelParameters;
  24385. /**
  24386. * Define the opacity fresnel parameters of the material.
  24387. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24388. */
  24389. opacityFresnelParameters: FresnelParameters;
  24390. private _reflectionFresnelParameters;
  24391. /**
  24392. * Define the reflection fresnel parameters of the material.
  24393. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24394. */
  24395. reflectionFresnelParameters: FresnelParameters;
  24396. private _refractionFresnelParameters;
  24397. /**
  24398. * Define the refraction fresnel parameters of the material.
  24399. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24400. */
  24401. refractionFresnelParameters: FresnelParameters;
  24402. private _emissiveFresnelParameters;
  24403. /**
  24404. * Define the emissive fresnel parameters of the material.
  24405. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24406. */
  24407. emissiveFresnelParameters: FresnelParameters;
  24408. private _useReflectionFresnelFromSpecular;
  24409. /**
  24410. * If true automatically deducts the fresnels values from the material specularity.
  24411. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24412. */
  24413. useReflectionFresnelFromSpecular: boolean;
  24414. private _useGlossinessFromSpecularMapAlpha;
  24415. /**
  24416. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  24417. */
  24418. useGlossinessFromSpecularMapAlpha: boolean;
  24419. private _maxSimultaneousLights;
  24420. /**
  24421. * Defines the maximum number of lights that can be used in the material
  24422. */
  24423. maxSimultaneousLights: number;
  24424. private _invertNormalMapX;
  24425. /**
  24426. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  24427. */
  24428. invertNormalMapX: boolean;
  24429. private _invertNormalMapY;
  24430. /**
  24431. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  24432. */
  24433. invertNormalMapY: boolean;
  24434. private _twoSidedLighting;
  24435. /**
  24436. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  24437. */
  24438. twoSidedLighting: boolean;
  24439. /**
  24440. * Default configuration related to image processing available in the standard Material.
  24441. */
  24442. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24443. /**
  24444. * Gets the image processing configuration used either in this material.
  24445. */
  24446. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24447. /**
  24448. * Sets the Default image processing configuration used either in the this material.
  24449. *
  24450. * If sets to null, the scene one is in use.
  24451. */
  24452. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24453. /**
  24454. * Keep track of the image processing observer to allow dispose and replace.
  24455. */
  24456. private _imageProcessingObserver;
  24457. /**
  24458. * Attaches a new image processing configuration to the Standard Material.
  24459. * @param configuration
  24460. */
  24461. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24462. /**
  24463. * Defines additionnal PrePass parameters for the material.
  24464. */
  24465. readonly prePassConfiguration: PrePassConfiguration;
  24466. /**
  24467. * Gets wether the color curves effect is enabled.
  24468. */
  24469. get cameraColorCurvesEnabled(): boolean;
  24470. /**
  24471. * Sets wether the color curves effect is enabled.
  24472. */
  24473. set cameraColorCurvesEnabled(value: boolean);
  24474. /**
  24475. * Gets wether the color grading effect is enabled.
  24476. */
  24477. get cameraColorGradingEnabled(): boolean;
  24478. /**
  24479. * Gets wether the color grading effect is enabled.
  24480. */
  24481. set cameraColorGradingEnabled(value: boolean);
  24482. /**
  24483. * Gets wether tonemapping is enabled or not.
  24484. */
  24485. get cameraToneMappingEnabled(): boolean;
  24486. /**
  24487. * Sets wether tonemapping is enabled or not
  24488. */
  24489. set cameraToneMappingEnabled(value: boolean);
  24490. /**
  24491. * The camera exposure used on this material.
  24492. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24493. * This corresponds to a photographic exposure.
  24494. */
  24495. get cameraExposure(): number;
  24496. /**
  24497. * The camera exposure used on this material.
  24498. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24499. * This corresponds to a photographic exposure.
  24500. */
  24501. set cameraExposure(value: number);
  24502. /**
  24503. * Gets The camera contrast used on this material.
  24504. */
  24505. get cameraContrast(): number;
  24506. /**
  24507. * Sets The camera contrast used on this material.
  24508. */
  24509. set cameraContrast(value: number);
  24510. /**
  24511. * Gets the Color Grading 2D Lookup Texture.
  24512. */
  24513. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  24514. /**
  24515. * Sets the Color Grading 2D Lookup Texture.
  24516. */
  24517. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  24518. /**
  24519. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24520. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24521. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  24522. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24523. */
  24524. get cameraColorCurves(): Nullable<ColorCurves>;
  24525. /**
  24526. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24527. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24528. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  24529. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24530. */
  24531. set cameraColorCurves(value: Nullable<ColorCurves>);
  24532. /**
  24533. * Can this material render to several textures at once
  24534. */
  24535. get canRenderToMRT(): boolean;
  24536. /**
  24537. * Defines the detail map parameters for the material.
  24538. */
  24539. readonly detailMap: DetailMapConfiguration;
  24540. protected _renderTargets: SmartArray<RenderTargetTexture>;
  24541. protected _worldViewProjectionMatrix: Matrix;
  24542. protected _globalAmbientColor: Color3;
  24543. protected _useLogarithmicDepth: boolean;
  24544. protected _rebuildInParallel: boolean;
  24545. /**
  24546. * Instantiates a new standard material.
  24547. * This is the default material used in Babylon. It is the best trade off between quality
  24548. * and performances.
  24549. * @see https://doc.babylonjs.com/babylon101/materials
  24550. * @param name Define the name of the material in the scene
  24551. * @param scene Define the scene the material belong to
  24552. */
  24553. constructor(name: string, scene: Scene);
  24554. /**
  24555. * Gets a boolean indicating that current material needs to register RTT
  24556. */
  24557. get hasRenderTargetTextures(): boolean;
  24558. /**
  24559. * Gets the current class name of the material e.g. "StandardMaterial"
  24560. * Mainly use in serialization.
  24561. * @returns the class name
  24562. */
  24563. getClassName(): string;
  24564. /**
  24565. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  24566. * You can try switching to logarithmic depth.
  24567. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  24568. */
  24569. get useLogarithmicDepth(): boolean;
  24570. set useLogarithmicDepth(value: boolean);
  24571. /**
  24572. * Specifies if the material will require alpha blending
  24573. * @returns a boolean specifying if alpha blending is needed
  24574. */
  24575. needAlphaBlending(): boolean;
  24576. /**
  24577. * Specifies if this material should be rendered in alpha test mode
  24578. * @returns a boolean specifying if an alpha test is needed.
  24579. */
  24580. needAlphaTesting(): boolean;
  24581. /**
  24582. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  24583. */
  24584. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  24585. /**
  24586. * Specifies whether or not there is a usable alpha channel for transparency.
  24587. */
  24588. protected _hasAlphaChannel(): boolean;
  24589. /**
  24590. * Get the texture used for alpha test purpose.
  24591. * @returns the diffuse texture in case of the standard material.
  24592. */
  24593. getAlphaTestTexture(): Nullable<BaseTexture>;
  24594. /**
  24595. * Get if the submesh is ready to be used and all its information available.
  24596. * Child classes can use it to update shaders
  24597. * @param mesh defines the mesh to check
  24598. * @param subMesh defines which submesh to check
  24599. * @param useInstances specifies that instances should be used
  24600. * @returns a boolean indicating that the submesh is ready or not
  24601. */
  24602. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24603. /**
  24604. * Builds the material UBO layouts.
  24605. * Used internally during the effect preparation.
  24606. */
  24607. buildUniformLayout(): void;
  24608. /**
  24609. * Unbinds the material from the mesh
  24610. */
  24611. unbind(): void;
  24612. /**
  24613. * Binds the submesh to this material by preparing the effect and shader to draw
  24614. * @param world defines the world transformation matrix
  24615. * @param mesh defines the mesh containing the submesh
  24616. * @param subMesh defines the submesh to bind the material to
  24617. */
  24618. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24619. /**
  24620. * Get the list of animatables in the material.
  24621. * @returns the list of animatables object used in the material
  24622. */
  24623. getAnimatables(): IAnimatable[];
  24624. /**
  24625. * Gets the active textures from the material
  24626. * @returns an array of textures
  24627. */
  24628. getActiveTextures(): BaseTexture[];
  24629. /**
  24630. * Specifies if the material uses a texture
  24631. * @param texture defines the texture to check against the material
  24632. * @returns a boolean specifying if the material uses the texture
  24633. */
  24634. hasTexture(texture: BaseTexture): boolean;
  24635. /**
  24636. * Disposes the material
  24637. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24638. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24639. */
  24640. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  24641. /**
  24642. * Makes a duplicate of the material, and gives it a new name
  24643. * @param name defines the new name for the duplicated material
  24644. * @returns the cloned material
  24645. */
  24646. clone(name: string): StandardMaterial;
  24647. /**
  24648. * Serializes this material in a JSON representation
  24649. * @returns the serialized material object
  24650. */
  24651. serialize(): any;
  24652. /**
  24653. * Creates a standard material from parsed material data
  24654. * @param source defines the JSON representation of the material
  24655. * @param scene defines the hosting scene
  24656. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24657. * @returns a new standard material
  24658. */
  24659. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  24660. /**
  24661. * Are diffuse textures enabled in the application.
  24662. */
  24663. static get DiffuseTextureEnabled(): boolean;
  24664. static set DiffuseTextureEnabled(value: boolean);
  24665. /**
  24666. * Are detail textures enabled in the application.
  24667. */
  24668. static get DetailTextureEnabled(): boolean;
  24669. static set DetailTextureEnabled(value: boolean);
  24670. /**
  24671. * Are ambient textures enabled in the application.
  24672. */
  24673. static get AmbientTextureEnabled(): boolean;
  24674. static set AmbientTextureEnabled(value: boolean);
  24675. /**
  24676. * Are opacity textures enabled in the application.
  24677. */
  24678. static get OpacityTextureEnabled(): boolean;
  24679. static set OpacityTextureEnabled(value: boolean);
  24680. /**
  24681. * Are reflection textures enabled in the application.
  24682. */
  24683. static get ReflectionTextureEnabled(): boolean;
  24684. static set ReflectionTextureEnabled(value: boolean);
  24685. /**
  24686. * Are emissive textures enabled in the application.
  24687. */
  24688. static get EmissiveTextureEnabled(): boolean;
  24689. static set EmissiveTextureEnabled(value: boolean);
  24690. /**
  24691. * Are specular textures enabled in the application.
  24692. */
  24693. static get SpecularTextureEnabled(): boolean;
  24694. static set SpecularTextureEnabled(value: boolean);
  24695. /**
  24696. * Are bump textures enabled in the application.
  24697. */
  24698. static get BumpTextureEnabled(): boolean;
  24699. static set BumpTextureEnabled(value: boolean);
  24700. /**
  24701. * Are lightmap textures enabled in the application.
  24702. */
  24703. static get LightmapTextureEnabled(): boolean;
  24704. static set LightmapTextureEnabled(value: boolean);
  24705. /**
  24706. * Are refraction textures enabled in the application.
  24707. */
  24708. static get RefractionTextureEnabled(): boolean;
  24709. static set RefractionTextureEnabled(value: boolean);
  24710. /**
  24711. * Are color grading textures enabled in the application.
  24712. */
  24713. static get ColorGradingTextureEnabled(): boolean;
  24714. static set ColorGradingTextureEnabled(value: boolean);
  24715. /**
  24716. * Are fresnels enabled in the application.
  24717. */
  24718. static get FresnelEnabled(): boolean;
  24719. static set FresnelEnabled(value: boolean);
  24720. }
  24721. }
  24722. declare module BABYLON {
  24723. /** @hidden */
  24724. export var rgbdDecodePixelShader: {
  24725. name: string;
  24726. shader: string;
  24727. };
  24728. }
  24729. declare module BABYLON {
  24730. /**
  24731. * Class used to host RGBD texture specific utilities
  24732. */
  24733. export class RGBDTextureTools {
  24734. /**
  24735. * Expand the RGBD Texture from RGBD to Half Float if possible.
  24736. * @param texture the texture to expand.
  24737. */
  24738. static ExpandRGBDTexture(texture: Texture): void;
  24739. }
  24740. }
  24741. declare module BABYLON {
  24742. /**
  24743. * Class used to host texture specific utilities
  24744. */
  24745. export class BRDFTextureTools {
  24746. /**
  24747. * Prevents texture cache collision
  24748. */
  24749. private static _instanceNumber;
  24750. /**
  24751. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  24752. * @param scene defines the hosting scene
  24753. * @returns the environment BRDF texture
  24754. */
  24755. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  24756. private static _environmentBRDFBase64Texture;
  24757. }
  24758. }
  24759. declare module BABYLON {
  24760. /**
  24761. * @hidden
  24762. */
  24763. export interface IMaterialClearCoatDefines {
  24764. CLEARCOAT: boolean;
  24765. CLEARCOAT_DEFAULTIOR: boolean;
  24766. CLEARCOAT_TEXTURE: boolean;
  24767. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  24768. CLEARCOAT_TEXTUREDIRECTUV: number;
  24769. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  24770. CLEARCOAT_BUMP: boolean;
  24771. CLEARCOAT_BUMPDIRECTUV: number;
  24772. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  24773. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  24774. CLEARCOAT_REMAP_F0: boolean;
  24775. CLEARCOAT_TINT: boolean;
  24776. CLEARCOAT_TINT_TEXTURE: boolean;
  24777. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  24778. /** @hidden */
  24779. _areTexturesDirty: boolean;
  24780. }
  24781. /**
  24782. * Define the code related to the clear coat parameters of the pbr material.
  24783. */
  24784. export class PBRClearCoatConfiguration {
  24785. /**
  24786. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24787. * The default fits with a polyurethane material.
  24788. */
  24789. private static readonly _DefaultIndexOfRefraction;
  24790. private _isEnabled;
  24791. /**
  24792. * Defines if the clear coat is enabled in the material.
  24793. */
  24794. isEnabled: boolean;
  24795. /**
  24796. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  24797. */
  24798. intensity: number;
  24799. /**
  24800. * Defines the clear coat layer roughness.
  24801. */
  24802. roughness: number;
  24803. private _indexOfRefraction;
  24804. /**
  24805. * Defines the index of refraction of the clear coat.
  24806. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24807. * The default fits with a polyurethane material.
  24808. * Changing the default value is more performance intensive.
  24809. */
  24810. indexOfRefraction: number;
  24811. private _texture;
  24812. /**
  24813. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  24814. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  24815. * if textureRoughness is not empty, else no texture roughness is used
  24816. */
  24817. texture: Nullable<BaseTexture>;
  24818. private _useRoughnessFromMainTexture;
  24819. /**
  24820. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  24821. * If false, the green channel from textureRoughness is used for roughness
  24822. */
  24823. useRoughnessFromMainTexture: boolean;
  24824. private _textureRoughness;
  24825. /**
  24826. * Stores the clear coat roughness in a texture (green channel)
  24827. * Not used if useRoughnessFromMainTexture is true
  24828. */
  24829. textureRoughness: Nullable<BaseTexture>;
  24830. private _remapF0OnInterfaceChange;
  24831. /**
  24832. * Defines if the F0 value should be remapped to account for the interface change in the material.
  24833. */
  24834. remapF0OnInterfaceChange: boolean;
  24835. private _bumpTexture;
  24836. /**
  24837. * Define the clear coat specific bump texture.
  24838. */
  24839. bumpTexture: Nullable<BaseTexture>;
  24840. private _isTintEnabled;
  24841. /**
  24842. * Defines if the clear coat tint is enabled in the material.
  24843. */
  24844. isTintEnabled: boolean;
  24845. /**
  24846. * Defines the clear coat tint of the material.
  24847. * This is only use if tint is enabled
  24848. */
  24849. tintColor: Color3;
  24850. /**
  24851. * Defines the distance at which the tint color should be found in the
  24852. * clear coat media.
  24853. * This is only use if tint is enabled
  24854. */
  24855. tintColorAtDistance: number;
  24856. /**
  24857. * Defines the clear coat layer thickness.
  24858. * This is only use if tint is enabled
  24859. */
  24860. tintThickness: number;
  24861. private _tintTexture;
  24862. /**
  24863. * Stores the clear tint values in a texture.
  24864. * rgb is tint
  24865. * a is a thickness factor
  24866. */
  24867. tintTexture: Nullable<BaseTexture>;
  24868. /** @hidden */
  24869. private _internalMarkAllSubMeshesAsTexturesDirty;
  24870. /** @hidden */
  24871. _markAllSubMeshesAsTexturesDirty(): void;
  24872. /**
  24873. * Instantiate a new istance of clear coat configuration.
  24874. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24875. */
  24876. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24877. /**
  24878. * Gets wehter the submesh is ready to be used or not.
  24879. * @param defines the list of "defines" to update.
  24880. * @param scene defines the scene the material belongs to.
  24881. * @param engine defines the engine the material belongs to.
  24882. * @param disableBumpMap defines wether the material disables bump or not.
  24883. * @returns - boolean indicating that the submesh is ready or not.
  24884. */
  24885. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  24886. /**
  24887. * Checks to see if a texture is used in the material.
  24888. * @param defines the list of "defines" to update.
  24889. * @param scene defines the scene to the material belongs to.
  24890. */
  24891. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  24892. /**
  24893. * Binds the material data.
  24894. * @param uniformBuffer defines the Uniform buffer to fill in.
  24895. * @param scene defines the scene the material belongs to.
  24896. * @param engine defines the engine the material belongs to.
  24897. * @param disableBumpMap defines wether the material disables bump or not.
  24898. * @param isFrozen defines wether the material is frozen or not.
  24899. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  24900. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  24901. * @param subMesh the submesh to bind data for
  24902. */
  24903. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  24904. /**
  24905. * Checks to see if a texture is used in the material.
  24906. * @param texture - Base texture to use.
  24907. * @returns - Boolean specifying if a texture is used in the material.
  24908. */
  24909. hasTexture(texture: BaseTexture): boolean;
  24910. /**
  24911. * Returns an array of the actively used textures.
  24912. * @param activeTextures Array of BaseTextures
  24913. */
  24914. getActiveTextures(activeTextures: BaseTexture[]): void;
  24915. /**
  24916. * Returns the animatable textures.
  24917. * @param animatables Array of animatable textures.
  24918. */
  24919. getAnimatables(animatables: IAnimatable[]): void;
  24920. /**
  24921. * Disposes the resources of the material.
  24922. * @param forceDisposeTextures - Forces the disposal of all textures.
  24923. */
  24924. dispose(forceDisposeTextures?: boolean): void;
  24925. /**
  24926. * Get the current class name of the texture useful for serialization or dynamic coding.
  24927. * @returns "PBRClearCoatConfiguration"
  24928. */
  24929. getClassName(): string;
  24930. /**
  24931. * Add fallbacks to the effect fallbacks list.
  24932. * @param defines defines the Base texture to use.
  24933. * @param fallbacks defines the current fallback list.
  24934. * @param currentRank defines the current fallback rank.
  24935. * @returns the new fallback rank.
  24936. */
  24937. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24938. /**
  24939. * Add the required uniforms to the current list.
  24940. * @param uniforms defines the current uniform list.
  24941. */
  24942. static AddUniforms(uniforms: string[]): void;
  24943. /**
  24944. * Add the required samplers to the current list.
  24945. * @param samplers defines the current sampler list.
  24946. */
  24947. static AddSamplers(samplers: string[]): void;
  24948. /**
  24949. * Add the required uniforms to the current buffer.
  24950. * @param uniformBuffer defines the current uniform buffer.
  24951. */
  24952. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24953. /**
  24954. * Makes a duplicate of the current configuration into another one.
  24955. * @param clearCoatConfiguration define the config where to copy the info
  24956. */
  24957. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  24958. /**
  24959. * Serializes this clear coat configuration.
  24960. * @returns - An object with the serialized config.
  24961. */
  24962. serialize(): any;
  24963. /**
  24964. * Parses a anisotropy Configuration from a serialized object.
  24965. * @param source - Serialized object.
  24966. * @param scene Defines the scene we are parsing for
  24967. * @param rootUrl Defines the rootUrl to load from
  24968. */
  24969. parse(source: any, scene: Scene, rootUrl: string): void;
  24970. }
  24971. }
  24972. declare module BABYLON {
  24973. /**
  24974. * @hidden
  24975. */
  24976. export interface IMaterialAnisotropicDefines {
  24977. ANISOTROPIC: boolean;
  24978. ANISOTROPIC_TEXTURE: boolean;
  24979. ANISOTROPIC_TEXTUREDIRECTUV: number;
  24980. MAINUV1: boolean;
  24981. _areTexturesDirty: boolean;
  24982. _needUVs: boolean;
  24983. }
  24984. /**
  24985. * Define the code related to the anisotropic parameters of the pbr material.
  24986. */
  24987. export class PBRAnisotropicConfiguration {
  24988. private _isEnabled;
  24989. /**
  24990. * Defines if the anisotropy is enabled in the material.
  24991. */
  24992. isEnabled: boolean;
  24993. /**
  24994. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  24995. */
  24996. intensity: number;
  24997. /**
  24998. * Defines if the effect is along the tangents, bitangents or in between.
  24999. * By default, the effect is "strectching" the highlights along the tangents.
  25000. */
  25001. direction: Vector2;
  25002. private _texture;
  25003. /**
  25004. * Stores the anisotropy values in a texture.
  25005. * rg is direction (like normal from -1 to 1)
  25006. * b is a intensity
  25007. */
  25008. texture: Nullable<BaseTexture>;
  25009. /** @hidden */
  25010. private _internalMarkAllSubMeshesAsTexturesDirty;
  25011. /** @hidden */
  25012. _markAllSubMeshesAsTexturesDirty(): void;
  25013. /**
  25014. * Instantiate a new istance of anisotropy configuration.
  25015. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25016. */
  25017. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25018. /**
  25019. * Specifies that the submesh is ready to be used.
  25020. * @param defines the list of "defines" to update.
  25021. * @param scene defines the scene the material belongs to.
  25022. * @returns - boolean indicating that the submesh is ready or not.
  25023. */
  25024. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25025. /**
  25026. * Checks to see if a texture is used in the material.
  25027. * @param defines the list of "defines" to update.
  25028. * @param mesh the mesh we are preparing the defines for.
  25029. * @param scene defines the scene the material belongs to.
  25030. */
  25031. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25032. /**
  25033. * Binds the material data.
  25034. * @param uniformBuffer defines the Uniform buffer to fill in.
  25035. * @param scene defines the scene the material belongs to.
  25036. * @param isFrozen defines wether the material is frozen or not.
  25037. */
  25038. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25039. /**
  25040. * Checks to see if a texture is used in the material.
  25041. * @param texture - Base texture to use.
  25042. * @returns - Boolean specifying if a texture is used in the material.
  25043. */
  25044. hasTexture(texture: BaseTexture): boolean;
  25045. /**
  25046. * Returns an array of the actively used textures.
  25047. * @param activeTextures Array of BaseTextures
  25048. */
  25049. getActiveTextures(activeTextures: BaseTexture[]): void;
  25050. /**
  25051. * Returns the animatable textures.
  25052. * @param animatables Array of animatable textures.
  25053. */
  25054. getAnimatables(animatables: IAnimatable[]): void;
  25055. /**
  25056. * Disposes the resources of the material.
  25057. * @param forceDisposeTextures - Forces the disposal of all textures.
  25058. */
  25059. dispose(forceDisposeTextures?: boolean): void;
  25060. /**
  25061. * Get the current class name of the texture useful for serialization or dynamic coding.
  25062. * @returns "PBRAnisotropicConfiguration"
  25063. */
  25064. getClassName(): string;
  25065. /**
  25066. * Add fallbacks to the effect fallbacks list.
  25067. * @param defines defines the Base texture to use.
  25068. * @param fallbacks defines the current fallback list.
  25069. * @param currentRank defines the current fallback rank.
  25070. * @returns the new fallback rank.
  25071. */
  25072. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25073. /**
  25074. * Add the required uniforms to the current list.
  25075. * @param uniforms defines the current uniform list.
  25076. */
  25077. static AddUniforms(uniforms: string[]): void;
  25078. /**
  25079. * Add the required uniforms to the current buffer.
  25080. * @param uniformBuffer defines the current uniform buffer.
  25081. */
  25082. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25083. /**
  25084. * Add the required samplers to the current list.
  25085. * @param samplers defines the current sampler list.
  25086. */
  25087. static AddSamplers(samplers: string[]): void;
  25088. /**
  25089. * Makes a duplicate of the current configuration into another one.
  25090. * @param anisotropicConfiguration define the config where to copy the info
  25091. */
  25092. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  25093. /**
  25094. * Serializes this anisotropy configuration.
  25095. * @returns - An object with the serialized config.
  25096. */
  25097. serialize(): any;
  25098. /**
  25099. * Parses a anisotropy Configuration from a serialized object.
  25100. * @param source - Serialized object.
  25101. * @param scene Defines the scene we are parsing for
  25102. * @param rootUrl Defines the rootUrl to load from
  25103. */
  25104. parse(source: any, scene: Scene, rootUrl: string): void;
  25105. }
  25106. }
  25107. declare module BABYLON {
  25108. /**
  25109. * @hidden
  25110. */
  25111. export interface IMaterialBRDFDefines {
  25112. BRDF_V_HEIGHT_CORRELATED: boolean;
  25113. MS_BRDF_ENERGY_CONSERVATION: boolean;
  25114. SPHERICAL_HARMONICS: boolean;
  25115. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  25116. /** @hidden */
  25117. _areMiscDirty: boolean;
  25118. }
  25119. /**
  25120. * Define the code related to the BRDF parameters of the pbr material.
  25121. */
  25122. export class PBRBRDFConfiguration {
  25123. /**
  25124. * Default value used for the energy conservation.
  25125. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25126. */
  25127. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  25128. /**
  25129. * Default value used for the Smith Visibility Height Correlated mode.
  25130. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  25131. */
  25132. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  25133. /**
  25134. * Default value used for the IBL diffuse part.
  25135. * This can help switching back to the polynomials mode globally which is a tiny bit
  25136. * less GPU intensive at the drawback of a lower quality.
  25137. */
  25138. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  25139. /**
  25140. * Default value used for activating energy conservation for the specular workflow.
  25141. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25142. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25143. */
  25144. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  25145. private _useEnergyConservation;
  25146. /**
  25147. * Defines if the material uses energy conservation.
  25148. */
  25149. useEnergyConservation: boolean;
  25150. private _useSmithVisibilityHeightCorrelated;
  25151. /**
  25152. * LEGACY Mode set to false
  25153. * Defines if the material uses height smith correlated visibility term.
  25154. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  25155. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  25156. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  25157. * Not relying on height correlated will also disable energy conservation.
  25158. */
  25159. useSmithVisibilityHeightCorrelated: boolean;
  25160. private _useSphericalHarmonics;
  25161. /**
  25162. * LEGACY Mode set to false
  25163. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  25164. * diffuse part of the IBL.
  25165. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  25166. * to the ground truth.
  25167. */
  25168. useSphericalHarmonics: boolean;
  25169. private _useSpecularGlossinessInputEnergyConservation;
  25170. /**
  25171. * Defines if the material uses energy conservation, when the specular workflow is active.
  25172. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  25173. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  25174. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  25175. */
  25176. useSpecularGlossinessInputEnergyConservation: boolean;
  25177. /** @hidden */
  25178. private _internalMarkAllSubMeshesAsMiscDirty;
  25179. /** @hidden */
  25180. _markAllSubMeshesAsMiscDirty(): void;
  25181. /**
  25182. * Instantiate a new istance of clear coat configuration.
  25183. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  25184. */
  25185. constructor(markAllSubMeshesAsMiscDirty: () => void);
  25186. /**
  25187. * Checks to see if a texture is used in the material.
  25188. * @param defines the list of "defines" to update.
  25189. */
  25190. prepareDefines(defines: IMaterialBRDFDefines): void;
  25191. /**
  25192. * Get the current class name of the texture useful for serialization or dynamic coding.
  25193. * @returns "PBRClearCoatConfiguration"
  25194. */
  25195. getClassName(): string;
  25196. /**
  25197. * Makes a duplicate of the current configuration into another one.
  25198. * @param brdfConfiguration define the config where to copy the info
  25199. */
  25200. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  25201. /**
  25202. * Serializes this BRDF configuration.
  25203. * @returns - An object with the serialized config.
  25204. */
  25205. serialize(): any;
  25206. /**
  25207. * Parses a anisotropy Configuration from a serialized object.
  25208. * @param source - Serialized object.
  25209. * @param scene Defines the scene we are parsing for
  25210. * @param rootUrl Defines the rootUrl to load from
  25211. */
  25212. parse(source: any, scene: Scene, rootUrl: string): void;
  25213. }
  25214. }
  25215. declare module BABYLON {
  25216. /**
  25217. * @hidden
  25218. */
  25219. export interface IMaterialSheenDefines {
  25220. SHEEN: boolean;
  25221. SHEEN_TEXTURE: boolean;
  25222. SHEEN_TEXTURE_ROUGHNESS: boolean;
  25223. SHEEN_TEXTUREDIRECTUV: number;
  25224. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  25225. SHEEN_LINKWITHALBEDO: boolean;
  25226. SHEEN_ROUGHNESS: boolean;
  25227. SHEEN_ALBEDOSCALING: boolean;
  25228. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25229. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25230. /** @hidden */
  25231. _areTexturesDirty: boolean;
  25232. }
  25233. /**
  25234. * Define the code related to the Sheen parameters of the pbr material.
  25235. */
  25236. export class PBRSheenConfiguration {
  25237. private _isEnabled;
  25238. /**
  25239. * Defines if the material uses sheen.
  25240. */
  25241. isEnabled: boolean;
  25242. private _linkSheenWithAlbedo;
  25243. /**
  25244. * Defines if the sheen is linked to the sheen color.
  25245. */
  25246. linkSheenWithAlbedo: boolean;
  25247. /**
  25248. * Defines the sheen intensity.
  25249. */
  25250. intensity: number;
  25251. /**
  25252. * Defines the sheen color.
  25253. */
  25254. color: Color3;
  25255. private _texture;
  25256. /**
  25257. * Stores the sheen tint values in a texture.
  25258. * rgb is tint
  25259. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  25260. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  25261. */
  25262. texture: Nullable<BaseTexture>;
  25263. private _useRoughnessFromMainTexture;
  25264. /**
  25265. * Indicates that the alpha channel of the texture property will be used for roughness.
  25266. * Has no effect if the roughness (and texture!) property is not defined
  25267. */
  25268. useRoughnessFromMainTexture: boolean;
  25269. private _roughness;
  25270. /**
  25271. * Defines the sheen roughness.
  25272. * It is not taken into account if linkSheenWithAlbedo is true.
  25273. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  25274. */
  25275. roughness: Nullable<number>;
  25276. private _textureRoughness;
  25277. /**
  25278. * Stores the sheen roughness in a texture.
  25279. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  25280. */
  25281. textureRoughness: Nullable<BaseTexture>;
  25282. private _albedoScaling;
  25283. /**
  25284. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  25285. * It allows the strength of the sheen effect to not depend on the base color of the material,
  25286. * making it easier to setup and tweak the effect
  25287. */
  25288. albedoScaling: boolean;
  25289. /** @hidden */
  25290. private _internalMarkAllSubMeshesAsTexturesDirty;
  25291. /** @hidden */
  25292. _markAllSubMeshesAsTexturesDirty(): void;
  25293. /**
  25294. * Instantiate a new istance of clear coat configuration.
  25295. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25296. */
  25297. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25298. /**
  25299. * Specifies that the submesh is ready to be used.
  25300. * @param defines the list of "defines" to update.
  25301. * @param scene defines the scene the material belongs to.
  25302. * @returns - boolean indicating that the submesh is ready or not.
  25303. */
  25304. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  25305. /**
  25306. * Checks to see if a texture is used in the material.
  25307. * @param defines the list of "defines" to update.
  25308. * @param scene defines the scene the material belongs to.
  25309. */
  25310. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  25311. /**
  25312. * Binds the material data.
  25313. * @param uniformBuffer defines the Uniform buffer to fill in.
  25314. * @param scene defines the scene the material belongs to.
  25315. * @param isFrozen defines wether the material is frozen or not.
  25316. * @param subMesh the submesh to bind data for
  25317. */
  25318. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  25319. /**
  25320. * Checks to see if a texture is used in the material.
  25321. * @param texture - Base texture to use.
  25322. * @returns - Boolean specifying if a texture is used in the material.
  25323. */
  25324. hasTexture(texture: BaseTexture): boolean;
  25325. /**
  25326. * Returns an array of the actively used textures.
  25327. * @param activeTextures Array of BaseTextures
  25328. */
  25329. getActiveTextures(activeTextures: BaseTexture[]): void;
  25330. /**
  25331. * Returns the animatable textures.
  25332. * @param animatables Array of animatable textures.
  25333. */
  25334. getAnimatables(animatables: IAnimatable[]): void;
  25335. /**
  25336. * Disposes the resources of the material.
  25337. * @param forceDisposeTextures - Forces the disposal of all textures.
  25338. */
  25339. dispose(forceDisposeTextures?: boolean): void;
  25340. /**
  25341. * Get the current class name of the texture useful for serialization or dynamic coding.
  25342. * @returns "PBRSheenConfiguration"
  25343. */
  25344. getClassName(): string;
  25345. /**
  25346. * Add fallbacks to the effect fallbacks list.
  25347. * @param defines defines the Base texture to use.
  25348. * @param fallbacks defines the current fallback list.
  25349. * @param currentRank defines the current fallback rank.
  25350. * @returns the new fallback rank.
  25351. */
  25352. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25353. /**
  25354. * Add the required uniforms to the current list.
  25355. * @param uniforms defines the current uniform list.
  25356. */
  25357. static AddUniforms(uniforms: string[]): void;
  25358. /**
  25359. * Add the required uniforms to the current buffer.
  25360. * @param uniformBuffer defines the current uniform buffer.
  25361. */
  25362. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25363. /**
  25364. * Add the required samplers to the current list.
  25365. * @param samplers defines the current sampler list.
  25366. */
  25367. static AddSamplers(samplers: string[]): void;
  25368. /**
  25369. * Makes a duplicate of the current configuration into another one.
  25370. * @param sheenConfiguration define the config where to copy the info
  25371. */
  25372. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  25373. /**
  25374. * Serializes this BRDF configuration.
  25375. * @returns - An object with the serialized config.
  25376. */
  25377. serialize(): any;
  25378. /**
  25379. * Parses a anisotropy Configuration from a serialized object.
  25380. * @param source - Serialized object.
  25381. * @param scene Defines the scene we are parsing for
  25382. * @param rootUrl Defines the rootUrl to load from
  25383. */
  25384. parse(source: any, scene: Scene, rootUrl: string): void;
  25385. }
  25386. }
  25387. declare module BABYLON {
  25388. /**
  25389. * @hidden
  25390. */
  25391. export interface IMaterialSubSurfaceDefines {
  25392. SUBSURFACE: boolean;
  25393. SS_REFRACTION: boolean;
  25394. SS_TRANSLUCENCY: boolean;
  25395. SS_SCATTERING: boolean;
  25396. SS_THICKNESSANDMASK_TEXTURE: boolean;
  25397. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  25398. SS_REFRACTIONMAP_3D: boolean;
  25399. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  25400. SS_LODINREFRACTIONALPHA: boolean;
  25401. SS_GAMMAREFRACTION: boolean;
  25402. SS_RGBDREFRACTION: boolean;
  25403. SS_LINEARSPECULARREFRACTION: boolean;
  25404. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  25405. SS_ALBEDOFORREFRACTIONTINT: boolean;
  25406. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  25407. /** @hidden */
  25408. _areTexturesDirty: boolean;
  25409. }
  25410. /**
  25411. * Define the code related to the sub surface parameters of the pbr material.
  25412. */
  25413. export class PBRSubSurfaceConfiguration {
  25414. private _isRefractionEnabled;
  25415. /**
  25416. * Defines if the refraction is enabled in the material.
  25417. */
  25418. isRefractionEnabled: boolean;
  25419. private _isTranslucencyEnabled;
  25420. /**
  25421. * Defines if the translucency is enabled in the material.
  25422. */
  25423. isTranslucencyEnabled: boolean;
  25424. private _isScatteringEnabled;
  25425. /**
  25426. * Defines if the sub surface scattering is enabled in the material.
  25427. */
  25428. isScatteringEnabled: boolean;
  25429. private _scatteringDiffusionProfileIndex;
  25430. /**
  25431. * Diffusion profile for subsurface scattering.
  25432. * Useful for better scattering in the skins or foliages.
  25433. */
  25434. get scatteringDiffusionProfile(): Nullable<Color3>;
  25435. set scatteringDiffusionProfile(c: Nullable<Color3>);
  25436. /**
  25437. * Defines the refraction intensity of the material.
  25438. * The refraction when enabled replaces the Diffuse part of the material.
  25439. * The intensity helps transitionning between diffuse and refraction.
  25440. */
  25441. refractionIntensity: number;
  25442. /**
  25443. * Defines the translucency intensity of the material.
  25444. * When translucency has been enabled, this defines how much of the "translucency"
  25445. * is addded to the diffuse part of the material.
  25446. */
  25447. translucencyIntensity: number;
  25448. /**
  25449. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  25450. */
  25451. useAlbedoToTintRefraction: boolean;
  25452. private _thicknessTexture;
  25453. /**
  25454. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  25455. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  25456. * 0 would mean minimumThickness
  25457. * 1 would mean maximumThickness
  25458. * The other channels might be use as a mask to vary the different effects intensity.
  25459. */
  25460. thicknessTexture: Nullable<BaseTexture>;
  25461. private _refractionTexture;
  25462. /**
  25463. * Defines the texture to use for refraction.
  25464. */
  25465. refractionTexture: Nullable<BaseTexture>;
  25466. private _indexOfRefraction;
  25467. /**
  25468. * Index of refraction of the material base layer.
  25469. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25470. *
  25471. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  25472. *
  25473. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  25474. */
  25475. indexOfRefraction: number;
  25476. private _volumeIndexOfRefraction;
  25477. /**
  25478. * Index of refraction of the material's volume.
  25479. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25480. *
  25481. * This ONLY impacts refraction. If not provided or given a non-valid value,
  25482. * the volume will use the same IOR as the surface.
  25483. */
  25484. get volumeIndexOfRefraction(): number;
  25485. set volumeIndexOfRefraction(value: number);
  25486. private _invertRefractionY;
  25487. /**
  25488. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  25489. */
  25490. invertRefractionY: boolean;
  25491. private _linkRefractionWithTransparency;
  25492. /**
  25493. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25494. * Materials half opaque for instance using refraction could benefit from this control.
  25495. */
  25496. linkRefractionWithTransparency: boolean;
  25497. /**
  25498. * Defines the minimum thickness stored in the thickness map.
  25499. * If no thickness map is defined, this value will be used to simulate thickness.
  25500. */
  25501. minimumThickness: number;
  25502. /**
  25503. * Defines the maximum thickness stored in the thickness map.
  25504. */
  25505. maximumThickness: number;
  25506. /**
  25507. * Defines the volume tint of the material.
  25508. * This is used for both translucency and scattering.
  25509. */
  25510. tintColor: Color3;
  25511. /**
  25512. * Defines the distance at which the tint color should be found in the media.
  25513. * This is used for refraction only.
  25514. */
  25515. tintColorAtDistance: number;
  25516. /**
  25517. * Defines how far each channel transmit through the media.
  25518. * It is defined as a color to simplify it selection.
  25519. */
  25520. diffusionDistance: Color3;
  25521. private _useMaskFromThicknessTexture;
  25522. /**
  25523. * Stores the intensity of the different subsurface effects in the thickness texture.
  25524. * * the green channel is the translucency intensity.
  25525. * * the blue channel is the scattering intensity.
  25526. * * the alpha channel is the refraction intensity.
  25527. */
  25528. useMaskFromThicknessTexture: boolean;
  25529. private _scene;
  25530. /** @hidden */
  25531. private _internalMarkAllSubMeshesAsTexturesDirty;
  25532. private _internalMarkScenePrePassDirty;
  25533. /** @hidden */
  25534. _markAllSubMeshesAsTexturesDirty(): void;
  25535. /** @hidden */
  25536. _markScenePrePassDirty(): void;
  25537. /**
  25538. * Instantiate a new istance of sub surface configuration.
  25539. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25540. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  25541. * @param scene The scene
  25542. */
  25543. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  25544. /**
  25545. * Gets wehter the submesh is ready to be used or not.
  25546. * @param defines the list of "defines" to update.
  25547. * @param scene defines the scene the material belongs to.
  25548. * @returns - boolean indicating that the submesh is ready or not.
  25549. */
  25550. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  25551. /**
  25552. * Checks to see if a texture is used in the material.
  25553. * @param defines the list of "defines" to update.
  25554. * @param scene defines the scene to the material belongs to.
  25555. */
  25556. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  25557. /**
  25558. * Binds the material data.
  25559. * @param uniformBuffer defines the Uniform buffer to fill in.
  25560. * @param scene defines the scene the material belongs to.
  25561. * @param engine defines the engine the material belongs to.
  25562. * @param isFrozen defines whether the material is frozen or not.
  25563. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  25564. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  25565. */
  25566. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  25567. /**
  25568. * Unbinds the material from the mesh.
  25569. * @param activeEffect defines the effect that should be unbound from.
  25570. * @returns true if unbound, otherwise false
  25571. */
  25572. unbind(activeEffect: Effect): boolean;
  25573. /**
  25574. * Returns the texture used for refraction or null if none is used.
  25575. * @param scene defines the scene the material belongs to.
  25576. * @returns - Refraction texture if present. If no refraction texture and refraction
  25577. * is linked with transparency, returns environment texture. Otherwise, returns null.
  25578. */
  25579. private _getRefractionTexture;
  25580. /**
  25581. * Returns true if alpha blending should be disabled.
  25582. */
  25583. get disableAlphaBlending(): boolean;
  25584. /**
  25585. * Fills the list of render target textures.
  25586. * @param renderTargets the list of render targets to update
  25587. */
  25588. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  25589. /**
  25590. * Checks to see if a texture is used in the material.
  25591. * @param texture - Base texture to use.
  25592. * @returns - Boolean specifying if a texture is used in the material.
  25593. */
  25594. hasTexture(texture: BaseTexture): boolean;
  25595. /**
  25596. * Gets a boolean indicating that current material needs to register RTT
  25597. * @returns true if this uses a render target otherwise false.
  25598. */
  25599. hasRenderTargetTextures(): boolean;
  25600. /**
  25601. * Returns an array of the actively used textures.
  25602. * @param activeTextures Array of BaseTextures
  25603. */
  25604. getActiveTextures(activeTextures: BaseTexture[]): void;
  25605. /**
  25606. * Returns the animatable textures.
  25607. * @param animatables Array of animatable textures.
  25608. */
  25609. getAnimatables(animatables: IAnimatable[]): void;
  25610. /**
  25611. * Disposes the resources of the material.
  25612. * @param forceDisposeTextures - Forces the disposal of all textures.
  25613. */
  25614. dispose(forceDisposeTextures?: boolean): void;
  25615. /**
  25616. * Get the current class name of the texture useful for serialization or dynamic coding.
  25617. * @returns "PBRSubSurfaceConfiguration"
  25618. */
  25619. getClassName(): string;
  25620. /**
  25621. * Add fallbacks to the effect fallbacks list.
  25622. * @param defines defines the Base texture to use.
  25623. * @param fallbacks defines the current fallback list.
  25624. * @param currentRank defines the current fallback rank.
  25625. * @returns the new fallback rank.
  25626. */
  25627. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25628. /**
  25629. * Add the required uniforms to the current list.
  25630. * @param uniforms defines the current uniform list.
  25631. */
  25632. static AddUniforms(uniforms: string[]): void;
  25633. /**
  25634. * Add the required samplers to the current list.
  25635. * @param samplers defines the current sampler list.
  25636. */
  25637. static AddSamplers(samplers: string[]): void;
  25638. /**
  25639. * Add the required uniforms to the current buffer.
  25640. * @param uniformBuffer defines the current uniform buffer.
  25641. */
  25642. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25643. /**
  25644. * Makes a duplicate of the current configuration into another one.
  25645. * @param configuration define the config where to copy the info
  25646. */
  25647. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  25648. /**
  25649. * Serializes this Sub Surface configuration.
  25650. * @returns - An object with the serialized config.
  25651. */
  25652. serialize(): any;
  25653. /**
  25654. * Parses a anisotropy Configuration from a serialized object.
  25655. * @param source - Serialized object.
  25656. * @param scene Defines the scene we are parsing for
  25657. * @param rootUrl Defines the rootUrl to load from
  25658. */
  25659. parse(source: any, scene: Scene, rootUrl: string): void;
  25660. }
  25661. }
  25662. declare module BABYLON {
  25663. /**
  25664. * Class representing spherical harmonics coefficients to the 3rd degree
  25665. */
  25666. export class SphericalHarmonics {
  25667. /**
  25668. * Defines whether or not the harmonics have been prescaled for rendering.
  25669. */
  25670. preScaled: boolean;
  25671. /**
  25672. * The l0,0 coefficients of the spherical harmonics
  25673. */
  25674. l00: Vector3;
  25675. /**
  25676. * The l1,-1 coefficients of the spherical harmonics
  25677. */
  25678. l1_1: Vector3;
  25679. /**
  25680. * The l1,0 coefficients of the spherical harmonics
  25681. */
  25682. l10: Vector3;
  25683. /**
  25684. * The l1,1 coefficients of the spherical harmonics
  25685. */
  25686. l11: Vector3;
  25687. /**
  25688. * The l2,-2 coefficients of the spherical harmonics
  25689. */
  25690. l2_2: Vector3;
  25691. /**
  25692. * The l2,-1 coefficients of the spherical harmonics
  25693. */
  25694. l2_1: Vector3;
  25695. /**
  25696. * The l2,0 coefficients of the spherical harmonics
  25697. */
  25698. l20: Vector3;
  25699. /**
  25700. * The l2,1 coefficients of the spherical harmonics
  25701. */
  25702. l21: Vector3;
  25703. /**
  25704. * The l2,2 coefficients of the spherical harmonics
  25705. */
  25706. l22: Vector3;
  25707. /**
  25708. * Adds a light to the spherical harmonics
  25709. * @param direction the direction of the light
  25710. * @param color the color of the light
  25711. * @param deltaSolidAngle the delta solid angle of the light
  25712. */
  25713. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  25714. /**
  25715. * Scales the spherical harmonics by the given amount
  25716. * @param scale the amount to scale
  25717. */
  25718. scaleInPlace(scale: number): void;
  25719. /**
  25720. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  25721. *
  25722. * ```
  25723. * E_lm = A_l * L_lm
  25724. * ```
  25725. *
  25726. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  25727. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  25728. * the scaling factors are given in equation 9.
  25729. */
  25730. convertIncidentRadianceToIrradiance(): void;
  25731. /**
  25732. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  25733. *
  25734. * ```
  25735. * L = (1/pi) * E * rho
  25736. * ```
  25737. *
  25738. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  25739. */
  25740. convertIrradianceToLambertianRadiance(): void;
  25741. /**
  25742. * Integrates the reconstruction coefficients directly in to the SH preventing further
  25743. * required operations at run time.
  25744. *
  25745. * This is simply done by scaling back the SH with Ylm constants parameter.
  25746. * The trigonometric part being applied by the shader at run time.
  25747. */
  25748. preScaleForRendering(): void;
  25749. /**
  25750. * Constructs a spherical harmonics from an array.
  25751. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  25752. * @returns the spherical harmonics
  25753. */
  25754. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  25755. /**
  25756. * Gets the spherical harmonics from polynomial
  25757. * @param polynomial the spherical polynomial
  25758. * @returns the spherical harmonics
  25759. */
  25760. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  25761. }
  25762. /**
  25763. * Class representing spherical polynomial coefficients to the 3rd degree
  25764. */
  25765. export class SphericalPolynomial {
  25766. private _harmonics;
  25767. /**
  25768. * The spherical harmonics used to create the polynomials.
  25769. */
  25770. get preScaledHarmonics(): SphericalHarmonics;
  25771. /**
  25772. * The x coefficients of the spherical polynomial
  25773. */
  25774. x: Vector3;
  25775. /**
  25776. * The y coefficients of the spherical polynomial
  25777. */
  25778. y: Vector3;
  25779. /**
  25780. * The z coefficients of the spherical polynomial
  25781. */
  25782. z: Vector3;
  25783. /**
  25784. * The xx coefficients of the spherical polynomial
  25785. */
  25786. xx: Vector3;
  25787. /**
  25788. * The yy coefficients of the spherical polynomial
  25789. */
  25790. yy: Vector3;
  25791. /**
  25792. * The zz coefficients of the spherical polynomial
  25793. */
  25794. zz: Vector3;
  25795. /**
  25796. * The xy coefficients of the spherical polynomial
  25797. */
  25798. xy: Vector3;
  25799. /**
  25800. * The yz coefficients of the spherical polynomial
  25801. */
  25802. yz: Vector3;
  25803. /**
  25804. * The zx coefficients of the spherical polynomial
  25805. */
  25806. zx: Vector3;
  25807. /**
  25808. * Adds an ambient color to the spherical polynomial
  25809. * @param color the color to add
  25810. */
  25811. addAmbient(color: Color3): void;
  25812. /**
  25813. * Scales the spherical polynomial by the given amount
  25814. * @param scale the amount to scale
  25815. */
  25816. scaleInPlace(scale: number): void;
  25817. /**
  25818. * Gets the spherical polynomial from harmonics
  25819. * @param harmonics the spherical harmonics
  25820. * @returns the spherical polynomial
  25821. */
  25822. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  25823. /**
  25824. * Constructs a spherical polynomial from an array.
  25825. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  25826. * @returns the spherical polynomial
  25827. */
  25828. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  25829. }
  25830. }
  25831. declare module BABYLON {
  25832. /**
  25833. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  25834. */
  25835. export interface CubeMapInfo {
  25836. /**
  25837. * The pixel array for the front face.
  25838. * This is stored in format, left to right, up to down format.
  25839. */
  25840. front: Nullable<ArrayBufferView>;
  25841. /**
  25842. * The pixel array for the back face.
  25843. * This is stored in format, left to right, up to down format.
  25844. */
  25845. back: Nullable<ArrayBufferView>;
  25846. /**
  25847. * The pixel array for the left face.
  25848. * This is stored in format, left to right, up to down format.
  25849. */
  25850. left: Nullable<ArrayBufferView>;
  25851. /**
  25852. * The pixel array for the right face.
  25853. * This is stored in format, left to right, up to down format.
  25854. */
  25855. right: Nullable<ArrayBufferView>;
  25856. /**
  25857. * The pixel array for the up face.
  25858. * This is stored in format, left to right, up to down format.
  25859. */
  25860. up: Nullable<ArrayBufferView>;
  25861. /**
  25862. * The pixel array for the down face.
  25863. * This is stored in format, left to right, up to down format.
  25864. */
  25865. down: Nullable<ArrayBufferView>;
  25866. /**
  25867. * The size of the cubemap stored.
  25868. *
  25869. * Each faces will be size * size pixels.
  25870. */
  25871. size: number;
  25872. /**
  25873. * The format of the texture.
  25874. *
  25875. * RGBA, RGB.
  25876. */
  25877. format: number;
  25878. /**
  25879. * The type of the texture data.
  25880. *
  25881. * UNSIGNED_INT, FLOAT.
  25882. */
  25883. type: number;
  25884. /**
  25885. * Specifies whether the texture is in gamma space.
  25886. */
  25887. gammaSpace: boolean;
  25888. }
  25889. /**
  25890. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  25891. */
  25892. export class PanoramaToCubeMapTools {
  25893. private static FACE_LEFT;
  25894. private static FACE_RIGHT;
  25895. private static FACE_FRONT;
  25896. private static FACE_BACK;
  25897. private static FACE_DOWN;
  25898. private static FACE_UP;
  25899. /**
  25900. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  25901. *
  25902. * @param float32Array The source data.
  25903. * @param inputWidth The width of the input panorama.
  25904. * @param inputHeight The height of the input panorama.
  25905. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  25906. * @return The cubemap data
  25907. */
  25908. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  25909. private static CreateCubemapTexture;
  25910. private static CalcProjectionSpherical;
  25911. }
  25912. }
  25913. declare module BABYLON {
  25914. /**
  25915. * Helper class dealing with the extraction of spherical polynomial dataArray
  25916. * from a cube map.
  25917. */
  25918. export class CubeMapToSphericalPolynomialTools {
  25919. private static FileFaces;
  25920. /**
  25921. * Converts a texture to the according Spherical Polynomial data.
  25922. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25923. *
  25924. * @param texture The texture to extract the information from.
  25925. * @return The Spherical Polynomial data.
  25926. */
  25927. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  25928. /**
  25929. * Converts a cubemap to the according Spherical Polynomial data.
  25930. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25931. *
  25932. * @param cubeInfo The Cube map to extract the information from.
  25933. * @return The Spherical Polynomial data.
  25934. */
  25935. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  25936. }
  25937. }
  25938. declare module BABYLON {
  25939. interface BaseTexture {
  25940. /**
  25941. * Get the polynomial representation of the texture data.
  25942. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25943. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25944. */
  25945. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25946. }
  25947. }
  25948. declare module BABYLON {
  25949. /** @hidden */
  25950. export var pbrFragmentDeclaration: {
  25951. name: string;
  25952. shader: string;
  25953. };
  25954. }
  25955. declare module BABYLON {
  25956. /** @hidden */
  25957. export var pbrUboDeclaration: {
  25958. name: string;
  25959. shader: string;
  25960. };
  25961. }
  25962. declare module BABYLON {
  25963. /** @hidden */
  25964. export var pbrFragmentExtraDeclaration: {
  25965. name: string;
  25966. shader: string;
  25967. };
  25968. }
  25969. declare module BABYLON {
  25970. /** @hidden */
  25971. export var pbrFragmentSamplersDeclaration: {
  25972. name: string;
  25973. shader: string;
  25974. };
  25975. }
  25976. declare module BABYLON {
  25977. /** @hidden */
  25978. export var subSurfaceScatteringFunctions: {
  25979. name: string;
  25980. shader: string;
  25981. };
  25982. }
  25983. declare module BABYLON {
  25984. /** @hidden */
  25985. export var importanceSampling: {
  25986. name: string;
  25987. shader: string;
  25988. };
  25989. }
  25990. declare module BABYLON {
  25991. /** @hidden */
  25992. export var pbrHelperFunctions: {
  25993. name: string;
  25994. shader: string;
  25995. };
  25996. }
  25997. declare module BABYLON {
  25998. /** @hidden */
  25999. export var harmonicsFunctions: {
  26000. name: string;
  26001. shader: string;
  26002. };
  26003. }
  26004. declare module BABYLON {
  26005. /** @hidden */
  26006. export var pbrDirectLightingSetupFunctions: {
  26007. name: string;
  26008. shader: string;
  26009. };
  26010. }
  26011. declare module BABYLON {
  26012. /** @hidden */
  26013. export var pbrDirectLightingFalloffFunctions: {
  26014. name: string;
  26015. shader: string;
  26016. };
  26017. }
  26018. declare module BABYLON {
  26019. /** @hidden */
  26020. export var pbrBRDFFunctions: {
  26021. name: string;
  26022. shader: string;
  26023. };
  26024. }
  26025. declare module BABYLON {
  26026. /** @hidden */
  26027. export var hdrFilteringFunctions: {
  26028. name: string;
  26029. shader: string;
  26030. };
  26031. }
  26032. declare module BABYLON {
  26033. /** @hidden */
  26034. export var pbrDirectLightingFunctions: {
  26035. name: string;
  26036. shader: string;
  26037. };
  26038. }
  26039. declare module BABYLON {
  26040. /** @hidden */
  26041. export var pbrIBLFunctions: {
  26042. name: string;
  26043. shader: string;
  26044. };
  26045. }
  26046. declare module BABYLON {
  26047. /** @hidden */
  26048. export var pbrBlockAlbedoOpacity: {
  26049. name: string;
  26050. shader: string;
  26051. };
  26052. }
  26053. declare module BABYLON {
  26054. /** @hidden */
  26055. export var pbrBlockReflectivity: {
  26056. name: string;
  26057. shader: string;
  26058. };
  26059. }
  26060. declare module BABYLON {
  26061. /** @hidden */
  26062. export var pbrBlockAmbientOcclusion: {
  26063. name: string;
  26064. shader: string;
  26065. };
  26066. }
  26067. declare module BABYLON {
  26068. /** @hidden */
  26069. export var pbrBlockAlphaFresnel: {
  26070. name: string;
  26071. shader: string;
  26072. };
  26073. }
  26074. declare module BABYLON {
  26075. /** @hidden */
  26076. export var pbrBlockAnisotropic: {
  26077. name: string;
  26078. shader: string;
  26079. };
  26080. }
  26081. declare module BABYLON {
  26082. /** @hidden */
  26083. export var pbrBlockReflection: {
  26084. name: string;
  26085. shader: string;
  26086. };
  26087. }
  26088. declare module BABYLON {
  26089. /** @hidden */
  26090. export var pbrBlockSheen: {
  26091. name: string;
  26092. shader: string;
  26093. };
  26094. }
  26095. declare module BABYLON {
  26096. /** @hidden */
  26097. export var pbrBlockClearcoat: {
  26098. name: string;
  26099. shader: string;
  26100. };
  26101. }
  26102. declare module BABYLON {
  26103. /** @hidden */
  26104. export var pbrBlockSubSurface: {
  26105. name: string;
  26106. shader: string;
  26107. };
  26108. }
  26109. declare module BABYLON {
  26110. /** @hidden */
  26111. export var pbrBlockNormalGeometric: {
  26112. name: string;
  26113. shader: string;
  26114. };
  26115. }
  26116. declare module BABYLON {
  26117. /** @hidden */
  26118. export var pbrBlockNormalFinal: {
  26119. name: string;
  26120. shader: string;
  26121. };
  26122. }
  26123. declare module BABYLON {
  26124. /** @hidden */
  26125. export var pbrBlockLightmapInit: {
  26126. name: string;
  26127. shader: string;
  26128. };
  26129. }
  26130. declare module BABYLON {
  26131. /** @hidden */
  26132. export var pbrBlockGeometryInfo: {
  26133. name: string;
  26134. shader: string;
  26135. };
  26136. }
  26137. declare module BABYLON {
  26138. /** @hidden */
  26139. export var pbrBlockReflectance0: {
  26140. name: string;
  26141. shader: string;
  26142. };
  26143. }
  26144. declare module BABYLON {
  26145. /** @hidden */
  26146. export var pbrBlockReflectance: {
  26147. name: string;
  26148. shader: string;
  26149. };
  26150. }
  26151. declare module BABYLON {
  26152. /** @hidden */
  26153. export var pbrBlockDirectLighting: {
  26154. name: string;
  26155. shader: string;
  26156. };
  26157. }
  26158. declare module BABYLON {
  26159. /** @hidden */
  26160. export var pbrBlockFinalLitComponents: {
  26161. name: string;
  26162. shader: string;
  26163. };
  26164. }
  26165. declare module BABYLON {
  26166. /** @hidden */
  26167. export var pbrBlockFinalUnlitComponents: {
  26168. name: string;
  26169. shader: string;
  26170. };
  26171. }
  26172. declare module BABYLON {
  26173. /** @hidden */
  26174. export var pbrBlockFinalColorComposition: {
  26175. name: string;
  26176. shader: string;
  26177. };
  26178. }
  26179. declare module BABYLON {
  26180. /** @hidden */
  26181. export var pbrBlockImageProcessing: {
  26182. name: string;
  26183. shader: string;
  26184. };
  26185. }
  26186. declare module BABYLON {
  26187. /** @hidden */
  26188. export var pbrDebug: {
  26189. name: string;
  26190. shader: string;
  26191. };
  26192. }
  26193. declare module BABYLON {
  26194. /** @hidden */
  26195. export var pbrPixelShader: {
  26196. name: string;
  26197. shader: string;
  26198. };
  26199. }
  26200. declare module BABYLON {
  26201. /** @hidden */
  26202. export var pbrVertexDeclaration: {
  26203. name: string;
  26204. shader: string;
  26205. };
  26206. }
  26207. declare module BABYLON {
  26208. /** @hidden */
  26209. export var pbrVertexShader: {
  26210. name: string;
  26211. shader: string;
  26212. };
  26213. }
  26214. declare module BABYLON {
  26215. /**
  26216. * Manages the defines for the PBR Material.
  26217. * @hidden
  26218. */
  26219. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  26220. PBR: boolean;
  26221. NUM_SAMPLES: string;
  26222. REALTIME_FILTERING: boolean;
  26223. MAINUV1: boolean;
  26224. MAINUV2: boolean;
  26225. UV1: boolean;
  26226. UV2: boolean;
  26227. ALBEDO: boolean;
  26228. GAMMAALBEDO: boolean;
  26229. ALBEDODIRECTUV: number;
  26230. VERTEXCOLOR: boolean;
  26231. DETAIL: boolean;
  26232. DETAILDIRECTUV: number;
  26233. DETAIL_NORMALBLENDMETHOD: number;
  26234. AMBIENT: boolean;
  26235. AMBIENTDIRECTUV: number;
  26236. AMBIENTINGRAYSCALE: boolean;
  26237. OPACITY: boolean;
  26238. VERTEXALPHA: boolean;
  26239. OPACITYDIRECTUV: number;
  26240. OPACITYRGB: boolean;
  26241. ALPHATEST: boolean;
  26242. DEPTHPREPASS: boolean;
  26243. ALPHABLEND: boolean;
  26244. ALPHAFROMALBEDO: boolean;
  26245. ALPHATESTVALUE: string;
  26246. SPECULAROVERALPHA: boolean;
  26247. RADIANCEOVERALPHA: boolean;
  26248. ALPHAFRESNEL: boolean;
  26249. LINEARALPHAFRESNEL: boolean;
  26250. PREMULTIPLYALPHA: boolean;
  26251. EMISSIVE: boolean;
  26252. EMISSIVEDIRECTUV: number;
  26253. REFLECTIVITY: boolean;
  26254. REFLECTIVITYDIRECTUV: number;
  26255. SPECULARTERM: boolean;
  26256. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  26257. MICROSURFACEAUTOMATIC: boolean;
  26258. LODBASEDMICROSFURACE: boolean;
  26259. MICROSURFACEMAP: boolean;
  26260. MICROSURFACEMAPDIRECTUV: number;
  26261. METALLICWORKFLOW: boolean;
  26262. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  26263. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  26264. METALLNESSSTOREINMETALMAPBLUE: boolean;
  26265. AOSTOREINMETALMAPRED: boolean;
  26266. METALLIC_REFLECTANCE: boolean;
  26267. METALLIC_REFLECTANCEDIRECTUV: number;
  26268. ENVIRONMENTBRDF: boolean;
  26269. ENVIRONMENTBRDF_RGBD: boolean;
  26270. NORMAL: boolean;
  26271. TANGENT: boolean;
  26272. BUMP: boolean;
  26273. BUMPDIRECTUV: number;
  26274. OBJECTSPACE_NORMALMAP: boolean;
  26275. PARALLAX: boolean;
  26276. PARALLAXOCCLUSION: boolean;
  26277. NORMALXYSCALE: boolean;
  26278. LIGHTMAP: boolean;
  26279. LIGHTMAPDIRECTUV: number;
  26280. USELIGHTMAPASSHADOWMAP: boolean;
  26281. GAMMALIGHTMAP: boolean;
  26282. RGBDLIGHTMAP: boolean;
  26283. REFLECTION: boolean;
  26284. REFLECTIONMAP_3D: boolean;
  26285. REFLECTIONMAP_SPHERICAL: boolean;
  26286. REFLECTIONMAP_PLANAR: boolean;
  26287. REFLECTIONMAP_CUBIC: boolean;
  26288. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26289. REFLECTIONMAP_PROJECTION: boolean;
  26290. REFLECTIONMAP_SKYBOX: boolean;
  26291. REFLECTIONMAP_EXPLICIT: boolean;
  26292. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26293. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26294. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26295. INVERTCUBICMAP: boolean;
  26296. USESPHERICALFROMREFLECTIONMAP: boolean;
  26297. USEIRRADIANCEMAP: boolean;
  26298. SPHERICAL_HARMONICS: boolean;
  26299. USESPHERICALINVERTEX: boolean;
  26300. REFLECTIONMAP_OPPOSITEZ: boolean;
  26301. LODINREFLECTIONALPHA: boolean;
  26302. GAMMAREFLECTION: boolean;
  26303. RGBDREFLECTION: boolean;
  26304. LINEARSPECULARREFLECTION: boolean;
  26305. RADIANCEOCCLUSION: boolean;
  26306. HORIZONOCCLUSION: boolean;
  26307. INSTANCES: boolean;
  26308. THIN_INSTANCES: boolean;
  26309. PREPASS: boolean;
  26310. PREPASS_IRRADIANCE: boolean;
  26311. PREPASS_IRRADIANCE_INDEX: number;
  26312. PREPASS_ALBEDO: boolean;
  26313. PREPASS_ALBEDO_INDEX: number;
  26314. PREPASS_DEPTHNORMAL: boolean;
  26315. PREPASS_DEPTHNORMAL_INDEX: number;
  26316. PREPASS_POSITION: boolean;
  26317. PREPASS_POSITION_INDEX: number;
  26318. PREPASS_VELOCITY: boolean;
  26319. PREPASS_VELOCITY_INDEX: number;
  26320. PREPASS_REFLECTIVITY: boolean;
  26321. PREPASS_REFLECTIVITY_INDEX: number;
  26322. SCENE_MRT_COUNT: number;
  26323. NUM_BONE_INFLUENCERS: number;
  26324. BonesPerMesh: number;
  26325. BONETEXTURE: boolean;
  26326. BONES_VELOCITY_ENABLED: boolean;
  26327. NONUNIFORMSCALING: boolean;
  26328. MORPHTARGETS: boolean;
  26329. MORPHTARGETS_NORMAL: boolean;
  26330. MORPHTARGETS_TANGENT: boolean;
  26331. MORPHTARGETS_UV: boolean;
  26332. NUM_MORPH_INFLUENCERS: number;
  26333. IMAGEPROCESSING: boolean;
  26334. VIGNETTE: boolean;
  26335. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26336. VIGNETTEBLENDMODEOPAQUE: boolean;
  26337. TONEMAPPING: boolean;
  26338. TONEMAPPING_ACES: boolean;
  26339. CONTRAST: boolean;
  26340. COLORCURVES: boolean;
  26341. COLORGRADING: boolean;
  26342. COLORGRADING3D: boolean;
  26343. SAMPLER3DGREENDEPTH: boolean;
  26344. SAMPLER3DBGRMAP: boolean;
  26345. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26346. EXPOSURE: boolean;
  26347. MULTIVIEW: boolean;
  26348. USEPHYSICALLIGHTFALLOFF: boolean;
  26349. USEGLTFLIGHTFALLOFF: boolean;
  26350. TWOSIDEDLIGHTING: boolean;
  26351. SHADOWFLOAT: boolean;
  26352. CLIPPLANE: boolean;
  26353. CLIPPLANE2: boolean;
  26354. CLIPPLANE3: boolean;
  26355. CLIPPLANE4: boolean;
  26356. CLIPPLANE5: boolean;
  26357. CLIPPLANE6: boolean;
  26358. POINTSIZE: boolean;
  26359. FOG: boolean;
  26360. LOGARITHMICDEPTH: boolean;
  26361. FORCENORMALFORWARD: boolean;
  26362. SPECULARAA: boolean;
  26363. CLEARCOAT: boolean;
  26364. CLEARCOAT_DEFAULTIOR: boolean;
  26365. CLEARCOAT_TEXTURE: boolean;
  26366. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  26367. CLEARCOAT_TEXTUREDIRECTUV: number;
  26368. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  26369. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26370. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26371. CLEARCOAT_BUMP: boolean;
  26372. CLEARCOAT_BUMPDIRECTUV: number;
  26373. CLEARCOAT_REMAP_F0: boolean;
  26374. CLEARCOAT_TINT: boolean;
  26375. CLEARCOAT_TINT_TEXTURE: boolean;
  26376. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  26377. ANISOTROPIC: boolean;
  26378. ANISOTROPIC_TEXTURE: boolean;
  26379. ANISOTROPIC_TEXTUREDIRECTUV: number;
  26380. BRDF_V_HEIGHT_CORRELATED: boolean;
  26381. MS_BRDF_ENERGY_CONSERVATION: boolean;
  26382. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  26383. SHEEN: boolean;
  26384. SHEEN_TEXTURE: boolean;
  26385. SHEEN_TEXTURE_ROUGHNESS: boolean;
  26386. SHEEN_TEXTUREDIRECTUV: number;
  26387. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  26388. SHEEN_LINKWITHALBEDO: boolean;
  26389. SHEEN_ROUGHNESS: boolean;
  26390. SHEEN_ALBEDOSCALING: boolean;
  26391. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26392. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26393. SUBSURFACE: boolean;
  26394. SS_REFRACTION: boolean;
  26395. SS_TRANSLUCENCY: boolean;
  26396. SS_SCATTERING: boolean;
  26397. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26398. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26399. SS_REFRACTIONMAP_3D: boolean;
  26400. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26401. SS_LODINREFRACTIONALPHA: boolean;
  26402. SS_GAMMAREFRACTION: boolean;
  26403. SS_RGBDREFRACTION: boolean;
  26404. SS_LINEARSPECULARREFRACTION: boolean;
  26405. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26406. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26407. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26408. UNLIT: boolean;
  26409. DEBUGMODE: number;
  26410. /**
  26411. * Initializes the PBR Material defines.
  26412. */
  26413. constructor();
  26414. /**
  26415. * Resets the PBR Material defines.
  26416. */
  26417. reset(): void;
  26418. }
  26419. /**
  26420. * The Physically based material base class of BJS.
  26421. *
  26422. * This offers the main features of a standard PBR material.
  26423. * For more information, please refer to the documentation :
  26424. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26425. */
  26426. export abstract class PBRBaseMaterial extends PushMaterial {
  26427. /**
  26428. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26429. */
  26430. static readonly PBRMATERIAL_OPAQUE: number;
  26431. /**
  26432. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26433. */
  26434. static readonly PBRMATERIAL_ALPHATEST: number;
  26435. /**
  26436. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26437. */
  26438. static readonly PBRMATERIAL_ALPHABLEND: number;
  26439. /**
  26440. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26441. * They are also discarded below the alpha cutoff threshold to improve performances.
  26442. */
  26443. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26444. /**
  26445. * Defines the default value of how much AO map is occluding the analytical lights
  26446. * (point spot...).
  26447. */
  26448. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26449. /**
  26450. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  26451. */
  26452. static readonly LIGHTFALLOFF_PHYSICAL: number;
  26453. /**
  26454. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  26455. * to enhance interoperability with other engines.
  26456. */
  26457. static readonly LIGHTFALLOFF_GLTF: number;
  26458. /**
  26459. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  26460. * to enhance interoperability with other materials.
  26461. */
  26462. static readonly LIGHTFALLOFF_STANDARD: number;
  26463. /**
  26464. * Intensity of the direct lights e.g. the four lights available in your scene.
  26465. * This impacts both the direct diffuse and specular highlights.
  26466. */
  26467. protected _directIntensity: number;
  26468. /**
  26469. * Intensity of the emissive part of the material.
  26470. * This helps controlling the emissive effect without modifying the emissive color.
  26471. */
  26472. protected _emissiveIntensity: number;
  26473. /**
  26474. * Intensity of the environment e.g. how much the environment will light the object
  26475. * either through harmonics for rough material or through the refelction for shiny ones.
  26476. */
  26477. protected _environmentIntensity: number;
  26478. /**
  26479. * This is a special control allowing the reduction of the specular highlights coming from the
  26480. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26481. */
  26482. protected _specularIntensity: number;
  26483. /**
  26484. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  26485. */
  26486. private _lightingInfos;
  26487. /**
  26488. * Debug Control allowing disabling the bump map on this material.
  26489. */
  26490. protected _disableBumpMap: boolean;
  26491. /**
  26492. * AKA Diffuse Texture in standard nomenclature.
  26493. */
  26494. protected _albedoTexture: Nullable<BaseTexture>;
  26495. /**
  26496. * AKA Occlusion Texture in other nomenclature.
  26497. */
  26498. protected _ambientTexture: Nullable<BaseTexture>;
  26499. /**
  26500. * AKA Occlusion Texture Intensity in other nomenclature.
  26501. */
  26502. protected _ambientTextureStrength: number;
  26503. /**
  26504. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26505. * 1 means it completely occludes it
  26506. * 0 mean it has no impact
  26507. */
  26508. protected _ambientTextureImpactOnAnalyticalLights: number;
  26509. /**
  26510. * Stores the alpha values in a texture.
  26511. */
  26512. protected _opacityTexture: Nullable<BaseTexture>;
  26513. /**
  26514. * Stores the reflection values in a texture.
  26515. */
  26516. protected _reflectionTexture: Nullable<BaseTexture>;
  26517. /**
  26518. * Stores the emissive values in a texture.
  26519. */
  26520. protected _emissiveTexture: Nullable<BaseTexture>;
  26521. /**
  26522. * AKA Specular texture in other nomenclature.
  26523. */
  26524. protected _reflectivityTexture: Nullable<BaseTexture>;
  26525. /**
  26526. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26527. */
  26528. protected _metallicTexture: Nullable<BaseTexture>;
  26529. /**
  26530. * Specifies the metallic scalar of the metallic/roughness workflow.
  26531. * Can also be used to scale the metalness values of the metallic texture.
  26532. */
  26533. protected _metallic: Nullable<number>;
  26534. /**
  26535. * Specifies the roughness scalar of the metallic/roughness workflow.
  26536. * Can also be used to scale the roughness values of the metallic texture.
  26537. */
  26538. protected _roughness: Nullable<number>;
  26539. /**
  26540. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26541. * By default the indexOfrefraction is used to compute F0;
  26542. *
  26543. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26544. *
  26545. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26546. * F90 = metallicReflectanceColor;
  26547. */
  26548. protected _metallicF0Factor: number;
  26549. /**
  26550. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26551. * By default the F90 is always 1;
  26552. *
  26553. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26554. *
  26555. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26556. * F90 = metallicReflectanceColor;
  26557. */
  26558. protected _metallicReflectanceColor: Color3;
  26559. /**
  26560. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26561. * This is multiply against the scalar values defined in the material.
  26562. */
  26563. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  26564. /**
  26565. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26566. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26567. */
  26568. protected _microSurfaceTexture: Nullable<BaseTexture>;
  26569. /**
  26570. * Stores surface normal data used to displace a mesh in a texture.
  26571. */
  26572. protected _bumpTexture: Nullable<BaseTexture>;
  26573. /**
  26574. * Stores the pre-calculated light information of a mesh in a texture.
  26575. */
  26576. protected _lightmapTexture: Nullable<BaseTexture>;
  26577. /**
  26578. * The color of a material in ambient lighting.
  26579. */
  26580. protected _ambientColor: Color3;
  26581. /**
  26582. * AKA Diffuse Color in other nomenclature.
  26583. */
  26584. protected _albedoColor: Color3;
  26585. /**
  26586. * AKA Specular Color in other nomenclature.
  26587. */
  26588. protected _reflectivityColor: Color3;
  26589. /**
  26590. * The color applied when light is reflected from a material.
  26591. */
  26592. protected _reflectionColor: Color3;
  26593. /**
  26594. * The color applied when light is emitted from a material.
  26595. */
  26596. protected _emissiveColor: Color3;
  26597. /**
  26598. * AKA Glossiness in other nomenclature.
  26599. */
  26600. protected _microSurface: number;
  26601. /**
  26602. * Specifies that the material will use the light map as a show map.
  26603. */
  26604. protected _useLightmapAsShadowmap: boolean;
  26605. /**
  26606. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26607. * makes the reflect vector face the model (under horizon).
  26608. */
  26609. protected _useHorizonOcclusion: boolean;
  26610. /**
  26611. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26612. * too much the area relying on ambient texture to define their ambient occlusion.
  26613. */
  26614. protected _useRadianceOcclusion: boolean;
  26615. /**
  26616. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26617. */
  26618. protected _useAlphaFromAlbedoTexture: boolean;
  26619. /**
  26620. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  26621. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26622. */
  26623. protected _useSpecularOverAlpha: boolean;
  26624. /**
  26625. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26626. */
  26627. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26628. /**
  26629. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26630. */
  26631. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  26632. /**
  26633. * Specifies if the metallic texture contains the roughness information in its green channel.
  26634. */
  26635. protected _useRoughnessFromMetallicTextureGreen: boolean;
  26636. /**
  26637. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26638. */
  26639. protected _useMetallnessFromMetallicTextureBlue: boolean;
  26640. /**
  26641. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26642. */
  26643. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  26644. /**
  26645. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26646. */
  26647. protected _useAmbientInGrayScale: boolean;
  26648. /**
  26649. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26650. * The material will try to infer what glossiness each pixel should be.
  26651. */
  26652. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  26653. /**
  26654. * Defines the falloff type used in this material.
  26655. * It by default is Physical.
  26656. */
  26657. protected _lightFalloff: number;
  26658. /**
  26659. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26660. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26661. */
  26662. protected _useRadianceOverAlpha: boolean;
  26663. /**
  26664. * Allows using an object space normal map (instead of tangent space).
  26665. */
  26666. protected _useObjectSpaceNormalMap: boolean;
  26667. /**
  26668. * Allows using the bump map in parallax mode.
  26669. */
  26670. protected _useParallax: boolean;
  26671. /**
  26672. * Allows using the bump map in parallax occlusion mode.
  26673. */
  26674. protected _useParallaxOcclusion: boolean;
  26675. /**
  26676. * Controls the scale bias of the parallax mode.
  26677. */
  26678. protected _parallaxScaleBias: number;
  26679. /**
  26680. * If sets to true, disables all the lights affecting the material.
  26681. */
  26682. protected _disableLighting: boolean;
  26683. /**
  26684. * Number of Simultaneous lights allowed on the material.
  26685. */
  26686. protected _maxSimultaneousLights: number;
  26687. /**
  26688. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  26689. */
  26690. protected _invertNormalMapX: boolean;
  26691. /**
  26692. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  26693. */
  26694. protected _invertNormalMapY: boolean;
  26695. /**
  26696. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26697. */
  26698. protected _twoSidedLighting: boolean;
  26699. /**
  26700. * Defines the alpha limits in alpha test mode.
  26701. */
  26702. protected _alphaCutOff: number;
  26703. /**
  26704. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26705. */
  26706. protected _forceAlphaTest: boolean;
  26707. /**
  26708. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26709. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26710. */
  26711. protected _useAlphaFresnel: boolean;
  26712. /**
  26713. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26714. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26715. */
  26716. protected _useLinearAlphaFresnel: boolean;
  26717. /**
  26718. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  26719. * from cos thetav and roughness:
  26720. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  26721. */
  26722. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  26723. /**
  26724. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26725. */
  26726. protected _forceIrradianceInFragment: boolean;
  26727. private _realTimeFiltering;
  26728. /**
  26729. * Enables realtime filtering on the texture.
  26730. */
  26731. get realTimeFiltering(): boolean;
  26732. set realTimeFiltering(b: boolean);
  26733. private _realTimeFilteringQuality;
  26734. /**
  26735. * Quality switch for realtime filtering
  26736. */
  26737. get realTimeFilteringQuality(): number;
  26738. set realTimeFilteringQuality(n: number);
  26739. /**
  26740. * Can this material render to several textures at once
  26741. */
  26742. get canRenderToMRT(): boolean;
  26743. /**
  26744. * Force normal to face away from face.
  26745. */
  26746. protected _forceNormalForward: boolean;
  26747. /**
  26748. * Enables specular anti aliasing in the PBR shader.
  26749. * It will both interacts on the Geometry for analytical and IBL lighting.
  26750. * It also prefilter the roughness map based on the bump values.
  26751. */
  26752. protected _enableSpecularAntiAliasing: boolean;
  26753. /**
  26754. * Default configuration related to image processing available in the PBR Material.
  26755. */
  26756. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26757. /**
  26758. * Keep track of the image processing observer to allow dispose and replace.
  26759. */
  26760. private _imageProcessingObserver;
  26761. /**
  26762. * Attaches a new image processing configuration to the PBR Material.
  26763. * @param configuration
  26764. */
  26765. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26766. /**
  26767. * Stores the available render targets.
  26768. */
  26769. private _renderTargets;
  26770. /**
  26771. * Sets the global ambient color for the material used in lighting calculations.
  26772. */
  26773. private _globalAmbientColor;
  26774. /**
  26775. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  26776. */
  26777. private _useLogarithmicDepth;
  26778. /**
  26779. * If set to true, no lighting calculations will be applied.
  26780. */
  26781. private _unlit;
  26782. private _debugMode;
  26783. /**
  26784. * @hidden
  26785. * This is reserved for the inspector.
  26786. * Defines the material debug mode.
  26787. * It helps seeing only some components of the material while troubleshooting.
  26788. */
  26789. debugMode: number;
  26790. /**
  26791. * @hidden
  26792. * This is reserved for the inspector.
  26793. * Specify from where on screen the debug mode should start.
  26794. * The value goes from -1 (full screen) to 1 (not visible)
  26795. * It helps with side by side comparison against the final render
  26796. * This defaults to -1
  26797. */
  26798. private debugLimit;
  26799. /**
  26800. * @hidden
  26801. * This is reserved for the inspector.
  26802. * As the default viewing range might not be enough (if the ambient is really small for instance)
  26803. * You can use the factor to better multiply the final value.
  26804. */
  26805. private debugFactor;
  26806. /**
  26807. * Defines the clear coat layer parameters for the material.
  26808. */
  26809. readonly clearCoat: PBRClearCoatConfiguration;
  26810. /**
  26811. * Defines the anisotropic parameters for the material.
  26812. */
  26813. readonly anisotropy: PBRAnisotropicConfiguration;
  26814. /**
  26815. * Defines the BRDF parameters for the material.
  26816. */
  26817. readonly brdf: PBRBRDFConfiguration;
  26818. /**
  26819. * Defines the Sheen parameters for the material.
  26820. */
  26821. readonly sheen: PBRSheenConfiguration;
  26822. /**
  26823. * Defines the SubSurface parameters for the material.
  26824. */
  26825. readonly subSurface: PBRSubSurfaceConfiguration;
  26826. /**
  26827. * Defines additionnal PrePass parameters for the material.
  26828. */
  26829. readonly prePassConfiguration: PrePassConfiguration;
  26830. /**
  26831. * Defines the detail map parameters for the material.
  26832. */
  26833. readonly detailMap: DetailMapConfiguration;
  26834. protected _rebuildInParallel: boolean;
  26835. /**
  26836. * Instantiates a new PBRMaterial instance.
  26837. *
  26838. * @param name The material name
  26839. * @param scene The scene the material will be use in.
  26840. */
  26841. constructor(name: string, scene: Scene);
  26842. /**
  26843. * Gets a boolean indicating that current material needs to register RTT
  26844. */
  26845. get hasRenderTargetTextures(): boolean;
  26846. /**
  26847. * Gets the name of the material class.
  26848. */
  26849. getClassName(): string;
  26850. /**
  26851. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26852. */
  26853. get useLogarithmicDepth(): boolean;
  26854. /**
  26855. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26856. */
  26857. set useLogarithmicDepth(value: boolean);
  26858. /**
  26859. * Returns true if alpha blending should be disabled.
  26860. */
  26861. protected get _disableAlphaBlending(): boolean;
  26862. /**
  26863. * Specifies whether or not this material should be rendered in alpha blend mode.
  26864. */
  26865. needAlphaBlending(): boolean;
  26866. /**
  26867. * Specifies whether or not this material should be rendered in alpha test mode.
  26868. */
  26869. needAlphaTesting(): boolean;
  26870. /**
  26871. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  26872. */
  26873. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  26874. /**
  26875. * Specifies whether or not there is a usable alpha channel for transparency.
  26876. */
  26877. protected _hasAlphaChannel(): boolean;
  26878. /**
  26879. * Gets the texture used for the alpha test.
  26880. */
  26881. getAlphaTestTexture(): Nullable<BaseTexture>;
  26882. /**
  26883. * Specifies that the submesh is ready to be used.
  26884. * @param mesh - BJS mesh.
  26885. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  26886. * @param useInstances - Specifies that instances should be used.
  26887. * @returns - boolean indicating that the submesh is ready or not.
  26888. */
  26889. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26890. /**
  26891. * Specifies if the material uses metallic roughness workflow.
  26892. * @returns boolean specifiying if the material uses metallic roughness workflow.
  26893. */
  26894. isMetallicWorkflow(): boolean;
  26895. private _prepareEffect;
  26896. private _prepareDefines;
  26897. /**
  26898. * Force shader compilation
  26899. */
  26900. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  26901. /**
  26902. * Initializes the uniform buffer layout for the shader.
  26903. */
  26904. buildUniformLayout(): void;
  26905. /**
  26906. * Unbinds the material from the mesh
  26907. */
  26908. unbind(): void;
  26909. /**
  26910. * Binds the submesh data.
  26911. * @param world - The world matrix.
  26912. * @param mesh - The BJS mesh.
  26913. * @param subMesh - A submesh of the BJS mesh.
  26914. */
  26915. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26916. /**
  26917. * Returns the animatable textures.
  26918. * @returns - Array of animatable textures.
  26919. */
  26920. getAnimatables(): IAnimatable[];
  26921. /**
  26922. * Returns the texture used for reflections.
  26923. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  26924. */
  26925. private _getReflectionTexture;
  26926. /**
  26927. * Returns an array of the actively used textures.
  26928. * @returns - Array of BaseTextures
  26929. */
  26930. getActiveTextures(): BaseTexture[];
  26931. /**
  26932. * Checks to see if a texture is used in the material.
  26933. * @param texture - Base texture to use.
  26934. * @returns - Boolean specifying if a texture is used in the material.
  26935. */
  26936. hasTexture(texture: BaseTexture): boolean;
  26937. /**
  26938. * Sets the required values to the prepass renderer.
  26939. * @param prePassRenderer defines the prepass renderer to setup
  26940. */
  26941. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26942. /**
  26943. * Disposes the resources of the material.
  26944. * @param forceDisposeEffect - Forces the disposal of effects.
  26945. * @param forceDisposeTextures - Forces the disposal of all textures.
  26946. */
  26947. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26948. }
  26949. }
  26950. declare module BABYLON {
  26951. /**
  26952. * The Physically based material of BJS.
  26953. *
  26954. * This offers the main features of a standard PBR material.
  26955. * For more information, please refer to the documentation :
  26956. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26957. */
  26958. export class PBRMaterial extends PBRBaseMaterial {
  26959. /**
  26960. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26961. */
  26962. static readonly PBRMATERIAL_OPAQUE: number;
  26963. /**
  26964. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26965. */
  26966. static readonly PBRMATERIAL_ALPHATEST: number;
  26967. /**
  26968. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26969. */
  26970. static readonly PBRMATERIAL_ALPHABLEND: number;
  26971. /**
  26972. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26973. * They are also discarded below the alpha cutoff threshold to improve performances.
  26974. */
  26975. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26976. /**
  26977. * Defines the default value of how much AO map is occluding the analytical lights
  26978. * (point spot...).
  26979. */
  26980. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26981. /**
  26982. * Intensity of the direct lights e.g. the four lights available in your scene.
  26983. * This impacts both the direct diffuse and specular highlights.
  26984. */
  26985. directIntensity: number;
  26986. /**
  26987. * Intensity of the emissive part of the material.
  26988. * This helps controlling the emissive effect without modifying the emissive color.
  26989. */
  26990. emissiveIntensity: number;
  26991. /**
  26992. * Intensity of the environment e.g. how much the environment will light the object
  26993. * either through harmonics for rough material or through the refelction for shiny ones.
  26994. */
  26995. environmentIntensity: number;
  26996. /**
  26997. * This is a special control allowing the reduction of the specular highlights coming from the
  26998. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26999. */
  27000. specularIntensity: number;
  27001. /**
  27002. * Debug Control allowing disabling the bump map on this material.
  27003. */
  27004. disableBumpMap: boolean;
  27005. /**
  27006. * AKA Diffuse Texture in standard nomenclature.
  27007. */
  27008. albedoTexture: BaseTexture;
  27009. /**
  27010. * AKA Occlusion Texture in other nomenclature.
  27011. */
  27012. ambientTexture: BaseTexture;
  27013. /**
  27014. * AKA Occlusion Texture Intensity in other nomenclature.
  27015. */
  27016. ambientTextureStrength: number;
  27017. /**
  27018. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27019. * 1 means it completely occludes it
  27020. * 0 mean it has no impact
  27021. */
  27022. ambientTextureImpactOnAnalyticalLights: number;
  27023. /**
  27024. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  27025. */
  27026. opacityTexture: BaseTexture;
  27027. /**
  27028. * Stores the reflection values in a texture.
  27029. */
  27030. reflectionTexture: Nullable<BaseTexture>;
  27031. /**
  27032. * Stores the emissive values in a texture.
  27033. */
  27034. emissiveTexture: BaseTexture;
  27035. /**
  27036. * AKA Specular texture in other nomenclature.
  27037. */
  27038. reflectivityTexture: BaseTexture;
  27039. /**
  27040. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27041. */
  27042. metallicTexture: BaseTexture;
  27043. /**
  27044. * Specifies the metallic scalar of the metallic/roughness workflow.
  27045. * Can also be used to scale the metalness values of the metallic texture.
  27046. */
  27047. metallic: Nullable<number>;
  27048. /**
  27049. * Specifies the roughness scalar of the metallic/roughness workflow.
  27050. * Can also be used to scale the roughness values of the metallic texture.
  27051. */
  27052. roughness: Nullable<number>;
  27053. /**
  27054. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27055. * By default the indexOfrefraction is used to compute F0;
  27056. *
  27057. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27058. *
  27059. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27060. * F90 = metallicReflectanceColor;
  27061. */
  27062. metallicF0Factor: number;
  27063. /**
  27064. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27065. * By default the F90 is always 1;
  27066. *
  27067. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27068. *
  27069. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27070. * F90 = metallicReflectanceColor;
  27071. */
  27072. metallicReflectanceColor: Color3;
  27073. /**
  27074. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27075. * This is multiply against the scalar values defined in the material.
  27076. */
  27077. metallicReflectanceTexture: Nullable<BaseTexture>;
  27078. /**
  27079. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27080. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27081. */
  27082. microSurfaceTexture: BaseTexture;
  27083. /**
  27084. * Stores surface normal data used to displace a mesh in a texture.
  27085. */
  27086. bumpTexture: BaseTexture;
  27087. /**
  27088. * Stores the pre-calculated light information of a mesh in a texture.
  27089. */
  27090. lightmapTexture: BaseTexture;
  27091. /**
  27092. * Stores the refracted light information in a texture.
  27093. */
  27094. get refractionTexture(): Nullable<BaseTexture>;
  27095. set refractionTexture(value: Nullable<BaseTexture>);
  27096. /**
  27097. * The color of a material in ambient lighting.
  27098. */
  27099. ambientColor: Color3;
  27100. /**
  27101. * AKA Diffuse Color in other nomenclature.
  27102. */
  27103. albedoColor: Color3;
  27104. /**
  27105. * AKA Specular Color in other nomenclature.
  27106. */
  27107. reflectivityColor: Color3;
  27108. /**
  27109. * The color reflected from the material.
  27110. */
  27111. reflectionColor: Color3;
  27112. /**
  27113. * The color emitted from the material.
  27114. */
  27115. emissiveColor: Color3;
  27116. /**
  27117. * AKA Glossiness in other nomenclature.
  27118. */
  27119. microSurface: number;
  27120. /**
  27121. * Index of refraction of the material base layer.
  27122. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  27123. *
  27124. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  27125. *
  27126. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  27127. */
  27128. get indexOfRefraction(): number;
  27129. set indexOfRefraction(value: number);
  27130. /**
  27131. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  27132. */
  27133. get invertRefractionY(): boolean;
  27134. set invertRefractionY(value: boolean);
  27135. /**
  27136. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  27137. * Materials half opaque for instance using refraction could benefit from this control.
  27138. */
  27139. get linkRefractionWithTransparency(): boolean;
  27140. set linkRefractionWithTransparency(value: boolean);
  27141. /**
  27142. * If true, the light map contains occlusion information instead of lighting info.
  27143. */
  27144. useLightmapAsShadowmap: boolean;
  27145. /**
  27146. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27147. */
  27148. useAlphaFromAlbedoTexture: boolean;
  27149. /**
  27150. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27151. */
  27152. forceAlphaTest: boolean;
  27153. /**
  27154. * Defines the alpha limits in alpha test mode.
  27155. */
  27156. alphaCutOff: number;
  27157. /**
  27158. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27159. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27160. */
  27161. useSpecularOverAlpha: boolean;
  27162. /**
  27163. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27164. */
  27165. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27166. /**
  27167. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27168. */
  27169. useRoughnessFromMetallicTextureAlpha: boolean;
  27170. /**
  27171. * Specifies if the metallic texture contains the roughness information in its green channel.
  27172. */
  27173. useRoughnessFromMetallicTextureGreen: boolean;
  27174. /**
  27175. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27176. */
  27177. useMetallnessFromMetallicTextureBlue: boolean;
  27178. /**
  27179. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27180. */
  27181. useAmbientOcclusionFromMetallicTextureRed: boolean;
  27182. /**
  27183. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27184. */
  27185. useAmbientInGrayScale: boolean;
  27186. /**
  27187. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27188. * The material will try to infer what glossiness each pixel should be.
  27189. */
  27190. useAutoMicroSurfaceFromReflectivityMap: boolean;
  27191. /**
  27192. * BJS is using an harcoded light falloff based on a manually sets up range.
  27193. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27194. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27195. */
  27196. get usePhysicalLightFalloff(): boolean;
  27197. /**
  27198. * BJS is using an harcoded light falloff based on a manually sets up range.
  27199. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  27200. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  27201. */
  27202. set usePhysicalLightFalloff(value: boolean);
  27203. /**
  27204. * In order to support the falloff compatibility with gltf, a special mode has been added
  27205. * to reproduce the gltf light falloff.
  27206. */
  27207. get useGLTFLightFalloff(): boolean;
  27208. /**
  27209. * In order to support the falloff compatibility with gltf, a special mode has been added
  27210. * to reproduce the gltf light falloff.
  27211. */
  27212. set useGLTFLightFalloff(value: boolean);
  27213. /**
  27214. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27215. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27216. */
  27217. useRadianceOverAlpha: boolean;
  27218. /**
  27219. * Allows using an object space normal map (instead of tangent space).
  27220. */
  27221. useObjectSpaceNormalMap: boolean;
  27222. /**
  27223. * Allows using the bump map in parallax mode.
  27224. */
  27225. useParallax: boolean;
  27226. /**
  27227. * Allows using the bump map in parallax occlusion mode.
  27228. */
  27229. useParallaxOcclusion: boolean;
  27230. /**
  27231. * Controls the scale bias of the parallax mode.
  27232. */
  27233. parallaxScaleBias: number;
  27234. /**
  27235. * If sets to true, disables all the lights affecting the material.
  27236. */
  27237. disableLighting: boolean;
  27238. /**
  27239. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27240. */
  27241. forceIrradianceInFragment: boolean;
  27242. /**
  27243. * Number of Simultaneous lights allowed on the material.
  27244. */
  27245. maxSimultaneousLights: number;
  27246. /**
  27247. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27248. */
  27249. invertNormalMapX: boolean;
  27250. /**
  27251. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27252. */
  27253. invertNormalMapY: boolean;
  27254. /**
  27255. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27256. */
  27257. twoSidedLighting: boolean;
  27258. /**
  27259. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27260. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27261. */
  27262. useAlphaFresnel: boolean;
  27263. /**
  27264. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27265. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27266. */
  27267. useLinearAlphaFresnel: boolean;
  27268. /**
  27269. * Let user defines the brdf lookup texture used for IBL.
  27270. * A default 8bit version is embedded but you could point at :
  27271. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  27272. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  27273. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  27274. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  27275. */
  27276. environmentBRDFTexture: Nullable<BaseTexture>;
  27277. /**
  27278. * Force normal to face away from face.
  27279. */
  27280. forceNormalForward: boolean;
  27281. /**
  27282. * Enables specular anti aliasing in the PBR shader.
  27283. * It will both interacts on the Geometry for analytical and IBL lighting.
  27284. * It also prefilter the roughness map based on the bump values.
  27285. */
  27286. enableSpecularAntiAliasing: boolean;
  27287. /**
  27288. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27289. * makes the reflect vector face the model (under horizon).
  27290. */
  27291. useHorizonOcclusion: boolean;
  27292. /**
  27293. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27294. * too much the area relying on ambient texture to define their ambient occlusion.
  27295. */
  27296. useRadianceOcclusion: boolean;
  27297. /**
  27298. * If set to true, no lighting calculations will be applied.
  27299. */
  27300. unlit: boolean;
  27301. /**
  27302. * Gets the image processing configuration used either in this material.
  27303. */
  27304. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27305. /**
  27306. * Sets the Default image processing configuration used either in the this material.
  27307. *
  27308. * If sets to null, the scene one is in use.
  27309. */
  27310. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27311. /**
  27312. * Gets wether the color curves effect is enabled.
  27313. */
  27314. get cameraColorCurvesEnabled(): boolean;
  27315. /**
  27316. * Sets wether the color curves effect is enabled.
  27317. */
  27318. set cameraColorCurvesEnabled(value: boolean);
  27319. /**
  27320. * Gets wether the color grading effect is enabled.
  27321. */
  27322. get cameraColorGradingEnabled(): boolean;
  27323. /**
  27324. * Gets wether the color grading effect is enabled.
  27325. */
  27326. set cameraColorGradingEnabled(value: boolean);
  27327. /**
  27328. * Gets wether tonemapping is enabled or not.
  27329. */
  27330. get cameraToneMappingEnabled(): boolean;
  27331. /**
  27332. * Sets wether tonemapping is enabled or not
  27333. */
  27334. set cameraToneMappingEnabled(value: boolean);
  27335. /**
  27336. * The camera exposure used on this material.
  27337. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27338. * This corresponds to a photographic exposure.
  27339. */
  27340. get cameraExposure(): number;
  27341. /**
  27342. * The camera exposure used on this material.
  27343. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27344. * This corresponds to a photographic exposure.
  27345. */
  27346. set cameraExposure(value: number);
  27347. /**
  27348. * Gets The camera contrast used on this material.
  27349. */
  27350. get cameraContrast(): number;
  27351. /**
  27352. * Sets The camera contrast used on this material.
  27353. */
  27354. set cameraContrast(value: number);
  27355. /**
  27356. * Gets the Color Grading 2D Lookup Texture.
  27357. */
  27358. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27359. /**
  27360. * Sets the Color Grading 2D Lookup Texture.
  27361. */
  27362. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27363. /**
  27364. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27365. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27366. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  27367. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27368. */
  27369. get cameraColorCurves(): Nullable<ColorCurves>;
  27370. /**
  27371. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27372. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27373. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  27374. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27375. */
  27376. set cameraColorCurves(value: Nullable<ColorCurves>);
  27377. /**
  27378. * Instantiates a new PBRMaterial instance.
  27379. *
  27380. * @param name The material name
  27381. * @param scene The scene the material will be use in.
  27382. */
  27383. constructor(name: string, scene: Scene);
  27384. /**
  27385. * Returns the name of this material class.
  27386. */
  27387. getClassName(): string;
  27388. /**
  27389. * Makes a duplicate of the current material.
  27390. * @param name - name to use for the new material.
  27391. */
  27392. clone(name: string): PBRMaterial;
  27393. /**
  27394. * Serializes this PBR Material.
  27395. * @returns - An object with the serialized material.
  27396. */
  27397. serialize(): any;
  27398. /**
  27399. * Parses a PBR Material from a serialized object.
  27400. * @param source - Serialized object.
  27401. * @param scene - BJS scene instance.
  27402. * @param rootUrl - url for the scene object
  27403. * @returns - PBRMaterial
  27404. */
  27405. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  27406. }
  27407. }
  27408. declare module BABYLON {
  27409. /** @hidden */
  27410. export var mrtFragmentDeclaration: {
  27411. name: string;
  27412. shader: string;
  27413. };
  27414. }
  27415. declare module BABYLON {
  27416. /** @hidden */
  27417. export var geometryPixelShader: {
  27418. name: string;
  27419. shader: string;
  27420. };
  27421. }
  27422. declare module BABYLON {
  27423. /** @hidden */
  27424. export var geometryVertexShader: {
  27425. name: string;
  27426. shader: string;
  27427. };
  27428. }
  27429. declare module BABYLON {
  27430. /** @hidden */
  27431. interface ISavedTransformationMatrix {
  27432. world: Matrix;
  27433. viewProjection: Matrix;
  27434. }
  27435. /**
  27436. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  27437. */
  27438. export class GeometryBufferRenderer {
  27439. /**
  27440. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  27441. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  27442. */
  27443. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  27444. /**
  27445. * Constant used to retrieve the position texture index in the G-Buffer textures array
  27446. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  27447. */
  27448. static readonly POSITION_TEXTURE_TYPE: number;
  27449. /**
  27450. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  27451. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  27452. */
  27453. static readonly VELOCITY_TEXTURE_TYPE: number;
  27454. /**
  27455. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  27456. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  27457. */
  27458. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  27459. /**
  27460. * Dictionary used to store the previous transformation matrices of each rendered mesh
  27461. * in order to compute objects velocities when enableVelocity is set to "true"
  27462. * @hidden
  27463. */
  27464. _previousTransformationMatrices: {
  27465. [index: number]: ISavedTransformationMatrix;
  27466. };
  27467. /**
  27468. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  27469. * in order to compute objects velocities when enableVelocity is set to "true"
  27470. * @hidden
  27471. */
  27472. _previousBonesTransformationMatrices: {
  27473. [index: number]: Float32Array;
  27474. };
  27475. /**
  27476. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  27477. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  27478. */
  27479. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  27480. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  27481. renderTransparentMeshes: boolean;
  27482. private _scene;
  27483. private _resizeObserver;
  27484. private _multiRenderTarget;
  27485. private _ratio;
  27486. private _enablePosition;
  27487. private _enableVelocity;
  27488. private _enableReflectivity;
  27489. private _positionIndex;
  27490. private _velocityIndex;
  27491. private _reflectivityIndex;
  27492. private _depthNormalIndex;
  27493. private _linkedWithPrePass;
  27494. private _prePassRenderer;
  27495. private _attachments;
  27496. protected _effect: Effect;
  27497. protected _cachedDefines: string;
  27498. /**
  27499. * @hidden
  27500. * Sets up internal structures to share outputs with PrePassRenderer
  27501. * This method should only be called by the PrePassRenderer itself
  27502. */
  27503. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  27504. /**
  27505. * @hidden
  27506. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  27507. * This method should only be called by the PrePassRenderer itself
  27508. */
  27509. _unlinkPrePassRenderer(): void;
  27510. /**
  27511. * @hidden
  27512. * Resets the geometry buffer layout
  27513. */
  27514. _resetLayout(): void;
  27515. /**
  27516. * @hidden
  27517. * Replaces a texture in the geometry buffer renderer
  27518. * Useful when linking textures of the prepass renderer
  27519. */
  27520. _forceTextureType(geometryBufferType: number, index: number): void;
  27521. /**
  27522. * @hidden
  27523. * Sets texture attachments
  27524. * Useful when linking textures of the prepass renderer
  27525. */
  27526. _setAttachments(attachments: number[]): void;
  27527. /**
  27528. * @hidden
  27529. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  27530. * Useful when linking textures of the prepass renderer
  27531. */
  27532. _linkInternalTexture(internalTexture: InternalTexture): void;
  27533. /**
  27534. * Gets the render list (meshes to be rendered) used in the G buffer.
  27535. */
  27536. get renderList(): Nullable<AbstractMesh[]>;
  27537. /**
  27538. * Set the render list (meshes to be rendered) used in the G buffer.
  27539. */
  27540. set renderList(meshes: Nullable<AbstractMesh[]>);
  27541. /**
  27542. * Gets wether or not G buffer are supported by the running hardware.
  27543. * This requires draw buffer supports
  27544. */
  27545. get isSupported(): boolean;
  27546. /**
  27547. * Returns the index of the given texture type in the G-Buffer textures array
  27548. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  27549. * @returns the index of the given texture type in the G-Buffer textures array
  27550. */
  27551. getTextureIndex(textureType: number): number;
  27552. /**
  27553. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  27554. */
  27555. get enablePosition(): boolean;
  27556. /**
  27557. * Sets whether or not objects positions are enabled for the G buffer.
  27558. */
  27559. set enablePosition(enable: boolean);
  27560. /**
  27561. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  27562. */
  27563. get enableVelocity(): boolean;
  27564. /**
  27565. * Sets wether or not objects velocities are enabled for the G buffer.
  27566. */
  27567. set enableVelocity(enable: boolean);
  27568. /**
  27569. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  27570. */
  27571. get enableReflectivity(): boolean;
  27572. /**
  27573. * Sets wether or not objects roughness are enabled for the G buffer.
  27574. */
  27575. set enableReflectivity(enable: boolean);
  27576. /**
  27577. * Gets the scene associated with the buffer.
  27578. */
  27579. get scene(): Scene;
  27580. /**
  27581. * Gets the ratio used by the buffer during its creation.
  27582. * How big is the buffer related to the main canvas.
  27583. */
  27584. get ratio(): number;
  27585. /** @hidden */
  27586. static _SceneComponentInitialization: (scene: Scene) => void;
  27587. /**
  27588. * Creates a new G Buffer for the scene
  27589. * @param scene The scene the buffer belongs to
  27590. * @param ratio How big is the buffer related to the main canvas.
  27591. */
  27592. constructor(scene: Scene, ratio?: number);
  27593. /**
  27594. * Checks wether everything is ready to render a submesh to the G buffer.
  27595. * @param subMesh the submesh to check readiness for
  27596. * @param useInstances is the mesh drawn using instance or not
  27597. * @returns true if ready otherwise false
  27598. */
  27599. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  27600. /**
  27601. * Gets the current underlying G Buffer.
  27602. * @returns the buffer
  27603. */
  27604. getGBuffer(): MultiRenderTarget;
  27605. /**
  27606. * Gets the number of samples used to render the buffer (anti aliasing).
  27607. */
  27608. get samples(): number;
  27609. /**
  27610. * Sets the number of samples used to render the buffer (anti aliasing).
  27611. */
  27612. set samples(value: number);
  27613. /**
  27614. * Disposes the renderer and frees up associated resources.
  27615. */
  27616. dispose(): void;
  27617. private _assignRenderTargetIndices;
  27618. protected _createRenderTargets(): void;
  27619. private _copyBonesTransformationMatrices;
  27620. }
  27621. }
  27622. declare module BABYLON {
  27623. /**
  27624. * Renders a pre pass of the scene
  27625. * This means every mesh in the scene will be rendered to a render target texture
  27626. * And then this texture will be composited to the rendering canvas with post processes
  27627. * It is necessary for effects like subsurface scattering or deferred shading
  27628. */
  27629. export class PrePassRenderer {
  27630. /** @hidden */
  27631. static _SceneComponentInitialization: (scene: Scene) => void;
  27632. private _textureFormats;
  27633. /**
  27634. * To save performance, we can excluded skinned meshes from the prepass
  27635. */
  27636. excludedSkinnedMesh: AbstractMesh[];
  27637. /**
  27638. * Force material to be excluded from the prepass
  27639. * Can be useful when `useGeometryBufferFallback` is set to `true`
  27640. * and you don't want a material to show in the effect.
  27641. */
  27642. excludedMaterials: Material[];
  27643. private _textureIndices;
  27644. private _scene;
  27645. private _engine;
  27646. private _isDirty;
  27647. /**
  27648. * Number of textures in the multi render target texture where the scene is directly rendered
  27649. */
  27650. mrtCount: number;
  27651. /**
  27652. * The render target where the scene is directly rendered
  27653. */
  27654. prePassRT: MultiRenderTarget;
  27655. private _multiRenderAttachments;
  27656. private _defaultAttachments;
  27657. private _clearAttachments;
  27658. private _postProcesses;
  27659. private readonly _clearColor;
  27660. /**
  27661. * Image processing post process for composition
  27662. */
  27663. imageProcessingPostProcess: ImageProcessingPostProcess;
  27664. /**
  27665. * Configuration for prepass effects
  27666. */
  27667. private _effectConfigurations;
  27668. private _mrtFormats;
  27669. private _mrtLayout;
  27670. private _enabled;
  27671. /**
  27672. * Indicates if the prepass is enabled
  27673. */
  27674. get enabled(): boolean;
  27675. /**
  27676. * How many samples are used for MSAA of the scene render target
  27677. */
  27678. get samples(): number;
  27679. set samples(n: number);
  27680. private _geometryBuffer;
  27681. private _useGeometryBufferFallback;
  27682. /**
  27683. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  27684. */
  27685. get useGeometryBufferFallback(): boolean;
  27686. set useGeometryBufferFallback(value: boolean);
  27687. /**
  27688. * Instanciates a prepass renderer
  27689. * @param scene The scene
  27690. */
  27691. constructor(scene: Scene);
  27692. private _initializeAttachments;
  27693. private _createCompositionEffect;
  27694. /**
  27695. * Indicates if rendering a prepass is supported
  27696. */
  27697. get isSupported(): boolean;
  27698. /**
  27699. * Sets the proper output textures to draw in the engine.
  27700. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  27701. * @param subMesh Submesh on which the effect is applied
  27702. */
  27703. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  27704. /**
  27705. * @hidden
  27706. */
  27707. _beforeCameraDraw(): void;
  27708. /**
  27709. * @hidden
  27710. */
  27711. _afterCameraDraw(): void;
  27712. private _checkRTSize;
  27713. private _bindFrameBuffer;
  27714. /**
  27715. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  27716. */
  27717. clear(): void;
  27718. private _setState;
  27719. private _updateGeometryBufferLayout;
  27720. /**
  27721. * Adds an effect configuration to the prepass.
  27722. * If an effect has already been added, it won't add it twice and will return the configuration
  27723. * already present.
  27724. * @param cfg the effect configuration
  27725. * @return the effect configuration now used by the prepass
  27726. */
  27727. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  27728. /**
  27729. * Returns the index of a texture in the multi render target texture array.
  27730. * @param type Texture type
  27731. * @return The index
  27732. */
  27733. getIndex(type: number): number;
  27734. private _enable;
  27735. private _disable;
  27736. private _resetLayout;
  27737. private _resetPostProcessChain;
  27738. private _bindPostProcessChain;
  27739. /**
  27740. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  27741. */
  27742. markAsDirty(): void;
  27743. /**
  27744. * Enables a texture on the MultiRenderTarget for prepass
  27745. */
  27746. private _enableTextures;
  27747. private _update;
  27748. private _markAllMaterialsAsPrePassDirty;
  27749. /**
  27750. * Disposes the prepass renderer.
  27751. */
  27752. dispose(): void;
  27753. }
  27754. }
  27755. declare module BABYLON {
  27756. /**
  27757. * Size options for a post process
  27758. */
  27759. export type PostProcessOptions = {
  27760. width: number;
  27761. height: number;
  27762. };
  27763. /**
  27764. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27765. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27766. */
  27767. export class PostProcess {
  27768. /**
  27769. * Gets or sets the unique id of the post process
  27770. */
  27771. uniqueId: number;
  27772. /** Name of the PostProcess. */
  27773. name: string;
  27774. /**
  27775. * Width of the texture to apply the post process on
  27776. */
  27777. width: number;
  27778. /**
  27779. * Height of the texture to apply the post process on
  27780. */
  27781. height: number;
  27782. /**
  27783. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  27784. */
  27785. nodeMaterialSource: Nullable<NodeMaterial>;
  27786. /**
  27787. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27788. * @hidden
  27789. */
  27790. _outputTexture: Nullable<InternalTexture>;
  27791. /**
  27792. * Sampling mode used by the shader
  27793. * See https://doc.babylonjs.com/classes/3.1/texture
  27794. */
  27795. renderTargetSamplingMode: number;
  27796. /**
  27797. * Clear color to use when screen clearing
  27798. */
  27799. clearColor: Color4;
  27800. /**
  27801. * If the buffer needs to be cleared before applying the post process. (default: true)
  27802. * Should be set to false if shader will overwrite all previous pixels.
  27803. */
  27804. autoClear: boolean;
  27805. /**
  27806. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27807. */
  27808. alphaMode: number;
  27809. /**
  27810. * Sets the setAlphaBlendConstants of the babylon engine
  27811. */
  27812. alphaConstants: Color4;
  27813. /**
  27814. * Animations to be used for the post processing
  27815. */
  27816. animations: Animation[];
  27817. /**
  27818. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27819. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27820. */
  27821. enablePixelPerfectMode: boolean;
  27822. /**
  27823. * Force the postprocess to be applied without taking in account viewport
  27824. */
  27825. forceFullscreenViewport: boolean;
  27826. /**
  27827. * List of inspectable custom properties (used by the Inspector)
  27828. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27829. */
  27830. inspectableCustomProperties: IInspectable[];
  27831. /**
  27832. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27833. *
  27834. * | Value | Type | Description |
  27835. * | ----- | ----------------------------------- | ----------- |
  27836. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27837. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27838. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27839. *
  27840. */
  27841. scaleMode: number;
  27842. /**
  27843. * Force textures to be a power of two (default: false)
  27844. */
  27845. alwaysForcePOT: boolean;
  27846. private _samples;
  27847. /**
  27848. * Number of sample textures (default: 1)
  27849. */
  27850. get samples(): number;
  27851. set samples(n: number);
  27852. /**
  27853. * Modify the scale of the post process to be the same as the viewport (default: false)
  27854. */
  27855. adaptScaleToCurrentViewport: boolean;
  27856. private _camera;
  27857. protected _scene: Scene;
  27858. private _engine;
  27859. private _options;
  27860. private _reusable;
  27861. private _textureType;
  27862. private _textureFormat;
  27863. /**
  27864. * Smart array of input and output textures for the post process.
  27865. * @hidden
  27866. */
  27867. _textures: SmartArray<InternalTexture>;
  27868. /**
  27869. * The index in _textures that corresponds to the output texture.
  27870. * @hidden
  27871. */
  27872. _currentRenderTextureInd: number;
  27873. private _effect;
  27874. private _samplers;
  27875. private _fragmentUrl;
  27876. private _vertexUrl;
  27877. private _parameters;
  27878. private _scaleRatio;
  27879. protected _indexParameters: any;
  27880. private _shareOutputWithPostProcess;
  27881. private _texelSize;
  27882. private _forcedOutputTexture;
  27883. /**
  27884. * Prepass configuration in case this post process needs a texture from prepass
  27885. * @hidden
  27886. */
  27887. _prePassEffectConfiguration: PrePassEffectConfiguration;
  27888. /**
  27889. * Returns the fragment url or shader name used in the post process.
  27890. * @returns the fragment url or name in the shader store.
  27891. */
  27892. getEffectName(): string;
  27893. /**
  27894. * An event triggered when the postprocess is activated.
  27895. */
  27896. onActivateObservable: Observable<Camera>;
  27897. private _onActivateObserver;
  27898. /**
  27899. * A function that is added to the onActivateObservable
  27900. */
  27901. set onActivate(callback: Nullable<(camera: Camera) => void>);
  27902. /**
  27903. * An event triggered when the postprocess changes its size.
  27904. */
  27905. onSizeChangedObservable: Observable<PostProcess>;
  27906. private _onSizeChangedObserver;
  27907. /**
  27908. * A function that is added to the onSizeChangedObservable
  27909. */
  27910. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  27911. /**
  27912. * An event triggered when the postprocess applies its effect.
  27913. */
  27914. onApplyObservable: Observable<Effect>;
  27915. private _onApplyObserver;
  27916. /**
  27917. * A function that is added to the onApplyObservable
  27918. */
  27919. set onApply(callback: (effect: Effect) => void);
  27920. /**
  27921. * An event triggered before rendering the postprocess
  27922. */
  27923. onBeforeRenderObservable: Observable<Effect>;
  27924. private _onBeforeRenderObserver;
  27925. /**
  27926. * A function that is added to the onBeforeRenderObservable
  27927. */
  27928. set onBeforeRender(callback: (effect: Effect) => void);
  27929. /**
  27930. * An event triggered after rendering the postprocess
  27931. */
  27932. onAfterRenderObservable: Observable<Effect>;
  27933. private _onAfterRenderObserver;
  27934. /**
  27935. * A function that is added to the onAfterRenderObservable
  27936. */
  27937. set onAfterRender(callback: (efect: Effect) => void);
  27938. /**
  27939. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  27940. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27941. */
  27942. get inputTexture(): InternalTexture;
  27943. set inputTexture(value: InternalTexture);
  27944. /**
  27945. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  27946. * the only way to unset it is to use this function to restore its internal state
  27947. */
  27948. restoreDefaultInputTexture(): void;
  27949. /**
  27950. * Gets the camera which post process is applied to.
  27951. * @returns The camera the post process is applied to.
  27952. */
  27953. getCamera(): Camera;
  27954. /**
  27955. * Gets the texel size of the postprocess.
  27956. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27957. */
  27958. get texelSize(): Vector2;
  27959. /**
  27960. * Creates a new instance PostProcess
  27961. * @param name The name of the PostProcess.
  27962. * @param fragmentUrl The url of the fragment shader to be used.
  27963. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27964. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27965. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27966. * @param camera The camera to apply the render pass to.
  27967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27968. * @param engine The engine which the post process will be applied. (default: current engine)
  27969. * @param reusable If the post process can be reused on the same frame. (default: false)
  27970. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27971. * @param textureType Type of textures used when performing the post process. (default: 0)
  27972. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27973. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  27974. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  27975. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  27976. */
  27977. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  27978. /**
  27979. * Gets a string identifying the name of the class
  27980. * @returns "PostProcess" string
  27981. */
  27982. getClassName(): string;
  27983. /**
  27984. * Gets the engine which this post process belongs to.
  27985. * @returns The engine the post process was enabled with.
  27986. */
  27987. getEngine(): Engine;
  27988. /**
  27989. * The effect that is created when initializing the post process.
  27990. * @returns The created effect corresponding the the postprocess.
  27991. */
  27992. getEffect(): Effect;
  27993. /**
  27994. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27995. * @param postProcess The post process to share the output with.
  27996. * @returns This post process.
  27997. */
  27998. shareOutputWith(postProcess: PostProcess): PostProcess;
  27999. /**
  28000. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  28001. * This should be called if the post process that shares output with this post process is disabled/disposed.
  28002. */
  28003. useOwnOutput(): void;
  28004. /**
  28005. * Updates the effect with the current post process compile time values and recompiles the shader.
  28006. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28007. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28008. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28009. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  28010. * @param onCompiled Called when the shader has been compiled.
  28011. * @param onError Called if there is an error when compiling a shader.
  28012. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  28013. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  28014. */
  28015. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  28016. /**
  28017. * The post process is reusable if it can be used multiple times within one frame.
  28018. * @returns If the post process is reusable
  28019. */
  28020. isReusable(): boolean;
  28021. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  28022. markTextureDirty(): void;
  28023. /**
  28024. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  28025. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  28026. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  28027. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  28028. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  28029. * @returns The target texture that was bound to be written to.
  28030. */
  28031. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  28032. /**
  28033. * If the post process is supported.
  28034. */
  28035. get isSupported(): boolean;
  28036. /**
  28037. * The aspect ratio of the output texture.
  28038. */
  28039. get aspectRatio(): number;
  28040. /**
  28041. * Get a value indicating if the post-process is ready to be used
  28042. * @returns true if the post-process is ready (shader is compiled)
  28043. */
  28044. isReady(): boolean;
  28045. /**
  28046. * Binds all textures and uniforms to the shader, this will be run on every pass.
  28047. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  28048. */
  28049. apply(): Nullable<Effect>;
  28050. private _disposeTextures;
  28051. /**
  28052. * Sets the required values to the prepass renderer.
  28053. * @param prePassRenderer defines the prepass renderer to setup.
  28054. * @returns true if the pre pass is needed.
  28055. */
  28056. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28057. /**
  28058. * Disposes the post process.
  28059. * @param camera The camera to dispose the post process on.
  28060. */
  28061. dispose(camera?: Camera): void;
  28062. /**
  28063. * Serializes the particle system to a JSON object
  28064. * @returns the JSON object
  28065. */
  28066. serialize(): any;
  28067. /**
  28068. * Creates a material from parsed material data
  28069. * @param parsedPostProcess defines parsed post process data
  28070. * @param scene defines the hosting scene
  28071. * @param rootUrl defines the root URL to use to load textures
  28072. * @returns a new post process
  28073. */
  28074. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  28075. }
  28076. }
  28077. declare module BABYLON {
  28078. /** @hidden */
  28079. export var kernelBlurVaryingDeclaration: {
  28080. name: string;
  28081. shader: string;
  28082. };
  28083. }
  28084. declare module BABYLON {
  28085. /** @hidden */
  28086. export var kernelBlurFragment: {
  28087. name: string;
  28088. shader: string;
  28089. };
  28090. }
  28091. declare module BABYLON {
  28092. /** @hidden */
  28093. export var kernelBlurFragment2: {
  28094. name: string;
  28095. shader: string;
  28096. };
  28097. }
  28098. declare module BABYLON {
  28099. /** @hidden */
  28100. export var kernelBlurPixelShader: {
  28101. name: string;
  28102. shader: string;
  28103. };
  28104. }
  28105. declare module BABYLON {
  28106. /** @hidden */
  28107. export var kernelBlurVertex: {
  28108. name: string;
  28109. shader: string;
  28110. };
  28111. }
  28112. declare module BABYLON {
  28113. /** @hidden */
  28114. export var kernelBlurVertexShader: {
  28115. name: string;
  28116. shader: string;
  28117. };
  28118. }
  28119. declare module BABYLON {
  28120. /**
  28121. * The Blur Post Process which blurs an image based on a kernel and direction.
  28122. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  28123. */
  28124. export class BlurPostProcess extends PostProcess {
  28125. private blockCompilation;
  28126. protected _kernel: number;
  28127. protected _idealKernel: number;
  28128. protected _packedFloat: boolean;
  28129. private _staticDefines;
  28130. /** The direction in which to blur the image. */
  28131. direction: Vector2;
  28132. /**
  28133. * Sets the length in pixels of the blur sample region
  28134. */
  28135. set kernel(v: number);
  28136. /**
  28137. * Gets the length in pixels of the blur sample region
  28138. */
  28139. get kernel(): number;
  28140. /**
  28141. * Sets wether or not the blur needs to unpack/repack floats
  28142. */
  28143. set packedFloat(v: boolean);
  28144. /**
  28145. * Gets wether or not the blur is unpacking/repacking floats
  28146. */
  28147. get packedFloat(): boolean;
  28148. /**
  28149. * Gets a string identifying the name of the class
  28150. * @returns "BlurPostProcess" string
  28151. */
  28152. getClassName(): string;
  28153. /**
  28154. * Creates a new instance BlurPostProcess
  28155. * @param name The name of the effect.
  28156. * @param direction The direction in which to blur the image.
  28157. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  28158. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  28159. * @param camera The camera to apply the render pass to.
  28160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  28161. * @param engine The engine which the post process will be applied. (default: current engine)
  28162. * @param reusable If the post process can be reused on the same frame. (default: false)
  28163. * @param textureType Type of textures used when performing the post process. (default: 0)
  28164. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  28165. */
  28166. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  28167. /**
  28168. * Updates the effect with the current post process compile time values and recompiles the shader.
  28169. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  28170. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  28171. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  28172. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  28173. * @param onCompiled Called when the shader has been compiled.
  28174. * @param onError Called if there is an error when compiling a shader.
  28175. */
  28176. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28177. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  28178. /**
  28179. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  28180. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  28181. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  28182. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  28183. * The gaps between physical kernels are compensated for in the weighting of the samples
  28184. * @param idealKernel Ideal blur kernel.
  28185. * @return Nearest best kernel.
  28186. */
  28187. protected _nearestBestKernel(idealKernel: number): number;
  28188. /**
  28189. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  28190. * @param x The point on the Gaussian distribution to sample.
  28191. * @return the value of the Gaussian function at x.
  28192. */
  28193. protected _gaussianWeight(x: number): number;
  28194. /**
  28195. * Generates a string that can be used as a floating point number in GLSL.
  28196. * @param x Value to print.
  28197. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  28198. * @return GLSL float string.
  28199. */
  28200. protected _glslFloat(x: number, decimalFigures?: number): string;
  28201. /** @hidden */
  28202. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  28203. }
  28204. }
  28205. declare module BABYLON {
  28206. /**
  28207. * Mirror texture can be used to simulate the view from a mirror in a scene.
  28208. * It will dynamically be rendered every frame to adapt to the camera point of view.
  28209. * You can then easily use it as a reflectionTexture on a flat surface.
  28210. * In case the surface is not a plane, please consider relying on reflection probes.
  28211. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28212. */
  28213. export class MirrorTexture extends RenderTargetTexture {
  28214. private scene;
  28215. /**
  28216. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  28217. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  28218. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28219. */
  28220. mirrorPlane: Plane;
  28221. /**
  28222. * Define the blur ratio used to blur the reflection if needed.
  28223. */
  28224. set blurRatio(value: number);
  28225. get blurRatio(): number;
  28226. /**
  28227. * Define the adaptive blur kernel used to blur the reflection if needed.
  28228. * This will autocompute the closest best match for the `blurKernel`
  28229. */
  28230. set adaptiveBlurKernel(value: number);
  28231. /**
  28232. * Define the blur kernel used to blur the reflection if needed.
  28233. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28234. */
  28235. set blurKernel(value: number);
  28236. /**
  28237. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  28238. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28239. */
  28240. set blurKernelX(value: number);
  28241. get blurKernelX(): number;
  28242. /**
  28243. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  28244. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  28245. */
  28246. set blurKernelY(value: number);
  28247. get blurKernelY(): number;
  28248. private _autoComputeBlurKernel;
  28249. protected _onRatioRescale(): void;
  28250. private _updateGammaSpace;
  28251. private _imageProcessingConfigChangeObserver;
  28252. private _transformMatrix;
  28253. private _mirrorMatrix;
  28254. private _savedViewMatrix;
  28255. private _blurX;
  28256. private _blurY;
  28257. private _adaptiveBlurKernel;
  28258. private _blurKernelX;
  28259. private _blurKernelY;
  28260. private _blurRatio;
  28261. /**
  28262. * Instantiates a Mirror Texture.
  28263. * Mirror texture can be used to simulate the view from a mirror in a scene.
  28264. * It will dynamically be rendered every frame to adapt to the camera point of view.
  28265. * You can then easily use it as a reflectionTexture on a flat surface.
  28266. * In case the surface is not a plane, please consider relying on reflection probes.
  28267. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  28268. * @param name
  28269. * @param size
  28270. * @param scene
  28271. * @param generateMipMaps
  28272. * @param type
  28273. * @param samplingMode
  28274. * @param generateDepthBuffer
  28275. */
  28276. constructor(name: string, size: number | {
  28277. width: number;
  28278. height: number;
  28279. } | {
  28280. ratio: number;
  28281. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  28282. private _preparePostProcesses;
  28283. /**
  28284. * Clone the mirror texture.
  28285. * @returns the cloned texture
  28286. */
  28287. clone(): MirrorTexture;
  28288. /**
  28289. * Serialize the texture to a JSON representation you could use in Parse later on
  28290. * @returns the serialized JSON representation
  28291. */
  28292. serialize(): any;
  28293. /**
  28294. * Dispose the texture and release its associated resources.
  28295. */
  28296. dispose(): void;
  28297. }
  28298. }
  28299. declare module BABYLON {
  28300. /**
  28301. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28302. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28303. */
  28304. export class Texture extends BaseTexture {
  28305. /**
  28306. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  28307. */
  28308. static SerializeBuffers: boolean;
  28309. /** @hidden */
  28310. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  28311. /** @hidden */
  28312. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  28313. /** @hidden */
  28314. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  28315. /** nearest is mag = nearest and min = nearest and mip = linear */
  28316. static readonly NEAREST_SAMPLINGMODE: number;
  28317. /** nearest is mag = nearest and min = nearest and mip = linear */
  28318. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  28319. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28320. static readonly BILINEAR_SAMPLINGMODE: number;
  28321. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28322. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  28323. /** Trilinear is mag = linear and min = linear and mip = linear */
  28324. static readonly TRILINEAR_SAMPLINGMODE: number;
  28325. /** Trilinear is mag = linear and min = linear and mip = linear */
  28326. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  28327. /** mag = nearest and min = nearest and mip = nearest */
  28328. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  28329. /** mag = nearest and min = linear and mip = nearest */
  28330. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  28331. /** mag = nearest and min = linear and mip = linear */
  28332. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  28333. /** mag = nearest and min = linear and mip = none */
  28334. static readonly NEAREST_LINEAR: number;
  28335. /** mag = nearest and min = nearest and mip = none */
  28336. static readonly NEAREST_NEAREST: number;
  28337. /** mag = linear and min = nearest and mip = nearest */
  28338. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  28339. /** mag = linear and min = nearest and mip = linear */
  28340. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  28341. /** mag = linear and min = linear and mip = none */
  28342. static readonly LINEAR_LINEAR: number;
  28343. /** mag = linear and min = nearest and mip = none */
  28344. static readonly LINEAR_NEAREST: number;
  28345. /** Explicit coordinates mode */
  28346. static readonly EXPLICIT_MODE: number;
  28347. /** Spherical coordinates mode */
  28348. static readonly SPHERICAL_MODE: number;
  28349. /** Planar coordinates mode */
  28350. static readonly PLANAR_MODE: number;
  28351. /** Cubic coordinates mode */
  28352. static readonly CUBIC_MODE: number;
  28353. /** Projection coordinates mode */
  28354. static readonly PROJECTION_MODE: number;
  28355. /** Inverse Cubic coordinates mode */
  28356. static readonly SKYBOX_MODE: number;
  28357. /** Inverse Cubic coordinates mode */
  28358. static readonly INVCUBIC_MODE: number;
  28359. /** Equirectangular coordinates mode */
  28360. static readonly EQUIRECTANGULAR_MODE: number;
  28361. /** Equirectangular Fixed coordinates mode */
  28362. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  28363. /** Equirectangular Fixed Mirrored coordinates mode */
  28364. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28365. /** Texture is not repeating outside of 0..1 UVs */
  28366. static readonly CLAMP_ADDRESSMODE: number;
  28367. /** Texture is repeating outside of 0..1 UVs */
  28368. static readonly WRAP_ADDRESSMODE: number;
  28369. /** Texture is repeating and mirrored */
  28370. static readonly MIRROR_ADDRESSMODE: number;
  28371. /**
  28372. * 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
  28373. */
  28374. static UseSerializedUrlIfAny: boolean;
  28375. /**
  28376. * Define the url of the texture.
  28377. */
  28378. url: Nullable<string>;
  28379. /**
  28380. * Define an offset on the texture to offset the u coordinates of the UVs
  28381. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28382. */
  28383. uOffset: number;
  28384. /**
  28385. * Define an offset on the texture to offset the v coordinates of the UVs
  28386. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28387. */
  28388. vOffset: number;
  28389. /**
  28390. * Define an offset on the texture to scale the u coordinates of the UVs
  28391. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28392. */
  28393. uScale: number;
  28394. /**
  28395. * Define an offset on the texture to scale the v coordinates of the UVs
  28396. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28397. */
  28398. vScale: number;
  28399. /**
  28400. * Define an offset on the texture to rotate around the u coordinates of the UVs
  28401. * @see https://doc.babylonjs.com/how_to/more_materials
  28402. */
  28403. uAng: number;
  28404. /**
  28405. * Define an offset on the texture to rotate around the v coordinates of the UVs
  28406. * @see https://doc.babylonjs.com/how_to/more_materials
  28407. */
  28408. vAng: number;
  28409. /**
  28410. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  28411. * @see https://doc.babylonjs.com/how_to/more_materials
  28412. */
  28413. wAng: number;
  28414. /**
  28415. * Defines the center of rotation (U)
  28416. */
  28417. uRotationCenter: number;
  28418. /**
  28419. * Defines the center of rotation (V)
  28420. */
  28421. vRotationCenter: number;
  28422. /**
  28423. * Defines the center of rotation (W)
  28424. */
  28425. wRotationCenter: number;
  28426. /**
  28427. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  28428. */
  28429. homogeneousRotationInUVTransform: boolean;
  28430. /**
  28431. * Are mip maps generated for this texture or not.
  28432. */
  28433. get noMipmap(): boolean;
  28434. /**
  28435. * List of inspectable custom properties (used by the Inspector)
  28436. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28437. */
  28438. inspectableCustomProperties: Nullable<IInspectable[]>;
  28439. private _noMipmap;
  28440. /** @hidden */
  28441. _invertY: boolean;
  28442. private _rowGenerationMatrix;
  28443. private _cachedTextureMatrix;
  28444. private _projectionModeMatrix;
  28445. private _t0;
  28446. private _t1;
  28447. private _t2;
  28448. private _cachedUOffset;
  28449. private _cachedVOffset;
  28450. private _cachedUScale;
  28451. private _cachedVScale;
  28452. private _cachedUAng;
  28453. private _cachedVAng;
  28454. private _cachedWAng;
  28455. private _cachedProjectionMatrixId;
  28456. private _cachedURotationCenter;
  28457. private _cachedVRotationCenter;
  28458. private _cachedWRotationCenter;
  28459. private _cachedHomogeneousRotationInUVTransform;
  28460. private _cachedCoordinatesMode;
  28461. /** @hidden */
  28462. protected _initialSamplingMode: number;
  28463. /** @hidden */
  28464. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  28465. private _deleteBuffer;
  28466. protected _format: Nullable<number>;
  28467. private _delayedOnLoad;
  28468. private _delayedOnError;
  28469. private _mimeType?;
  28470. private _loaderOptions?;
  28471. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  28472. get mimeType(): string | undefined;
  28473. /**
  28474. * Observable triggered once the texture has been loaded.
  28475. */
  28476. onLoadObservable: Observable<Texture>;
  28477. protected _isBlocking: boolean;
  28478. /**
  28479. * Is the texture preventing material to render while loading.
  28480. * If false, a default texture will be used instead of the loading one during the preparation step.
  28481. */
  28482. set isBlocking(value: boolean);
  28483. get isBlocking(): boolean;
  28484. /**
  28485. * Get the current sampling mode associated with the texture.
  28486. */
  28487. get samplingMode(): number;
  28488. /**
  28489. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  28490. */
  28491. get invertY(): boolean;
  28492. /**
  28493. * Instantiates a new texture.
  28494. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28495. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28496. * @param url defines the url of the picture to load as a texture
  28497. * @param sceneOrEngine defines the scene or engine the texture will belong to
  28498. * @param noMipmap defines if the texture will require mip maps or not
  28499. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  28500. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28501. * @param onLoad defines a callback triggered when the texture has been loaded
  28502. * @param onError defines a callback triggered when an error occurred during the loading session
  28503. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  28504. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  28505. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28506. * @param mimeType defines an optional mime type information
  28507. * @param loaderOptions options to be passed to the loader
  28508. */
  28509. 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);
  28510. /**
  28511. * Update the url (and optional buffer) of this texture if url was null during construction.
  28512. * @param url the url of the texture
  28513. * @param buffer the buffer of the texture (defaults to null)
  28514. * @param onLoad callback called when the texture is loaded (defaults to null)
  28515. */
  28516. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  28517. /**
  28518. * Finish the loading sequence of a texture flagged as delayed load.
  28519. * @hidden
  28520. */
  28521. delayLoad(): void;
  28522. private _prepareRowForTextureGeneration;
  28523. /**
  28524. * Checks if the texture has the same transform matrix than another texture
  28525. * @param texture texture to check against
  28526. * @returns true if the transforms are the same, else false
  28527. */
  28528. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  28529. /**
  28530. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  28531. * @returns the transform matrix of the texture.
  28532. */
  28533. getTextureMatrix(uBase?: number): Matrix;
  28534. /**
  28535. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  28536. * @returns The reflection texture transform
  28537. */
  28538. getReflectionTextureMatrix(): Matrix;
  28539. /**
  28540. * Clones the texture.
  28541. * @returns the cloned texture
  28542. */
  28543. clone(): Texture;
  28544. /**
  28545. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28546. * @returns The JSON representation of the texture
  28547. */
  28548. serialize(): any;
  28549. /**
  28550. * Get the current class name of the texture useful for serialization or dynamic coding.
  28551. * @returns "Texture"
  28552. */
  28553. getClassName(): string;
  28554. /**
  28555. * Dispose the texture and release its associated resources.
  28556. */
  28557. dispose(): void;
  28558. /**
  28559. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  28560. * @param parsedTexture Define the JSON representation of the texture
  28561. * @param scene Define the scene the parsed texture should be instantiated in
  28562. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  28563. * @returns The parsed texture if successful
  28564. */
  28565. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  28566. /**
  28567. * Creates a texture from its base 64 representation.
  28568. * @param data Define the base64 payload without the data: prefix
  28569. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28570. * @param scene Define the scene the texture should belong to
  28571. * @param noMipmap Forces the texture to not create mip map information if true
  28572. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28573. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28574. * @param onLoad define a callback triggered when the texture has been loaded
  28575. * @param onError define a callback triggered when an error occurred during the loading session
  28576. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28577. * @returns the created texture
  28578. */
  28579. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  28580. /**
  28581. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  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 buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  28585. * @param scene Define the scene the texture should belong to
  28586. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  28587. * @param noMipmap Forces the texture to not create mip map information if true
  28588. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28589. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28590. * @param onLoad define a callback triggered when the texture has been loaded
  28591. * @param onError define a callback triggered when an error occurred during the loading session
  28592. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28593. * @returns the created texture
  28594. */
  28595. 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;
  28596. }
  28597. }
  28598. declare module BABYLON {
  28599. /**
  28600. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28601. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28602. */
  28603. export class PostProcessManager {
  28604. private _scene;
  28605. private _indexBuffer;
  28606. private _vertexBuffers;
  28607. /**
  28608. * Creates a new instance PostProcess
  28609. * @param scene The scene that the post process is associated with.
  28610. */
  28611. constructor(scene: Scene);
  28612. private _prepareBuffers;
  28613. private _buildIndexBuffer;
  28614. /**
  28615. * Rebuilds the vertex buffers of the manager.
  28616. * @hidden
  28617. */
  28618. _rebuild(): void;
  28619. /**
  28620. * Prepares a frame to be run through a post process.
  28621. * @param sourceTexture The input texture to the post procesess. (default: null)
  28622. * @param postProcesses An array of post processes to be run. (default: null)
  28623. * @returns True if the post processes were able to be run.
  28624. * @hidden
  28625. */
  28626. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28627. /**
  28628. * Manually render a set of post processes to a texture.
  28629. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  28630. * @param postProcesses An array of post processes to be run.
  28631. * @param targetTexture The target texture to render to.
  28632. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28633. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28634. * @param lodLevel defines which lod of the texture to render to
  28635. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  28636. */
  28637. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  28638. /**
  28639. * Finalize the result of the output of the postprocesses.
  28640. * @param doNotPresent If true the result will not be displayed to the screen.
  28641. * @param targetTexture The target texture to render to.
  28642. * @param faceIndex The index of the face to bind the target texture to.
  28643. * @param postProcesses The array of post processes to render.
  28644. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28645. * @hidden
  28646. */
  28647. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28648. /**
  28649. * Disposes of the post process manager.
  28650. */
  28651. dispose(): void;
  28652. }
  28653. }
  28654. declare module BABYLON {
  28655. /**
  28656. * This Helps creating a texture that will be created from a camera in your scene.
  28657. * It is basically a dynamic texture that could be used to create special effects for instance.
  28658. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  28659. */
  28660. export class RenderTargetTexture extends Texture {
  28661. /**
  28662. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  28663. */
  28664. static readonly REFRESHRATE_RENDER_ONCE: number;
  28665. /**
  28666. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  28667. */
  28668. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  28669. /**
  28670. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  28671. * the central point of your effect and can save a lot of performances.
  28672. */
  28673. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  28674. /**
  28675. * Use this predicate to dynamically define the list of mesh you want to render.
  28676. * If set, the renderList property will be overwritten.
  28677. */
  28678. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  28679. private _renderList;
  28680. /**
  28681. * Use this list to define the list of mesh you want to render.
  28682. */
  28683. get renderList(): Nullable<Array<AbstractMesh>>;
  28684. set renderList(value: Nullable<Array<AbstractMesh>>);
  28685. /**
  28686. * Use this function to overload the renderList array at rendering time.
  28687. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  28688. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  28689. * the cube (if the RTT is a cube, else layerOrFace=0).
  28690. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  28691. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  28692. * hold dummy elements!
  28693. */
  28694. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  28695. private _hookArray;
  28696. /**
  28697. * Define if particles should be rendered in your texture.
  28698. */
  28699. renderParticles: boolean;
  28700. /**
  28701. * Define if sprites should be rendered in your texture.
  28702. */
  28703. renderSprites: boolean;
  28704. /**
  28705. * Define the camera used to render the texture.
  28706. */
  28707. activeCamera: Nullable<Camera>;
  28708. /**
  28709. * Override the mesh isReady function with your own one.
  28710. */
  28711. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  28712. /**
  28713. * Override the render function of the texture with your own one.
  28714. */
  28715. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  28716. /**
  28717. * Define if camera post processes should be use while rendering the texture.
  28718. */
  28719. useCameraPostProcesses: boolean;
  28720. /**
  28721. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  28722. */
  28723. ignoreCameraViewport: boolean;
  28724. private _postProcessManager;
  28725. private _postProcesses;
  28726. private _resizeObserver;
  28727. /**
  28728. * An event triggered when the texture is unbind.
  28729. */
  28730. onBeforeBindObservable: Observable<RenderTargetTexture>;
  28731. /**
  28732. * An event triggered when the texture is unbind.
  28733. */
  28734. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  28735. private _onAfterUnbindObserver;
  28736. /**
  28737. * Set a after unbind callback in the texture.
  28738. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  28739. */
  28740. set onAfterUnbind(callback: () => void);
  28741. /**
  28742. * An event triggered before rendering the texture
  28743. */
  28744. onBeforeRenderObservable: Observable<number>;
  28745. private _onBeforeRenderObserver;
  28746. /**
  28747. * Set a before render callback in the texture.
  28748. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  28749. */
  28750. set onBeforeRender(callback: (faceIndex: number) => void);
  28751. /**
  28752. * An event triggered after rendering the texture
  28753. */
  28754. onAfterRenderObservable: Observable<number>;
  28755. private _onAfterRenderObserver;
  28756. /**
  28757. * Set a after render callback in the texture.
  28758. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  28759. */
  28760. set onAfterRender(callback: (faceIndex: number) => void);
  28761. /**
  28762. * An event triggered after the texture clear
  28763. */
  28764. onClearObservable: Observable<Engine>;
  28765. private _onClearObserver;
  28766. /**
  28767. * Set a clear callback in the texture.
  28768. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  28769. */
  28770. set onClear(callback: (Engine: Engine) => void);
  28771. /**
  28772. * An event triggered when the texture is resized.
  28773. */
  28774. onResizeObservable: Observable<RenderTargetTexture>;
  28775. /**
  28776. * Define the clear color of the Render Target if it should be different from the scene.
  28777. */
  28778. clearColor: Color4;
  28779. protected _size: number | {
  28780. width: number;
  28781. height: number;
  28782. layers?: number;
  28783. };
  28784. protected _initialSizeParameter: number | {
  28785. width: number;
  28786. height: number;
  28787. } | {
  28788. ratio: number;
  28789. };
  28790. protected _sizeRatio: Nullable<number>;
  28791. /** @hidden */
  28792. _generateMipMaps: boolean;
  28793. protected _renderingManager: RenderingManager;
  28794. /** @hidden */
  28795. _waitingRenderList?: string[];
  28796. protected _doNotChangeAspectRatio: boolean;
  28797. protected _currentRefreshId: number;
  28798. protected _refreshRate: number;
  28799. protected _textureMatrix: Matrix;
  28800. protected _samples: number;
  28801. protected _renderTargetOptions: RenderTargetCreationOptions;
  28802. /**
  28803. * Gets render target creation options that were used.
  28804. */
  28805. get renderTargetOptions(): RenderTargetCreationOptions;
  28806. protected _onRatioRescale(): void;
  28807. /**
  28808. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  28809. * It must define where the camera used to render the texture is set
  28810. */
  28811. boundingBoxPosition: Vector3;
  28812. private _boundingBoxSize;
  28813. /**
  28814. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  28815. * When defined, the cubemap will switch to local mode
  28816. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  28817. * @example https://www.babylonjs-playground.com/#RNASML
  28818. */
  28819. set boundingBoxSize(value: Vector3);
  28820. get boundingBoxSize(): Vector3;
  28821. /**
  28822. * In case the RTT has been created with a depth texture, get the associated
  28823. * depth texture.
  28824. * Otherwise, return null.
  28825. */
  28826. get depthStencilTexture(): Nullable<InternalTexture>;
  28827. /**
  28828. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  28829. * or used a shadow, depth texture...
  28830. * @param name The friendly name of the texture
  28831. * @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)
  28832. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  28833. * @param generateMipMaps True if mip maps need to be generated after render.
  28834. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  28835. * @param type The type of the buffer in the RTT (int, half float, float...)
  28836. * @param isCube True if a cube texture needs to be created
  28837. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  28838. * @param generateDepthBuffer True to generate a depth buffer
  28839. * @param generateStencilBuffer True to generate a stencil buffer
  28840. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  28841. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  28842. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28843. */
  28844. constructor(name: string, size: number | {
  28845. width: number;
  28846. height: number;
  28847. layers?: number;
  28848. } | {
  28849. ratio: number;
  28850. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  28851. /**
  28852. * Creates a depth stencil texture.
  28853. * This is only available in WebGL 2 or with the depth texture extension available.
  28854. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  28855. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  28856. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  28857. */
  28858. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  28859. private _processSizeParameter;
  28860. /**
  28861. * Define the number of samples to use in case of MSAA.
  28862. * It defaults to one meaning no MSAA has been enabled.
  28863. */
  28864. get samples(): number;
  28865. set samples(value: number);
  28866. /**
  28867. * Resets the refresh counter of the texture and start bak from scratch.
  28868. * Could be useful to regenerate the texture if it is setup to render only once.
  28869. */
  28870. resetRefreshCounter(): void;
  28871. /**
  28872. * Define the refresh rate of the texture or the rendering frequency.
  28873. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  28874. */
  28875. get refreshRate(): number;
  28876. set refreshRate(value: number);
  28877. /**
  28878. * Adds a post process to the render target rendering passes.
  28879. * @param postProcess define the post process to add
  28880. */
  28881. addPostProcess(postProcess: PostProcess): void;
  28882. /**
  28883. * Clear all the post processes attached to the render target
  28884. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  28885. */
  28886. clearPostProcesses(dispose?: boolean): void;
  28887. /**
  28888. * Remove one of the post process from the list of attached post processes to the texture
  28889. * @param postProcess define the post process to remove from the list
  28890. */
  28891. removePostProcess(postProcess: PostProcess): void;
  28892. /** @hidden */
  28893. _shouldRender(): boolean;
  28894. /**
  28895. * Gets the actual render size of the texture.
  28896. * @returns the width of the render size
  28897. */
  28898. getRenderSize(): number;
  28899. /**
  28900. * Gets the actual render width of the texture.
  28901. * @returns the width of the render size
  28902. */
  28903. getRenderWidth(): number;
  28904. /**
  28905. * Gets the actual render height of the texture.
  28906. * @returns the height of the render size
  28907. */
  28908. getRenderHeight(): number;
  28909. /**
  28910. * Gets the actual number of layers of the texture.
  28911. * @returns the number of layers
  28912. */
  28913. getRenderLayers(): number;
  28914. /**
  28915. * Get if the texture can be rescaled or not.
  28916. */
  28917. get canRescale(): boolean;
  28918. /**
  28919. * Resize the texture using a ratio.
  28920. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  28921. */
  28922. scale(ratio: number): void;
  28923. /**
  28924. * Get the texture reflection matrix used to rotate/transform the reflection.
  28925. * @returns the reflection matrix
  28926. */
  28927. getReflectionTextureMatrix(): Matrix;
  28928. /**
  28929. * Resize the texture to a new desired size.
  28930. * Be carrefull as it will recreate all the data in the new texture.
  28931. * @param size Define the new size. It can be:
  28932. * - a number for squared texture,
  28933. * - an object containing { width: number, height: number }
  28934. * - or an object containing a ratio { ratio: number }
  28935. */
  28936. resize(size: number | {
  28937. width: number;
  28938. height: number;
  28939. } | {
  28940. ratio: number;
  28941. }): void;
  28942. private _defaultRenderListPrepared;
  28943. /**
  28944. * Renders all the objects from the render list into the texture.
  28945. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  28946. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  28947. */
  28948. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  28949. private _bestReflectionRenderTargetDimension;
  28950. private _prepareRenderingManager;
  28951. /**
  28952. * @hidden
  28953. * @param faceIndex face index to bind to if this is a cubetexture
  28954. * @param layer defines the index of the texture to bind in the array
  28955. */
  28956. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  28957. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  28958. private renderToTarget;
  28959. /**
  28960. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28961. * This allowed control for front to back rendering or reversly depending of the special needs.
  28962. *
  28963. * @param renderingGroupId The rendering group id corresponding to its index
  28964. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28965. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28966. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28967. */
  28968. 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;
  28969. /**
  28970. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28971. *
  28972. * @param renderingGroupId The rendering group id corresponding to its index
  28973. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28974. */
  28975. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  28976. /**
  28977. * Clones the texture.
  28978. * @returns the cloned texture
  28979. */
  28980. clone(): RenderTargetTexture;
  28981. /**
  28982. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28983. * @returns The JSON representation of the texture
  28984. */
  28985. serialize(): any;
  28986. /**
  28987. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  28988. */
  28989. disposeFramebufferObjects(): void;
  28990. /**
  28991. * Dispose the texture and release its associated resources.
  28992. */
  28993. dispose(): void;
  28994. /** @hidden */
  28995. _rebuild(): void;
  28996. /**
  28997. * Clear the info related to rendering groups preventing retention point in material dispose.
  28998. */
  28999. freeRenderingGroups(): void;
  29000. /**
  29001. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  29002. * @returns the view count
  29003. */
  29004. getViewCount(): number;
  29005. }
  29006. }
  29007. declare module BABYLON {
  29008. /**
  29009. * Class used to manipulate GUIDs
  29010. */
  29011. export class GUID {
  29012. /**
  29013. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29014. * Be aware Math.random() could cause collisions, but:
  29015. * "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"
  29016. * @returns a pseudo random id
  29017. */
  29018. static RandomId(): string;
  29019. }
  29020. }
  29021. declare module BABYLON {
  29022. /**
  29023. * Options to be used when creating a shadow depth material
  29024. */
  29025. export interface IIOptionShadowDepthMaterial {
  29026. /** Variables in the vertex shader code that need to have their names remapped.
  29027. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29028. * "var_name" should be either: worldPos or vNormalW
  29029. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29030. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29031. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29032. */
  29033. remappedVariables?: string[];
  29034. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29035. standalone?: boolean;
  29036. }
  29037. /**
  29038. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29039. */
  29040. export class ShadowDepthWrapper {
  29041. private _scene;
  29042. private _options?;
  29043. private _baseMaterial;
  29044. private _onEffectCreatedObserver;
  29045. private _subMeshToEffect;
  29046. private _subMeshToDepthEffect;
  29047. private _meshes;
  29048. /** @hidden */
  29049. _matriceNames: any;
  29050. /** Gets the standalone status of the wrapper */
  29051. get standalone(): boolean;
  29052. /** Gets the base material the wrapper is built upon */
  29053. get baseMaterial(): Material;
  29054. /**
  29055. * Instantiate a new shadow depth wrapper.
  29056. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29057. * generate the shadow depth map. For more information, please refer to the documentation:
  29058. * https://doc.babylonjs.com/babylon101/shadows
  29059. * @param baseMaterial Material to wrap
  29060. * @param scene Define the scene the material belongs to
  29061. * @param options Options used to create the wrapper
  29062. */
  29063. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29064. /**
  29065. * Gets the effect to use to generate the depth map
  29066. * @param subMesh subMesh to get the effect for
  29067. * @param shadowGenerator shadow generator to get the effect for
  29068. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29069. */
  29070. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29071. /**
  29072. * Specifies that the submesh is ready to be used for depth rendering
  29073. * @param subMesh submesh to check
  29074. * @param defines the list of defines to take into account when checking the effect
  29075. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29076. * @param useInstances specifies that instances should be used
  29077. * @returns a boolean indicating that the submesh is ready or not
  29078. */
  29079. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29080. /**
  29081. * Disposes the resources
  29082. */
  29083. dispose(): void;
  29084. private _makeEffect;
  29085. }
  29086. }
  29087. declare module BABYLON {
  29088. /**
  29089. * Options for compiling materials.
  29090. */
  29091. export interface IMaterialCompilationOptions {
  29092. /**
  29093. * Defines whether clip planes are enabled.
  29094. */
  29095. clipPlane: boolean;
  29096. /**
  29097. * Defines whether instances are enabled.
  29098. */
  29099. useInstances: boolean;
  29100. }
  29101. /**
  29102. * Options passed when calling customShaderNameResolve
  29103. */
  29104. export interface ICustomShaderNameResolveOptions {
  29105. /**
  29106. * 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
  29107. */
  29108. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29109. }
  29110. /**
  29111. * Base class for the main features of a material in Babylon.js
  29112. */
  29113. export class Material implements IAnimatable {
  29114. /**
  29115. * Returns the triangle fill mode
  29116. */
  29117. static readonly TriangleFillMode: number;
  29118. /**
  29119. * Returns the wireframe mode
  29120. */
  29121. static readonly WireFrameFillMode: number;
  29122. /**
  29123. * Returns the point fill mode
  29124. */
  29125. static readonly PointFillMode: number;
  29126. /**
  29127. * Returns the point list draw mode
  29128. */
  29129. static readonly PointListDrawMode: number;
  29130. /**
  29131. * Returns the line list draw mode
  29132. */
  29133. static readonly LineListDrawMode: number;
  29134. /**
  29135. * Returns the line loop draw mode
  29136. */
  29137. static readonly LineLoopDrawMode: number;
  29138. /**
  29139. * Returns the line strip draw mode
  29140. */
  29141. static readonly LineStripDrawMode: number;
  29142. /**
  29143. * Returns the triangle strip draw mode
  29144. */
  29145. static readonly TriangleStripDrawMode: number;
  29146. /**
  29147. * Returns the triangle fan draw mode
  29148. */
  29149. static readonly TriangleFanDrawMode: number;
  29150. /**
  29151. * Stores the clock-wise side orientation
  29152. */
  29153. static readonly ClockWiseSideOrientation: number;
  29154. /**
  29155. * Stores the counter clock-wise side orientation
  29156. */
  29157. static readonly CounterClockWiseSideOrientation: number;
  29158. /**
  29159. * The dirty texture flag value
  29160. */
  29161. static readonly TextureDirtyFlag: number;
  29162. /**
  29163. * The dirty light flag value
  29164. */
  29165. static readonly LightDirtyFlag: number;
  29166. /**
  29167. * The dirty fresnel flag value
  29168. */
  29169. static readonly FresnelDirtyFlag: number;
  29170. /**
  29171. * The dirty attribute flag value
  29172. */
  29173. static readonly AttributesDirtyFlag: number;
  29174. /**
  29175. * The dirty misc flag value
  29176. */
  29177. static readonly MiscDirtyFlag: number;
  29178. /**
  29179. * The dirty prepass flag value
  29180. */
  29181. static readonly PrePassDirtyFlag: number;
  29182. /**
  29183. * The all dirty flag value
  29184. */
  29185. static readonly AllDirtyFlag: number;
  29186. /**
  29187. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  29188. */
  29189. static readonly MATERIAL_OPAQUE: number;
  29190. /**
  29191. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  29192. */
  29193. static readonly MATERIAL_ALPHATEST: number;
  29194. /**
  29195. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29196. */
  29197. static readonly MATERIAL_ALPHABLEND: number;
  29198. /**
  29199. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29200. * They are also discarded below the alpha cutoff threshold to improve performances.
  29201. */
  29202. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  29203. /**
  29204. * The Whiteout method is used to blend normals.
  29205. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29206. */
  29207. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  29208. /**
  29209. * The Reoriented Normal Mapping method is used to blend normals.
  29210. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29211. */
  29212. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  29213. /**
  29214. * Custom callback helping to override the default shader used in the material.
  29215. */
  29216. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  29217. /**
  29218. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  29219. */
  29220. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  29221. /**
  29222. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  29223. * This means that the material can keep using a previous shader while a new one is being compiled.
  29224. * This is mostly used when shader parallel compilation is supported (true by default)
  29225. */
  29226. allowShaderHotSwapping: boolean;
  29227. /**
  29228. * The ID of the material
  29229. */
  29230. id: string;
  29231. /**
  29232. * Gets or sets the unique id of the material
  29233. */
  29234. uniqueId: number;
  29235. /**
  29236. * The name of the material
  29237. */
  29238. name: string;
  29239. /**
  29240. * Gets or sets user defined metadata
  29241. */
  29242. metadata: any;
  29243. /**
  29244. * For internal use only. Please do not use.
  29245. */
  29246. reservedDataStore: any;
  29247. /**
  29248. * Specifies if the ready state should be checked on each call
  29249. */
  29250. checkReadyOnEveryCall: boolean;
  29251. /**
  29252. * Specifies if the ready state should be checked once
  29253. */
  29254. checkReadyOnlyOnce: boolean;
  29255. /**
  29256. * The state of the material
  29257. */
  29258. state: string;
  29259. /**
  29260. * If the material can be rendered to several textures with MRT extension
  29261. */
  29262. get canRenderToMRT(): boolean;
  29263. /**
  29264. * The alpha value of the material
  29265. */
  29266. protected _alpha: number;
  29267. /**
  29268. * List of inspectable custom properties (used by the Inspector)
  29269. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29270. */
  29271. inspectableCustomProperties: IInspectable[];
  29272. /**
  29273. * Sets the alpha value of the material
  29274. */
  29275. set alpha(value: number);
  29276. /**
  29277. * Gets the alpha value of the material
  29278. */
  29279. get alpha(): number;
  29280. /**
  29281. * Specifies if back face culling is enabled
  29282. */
  29283. protected _backFaceCulling: boolean;
  29284. /**
  29285. * Sets the back-face culling state
  29286. */
  29287. set backFaceCulling(value: boolean);
  29288. /**
  29289. * Gets the back-face culling state
  29290. */
  29291. get backFaceCulling(): boolean;
  29292. /**
  29293. * Stores the value for side orientation
  29294. */
  29295. sideOrientation: number;
  29296. /**
  29297. * Callback triggered when the material is compiled
  29298. */
  29299. onCompiled: Nullable<(effect: Effect) => void>;
  29300. /**
  29301. * Callback triggered when an error occurs
  29302. */
  29303. onError: Nullable<(effect: Effect, errors: string) => void>;
  29304. /**
  29305. * Callback triggered to get the render target textures
  29306. */
  29307. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29308. /**
  29309. * Gets a boolean indicating that current material needs to register RTT
  29310. */
  29311. get hasRenderTargetTextures(): boolean;
  29312. /**
  29313. * Specifies if the material should be serialized
  29314. */
  29315. doNotSerialize: boolean;
  29316. /**
  29317. * @hidden
  29318. */
  29319. _storeEffectOnSubMeshes: boolean;
  29320. /**
  29321. * Stores the animations for the material
  29322. */
  29323. animations: Nullable<Array<Animation>>;
  29324. /**
  29325. * An event triggered when the material is disposed
  29326. */
  29327. onDisposeObservable: Observable<Material>;
  29328. /**
  29329. * An observer which watches for dispose events
  29330. */
  29331. private _onDisposeObserver;
  29332. private _onUnBindObservable;
  29333. /**
  29334. * Called during a dispose event
  29335. */
  29336. set onDispose(callback: () => void);
  29337. private _onBindObservable;
  29338. /**
  29339. * An event triggered when the material is bound
  29340. */
  29341. get onBindObservable(): Observable<AbstractMesh>;
  29342. /**
  29343. * An observer which watches for bind events
  29344. */
  29345. private _onBindObserver;
  29346. /**
  29347. * Called during a bind event
  29348. */
  29349. set onBind(callback: (Mesh: AbstractMesh) => void);
  29350. /**
  29351. * An event triggered when the material is unbound
  29352. */
  29353. get onUnBindObservable(): Observable<Material>;
  29354. protected _onEffectCreatedObservable: Nullable<Observable<{
  29355. effect: Effect;
  29356. subMesh: Nullable<SubMesh>;
  29357. }>>;
  29358. /**
  29359. * An event triggered when the effect is (re)created
  29360. */
  29361. get onEffectCreatedObservable(): Observable<{
  29362. effect: Effect;
  29363. subMesh: Nullable<SubMesh>;
  29364. }>;
  29365. /**
  29366. * Stores the value of the alpha mode
  29367. */
  29368. private _alphaMode;
  29369. /**
  29370. * Sets the value of the alpha mode.
  29371. *
  29372. * | Value | Type | Description |
  29373. * | --- | --- | --- |
  29374. * | 0 | ALPHA_DISABLE | |
  29375. * | 1 | ALPHA_ADD | |
  29376. * | 2 | ALPHA_COMBINE | |
  29377. * | 3 | ALPHA_SUBTRACT | |
  29378. * | 4 | ALPHA_MULTIPLY | |
  29379. * | 5 | ALPHA_MAXIMIZED | |
  29380. * | 6 | ALPHA_ONEONE | |
  29381. * | 7 | ALPHA_PREMULTIPLIED | |
  29382. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29383. * | 9 | ALPHA_INTERPOLATE | |
  29384. * | 10 | ALPHA_SCREENMODE | |
  29385. *
  29386. */
  29387. set alphaMode(value: number);
  29388. /**
  29389. * Gets the value of the alpha mode
  29390. */
  29391. get alphaMode(): number;
  29392. /**
  29393. * Stores the state of the need depth pre-pass value
  29394. */
  29395. private _needDepthPrePass;
  29396. /**
  29397. * Sets the need depth pre-pass value
  29398. */
  29399. set needDepthPrePass(value: boolean);
  29400. /**
  29401. * Gets the depth pre-pass value
  29402. */
  29403. get needDepthPrePass(): boolean;
  29404. /**
  29405. * Specifies if depth writing should be disabled
  29406. */
  29407. disableDepthWrite: boolean;
  29408. /**
  29409. * Specifies if color writing should be disabled
  29410. */
  29411. disableColorWrite: boolean;
  29412. /**
  29413. * Specifies if depth writing should be forced
  29414. */
  29415. forceDepthWrite: boolean;
  29416. /**
  29417. * Specifies the depth function that should be used. 0 means the default engine function
  29418. */
  29419. depthFunction: number;
  29420. /**
  29421. * Specifies if there should be a separate pass for culling
  29422. */
  29423. separateCullingPass: boolean;
  29424. /**
  29425. * Stores the state specifing if fog should be enabled
  29426. */
  29427. private _fogEnabled;
  29428. /**
  29429. * Sets the state for enabling fog
  29430. */
  29431. set fogEnabled(value: boolean);
  29432. /**
  29433. * Gets the value of the fog enabled state
  29434. */
  29435. get fogEnabled(): boolean;
  29436. /**
  29437. * Stores the size of points
  29438. */
  29439. pointSize: number;
  29440. /**
  29441. * Stores the z offset value
  29442. */
  29443. zOffset: number;
  29444. get wireframe(): boolean;
  29445. /**
  29446. * Sets the state of wireframe mode
  29447. */
  29448. set wireframe(value: boolean);
  29449. /**
  29450. * Gets the value specifying if point clouds are enabled
  29451. */
  29452. get pointsCloud(): boolean;
  29453. /**
  29454. * Sets the state of point cloud mode
  29455. */
  29456. set pointsCloud(value: boolean);
  29457. /**
  29458. * Gets the material fill mode
  29459. */
  29460. get fillMode(): number;
  29461. /**
  29462. * Sets the material fill mode
  29463. */
  29464. set fillMode(value: number);
  29465. /**
  29466. * @hidden
  29467. * Stores the effects for the material
  29468. */
  29469. _effect: Nullable<Effect>;
  29470. /**
  29471. * Specifies if uniform buffers should be used
  29472. */
  29473. private _useUBO;
  29474. /**
  29475. * Stores a reference to the scene
  29476. */
  29477. private _scene;
  29478. /**
  29479. * Stores the fill mode state
  29480. */
  29481. private _fillMode;
  29482. /**
  29483. * Specifies if the depth write state should be cached
  29484. */
  29485. private _cachedDepthWriteState;
  29486. /**
  29487. * Specifies if the color write state should be cached
  29488. */
  29489. private _cachedColorWriteState;
  29490. /**
  29491. * Specifies if the depth function state should be cached
  29492. */
  29493. private _cachedDepthFunctionState;
  29494. /**
  29495. * Stores the uniform buffer
  29496. */
  29497. protected _uniformBuffer: UniformBuffer;
  29498. /** @hidden */
  29499. _indexInSceneMaterialArray: number;
  29500. /** @hidden */
  29501. meshMap: Nullable<{
  29502. [id: string]: AbstractMesh | undefined;
  29503. }>;
  29504. /**
  29505. * Creates a material instance
  29506. * @param name defines the name of the material
  29507. * @param scene defines the scene to reference
  29508. * @param doNotAdd specifies if the material should be added to the scene
  29509. */
  29510. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29511. /**
  29512. * Returns a string representation of the current material
  29513. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29514. * @returns a string with material information
  29515. */
  29516. toString(fullDetails?: boolean): string;
  29517. /**
  29518. * Gets the class name of the material
  29519. * @returns a string with the class name of the material
  29520. */
  29521. getClassName(): string;
  29522. /**
  29523. * Specifies if updates for the material been locked
  29524. */
  29525. get isFrozen(): boolean;
  29526. /**
  29527. * Locks updates for the material
  29528. */
  29529. freeze(): void;
  29530. /**
  29531. * Unlocks updates for the material
  29532. */
  29533. unfreeze(): void;
  29534. /**
  29535. * Specifies if the material is ready to be used
  29536. * @param mesh defines the mesh to check
  29537. * @param useInstances specifies if instances should be used
  29538. * @returns a boolean indicating if the material is ready to be used
  29539. */
  29540. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29541. /**
  29542. * Specifies that the submesh is ready to be used
  29543. * @param mesh defines the mesh to check
  29544. * @param subMesh defines which submesh to check
  29545. * @param useInstances specifies that instances should be used
  29546. * @returns a boolean indicating that the submesh is ready or not
  29547. */
  29548. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29549. /**
  29550. * Returns the material effect
  29551. * @returns the effect associated with the material
  29552. */
  29553. getEffect(): Nullable<Effect>;
  29554. /**
  29555. * Returns the current scene
  29556. * @returns a Scene
  29557. */
  29558. getScene(): Scene;
  29559. /**
  29560. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29561. */
  29562. protected _forceAlphaTest: boolean;
  29563. /**
  29564. * The transparency mode of the material.
  29565. */
  29566. protected _transparencyMode: Nullable<number>;
  29567. /**
  29568. * Gets the current transparency mode.
  29569. */
  29570. get transparencyMode(): Nullable<number>;
  29571. /**
  29572. * Sets the transparency mode of the material.
  29573. *
  29574. * | Value | Type | Description |
  29575. * | ----- | ----------------------------------- | ----------- |
  29576. * | 0 | OPAQUE | |
  29577. * | 1 | ALPHATEST | |
  29578. * | 2 | ALPHABLEND | |
  29579. * | 3 | ALPHATESTANDBLEND | |
  29580. *
  29581. */
  29582. set transparencyMode(value: Nullable<number>);
  29583. /**
  29584. * Returns true if alpha blending should be disabled.
  29585. */
  29586. protected get _disableAlphaBlending(): boolean;
  29587. /**
  29588. * Specifies whether or not this material should be rendered in alpha blend mode.
  29589. * @returns a boolean specifying if alpha blending is needed
  29590. */
  29591. needAlphaBlending(): boolean;
  29592. /**
  29593. * Specifies if the mesh will require alpha blending
  29594. * @param mesh defines the mesh to check
  29595. * @returns a boolean specifying if alpha blending is needed for the mesh
  29596. */
  29597. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29598. /**
  29599. * Specifies whether or not this material should be rendered in alpha test mode.
  29600. * @returns a boolean specifying if an alpha test is needed.
  29601. */
  29602. needAlphaTesting(): boolean;
  29603. /**
  29604. * Specifies if material alpha testing should be turned on for the mesh
  29605. * @param mesh defines the mesh to check
  29606. */
  29607. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29608. /**
  29609. * Gets the texture used for the alpha test
  29610. * @returns the texture to use for alpha testing
  29611. */
  29612. getAlphaTestTexture(): Nullable<BaseTexture>;
  29613. /**
  29614. * Marks the material to indicate that it needs to be re-calculated
  29615. */
  29616. markDirty(): void;
  29617. /** @hidden */
  29618. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29619. /**
  29620. * Binds the material to the mesh
  29621. * @param world defines the world transformation matrix
  29622. * @param mesh defines the mesh to bind the material to
  29623. */
  29624. bind(world: Matrix, mesh?: Mesh): void;
  29625. /**
  29626. * Binds the submesh to the material
  29627. * @param world defines the world transformation matrix
  29628. * @param mesh defines the mesh containing the submesh
  29629. * @param subMesh defines the submesh to bind the material to
  29630. */
  29631. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29632. /**
  29633. * Binds the world matrix to the material
  29634. * @param world defines the world transformation matrix
  29635. */
  29636. bindOnlyWorldMatrix(world: Matrix): void;
  29637. /**
  29638. * Binds the scene's uniform buffer to the effect.
  29639. * @param effect defines the effect to bind to the scene uniform buffer
  29640. * @param sceneUbo defines the uniform buffer storing scene data
  29641. */
  29642. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29643. /**
  29644. * Binds the view matrix to the effect
  29645. * @param effect defines the effect to bind the view matrix to
  29646. */
  29647. bindView(effect: Effect): void;
  29648. /**
  29649. * Binds the view projection matrix to the effect
  29650. * @param effect defines the effect to bind the view projection matrix to
  29651. */
  29652. bindViewProjection(effect: Effect): void;
  29653. /**
  29654. * Processes to execute after binding the material to a mesh
  29655. * @param mesh defines the rendered mesh
  29656. */
  29657. protected _afterBind(mesh?: Mesh): void;
  29658. /**
  29659. * Unbinds the material from the mesh
  29660. */
  29661. unbind(): void;
  29662. /**
  29663. * Gets the active textures from the material
  29664. * @returns an array of textures
  29665. */
  29666. getActiveTextures(): BaseTexture[];
  29667. /**
  29668. * Specifies if the material uses a texture
  29669. * @param texture defines the texture to check against the material
  29670. * @returns a boolean specifying if the material uses the texture
  29671. */
  29672. hasTexture(texture: BaseTexture): boolean;
  29673. /**
  29674. * Makes a duplicate of the material, and gives it a new name
  29675. * @param name defines the new name for the duplicated material
  29676. * @returns the cloned material
  29677. */
  29678. clone(name: string): Nullable<Material>;
  29679. /**
  29680. * Gets the meshes bound to the material
  29681. * @returns an array of meshes bound to the material
  29682. */
  29683. getBindedMeshes(): AbstractMesh[];
  29684. /**
  29685. * Force shader compilation
  29686. * @param mesh defines the mesh associated with this material
  29687. * @param onCompiled defines a function to execute once the material is compiled
  29688. * @param options defines the options to configure the compilation
  29689. * @param onError defines a function to execute if the material fails compiling
  29690. */
  29691. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29692. /**
  29693. * Force shader compilation
  29694. * @param mesh defines the mesh that will use this material
  29695. * @param options defines additional options for compiling the shaders
  29696. * @returns a promise that resolves when the compilation completes
  29697. */
  29698. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29699. private static readonly _AllDirtyCallBack;
  29700. private static readonly _ImageProcessingDirtyCallBack;
  29701. private static readonly _TextureDirtyCallBack;
  29702. private static readonly _FresnelDirtyCallBack;
  29703. private static readonly _MiscDirtyCallBack;
  29704. private static readonly _PrePassDirtyCallBack;
  29705. private static readonly _LightsDirtyCallBack;
  29706. private static readonly _AttributeDirtyCallBack;
  29707. private static _FresnelAndMiscDirtyCallBack;
  29708. private static _TextureAndMiscDirtyCallBack;
  29709. private static readonly _DirtyCallbackArray;
  29710. private static readonly _RunDirtyCallBacks;
  29711. /**
  29712. * Marks a define in the material to indicate that it needs to be re-computed
  29713. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29714. */
  29715. markAsDirty(flag: number): void;
  29716. /**
  29717. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29718. * @param func defines a function which checks material defines against the submeshes
  29719. */
  29720. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29721. /**
  29722. * Indicates that the scene should check if the rendering now needs a prepass
  29723. */
  29724. protected _markScenePrePassDirty(): void;
  29725. /**
  29726. * Indicates that we need to re-calculated for all submeshes
  29727. */
  29728. protected _markAllSubMeshesAsAllDirty(): void;
  29729. /**
  29730. * Indicates that image processing needs to be re-calculated for all submeshes
  29731. */
  29732. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29733. /**
  29734. * Indicates that textures need to be re-calculated for all submeshes
  29735. */
  29736. protected _markAllSubMeshesAsTexturesDirty(): void;
  29737. /**
  29738. * Indicates that fresnel needs to be re-calculated for all submeshes
  29739. */
  29740. protected _markAllSubMeshesAsFresnelDirty(): void;
  29741. /**
  29742. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29743. */
  29744. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29745. /**
  29746. * Indicates that lights need to be re-calculated for all submeshes
  29747. */
  29748. protected _markAllSubMeshesAsLightsDirty(): void;
  29749. /**
  29750. * Indicates that attributes need to be re-calculated for all submeshes
  29751. */
  29752. protected _markAllSubMeshesAsAttributesDirty(): void;
  29753. /**
  29754. * Indicates that misc needs to be re-calculated for all submeshes
  29755. */
  29756. protected _markAllSubMeshesAsMiscDirty(): void;
  29757. /**
  29758. * Indicates that prepass needs to be re-calculated for all submeshes
  29759. */
  29760. protected _markAllSubMeshesAsPrePassDirty(): void;
  29761. /**
  29762. * Indicates that textures and misc need to be re-calculated for all submeshes
  29763. */
  29764. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29765. /**
  29766. * Sets the required values to the prepass renderer.
  29767. * @param prePassRenderer defines the prepass renderer to setup.
  29768. * @returns true if the pre pass is needed.
  29769. */
  29770. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29771. /**
  29772. * Disposes the material
  29773. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29774. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29775. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29776. */
  29777. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29778. /** @hidden */
  29779. private releaseVertexArrayObject;
  29780. /**
  29781. * Serializes this material
  29782. * @returns the serialized material object
  29783. */
  29784. serialize(): any;
  29785. /**
  29786. * Creates a material from parsed material data
  29787. * @param parsedMaterial defines parsed material data
  29788. * @param scene defines the hosting scene
  29789. * @param rootUrl defines the root URL to use to load textures
  29790. * @returns a new material
  29791. */
  29792. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29793. }
  29794. }
  29795. declare module BABYLON {
  29796. /**
  29797. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29798. * separate meshes. This can be use to improve performances.
  29799. * @see https://doc.babylonjs.com/how_to/multi_materials
  29800. */
  29801. export class MultiMaterial extends Material {
  29802. private _subMaterials;
  29803. /**
  29804. * Gets or Sets the list of Materials used within the multi material.
  29805. * They need to be ordered according to the submeshes order in the associated mesh
  29806. */
  29807. get subMaterials(): Nullable<Material>[];
  29808. set subMaterials(value: Nullable<Material>[]);
  29809. /**
  29810. * Function used to align with Node.getChildren()
  29811. * @returns the list of Materials used within the multi material
  29812. */
  29813. getChildren(): Nullable<Material>[];
  29814. /**
  29815. * Instantiates a new Multi Material
  29816. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29817. * separate meshes. This can be use to improve performances.
  29818. * @see https://doc.babylonjs.com/how_to/multi_materials
  29819. * @param name Define the name in the scene
  29820. * @param scene Define the scene the material belongs to
  29821. */
  29822. constructor(name: string, scene: Scene);
  29823. private _hookArray;
  29824. /**
  29825. * Get one of the submaterial by its index in the submaterials array
  29826. * @param index The index to look the sub material at
  29827. * @returns The Material if the index has been defined
  29828. */
  29829. getSubMaterial(index: number): Nullable<Material>;
  29830. /**
  29831. * Get the list of active textures for the whole sub materials list.
  29832. * @returns All the textures that will be used during the rendering
  29833. */
  29834. getActiveTextures(): BaseTexture[];
  29835. /**
  29836. * Gets the current class name of the material e.g. "MultiMaterial"
  29837. * Mainly use in serialization.
  29838. * @returns the class name
  29839. */
  29840. getClassName(): string;
  29841. /**
  29842. * Checks if the material is ready to render the requested sub mesh
  29843. * @param mesh Define the mesh the submesh belongs to
  29844. * @param subMesh Define the sub mesh to look readyness for
  29845. * @param useInstances Define whether or not the material is used with instances
  29846. * @returns true if ready, otherwise false
  29847. */
  29848. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29849. /**
  29850. * Clones the current material and its related sub materials
  29851. * @param name Define the name of the newly cloned material
  29852. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  29853. * @returns the cloned material
  29854. */
  29855. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  29856. /**
  29857. * Serializes the materials into a JSON representation.
  29858. * @returns the JSON representation
  29859. */
  29860. serialize(): any;
  29861. /**
  29862. * Dispose the material and release its associated resources
  29863. * @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)
  29864. * @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)
  29865. * @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)
  29866. */
  29867. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  29868. /**
  29869. * Creates a MultiMaterial from parsed MultiMaterial data.
  29870. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  29871. * @param scene defines the hosting scene
  29872. * @returns a new MultiMaterial
  29873. */
  29874. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  29875. }
  29876. }
  29877. declare module BABYLON {
  29878. /**
  29879. * Defines a subdivision inside a mesh
  29880. */
  29881. export class SubMesh implements ICullable {
  29882. /** the material index to use */
  29883. materialIndex: number;
  29884. /** vertex index start */
  29885. verticesStart: number;
  29886. /** vertices count */
  29887. verticesCount: number;
  29888. /** index start */
  29889. indexStart: number;
  29890. /** indices count */
  29891. indexCount: number;
  29892. /** @hidden */
  29893. _materialDefines: Nullable<MaterialDefines>;
  29894. /** @hidden */
  29895. _materialEffect: Nullable<Effect>;
  29896. /** @hidden */
  29897. _effectOverride: Nullable<Effect>;
  29898. /**
  29899. * Gets material defines used by the effect associated to the sub mesh
  29900. */
  29901. get materialDefines(): Nullable<MaterialDefines>;
  29902. /**
  29903. * Sets material defines used by the effect associated to the sub mesh
  29904. */
  29905. set materialDefines(defines: Nullable<MaterialDefines>);
  29906. /**
  29907. * Gets associated effect
  29908. */
  29909. get effect(): Nullable<Effect>;
  29910. /**
  29911. * Sets associated effect (effect used to render this submesh)
  29912. * @param effect defines the effect to associate with
  29913. * @param defines defines the set of defines used to compile this effect
  29914. */
  29915. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29916. /** @hidden */
  29917. _linesIndexCount: number;
  29918. private _mesh;
  29919. private _renderingMesh;
  29920. private _boundingInfo;
  29921. private _linesIndexBuffer;
  29922. /** @hidden */
  29923. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29924. /** @hidden */
  29925. _trianglePlanes: Plane[];
  29926. /** @hidden */
  29927. _lastColliderTransformMatrix: Nullable<Matrix>;
  29928. /** @hidden */
  29929. _renderId: number;
  29930. /** @hidden */
  29931. _alphaIndex: number;
  29932. /** @hidden */
  29933. _distanceToCamera: number;
  29934. /** @hidden */
  29935. _id: number;
  29936. private _currentMaterial;
  29937. /**
  29938. * Add a new submesh to a mesh
  29939. * @param materialIndex defines the material index to use
  29940. * @param verticesStart defines vertex index start
  29941. * @param verticesCount defines vertices count
  29942. * @param indexStart defines index start
  29943. * @param indexCount defines indices count
  29944. * @param mesh defines the parent mesh
  29945. * @param renderingMesh defines an optional rendering mesh
  29946. * @param createBoundingBox defines if bounding box should be created for this submesh
  29947. * @returns the new submesh
  29948. */
  29949. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29950. /**
  29951. * Creates a new submesh
  29952. * @param materialIndex defines the material index to use
  29953. * @param verticesStart defines vertex index start
  29954. * @param verticesCount defines vertices count
  29955. * @param indexStart defines index start
  29956. * @param indexCount defines indices count
  29957. * @param mesh defines the parent mesh
  29958. * @param renderingMesh defines an optional rendering mesh
  29959. * @param createBoundingBox defines if bounding box should be created for this submesh
  29960. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  29961. */
  29962. constructor(
  29963. /** the material index to use */
  29964. materialIndex: number,
  29965. /** vertex index start */
  29966. verticesStart: number,
  29967. /** vertices count */
  29968. verticesCount: number,
  29969. /** index start */
  29970. indexStart: number,
  29971. /** indices count */
  29972. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  29973. /**
  29974. * Returns true if this submesh covers the entire parent mesh
  29975. * @ignorenaming
  29976. */
  29977. get IsGlobal(): boolean;
  29978. /**
  29979. * Returns the submesh BoudingInfo object
  29980. * @returns current bounding info (or mesh's one if the submesh is global)
  29981. */
  29982. getBoundingInfo(): BoundingInfo;
  29983. /**
  29984. * Sets the submesh BoundingInfo
  29985. * @param boundingInfo defines the new bounding info to use
  29986. * @returns the SubMesh
  29987. */
  29988. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29989. /**
  29990. * Returns the mesh of the current submesh
  29991. * @return the parent mesh
  29992. */
  29993. getMesh(): AbstractMesh;
  29994. /**
  29995. * Returns the rendering mesh of the submesh
  29996. * @returns the rendering mesh (could be different from parent mesh)
  29997. */
  29998. getRenderingMesh(): Mesh;
  29999. /**
  30000. * Returns the replacement mesh of the submesh
  30001. * @returns the replacement mesh (could be different from parent mesh)
  30002. */
  30003. getReplacementMesh(): Nullable<AbstractMesh>;
  30004. /**
  30005. * Returns the effective mesh of the submesh
  30006. * @returns the effective mesh (could be different from parent mesh)
  30007. */
  30008. getEffectiveMesh(): AbstractMesh;
  30009. /**
  30010. * Returns the submesh material
  30011. * @returns null or the current material
  30012. */
  30013. getMaterial(): Nullable<Material>;
  30014. private _IsMultiMaterial;
  30015. /**
  30016. * Sets a new updated BoundingInfo object to the submesh
  30017. * @param data defines an optional position array to use to determine the bounding info
  30018. * @returns the SubMesh
  30019. */
  30020. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30021. /** @hidden */
  30022. _checkCollision(collider: Collider): boolean;
  30023. /**
  30024. * Updates the submesh BoundingInfo
  30025. * @param world defines the world matrix to use to update the bounding info
  30026. * @returns the submesh
  30027. */
  30028. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30029. /**
  30030. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30031. * @param frustumPlanes defines the frustum planes
  30032. * @returns true if the submesh is intersecting with the frustum
  30033. */
  30034. isInFrustum(frustumPlanes: Plane[]): boolean;
  30035. /**
  30036. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30037. * @param frustumPlanes defines the frustum planes
  30038. * @returns true if the submesh is inside the frustum
  30039. */
  30040. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30041. /**
  30042. * Renders the submesh
  30043. * @param enableAlphaMode defines if alpha needs to be used
  30044. * @returns the submesh
  30045. */
  30046. render(enableAlphaMode: boolean): SubMesh;
  30047. /**
  30048. * @hidden
  30049. */
  30050. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30051. /**
  30052. * Checks if the submesh intersects with a ray
  30053. * @param ray defines the ray to test
  30054. * @returns true is the passed ray intersects the submesh bounding box
  30055. */
  30056. canIntersects(ray: Ray): boolean;
  30057. /**
  30058. * Intersects current submesh with a ray
  30059. * @param ray defines the ray to test
  30060. * @param positions defines mesh's positions array
  30061. * @param indices defines mesh's indices array
  30062. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30063. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30064. * @returns intersection info or null if no intersection
  30065. */
  30066. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30067. /** @hidden */
  30068. private _intersectLines;
  30069. /** @hidden */
  30070. private _intersectUnIndexedLines;
  30071. /** @hidden */
  30072. private _intersectTriangles;
  30073. /** @hidden */
  30074. private _intersectUnIndexedTriangles;
  30075. /** @hidden */
  30076. _rebuild(): void;
  30077. /**
  30078. * Creates a new submesh from the passed mesh
  30079. * @param newMesh defines the new hosting mesh
  30080. * @param newRenderingMesh defines an optional rendering mesh
  30081. * @returns the new submesh
  30082. */
  30083. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30084. /**
  30085. * Release associated resources
  30086. */
  30087. dispose(): void;
  30088. /**
  30089. * Gets the class name
  30090. * @returns the string "SubMesh".
  30091. */
  30092. getClassName(): string;
  30093. /**
  30094. * Creates a new submesh from indices data
  30095. * @param materialIndex the index of the main mesh material
  30096. * @param startIndex the index where to start the copy in the mesh indices array
  30097. * @param indexCount the number of indices to copy then from the startIndex
  30098. * @param mesh the main mesh to create the submesh from
  30099. * @param renderingMesh the optional rendering mesh
  30100. * @returns a new submesh
  30101. */
  30102. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30103. }
  30104. }
  30105. declare module BABYLON {
  30106. /**
  30107. * Class used to represent data loading progression
  30108. */
  30109. export class SceneLoaderFlags {
  30110. private static _ForceFullSceneLoadingForIncremental;
  30111. private static _ShowLoadingScreen;
  30112. private static _CleanBoneMatrixWeights;
  30113. private static _loggingLevel;
  30114. /**
  30115. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30116. */
  30117. static get ForceFullSceneLoadingForIncremental(): boolean;
  30118. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30119. /**
  30120. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30121. */
  30122. static get ShowLoadingScreen(): boolean;
  30123. static set ShowLoadingScreen(value: boolean);
  30124. /**
  30125. * Defines the current logging level (while loading the scene)
  30126. * @ignorenaming
  30127. */
  30128. static get loggingLevel(): number;
  30129. static set loggingLevel(value: number);
  30130. /**
  30131. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30132. */
  30133. static get CleanBoneMatrixWeights(): boolean;
  30134. static set CleanBoneMatrixWeights(value: boolean);
  30135. }
  30136. }
  30137. declare module BABYLON {
  30138. /**
  30139. * Class used to store geometry data (vertex buffers + index buffer)
  30140. */
  30141. export class Geometry implements IGetSetVerticesData {
  30142. /**
  30143. * Gets or sets the ID of the geometry
  30144. */
  30145. id: string;
  30146. /**
  30147. * Gets or sets the unique ID of the geometry
  30148. */
  30149. uniqueId: number;
  30150. /**
  30151. * Gets the delay loading state of the geometry (none by default which means not delayed)
  30152. */
  30153. delayLoadState: number;
  30154. /**
  30155. * Gets the file containing the data to load when running in delay load state
  30156. */
  30157. delayLoadingFile: Nullable<string>;
  30158. /**
  30159. * Callback called when the geometry is updated
  30160. */
  30161. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  30162. private _scene;
  30163. private _engine;
  30164. private _meshes;
  30165. private _totalVertices;
  30166. /** @hidden */
  30167. _indices: IndicesArray;
  30168. /** @hidden */
  30169. _vertexBuffers: {
  30170. [key: string]: VertexBuffer;
  30171. };
  30172. private _isDisposed;
  30173. private _extend;
  30174. private _boundingBias;
  30175. /** @hidden */
  30176. _delayInfo: Array<string>;
  30177. private _indexBuffer;
  30178. private _indexBufferIsUpdatable;
  30179. /** @hidden */
  30180. _boundingInfo: Nullable<BoundingInfo>;
  30181. /** @hidden */
  30182. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  30183. /** @hidden */
  30184. _softwareSkinningFrameId: number;
  30185. private _vertexArrayObjects;
  30186. private _updatable;
  30187. /** @hidden */
  30188. _positions: Nullable<Vector3[]>;
  30189. private _positionsCache;
  30190. /**
  30191. * 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
  30192. */
  30193. get boundingBias(): Vector2;
  30194. /**
  30195. * 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
  30196. */
  30197. set boundingBias(value: Vector2);
  30198. /**
  30199. * Static function used to attach a new empty geometry to a mesh
  30200. * @param mesh defines the mesh to attach the geometry to
  30201. * @returns the new Geometry
  30202. */
  30203. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  30204. /** Get the list of meshes using this geometry */
  30205. get meshes(): Mesh[];
  30206. /**
  30207. * 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
  30208. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  30209. */
  30210. useBoundingInfoFromGeometry: boolean;
  30211. /**
  30212. * Creates a new geometry
  30213. * @param id defines the unique ID
  30214. * @param scene defines the hosting scene
  30215. * @param vertexData defines the VertexData used to get geometry data
  30216. * @param updatable defines if geometry must be updatable (false by default)
  30217. * @param mesh defines the mesh that will be associated with the geometry
  30218. */
  30219. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  30220. /**
  30221. * Gets the current extend of the geometry
  30222. */
  30223. get extend(): {
  30224. minimum: Vector3;
  30225. maximum: Vector3;
  30226. };
  30227. /**
  30228. * Gets the hosting scene
  30229. * @returns the hosting Scene
  30230. */
  30231. getScene(): Scene;
  30232. /**
  30233. * Gets the hosting engine
  30234. * @returns the hosting Engine
  30235. */
  30236. getEngine(): Engine;
  30237. /**
  30238. * Defines if the geometry is ready to use
  30239. * @returns true if the geometry is ready to be used
  30240. */
  30241. isReady(): boolean;
  30242. /**
  30243. * Gets a value indicating that the geometry should not be serialized
  30244. */
  30245. get doNotSerialize(): boolean;
  30246. /** @hidden */
  30247. _rebuild(): void;
  30248. /**
  30249. * Affects all geometry data in one call
  30250. * @param vertexData defines the geometry data
  30251. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  30252. */
  30253. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  30254. /**
  30255. * Set specific vertex data
  30256. * @param kind defines the data kind (Position, normal, etc...)
  30257. * @param data defines the vertex data to use
  30258. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30259. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30260. */
  30261. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  30262. /**
  30263. * Removes a specific vertex data
  30264. * @param kind defines the data kind (Position, normal, etc...)
  30265. */
  30266. removeVerticesData(kind: string): void;
  30267. /**
  30268. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30269. * @param buffer defines the vertex buffer to use
  30270. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30271. */
  30272. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30273. /**
  30274. * Update a specific vertex buffer
  30275. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30276. * It will do nothing if the buffer is not updatable
  30277. * @param kind defines the data kind (Position, normal, etc...)
  30278. * @param data defines the data to use
  30279. * @param offset defines the offset in the target buffer where to store the data
  30280. * @param useBytes set to true if the offset is in bytes
  30281. */
  30282. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30283. /**
  30284. * Update a specific vertex buffer
  30285. * This function will create a new buffer if the current one is not updatable
  30286. * @param kind defines the data kind (Position, normal, etc...)
  30287. * @param data defines the data to use
  30288. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30289. */
  30290. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30291. private _updateBoundingInfo;
  30292. /** @hidden */
  30293. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30294. /**
  30295. * Gets total number of vertices
  30296. * @returns the total number of vertices
  30297. */
  30298. getTotalVertices(): number;
  30299. /**
  30300. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30301. * @param kind defines the data kind (Position, normal, etc...)
  30302. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30303. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30304. * @returns a float array containing vertex data
  30305. */
  30306. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30307. /**
  30308. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30309. * @param kind defines the data kind (Position, normal, etc...)
  30310. * @returns true if the vertex buffer with the specified kind is updatable
  30311. */
  30312. isVertexBufferUpdatable(kind: string): boolean;
  30313. /**
  30314. * Gets a specific vertex buffer
  30315. * @param kind defines the data kind (Position, normal, etc...)
  30316. * @returns a VertexBuffer
  30317. */
  30318. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30319. /**
  30320. * Returns all vertex buffers
  30321. * @return an object holding all vertex buffers indexed by kind
  30322. */
  30323. getVertexBuffers(): Nullable<{
  30324. [key: string]: VertexBuffer;
  30325. }>;
  30326. /**
  30327. * Gets a boolean indicating if specific vertex buffer is present
  30328. * @param kind defines the data kind (Position, normal, etc...)
  30329. * @returns true if data is present
  30330. */
  30331. isVerticesDataPresent(kind: string): boolean;
  30332. /**
  30333. * Gets a list of all attached data kinds (Position, normal, etc...)
  30334. * @returns a list of string containing all kinds
  30335. */
  30336. getVerticesDataKinds(): string[];
  30337. /**
  30338. * Update index buffer
  30339. * @param indices defines the indices to store in the index buffer
  30340. * @param offset defines the offset in the target buffer where to store the data
  30341. * @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)
  30342. */
  30343. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30344. /**
  30345. * Creates a new index buffer
  30346. * @param indices defines the indices to store in the index buffer
  30347. * @param totalVertices defines the total number of vertices (could be null)
  30348. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30349. */
  30350. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30351. /**
  30352. * Return the total number of indices
  30353. * @returns the total number of indices
  30354. */
  30355. getTotalIndices(): number;
  30356. /**
  30357. * Gets the index buffer array
  30358. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30359. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30360. * @returns the index buffer array
  30361. */
  30362. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30363. /**
  30364. * Gets the index buffer
  30365. * @return the index buffer
  30366. */
  30367. getIndexBuffer(): Nullable<DataBuffer>;
  30368. /** @hidden */
  30369. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30370. /**
  30371. * Release the associated resources for a specific mesh
  30372. * @param mesh defines the source mesh
  30373. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30374. */
  30375. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30376. /**
  30377. * Apply current geometry to a given mesh
  30378. * @param mesh defines the mesh to apply geometry to
  30379. */
  30380. applyToMesh(mesh: Mesh): void;
  30381. private _updateExtend;
  30382. private _applyToMesh;
  30383. private notifyUpdate;
  30384. /**
  30385. * Load the geometry if it was flagged as delay loaded
  30386. * @param scene defines the hosting scene
  30387. * @param onLoaded defines a callback called when the geometry is loaded
  30388. */
  30389. load(scene: Scene, onLoaded?: () => void): void;
  30390. private _queueLoad;
  30391. /**
  30392. * Invert the geometry to move from a right handed system to a left handed one.
  30393. */
  30394. toLeftHanded(): void;
  30395. /** @hidden */
  30396. _resetPointsArrayCache(): void;
  30397. /** @hidden */
  30398. _generatePointsArray(): boolean;
  30399. /**
  30400. * Gets a value indicating if the geometry is disposed
  30401. * @returns true if the geometry was disposed
  30402. */
  30403. isDisposed(): boolean;
  30404. private _disposeVertexArrayObjects;
  30405. /**
  30406. * Free all associated resources
  30407. */
  30408. dispose(): void;
  30409. /**
  30410. * Clone the current geometry into a new geometry
  30411. * @param id defines the unique ID of the new geometry
  30412. * @returns a new geometry object
  30413. */
  30414. copy(id: string): Geometry;
  30415. /**
  30416. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30417. * @return a JSON representation of the current geometry data (without the vertices data)
  30418. */
  30419. serialize(): any;
  30420. private toNumberArray;
  30421. /**
  30422. * Serialize all vertices data into a JSON oject
  30423. * @returns a JSON representation of the current geometry data
  30424. */
  30425. serializeVerticeData(): any;
  30426. /**
  30427. * Extracts a clone of a mesh geometry
  30428. * @param mesh defines the source mesh
  30429. * @param id defines the unique ID of the new geometry object
  30430. * @returns the new geometry object
  30431. */
  30432. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30433. /**
  30434. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30435. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30436. * Be aware Math.random() could cause collisions, but:
  30437. * "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"
  30438. * @returns a string containing a new GUID
  30439. */
  30440. static RandomId(): string;
  30441. /** @hidden */
  30442. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30443. private static _CleanMatricesWeights;
  30444. /**
  30445. * Create a new geometry from persisted data (Using .babylon file format)
  30446. * @param parsedVertexData defines the persisted data
  30447. * @param scene defines the hosting scene
  30448. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30449. * @returns the new geometry object
  30450. */
  30451. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30452. }
  30453. }
  30454. declare module BABYLON {
  30455. /**
  30456. * Define an interface for all classes that will get and set the data on vertices
  30457. */
  30458. export interface IGetSetVerticesData {
  30459. /**
  30460. * Gets a boolean indicating if specific vertex data is present
  30461. * @param kind defines the vertex data kind to use
  30462. * @returns true is data kind is present
  30463. */
  30464. isVerticesDataPresent(kind: string): boolean;
  30465. /**
  30466. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30467. * @param kind defines the data kind (Position, normal, etc...)
  30468. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30469. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30470. * @returns a float array containing vertex data
  30471. */
  30472. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30473. /**
  30474. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  30475. * @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.
  30476. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30477. * @returns the indices array or an empty array if the mesh has no geometry
  30478. */
  30479. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30480. /**
  30481. * Set specific vertex data
  30482. * @param kind defines the data kind (Position, normal, etc...)
  30483. * @param data defines the vertex data to use
  30484. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30485. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30486. */
  30487. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  30488. /**
  30489. * Update a specific associated vertex buffer
  30490. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  30491. * - VertexBuffer.PositionKind
  30492. * - VertexBuffer.UVKind
  30493. * - VertexBuffer.UV2Kind
  30494. * - VertexBuffer.UV3Kind
  30495. * - VertexBuffer.UV4Kind
  30496. * - VertexBuffer.UV5Kind
  30497. * - VertexBuffer.UV6Kind
  30498. * - VertexBuffer.ColorKind
  30499. * - VertexBuffer.MatricesIndicesKind
  30500. * - VertexBuffer.MatricesIndicesExtraKind
  30501. * - VertexBuffer.MatricesWeightsKind
  30502. * - VertexBuffer.MatricesWeightsExtraKind
  30503. * @param data defines the data source
  30504. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  30505. * @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)
  30506. */
  30507. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  30508. /**
  30509. * Creates a new index buffer
  30510. * @param indices defines the indices to store in the index buffer
  30511. * @param totalVertices defines the total number of vertices (could be null)
  30512. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30513. */
  30514. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  30515. }
  30516. /**
  30517. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  30518. */
  30519. export class VertexData {
  30520. /**
  30521. * Mesh side orientation : usually the external or front surface
  30522. */
  30523. static readonly FRONTSIDE: number;
  30524. /**
  30525. * Mesh side orientation : usually the internal or back surface
  30526. */
  30527. static readonly BACKSIDE: number;
  30528. /**
  30529. * Mesh side orientation : both internal and external or front and back surfaces
  30530. */
  30531. static readonly DOUBLESIDE: number;
  30532. /**
  30533. * Mesh side orientation : by default, `FRONTSIDE`
  30534. */
  30535. static readonly DEFAULTSIDE: number;
  30536. /**
  30537. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  30538. */
  30539. positions: Nullable<FloatArray>;
  30540. /**
  30541. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  30542. */
  30543. normals: Nullable<FloatArray>;
  30544. /**
  30545. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  30546. */
  30547. tangents: Nullable<FloatArray>;
  30548. /**
  30549. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30550. */
  30551. uvs: Nullable<FloatArray>;
  30552. /**
  30553. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30554. */
  30555. uvs2: Nullable<FloatArray>;
  30556. /**
  30557. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30558. */
  30559. uvs3: Nullable<FloatArray>;
  30560. /**
  30561. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30562. */
  30563. uvs4: Nullable<FloatArray>;
  30564. /**
  30565. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30566. */
  30567. uvs5: Nullable<FloatArray>;
  30568. /**
  30569. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30570. */
  30571. uvs6: Nullable<FloatArray>;
  30572. /**
  30573. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  30574. */
  30575. colors: Nullable<FloatArray>;
  30576. /**
  30577. * 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).
  30578. */
  30579. matricesIndices: Nullable<FloatArray>;
  30580. /**
  30581. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  30582. */
  30583. matricesWeights: Nullable<FloatArray>;
  30584. /**
  30585. * An array extending the number of possible indices
  30586. */
  30587. matricesIndicesExtra: Nullable<FloatArray>;
  30588. /**
  30589. * An array extending the number of possible weights when the number of indices is extended
  30590. */
  30591. matricesWeightsExtra: Nullable<FloatArray>;
  30592. /**
  30593. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  30594. */
  30595. indices: Nullable<IndicesArray>;
  30596. /**
  30597. * Uses the passed data array to set the set the values for the specified kind of data
  30598. * @param data a linear array of floating numbers
  30599. * @param kind the type of data that is being set, eg positions, colors etc
  30600. */
  30601. set(data: FloatArray, kind: string): void;
  30602. /**
  30603. * Associates the vertexData to the passed Mesh.
  30604. * Sets it as updatable or not (default `false`)
  30605. * @param mesh the mesh the vertexData is applied to
  30606. * @param updatable when used and having the value true allows new data to update the vertexData
  30607. * @returns the VertexData
  30608. */
  30609. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  30610. /**
  30611. * Associates the vertexData to the passed Geometry.
  30612. * Sets it as updatable or not (default `false`)
  30613. * @param geometry the geometry the vertexData is applied to
  30614. * @param updatable when used and having the value true allows new data to update the vertexData
  30615. * @returns VertexData
  30616. */
  30617. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  30618. /**
  30619. * Updates the associated mesh
  30620. * @param mesh the mesh to be updated
  30621. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30622. * @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
  30623. * @returns VertexData
  30624. */
  30625. updateMesh(mesh: Mesh): VertexData;
  30626. /**
  30627. * Updates the associated geometry
  30628. * @param geometry the geometry to be updated
  30629. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30630. * @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
  30631. * @returns VertexData.
  30632. */
  30633. updateGeometry(geometry: Geometry): VertexData;
  30634. private _applyTo;
  30635. private _update;
  30636. /**
  30637. * Transforms each position and each normal of the vertexData according to the passed Matrix
  30638. * @param matrix the transforming matrix
  30639. * @returns the VertexData
  30640. */
  30641. transform(matrix: Matrix): VertexData;
  30642. /**
  30643. * Merges the passed VertexData into the current one
  30644. * @param other the VertexData to be merged into the current one
  30645. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  30646. * @returns the modified VertexData
  30647. */
  30648. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  30649. private _mergeElement;
  30650. private _validate;
  30651. /**
  30652. * Serializes the VertexData
  30653. * @returns a serialized object
  30654. */
  30655. serialize(): any;
  30656. /**
  30657. * Extracts the vertexData from a mesh
  30658. * @param mesh the mesh from which to extract the VertexData
  30659. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  30660. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30661. * @returns the object VertexData associated to the passed mesh
  30662. */
  30663. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30664. /**
  30665. * Extracts the vertexData from the geometry
  30666. * @param geometry the geometry from which to extract the VertexData
  30667. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  30668. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30669. * @returns the object VertexData associated to the passed mesh
  30670. */
  30671. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30672. private static _ExtractFrom;
  30673. /**
  30674. * Creates the VertexData for a Ribbon
  30675. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  30676. * * pathArray array of paths, each of which an array of successive Vector3
  30677. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  30678. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  30679. * * 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
  30680. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30681. * * 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)
  30682. * * 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)
  30683. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  30684. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  30685. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  30686. * @returns the VertexData of the ribbon
  30687. */
  30688. static CreateRibbon(options: {
  30689. pathArray: Vector3[][];
  30690. closeArray?: boolean;
  30691. closePath?: boolean;
  30692. offset?: number;
  30693. sideOrientation?: number;
  30694. frontUVs?: Vector4;
  30695. backUVs?: Vector4;
  30696. invertUV?: boolean;
  30697. uvs?: Vector2[];
  30698. colors?: Color4[];
  30699. }): VertexData;
  30700. /**
  30701. * Creates the VertexData for a box
  30702. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30703. * * size sets the width, height and depth of the box to the value of size, optional default 1
  30704. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  30705. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  30706. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  30707. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30708. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30709. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30710. * * 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)
  30711. * * 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)
  30712. * @returns the VertexData of the box
  30713. */
  30714. static CreateBox(options: {
  30715. size?: number;
  30716. width?: number;
  30717. height?: number;
  30718. depth?: number;
  30719. faceUV?: Vector4[];
  30720. faceColors?: Color4[];
  30721. sideOrientation?: number;
  30722. frontUVs?: Vector4;
  30723. backUVs?: Vector4;
  30724. }): VertexData;
  30725. /**
  30726. * Creates the VertexData for a tiled box
  30727. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30728. * * faceTiles sets the pattern, tile size and number of tiles for a face
  30729. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30730. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30731. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30732. * @returns the VertexData of the box
  30733. */
  30734. static CreateTiledBox(options: {
  30735. pattern?: number;
  30736. width?: number;
  30737. height?: number;
  30738. depth?: number;
  30739. tileSize?: number;
  30740. tileWidth?: number;
  30741. tileHeight?: number;
  30742. alignHorizontal?: number;
  30743. alignVertical?: number;
  30744. faceUV?: Vector4[];
  30745. faceColors?: Color4[];
  30746. sideOrientation?: number;
  30747. }): VertexData;
  30748. /**
  30749. * Creates the VertexData for a tiled plane
  30750. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30751. * * pattern a limited pattern arrangement depending on the number
  30752. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  30753. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  30754. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  30755. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30756. * * 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)
  30757. * * 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)
  30758. * @returns the VertexData of the tiled plane
  30759. */
  30760. static CreateTiledPlane(options: {
  30761. pattern?: number;
  30762. tileSize?: number;
  30763. tileWidth?: number;
  30764. tileHeight?: number;
  30765. size?: number;
  30766. width?: number;
  30767. height?: number;
  30768. alignHorizontal?: number;
  30769. alignVertical?: number;
  30770. sideOrientation?: number;
  30771. frontUVs?: Vector4;
  30772. backUVs?: Vector4;
  30773. }): VertexData;
  30774. /**
  30775. * Creates the VertexData for an ellipsoid, defaults to a sphere
  30776. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30777. * * segments sets the number of horizontal strips optional, default 32
  30778. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  30779. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  30780. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  30781. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  30782. * * 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
  30783. * * 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
  30784. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30785. * * 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)
  30786. * * 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)
  30787. * @returns the VertexData of the ellipsoid
  30788. */
  30789. static CreateSphere(options: {
  30790. segments?: number;
  30791. diameter?: number;
  30792. diameterX?: number;
  30793. diameterY?: number;
  30794. diameterZ?: number;
  30795. arc?: number;
  30796. slice?: number;
  30797. sideOrientation?: number;
  30798. frontUVs?: Vector4;
  30799. backUVs?: Vector4;
  30800. }): VertexData;
  30801. /**
  30802. * Creates the VertexData for a cylinder, cone or prism
  30803. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30804. * * height sets the height (y direction) of the cylinder, optional, default 2
  30805. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  30806. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  30807. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  30808. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30809. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  30810. * * 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
  30811. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30812. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30813. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  30814. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  30815. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30816. * * 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)
  30817. * * 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)
  30818. * @returns the VertexData of the cylinder, cone or prism
  30819. */
  30820. static CreateCylinder(options: {
  30821. height?: number;
  30822. diameterTop?: number;
  30823. diameterBottom?: number;
  30824. diameter?: number;
  30825. tessellation?: number;
  30826. subdivisions?: number;
  30827. arc?: number;
  30828. faceColors?: Color4[];
  30829. faceUV?: Vector4[];
  30830. hasRings?: boolean;
  30831. enclose?: boolean;
  30832. sideOrientation?: number;
  30833. frontUVs?: Vector4;
  30834. backUVs?: Vector4;
  30835. }): VertexData;
  30836. /**
  30837. * Creates the VertexData for a torus
  30838. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30839. * * diameter the diameter of the torus, optional default 1
  30840. * * thickness the diameter of the tube forming the torus, optional default 0.5
  30841. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30842. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30843. * * 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)
  30844. * * 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)
  30845. * @returns the VertexData of the torus
  30846. */
  30847. static CreateTorus(options: {
  30848. diameter?: number;
  30849. thickness?: number;
  30850. tessellation?: number;
  30851. sideOrientation?: number;
  30852. frontUVs?: Vector4;
  30853. backUVs?: Vector4;
  30854. }): VertexData;
  30855. /**
  30856. * Creates the VertexData of the LineSystem
  30857. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  30858. * - lines an array of lines, each line being an array of successive Vector3
  30859. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  30860. * @returns the VertexData of the LineSystem
  30861. */
  30862. static CreateLineSystem(options: {
  30863. lines: Vector3[][];
  30864. colors?: Nullable<Color4[][]>;
  30865. }): VertexData;
  30866. /**
  30867. * Create the VertexData for a DashedLines
  30868. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  30869. * - points an array successive Vector3
  30870. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  30871. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  30872. * - dashNb the intended total number of dashes, optional, default 200
  30873. * @returns the VertexData for the DashedLines
  30874. */
  30875. static CreateDashedLines(options: {
  30876. points: Vector3[];
  30877. dashSize?: number;
  30878. gapSize?: number;
  30879. dashNb?: number;
  30880. }): VertexData;
  30881. /**
  30882. * Creates the VertexData for a Ground
  30883. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30884. * - width the width (x direction) of the ground, optional, default 1
  30885. * - height the height (z direction) of the ground, optional, default 1
  30886. * - subdivisions the number of subdivisions per side, optional, default 1
  30887. * @returns the VertexData of the Ground
  30888. */
  30889. static CreateGround(options: {
  30890. width?: number;
  30891. height?: number;
  30892. subdivisions?: number;
  30893. subdivisionsX?: number;
  30894. subdivisionsY?: number;
  30895. }): VertexData;
  30896. /**
  30897. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  30898. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30899. * * xmin the ground minimum X coordinate, optional, default -1
  30900. * * zmin the ground minimum Z coordinate, optional, default -1
  30901. * * xmax the ground maximum X coordinate, optional, default 1
  30902. * * zmax the ground maximum Z coordinate, optional, default 1
  30903. * * 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}
  30904. * * 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}
  30905. * @returns the VertexData of the TiledGround
  30906. */
  30907. static CreateTiledGround(options: {
  30908. xmin: number;
  30909. zmin: number;
  30910. xmax: number;
  30911. zmax: number;
  30912. subdivisions?: {
  30913. w: number;
  30914. h: number;
  30915. };
  30916. precision?: {
  30917. w: number;
  30918. h: number;
  30919. };
  30920. }): VertexData;
  30921. /**
  30922. * Creates the VertexData of the Ground designed from a heightmap
  30923. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  30924. * * width the width (x direction) of the ground
  30925. * * height the height (z direction) of the ground
  30926. * * subdivisions the number of subdivisions per side
  30927. * * minHeight the minimum altitude on the ground, optional, default 0
  30928. * * maxHeight the maximum altitude on the ground, optional default 1
  30929. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  30930. * * buffer the array holding the image color data
  30931. * * bufferWidth the width of image
  30932. * * bufferHeight the height of image
  30933. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  30934. * @returns the VertexData of the Ground designed from a heightmap
  30935. */
  30936. static CreateGroundFromHeightMap(options: {
  30937. width: number;
  30938. height: number;
  30939. subdivisions: number;
  30940. minHeight: number;
  30941. maxHeight: number;
  30942. colorFilter: Color3;
  30943. buffer: Uint8Array;
  30944. bufferWidth: number;
  30945. bufferHeight: number;
  30946. alphaFilter: number;
  30947. }): VertexData;
  30948. /**
  30949. * Creates the VertexData for a Plane
  30950. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  30951. * * size sets the width and height of the plane to the value of size, optional default 1
  30952. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  30953. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  30954. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30955. * * 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)
  30956. * * 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)
  30957. * @returns the VertexData of the box
  30958. */
  30959. static CreatePlane(options: {
  30960. size?: number;
  30961. width?: number;
  30962. height?: number;
  30963. sideOrientation?: number;
  30964. frontUVs?: Vector4;
  30965. backUVs?: Vector4;
  30966. }): VertexData;
  30967. /**
  30968. * Creates the VertexData of the Disc or regular Polygon
  30969. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  30970. * * radius the radius of the disc, optional default 0.5
  30971. * * tessellation the number of polygon sides, optional, default 64
  30972. * * 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
  30973. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30974. * * 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)
  30975. * * 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)
  30976. * @returns the VertexData of the box
  30977. */
  30978. static CreateDisc(options: {
  30979. radius?: number;
  30980. tessellation?: number;
  30981. arc?: number;
  30982. sideOrientation?: number;
  30983. frontUVs?: Vector4;
  30984. backUVs?: Vector4;
  30985. }): VertexData;
  30986. /**
  30987. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  30988. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  30989. * @param polygon a mesh built from polygonTriangulation.build()
  30990. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30991. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30992. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30993. * @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)
  30994. * @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)
  30995. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  30996. * @returns the VertexData of the Polygon
  30997. */
  30998. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  30999. /**
  31000. * Creates the VertexData of the IcoSphere
  31001. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  31002. * * radius the radius of the IcoSphere, optional default 1
  31003. * * radiusX allows stretching in the x direction, optional, default radius
  31004. * * radiusY allows stretching in the y direction, optional, default radius
  31005. * * radiusZ allows stretching in the z direction, optional, default radius
  31006. * * flat when true creates a flat shaded mesh, optional, default true
  31007. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31008. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31009. * * 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)
  31010. * * 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)
  31011. * @returns the VertexData of the IcoSphere
  31012. */
  31013. static CreateIcoSphere(options: {
  31014. radius?: number;
  31015. radiusX?: number;
  31016. radiusY?: number;
  31017. radiusZ?: number;
  31018. flat?: boolean;
  31019. subdivisions?: number;
  31020. sideOrientation?: number;
  31021. frontUVs?: Vector4;
  31022. backUVs?: Vector4;
  31023. }): VertexData;
  31024. /**
  31025. * Creates the VertexData for a Polyhedron
  31026. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  31027. * * type provided types are:
  31028. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  31029. * * 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)
  31030. * * size the size of the IcoSphere, optional default 1
  31031. * * sizeX allows stretching in the x direction, optional, default size
  31032. * * sizeY allows stretching in the y direction, optional, default size
  31033. * * sizeZ allows stretching in the z direction, optional, default size
  31034. * * 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
  31035. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  31036. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  31037. * * flat when true creates a flat shaded mesh, optional, default true
  31038. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  31039. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31040. * * 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)
  31041. * * 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)
  31042. * @returns the VertexData of the Polyhedron
  31043. */
  31044. static CreatePolyhedron(options: {
  31045. type?: number;
  31046. size?: number;
  31047. sizeX?: number;
  31048. sizeY?: number;
  31049. sizeZ?: number;
  31050. custom?: any;
  31051. faceUV?: Vector4[];
  31052. faceColors?: Color4[];
  31053. flat?: boolean;
  31054. sideOrientation?: number;
  31055. frontUVs?: Vector4;
  31056. backUVs?: Vector4;
  31057. }): VertexData;
  31058. /**
  31059. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  31060. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  31061. * @returns the VertexData of the Capsule
  31062. */
  31063. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  31064. /**
  31065. * Creates the VertexData for a TorusKnot
  31066. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  31067. * * radius the radius of the torus knot, optional, default 2
  31068. * * tube the thickness of the tube, optional, default 0.5
  31069. * * radialSegments the number of sides on each tube segments, optional, default 32
  31070. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  31071. * * p the number of windings around the z axis, optional, default 2
  31072. * * q the number of windings around the x axis, optional, default 3
  31073. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31074. * * 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)
  31075. * * 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)
  31076. * @returns the VertexData of the Torus Knot
  31077. */
  31078. static CreateTorusKnot(options: {
  31079. radius?: number;
  31080. tube?: number;
  31081. radialSegments?: number;
  31082. tubularSegments?: number;
  31083. p?: number;
  31084. q?: number;
  31085. sideOrientation?: number;
  31086. frontUVs?: Vector4;
  31087. backUVs?: Vector4;
  31088. }): VertexData;
  31089. /**
  31090. * Compute normals for given positions and indices
  31091. * @param positions an array of vertex positions, [...., x, y, z, ......]
  31092. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  31093. * @param normals an array of vertex normals, [...., x, y, z, ......]
  31094. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  31095. * * facetNormals : optional array of facet normals (vector3)
  31096. * * facetPositions : optional array of facet positions (vector3)
  31097. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  31098. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  31099. * * bInfo : optional bounding info, required for facetPartitioning computation
  31100. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  31101. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  31102. * * useRightHandedSystem: optional boolean to for right handed system computation
  31103. * * depthSort : optional boolean to enable the facet depth sort computation
  31104. * * distanceTo : optional Vector3 to compute the facet depth from this location
  31105. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  31106. */
  31107. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  31108. facetNormals?: any;
  31109. facetPositions?: any;
  31110. facetPartitioning?: any;
  31111. ratio?: number;
  31112. bInfo?: any;
  31113. bbSize?: Vector3;
  31114. subDiv?: any;
  31115. useRightHandedSystem?: boolean;
  31116. depthSort?: boolean;
  31117. distanceTo?: Vector3;
  31118. depthSortedFacets?: any;
  31119. }): void;
  31120. /** @hidden */
  31121. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  31122. /**
  31123. * Applies VertexData created from the imported parameters to the geometry
  31124. * @param parsedVertexData the parsed data from an imported file
  31125. * @param geometry the geometry to apply the VertexData to
  31126. */
  31127. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  31128. }
  31129. }
  31130. declare module BABYLON {
  31131. /**
  31132. * Defines a target to use with MorphTargetManager
  31133. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31134. */
  31135. export class MorphTarget implements IAnimatable {
  31136. /** defines the name of the target */
  31137. name: string;
  31138. /**
  31139. * Gets or sets the list of animations
  31140. */
  31141. animations: Animation[];
  31142. private _scene;
  31143. private _positions;
  31144. private _normals;
  31145. private _tangents;
  31146. private _uvs;
  31147. private _influence;
  31148. private _uniqueId;
  31149. /**
  31150. * Observable raised when the influence changes
  31151. */
  31152. onInfluenceChanged: Observable<boolean>;
  31153. /** @hidden */
  31154. _onDataLayoutChanged: Observable<void>;
  31155. /**
  31156. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31157. */
  31158. get influence(): number;
  31159. set influence(influence: number);
  31160. /**
  31161. * Gets or sets the id of the morph Target
  31162. */
  31163. id: string;
  31164. private _animationPropertiesOverride;
  31165. /**
  31166. * Gets or sets the animation properties override
  31167. */
  31168. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31169. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31170. /**
  31171. * Creates a new MorphTarget
  31172. * @param name defines the name of the target
  31173. * @param influence defines the influence to use
  31174. * @param scene defines the scene the morphtarget belongs to
  31175. */
  31176. constructor(
  31177. /** defines the name of the target */
  31178. name: string, influence?: number, scene?: Nullable<Scene>);
  31179. /**
  31180. * Gets the unique ID of this manager
  31181. */
  31182. get uniqueId(): number;
  31183. /**
  31184. * Gets a boolean defining if the target contains position data
  31185. */
  31186. get hasPositions(): boolean;
  31187. /**
  31188. * Gets a boolean defining if the target contains normal data
  31189. */
  31190. get hasNormals(): boolean;
  31191. /**
  31192. * Gets a boolean defining if the target contains tangent data
  31193. */
  31194. get hasTangents(): boolean;
  31195. /**
  31196. * Gets a boolean defining if the target contains texture coordinates data
  31197. */
  31198. get hasUVs(): boolean;
  31199. /**
  31200. * Affects position data to this target
  31201. * @param data defines the position data to use
  31202. */
  31203. setPositions(data: Nullable<FloatArray>): void;
  31204. /**
  31205. * Gets the position data stored in this target
  31206. * @returns a FloatArray containing the position data (or null if not present)
  31207. */
  31208. getPositions(): Nullable<FloatArray>;
  31209. /**
  31210. * Affects normal data to this target
  31211. * @param data defines the normal data to use
  31212. */
  31213. setNormals(data: Nullable<FloatArray>): void;
  31214. /**
  31215. * Gets the normal data stored in this target
  31216. * @returns a FloatArray containing the normal data (or null if not present)
  31217. */
  31218. getNormals(): Nullable<FloatArray>;
  31219. /**
  31220. * Affects tangent data to this target
  31221. * @param data defines the tangent data to use
  31222. */
  31223. setTangents(data: Nullable<FloatArray>): void;
  31224. /**
  31225. * Gets the tangent data stored in this target
  31226. * @returns a FloatArray containing the tangent data (or null if not present)
  31227. */
  31228. getTangents(): Nullable<FloatArray>;
  31229. /**
  31230. * Affects texture coordinates data to this target
  31231. * @param data defines the texture coordinates data to use
  31232. */
  31233. setUVs(data: Nullable<FloatArray>): void;
  31234. /**
  31235. * Gets the texture coordinates data stored in this target
  31236. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31237. */
  31238. getUVs(): Nullable<FloatArray>;
  31239. /**
  31240. * Clone the current target
  31241. * @returns a new MorphTarget
  31242. */
  31243. clone(): MorphTarget;
  31244. /**
  31245. * Serializes the current target into a Serialization object
  31246. * @returns the serialized object
  31247. */
  31248. serialize(): any;
  31249. /**
  31250. * Returns the string "MorphTarget"
  31251. * @returns "MorphTarget"
  31252. */
  31253. getClassName(): string;
  31254. /**
  31255. * Creates a new target from serialized data
  31256. * @param serializationObject defines the serialized data to use
  31257. * @returns a new MorphTarget
  31258. */
  31259. static Parse(serializationObject: any): MorphTarget;
  31260. /**
  31261. * Creates a MorphTarget from mesh data
  31262. * @param mesh defines the source mesh
  31263. * @param name defines the name to use for the new target
  31264. * @param influence defines the influence to attach to the target
  31265. * @returns a new MorphTarget
  31266. */
  31267. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31268. }
  31269. }
  31270. declare module BABYLON {
  31271. /**
  31272. * This class is used to deform meshes using morphing between different targets
  31273. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31274. */
  31275. export class MorphTargetManager {
  31276. private _targets;
  31277. private _targetInfluenceChangedObservers;
  31278. private _targetDataLayoutChangedObservers;
  31279. private _activeTargets;
  31280. private _scene;
  31281. private _influences;
  31282. private _supportsNormals;
  31283. private _supportsTangents;
  31284. private _supportsUVs;
  31285. private _vertexCount;
  31286. private _uniqueId;
  31287. private _tempInfluences;
  31288. /**
  31289. * Gets or sets a boolean indicating if normals must be morphed
  31290. */
  31291. enableNormalMorphing: boolean;
  31292. /**
  31293. * Gets or sets a boolean indicating if tangents must be morphed
  31294. */
  31295. enableTangentMorphing: boolean;
  31296. /**
  31297. * Gets or sets a boolean indicating if UV must be morphed
  31298. */
  31299. enableUVMorphing: boolean;
  31300. /**
  31301. * Creates a new MorphTargetManager
  31302. * @param scene defines the current scene
  31303. */
  31304. constructor(scene?: Nullable<Scene>);
  31305. /**
  31306. * Gets the unique ID of this manager
  31307. */
  31308. get uniqueId(): number;
  31309. /**
  31310. * Gets the number of vertices handled by this manager
  31311. */
  31312. get vertexCount(): number;
  31313. /**
  31314. * Gets a boolean indicating if this manager supports morphing of normals
  31315. */
  31316. get supportsNormals(): boolean;
  31317. /**
  31318. * Gets a boolean indicating if this manager supports morphing of tangents
  31319. */
  31320. get supportsTangents(): boolean;
  31321. /**
  31322. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31323. */
  31324. get supportsUVs(): boolean;
  31325. /**
  31326. * Gets the number of targets stored in this manager
  31327. */
  31328. get numTargets(): number;
  31329. /**
  31330. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31331. */
  31332. get numInfluencers(): number;
  31333. /**
  31334. * Gets the list of influences (one per target)
  31335. */
  31336. get influences(): Float32Array;
  31337. /**
  31338. * Gets the active target at specified index. An active target is a target with an influence > 0
  31339. * @param index defines the index to check
  31340. * @returns the requested target
  31341. */
  31342. getActiveTarget(index: number): MorphTarget;
  31343. /**
  31344. * Gets the target at specified index
  31345. * @param index defines the index to check
  31346. * @returns the requested target
  31347. */
  31348. getTarget(index: number): MorphTarget;
  31349. /**
  31350. * Add a new target to this manager
  31351. * @param target defines the target to add
  31352. */
  31353. addTarget(target: MorphTarget): void;
  31354. /**
  31355. * Removes a target from the manager
  31356. * @param target defines the target to remove
  31357. */
  31358. removeTarget(target: MorphTarget): void;
  31359. /**
  31360. * Clone the current manager
  31361. * @returns a new MorphTargetManager
  31362. */
  31363. clone(): MorphTargetManager;
  31364. /**
  31365. * Serializes the current manager into a Serialization object
  31366. * @returns the serialized object
  31367. */
  31368. serialize(): any;
  31369. private _syncActiveTargets;
  31370. /**
  31371. * Syncrhonize the targets with all the meshes using this morph target manager
  31372. */
  31373. synchronize(): void;
  31374. /**
  31375. * Creates a new MorphTargetManager from serialized data
  31376. * @param serializationObject defines the serialized data
  31377. * @param scene defines the hosting scene
  31378. * @returns the new MorphTargetManager
  31379. */
  31380. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31381. }
  31382. }
  31383. declare module BABYLON {
  31384. /**
  31385. * Class used to represent a specific level of detail of a mesh
  31386. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31387. */
  31388. export class MeshLODLevel {
  31389. /** Defines the distance where this level should start being displayed */
  31390. distance: number;
  31391. /** Defines the mesh to use to render this level */
  31392. mesh: Nullable<Mesh>;
  31393. /**
  31394. * Creates a new LOD level
  31395. * @param distance defines the distance where this level should star being displayed
  31396. * @param mesh defines the mesh to use to render this level
  31397. */
  31398. constructor(
  31399. /** Defines the distance where this level should start being displayed */
  31400. distance: number,
  31401. /** Defines the mesh to use to render this level */
  31402. mesh: Nullable<Mesh>);
  31403. }
  31404. }
  31405. declare module BABYLON {
  31406. /**
  31407. * Helper class used to generate a canvas to manipulate images
  31408. */
  31409. export class CanvasGenerator {
  31410. /**
  31411. * Create a new canvas (or offscreen canvas depending on the context)
  31412. * @param width defines the expected width
  31413. * @param height defines the expected height
  31414. * @return a new canvas or offscreen canvas
  31415. */
  31416. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31417. }
  31418. }
  31419. declare module BABYLON {
  31420. /**
  31421. * Mesh representing the gorund
  31422. */
  31423. export class GroundMesh extends Mesh {
  31424. /** If octree should be generated */
  31425. generateOctree: boolean;
  31426. private _heightQuads;
  31427. /** @hidden */
  31428. _subdivisionsX: number;
  31429. /** @hidden */
  31430. _subdivisionsY: number;
  31431. /** @hidden */
  31432. _width: number;
  31433. /** @hidden */
  31434. _height: number;
  31435. /** @hidden */
  31436. _minX: number;
  31437. /** @hidden */
  31438. _maxX: number;
  31439. /** @hidden */
  31440. _minZ: number;
  31441. /** @hidden */
  31442. _maxZ: number;
  31443. constructor(name: string, scene: Scene);
  31444. /**
  31445. * "GroundMesh"
  31446. * @returns "GroundMesh"
  31447. */
  31448. getClassName(): string;
  31449. /**
  31450. * The minimum of x and y subdivisions
  31451. */
  31452. get subdivisions(): number;
  31453. /**
  31454. * X subdivisions
  31455. */
  31456. get subdivisionsX(): number;
  31457. /**
  31458. * Y subdivisions
  31459. */
  31460. get subdivisionsY(): number;
  31461. /**
  31462. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31463. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31464. * @param chunksCount the number of subdivisions for x and y
  31465. * @param octreeBlocksSize (Default: 32)
  31466. */
  31467. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31468. /**
  31469. * Returns a height (y) value in the Worl system :
  31470. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31471. * @param x x coordinate
  31472. * @param z z coordinate
  31473. * @returns the ground y position if (x, z) are outside the ground surface.
  31474. */
  31475. getHeightAtCoordinates(x: number, z: number): number;
  31476. /**
  31477. * Returns a normalized vector (Vector3) orthogonal to the ground
  31478. * at the ground coordinates (x, z) expressed in the World system.
  31479. * @param x x coordinate
  31480. * @param z z coordinate
  31481. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31482. */
  31483. getNormalAtCoordinates(x: number, z: number): Vector3;
  31484. /**
  31485. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31486. * at the ground coordinates (x, z) expressed in the World system.
  31487. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31488. * @param x x coordinate
  31489. * @param z z coordinate
  31490. * @param ref vector to store the result
  31491. * @returns the GroundMesh.
  31492. */
  31493. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31494. /**
  31495. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31496. * if the ground has been updated.
  31497. * This can be used in the render loop.
  31498. * @returns the GroundMesh.
  31499. */
  31500. updateCoordinateHeights(): GroundMesh;
  31501. private _getFacetAt;
  31502. private _initHeightQuads;
  31503. private _computeHeightQuads;
  31504. /**
  31505. * Serializes this ground mesh
  31506. * @param serializationObject object to write serialization to
  31507. */
  31508. serialize(serializationObject: any): void;
  31509. /**
  31510. * Parses a serialized ground mesh
  31511. * @param parsedMesh the serialized mesh
  31512. * @param scene the scene to create the ground mesh in
  31513. * @returns the created ground mesh
  31514. */
  31515. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31516. }
  31517. }
  31518. declare module BABYLON {
  31519. /**
  31520. * Interface for Physics-Joint data
  31521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31522. */
  31523. export interface PhysicsJointData {
  31524. /**
  31525. * The main pivot of the joint
  31526. */
  31527. mainPivot?: Vector3;
  31528. /**
  31529. * The connected pivot of the joint
  31530. */
  31531. connectedPivot?: Vector3;
  31532. /**
  31533. * The main axis of the joint
  31534. */
  31535. mainAxis?: Vector3;
  31536. /**
  31537. * The connected axis of the joint
  31538. */
  31539. connectedAxis?: Vector3;
  31540. /**
  31541. * The collision of the joint
  31542. */
  31543. collision?: boolean;
  31544. /**
  31545. * Native Oimo/Cannon/Energy data
  31546. */
  31547. nativeParams?: any;
  31548. }
  31549. /**
  31550. * This is a holder class for the physics joint created by the physics plugin
  31551. * It holds a set of functions to control the underlying joint
  31552. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31553. */
  31554. export class PhysicsJoint {
  31555. /**
  31556. * The type of the physics joint
  31557. */
  31558. type: number;
  31559. /**
  31560. * The data for the physics joint
  31561. */
  31562. jointData: PhysicsJointData;
  31563. private _physicsJoint;
  31564. protected _physicsPlugin: IPhysicsEnginePlugin;
  31565. /**
  31566. * Initializes the physics joint
  31567. * @param type The type of the physics joint
  31568. * @param jointData The data for the physics joint
  31569. */
  31570. constructor(
  31571. /**
  31572. * The type of the physics joint
  31573. */
  31574. type: number,
  31575. /**
  31576. * The data for the physics joint
  31577. */
  31578. jointData: PhysicsJointData);
  31579. /**
  31580. * Gets the physics joint
  31581. */
  31582. get physicsJoint(): any;
  31583. /**
  31584. * Sets the physics joint
  31585. */
  31586. set physicsJoint(newJoint: any);
  31587. /**
  31588. * Sets the physics plugin
  31589. */
  31590. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31591. /**
  31592. * Execute a function that is physics-plugin specific.
  31593. * @param {Function} func the function that will be executed.
  31594. * It accepts two parameters: the physics world and the physics joint
  31595. */
  31596. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31597. /**
  31598. * Distance-Joint type
  31599. */
  31600. static DistanceJoint: number;
  31601. /**
  31602. * Hinge-Joint type
  31603. */
  31604. static HingeJoint: number;
  31605. /**
  31606. * Ball-and-Socket joint type
  31607. */
  31608. static BallAndSocketJoint: number;
  31609. /**
  31610. * Wheel-Joint type
  31611. */
  31612. static WheelJoint: number;
  31613. /**
  31614. * Slider-Joint type
  31615. */
  31616. static SliderJoint: number;
  31617. /**
  31618. * Prismatic-Joint type
  31619. */
  31620. static PrismaticJoint: number;
  31621. /**
  31622. * Universal-Joint type
  31623. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31624. */
  31625. static UniversalJoint: number;
  31626. /**
  31627. * Hinge-Joint 2 type
  31628. */
  31629. static Hinge2Joint: number;
  31630. /**
  31631. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31632. */
  31633. static PointToPointJoint: number;
  31634. /**
  31635. * Spring-Joint type
  31636. */
  31637. static SpringJoint: number;
  31638. /**
  31639. * Lock-Joint type
  31640. */
  31641. static LockJoint: number;
  31642. }
  31643. /**
  31644. * A class representing a physics distance joint
  31645. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31646. */
  31647. export class DistanceJoint extends PhysicsJoint {
  31648. /**
  31649. *
  31650. * @param jointData The data for the Distance-Joint
  31651. */
  31652. constructor(jointData: DistanceJointData);
  31653. /**
  31654. * Update the predefined distance.
  31655. * @param maxDistance The maximum preferred distance
  31656. * @param minDistance The minimum preferred distance
  31657. */
  31658. updateDistance(maxDistance: number, minDistance?: number): void;
  31659. }
  31660. /**
  31661. * Represents a Motor-Enabled Joint
  31662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31663. */
  31664. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31665. /**
  31666. * Initializes the Motor-Enabled Joint
  31667. * @param type The type of the joint
  31668. * @param jointData The physica joint data for the joint
  31669. */
  31670. constructor(type: number, jointData: PhysicsJointData);
  31671. /**
  31672. * Set the motor values.
  31673. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31674. * @param force the force to apply
  31675. * @param maxForce max force for this motor.
  31676. */
  31677. setMotor(force?: number, maxForce?: number): void;
  31678. /**
  31679. * Set the motor's limits.
  31680. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31681. * @param upperLimit The upper limit of the motor
  31682. * @param lowerLimit The lower limit of the motor
  31683. */
  31684. setLimit(upperLimit: number, lowerLimit?: number): void;
  31685. }
  31686. /**
  31687. * This class represents a single physics Hinge-Joint
  31688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31689. */
  31690. export class HingeJoint extends MotorEnabledJoint {
  31691. /**
  31692. * Initializes the Hinge-Joint
  31693. * @param jointData The joint data for the Hinge-Joint
  31694. */
  31695. constructor(jointData: PhysicsJointData);
  31696. /**
  31697. * Set the motor values.
  31698. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31699. * @param {number} force the force to apply
  31700. * @param {number} maxForce max force for this motor.
  31701. */
  31702. setMotor(force?: number, maxForce?: number): void;
  31703. /**
  31704. * Set the motor's limits.
  31705. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31706. * @param upperLimit The upper limit of the motor
  31707. * @param lowerLimit The lower limit of the motor
  31708. */
  31709. setLimit(upperLimit: number, lowerLimit?: number): void;
  31710. }
  31711. /**
  31712. * This class represents a dual hinge physics joint (same as wheel joint)
  31713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31714. */
  31715. export class Hinge2Joint extends MotorEnabledJoint {
  31716. /**
  31717. * Initializes the Hinge2-Joint
  31718. * @param jointData The joint data for the Hinge2-Joint
  31719. */
  31720. constructor(jointData: PhysicsJointData);
  31721. /**
  31722. * Set the motor values.
  31723. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31724. * @param {number} targetSpeed the speed the motor is to reach
  31725. * @param {number} maxForce max force for this motor.
  31726. * @param {motorIndex} the motor's index, 0 or 1.
  31727. */
  31728. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31729. /**
  31730. * Set the motor limits.
  31731. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31732. * @param {number} upperLimit the upper limit
  31733. * @param {number} lowerLimit lower limit
  31734. * @param {motorIndex} the motor's index, 0 or 1.
  31735. */
  31736. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31737. }
  31738. /**
  31739. * Interface for a motor enabled joint
  31740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31741. */
  31742. export interface IMotorEnabledJoint {
  31743. /**
  31744. * Physics joint
  31745. */
  31746. physicsJoint: any;
  31747. /**
  31748. * Sets the motor of the motor-enabled joint
  31749. * @param force The force of the motor
  31750. * @param maxForce The maximum force of the motor
  31751. * @param motorIndex The index of the motor
  31752. */
  31753. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31754. /**
  31755. * Sets the limit of the motor
  31756. * @param upperLimit The upper limit of the motor
  31757. * @param lowerLimit The lower limit of the motor
  31758. * @param motorIndex The index of the motor
  31759. */
  31760. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31761. }
  31762. /**
  31763. * Joint data for a Distance-Joint
  31764. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31765. */
  31766. export interface DistanceJointData extends PhysicsJointData {
  31767. /**
  31768. * Max distance the 2 joint objects can be apart
  31769. */
  31770. maxDistance: number;
  31771. }
  31772. /**
  31773. * Joint data from a spring joint
  31774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31775. */
  31776. export interface SpringJointData extends PhysicsJointData {
  31777. /**
  31778. * Length of the spring
  31779. */
  31780. length: number;
  31781. /**
  31782. * Stiffness of the spring
  31783. */
  31784. stiffness: number;
  31785. /**
  31786. * Damping of the spring
  31787. */
  31788. damping: number;
  31789. /** this callback will be called when applying the force to the impostors. */
  31790. forceApplicationCallback: () => void;
  31791. }
  31792. }
  31793. declare module BABYLON {
  31794. /**
  31795. * Holds the data for the raycast result
  31796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31797. */
  31798. export class PhysicsRaycastResult {
  31799. private _hasHit;
  31800. private _hitDistance;
  31801. private _hitNormalWorld;
  31802. private _hitPointWorld;
  31803. private _rayFromWorld;
  31804. private _rayToWorld;
  31805. /**
  31806. * Gets if there was a hit
  31807. */
  31808. get hasHit(): boolean;
  31809. /**
  31810. * Gets the distance from the hit
  31811. */
  31812. get hitDistance(): number;
  31813. /**
  31814. * Gets the hit normal/direction in the world
  31815. */
  31816. get hitNormalWorld(): Vector3;
  31817. /**
  31818. * Gets the hit point in the world
  31819. */
  31820. get hitPointWorld(): Vector3;
  31821. /**
  31822. * Gets the ray "start point" of the ray in the world
  31823. */
  31824. get rayFromWorld(): Vector3;
  31825. /**
  31826. * Gets the ray "end point" of the ray in the world
  31827. */
  31828. get rayToWorld(): Vector3;
  31829. /**
  31830. * Sets the hit data (normal & point in world space)
  31831. * @param hitNormalWorld defines the normal in world space
  31832. * @param hitPointWorld defines the point in world space
  31833. */
  31834. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31835. /**
  31836. * Sets the distance from the start point to the hit point
  31837. * @param distance
  31838. */
  31839. setHitDistance(distance: number): void;
  31840. /**
  31841. * Calculates the distance manually
  31842. */
  31843. calculateHitDistance(): void;
  31844. /**
  31845. * Resets all the values to default
  31846. * @param from The from point on world space
  31847. * @param to The to point on world space
  31848. */
  31849. reset(from?: Vector3, to?: Vector3): void;
  31850. }
  31851. /**
  31852. * Interface for the size containing width and height
  31853. */
  31854. interface IXYZ {
  31855. /**
  31856. * X
  31857. */
  31858. x: number;
  31859. /**
  31860. * Y
  31861. */
  31862. y: number;
  31863. /**
  31864. * Z
  31865. */
  31866. z: number;
  31867. }
  31868. }
  31869. declare module BABYLON {
  31870. /**
  31871. * Interface used to describe a physics joint
  31872. */
  31873. export interface PhysicsImpostorJoint {
  31874. /** Defines the main impostor to which the joint is linked */
  31875. mainImpostor: PhysicsImpostor;
  31876. /** Defines the impostor that is connected to the main impostor using this joint */
  31877. connectedImpostor: PhysicsImpostor;
  31878. /** Defines the joint itself */
  31879. joint: PhysicsJoint;
  31880. }
  31881. /** @hidden */
  31882. export interface IPhysicsEnginePlugin {
  31883. world: any;
  31884. name: string;
  31885. setGravity(gravity: Vector3): void;
  31886. setTimeStep(timeStep: number): void;
  31887. getTimeStep(): number;
  31888. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31889. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31890. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31891. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31892. removePhysicsBody(impostor: PhysicsImpostor): void;
  31893. generateJoint(joint: PhysicsImpostorJoint): void;
  31894. removeJoint(joint: PhysicsImpostorJoint): void;
  31895. isSupported(): boolean;
  31896. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31897. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31898. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31899. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31900. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31901. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31902. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31903. getBodyMass(impostor: PhysicsImpostor): number;
  31904. getBodyFriction(impostor: PhysicsImpostor): number;
  31905. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31906. getBodyRestitution(impostor: PhysicsImpostor): number;
  31907. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31908. getBodyPressure?(impostor: PhysicsImpostor): number;
  31909. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31910. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31911. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31912. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31913. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31914. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31915. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31916. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31917. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31918. sleepBody(impostor: PhysicsImpostor): void;
  31919. wakeUpBody(impostor: PhysicsImpostor): void;
  31920. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31921. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31922. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31923. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31924. getRadius(impostor: PhysicsImpostor): number;
  31925. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31926. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31927. dispose(): void;
  31928. }
  31929. /**
  31930. * Interface used to define a physics engine
  31931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31932. */
  31933. export interface IPhysicsEngine {
  31934. /**
  31935. * Gets the gravity vector used by the simulation
  31936. */
  31937. gravity: Vector3;
  31938. /**
  31939. * Sets the gravity vector used by the simulation
  31940. * @param gravity defines the gravity vector to use
  31941. */
  31942. setGravity(gravity: Vector3): void;
  31943. /**
  31944. * Set the time step of the physics engine.
  31945. * Default is 1/60.
  31946. * To slow it down, enter 1/600 for example.
  31947. * To speed it up, 1/30
  31948. * @param newTimeStep the new timestep to apply to this world.
  31949. */
  31950. setTimeStep(newTimeStep: number): void;
  31951. /**
  31952. * Get the time step of the physics engine.
  31953. * @returns the current time step
  31954. */
  31955. getTimeStep(): number;
  31956. /**
  31957. * Set the sub time step of the physics engine.
  31958. * Default is 0 meaning there is no sub steps
  31959. * To increase physics resolution precision, set a small value (like 1 ms)
  31960. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31961. */
  31962. setSubTimeStep(subTimeStep: number): void;
  31963. /**
  31964. * Get the sub time step of the physics engine.
  31965. * @returns the current sub time step
  31966. */
  31967. getSubTimeStep(): number;
  31968. /**
  31969. * Release all resources
  31970. */
  31971. dispose(): void;
  31972. /**
  31973. * Gets the name of the current physics plugin
  31974. * @returns the name of the plugin
  31975. */
  31976. getPhysicsPluginName(): string;
  31977. /**
  31978. * Adding a new impostor for the impostor tracking.
  31979. * This will be done by the impostor itself.
  31980. * @param impostor the impostor to add
  31981. */
  31982. addImpostor(impostor: PhysicsImpostor): void;
  31983. /**
  31984. * Remove an impostor from the engine.
  31985. * This impostor and its mesh will not longer be updated by the physics engine.
  31986. * @param impostor the impostor to remove
  31987. */
  31988. removeImpostor(impostor: PhysicsImpostor): void;
  31989. /**
  31990. * Add a joint to the physics engine
  31991. * @param mainImpostor defines the main impostor to which the joint is added.
  31992. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31993. * @param joint defines the joint that will connect both impostors.
  31994. */
  31995. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31996. /**
  31997. * Removes a joint from the simulation
  31998. * @param mainImpostor defines the impostor used with the joint
  31999. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32000. * @param joint defines the joint to remove
  32001. */
  32002. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32003. /**
  32004. * Gets the current plugin used to run the simulation
  32005. * @returns current plugin
  32006. */
  32007. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32008. /**
  32009. * Gets the list of physic impostors
  32010. * @returns an array of PhysicsImpostor
  32011. */
  32012. getImpostors(): Array<PhysicsImpostor>;
  32013. /**
  32014. * Gets the impostor for a physics enabled object
  32015. * @param object defines the object impersonated by the impostor
  32016. * @returns the PhysicsImpostor or null if not found
  32017. */
  32018. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32019. /**
  32020. * Gets the impostor for a physics body object
  32021. * @param body defines physics body used by the impostor
  32022. * @returns the PhysicsImpostor or null if not found
  32023. */
  32024. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32025. /**
  32026. * Does a raycast in the physics world
  32027. * @param from when should the ray start?
  32028. * @param to when should the ray end?
  32029. * @returns PhysicsRaycastResult
  32030. */
  32031. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32032. /**
  32033. * Called by the scene. No need to call it.
  32034. * @param delta defines the timespam between frames
  32035. */
  32036. _step(delta: number): void;
  32037. }
  32038. }
  32039. declare module BABYLON {
  32040. /**
  32041. * The interface for the physics imposter parameters
  32042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32043. */
  32044. export interface PhysicsImpostorParameters {
  32045. /**
  32046. * The mass of the physics imposter
  32047. */
  32048. mass: number;
  32049. /**
  32050. * The friction of the physics imposter
  32051. */
  32052. friction?: number;
  32053. /**
  32054. * The coefficient of restitution of the physics imposter
  32055. */
  32056. restitution?: number;
  32057. /**
  32058. * The native options of the physics imposter
  32059. */
  32060. nativeOptions?: any;
  32061. /**
  32062. * Specifies if the parent should be ignored
  32063. */
  32064. ignoreParent?: boolean;
  32065. /**
  32066. * Specifies if bi-directional transformations should be disabled
  32067. */
  32068. disableBidirectionalTransformation?: boolean;
  32069. /**
  32070. * The pressure inside the physics imposter, soft object only
  32071. */
  32072. pressure?: number;
  32073. /**
  32074. * The stiffness the physics imposter, soft object only
  32075. */
  32076. stiffness?: number;
  32077. /**
  32078. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32079. */
  32080. velocityIterations?: number;
  32081. /**
  32082. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32083. */
  32084. positionIterations?: number;
  32085. /**
  32086. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32087. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32088. * Add to fix multiple points
  32089. */
  32090. fixedPoints?: number;
  32091. /**
  32092. * The collision margin around a soft object
  32093. */
  32094. margin?: number;
  32095. /**
  32096. * The collision margin around a soft object
  32097. */
  32098. damping?: number;
  32099. /**
  32100. * The path for a rope based on an extrusion
  32101. */
  32102. path?: any;
  32103. /**
  32104. * The shape of an extrusion used for a rope based on an extrusion
  32105. */
  32106. shape?: any;
  32107. }
  32108. /**
  32109. * Interface for a physics-enabled object
  32110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32111. */
  32112. export interface IPhysicsEnabledObject {
  32113. /**
  32114. * The position of the physics-enabled object
  32115. */
  32116. position: Vector3;
  32117. /**
  32118. * The rotation of the physics-enabled object
  32119. */
  32120. rotationQuaternion: Nullable<Quaternion>;
  32121. /**
  32122. * The scale of the physics-enabled object
  32123. */
  32124. scaling: Vector3;
  32125. /**
  32126. * The rotation of the physics-enabled object
  32127. */
  32128. rotation?: Vector3;
  32129. /**
  32130. * The parent of the physics-enabled object
  32131. */
  32132. parent?: any;
  32133. /**
  32134. * The bounding info of the physics-enabled object
  32135. * @returns The bounding info of the physics-enabled object
  32136. */
  32137. getBoundingInfo(): BoundingInfo;
  32138. /**
  32139. * Computes the world matrix
  32140. * @param force Specifies if the world matrix should be computed by force
  32141. * @returns A world matrix
  32142. */
  32143. computeWorldMatrix(force: boolean): Matrix;
  32144. /**
  32145. * Gets the world matrix
  32146. * @returns A world matrix
  32147. */
  32148. getWorldMatrix?(): Matrix;
  32149. /**
  32150. * Gets the child meshes
  32151. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32152. * @returns An array of abstract meshes
  32153. */
  32154. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32155. /**
  32156. * Gets the vertex data
  32157. * @param kind The type of vertex data
  32158. * @returns A nullable array of numbers, or a float32 array
  32159. */
  32160. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32161. /**
  32162. * Gets the indices from the mesh
  32163. * @returns A nullable array of index arrays
  32164. */
  32165. getIndices?(): Nullable<IndicesArray>;
  32166. /**
  32167. * Gets the scene from the mesh
  32168. * @returns the indices array or null
  32169. */
  32170. getScene?(): Scene;
  32171. /**
  32172. * Gets the absolute position from the mesh
  32173. * @returns the absolute position
  32174. */
  32175. getAbsolutePosition(): Vector3;
  32176. /**
  32177. * Gets the absolute pivot point from the mesh
  32178. * @returns the absolute pivot point
  32179. */
  32180. getAbsolutePivotPoint(): Vector3;
  32181. /**
  32182. * Rotates the mesh
  32183. * @param axis The axis of rotation
  32184. * @param amount The amount of rotation
  32185. * @param space The space of the rotation
  32186. * @returns The rotation transform node
  32187. */
  32188. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32189. /**
  32190. * Translates the mesh
  32191. * @param axis The axis of translation
  32192. * @param distance The distance of translation
  32193. * @param space The space of the translation
  32194. * @returns The transform node
  32195. */
  32196. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32197. /**
  32198. * Sets the absolute position of the mesh
  32199. * @param absolutePosition The absolute position of the mesh
  32200. * @returns The transform node
  32201. */
  32202. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32203. /**
  32204. * Gets the class name of the mesh
  32205. * @returns The class name
  32206. */
  32207. getClassName(): string;
  32208. }
  32209. /**
  32210. * Represents a physics imposter
  32211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32212. */
  32213. export class PhysicsImpostor {
  32214. /**
  32215. * The physics-enabled object used as the physics imposter
  32216. */
  32217. object: IPhysicsEnabledObject;
  32218. /**
  32219. * The type of the physics imposter
  32220. */
  32221. type: number;
  32222. private _options;
  32223. private _scene?;
  32224. /**
  32225. * The default object size of the imposter
  32226. */
  32227. static DEFAULT_OBJECT_SIZE: Vector3;
  32228. /**
  32229. * The identity quaternion of the imposter
  32230. */
  32231. static IDENTITY_QUATERNION: Quaternion;
  32232. /** @hidden */
  32233. _pluginData: any;
  32234. private _physicsEngine;
  32235. private _physicsBody;
  32236. private _bodyUpdateRequired;
  32237. private _onBeforePhysicsStepCallbacks;
  32238. private _onAfterPhysicsStepCallbacks;
  32239. /** @hidden */
  32240. _onPhysicsCollideCallbacks: Array<{
  32241. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32242. otherImpostors: Array<PhysicsImpostor>;
  32243. }>;
  32244. private _deltaPosition;
  32245. private _deltaRotation;
  32246. private _deltaRotationConjugated;
  32247. /** @hidden */
  32248. _isFromLine: boolean;
  32249. private _parent;
  32250. private _isDisposed;
  32251. private static _tmpVecs;
  32252. private static _tmpQuat;
  32253. /**
  32254. * Specifies if the physics imposter is disposed
  32255. */
  32256. get isDisposed(): boolean;
  32257. /**
  32258. * Gets the mass of the physics imposter
  32259. */
  32260. get mass(): number;
  32261. set mass(value: number);
  32262. /**
  32263. * Gets the coefficient of friction
  32264. */
  32265. get friction(): number;
  32266. /**
  32267. * Sets the coefficient of friction
  32268. */
  32269. set friction(value: number);
  32270. /**
  32271. * Gets the coefficient of restitution
  32272. */
  32273. get restitution(): number;
  32274. /**
  32275. * Sets the coefficient of restitution
  32276. */
  32277. set restitution(value: number);
  32278. /**
  32279. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32280. */
  32281. get pressure(): number;
  32282. /**
  32283. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32284. */
  32285. set pressure(value: number);
  32286. /**
  32287. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32288. */
  32289. get stiffness(): number;
  32290. /**
  32291. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32292. */
  32293. set stiffness(value: number);
  32294. /**
  32295. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32296. */
  32297. get velocityIterations(): number;
  32298. /**
  32299. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32300. */
  32301. set velocityIterations(value: number);
  32302. /**
  32303. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32304. */
  32305. get positionIterations(): number;
  32306. /**
  32307. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32308. */
  32309. set positionIterations(value: number);
  32310. /**
  32311. * The unique id of the physics imposter
  32312. * set by the physics engine when adding this impostor to the array
  32313. */
  32314. uniqueId: number;
  32315. /**
  32316. * @hidden
  32317. */
  32318. soft: boolean;
  32319. /**
  32320. * @hidden
  32321. */
  32322. segments: number;
  32323. private _joints;
  32324. /**
  32325. * Initializes the physics imposter
  32326. * @param object The physics-enabled object used as the physics imposter
  32327. * @param type The type of the physics imposter
  32328. * @param _options The options for the physics imposter
  32329. * @param _scene The Babylon scene
  32330. */
  32331. constructor(
  32332. /**
  32333. * The physics-enabled object used as the physics imposter
  32334. */
  32335. object: IPhysicsEnabledObject,
  32336. /**
  32337. * The type of the physics imposter
  32338. */
  32339. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32340. /**
  32341. * This function will completly initialize this impostor.
  32342. * It will create a new body - but only if this mesh has no parent.
  32343. * If it has, this impostor will not be used other than to define the impostor
  32344. * of the child mesh.
  32345. * @hidden
  32346. */
  32347. _init(): void;
  32348. private _getPhysicsParent;
  32349. /**
  32350. * Should a new body be generated.
  32351. * @returns boolean specifying if body initialization is required
  32352. */
  32353. isBodyInitRequired(): boolean;
  32354. /**
  32355. * Sets the updated scaling
  32356. * @param updated Specifies if the scaling is updated
  32357. */
  32358. setScalingUpdated(): void;
  32359. /**
  32360. * Force a regeneration of this or the parent's impostor's body.
  32361. * Use under cautious - This will remove all joints already implemented.
  32362. */
  32363. forceUpdate(): void;
  32364. /**
  32365. * Gets the body that holds this impostor. Either its own, or its parent.
  32366. */
  32367. get physicsBody(): any;
  32368. /**
  32369. * Get the parent of the physics imposter
  32370. * @returns Physics imposter or null
  32371. */
  32372. get parent(): Nullable<PhysicsImpostor>;
  32373. /**
  32374. * Sets the parent of the physics imposter
  32375. */
  32376. set parent(value: Nullable<PhysicsImpostor>);
  32377. /**
  32378. * Set the physics body. Used mainly by the physics engine/plugin
  32379. */
  32380. set physicsBody(physicsBody: any);
  32381. /**
  32382. * Resets the update flags
  32383. */
  32384. resetUpdateFlags(): void;
  32385. /**
  32386. * Gets the object extend size
  32387. * @returns the object extend size
  32388. */
  32389. getObjectExtendSize(): Vector3;
  32390. /**
  32391. * Gets the object center
  32392. * @returns The object center
  32393. */
  32394. getObjectCenter(): Vector3;
  32395. /**
  32396. * Get a specific parameter from the options parameters
  32397. * @param paramName The object parameter name
  32398. * @returns The object parameter
  32399. */
  32400. getParam(paramName: string): any;
  32401. /**
  32402. * Sets a specific parameter in the options given to the physics plugin
  32403. * @param paramName The parameter name
  32404. * @param value The value of the parameter
  32405. */
  32406. setParam(paramName: string, value: number): void;
  32407. /**
  32408. * Specifically change the body's mass option. Won't recreate the physics body object
  32409. * @param mass The mass of the physics imposter
  32410. */
  32411. setMass(mass: number): void;
  32412. /**
  32413. * Gets the linear velocity
  32414. * @returns linear velocity or null
  32415. */
  32416. getLinearVelocity(): Nullable<Vector3>;
  32417. /**
  32418. * Sets the linear velocity
  32419. * @param velocity linear velocity or null
  32420. */
  32421. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32422. /**
  32423. * Gets the angular velocity
  32424. * @returns angular velocity or null
  32425. */
  32426. getAngularVelocity(): Nullable<Vector3>;
  32427. /**
  32428. * Sets the angular velocity
  32429. * @param velocity The velocity or null
  32430. */
  32431. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32432. /**
  32433. * Execute a function with the physics plugin native code
  32434. * Provide a function the will have two variables - the world object and the physics body object
  32435. * @param func The function to execute with the physics plugin native code
  32436. */
  32437. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32438. /**
  32439. * Register a function that will be executed before the physics world is stepping forward
  32440. * @param func The function to execute before the physics world is stepped forward
  32441. */
  32442. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32443. /**
  32444. * Unregister a function that will be executed before the physics world is stepping forward
  32445. * @param func The function to execute before the physics world is stepped forward
  32446. */
  32447. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32448. /**
  32449. * Register a function that will be executed after the physics step
  32450. * @param func The function to execute after physics step
  32451. */
  32452. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32453. /**
  32454. * Unregisters a function that will be executed after the physics step
  32455. * @param func The function to execute after physics step
  32456. */
  32457. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32458. /**
  32459. * register a function that will be executed when this impostor collides against a different body
  32460. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32461. * @param func Callback that is executed on collision
  32462. */
  32463. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32464. /**
  32465. * Unregisters the physics imposter on contact
  32466. * @param collideAgainst The physics object to collide against
  32467. * @param func Callback to execute on collision
  32468. */
  32469. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32470. private _tmpQuat;
  32471. private _tmpQuat2;
  32472. /**
  32473. * Get the parent rotation
  32474. * @returns The parent rotation
  32475. */
  32476. getParentsRotation(): Quaternion;
  32477. /**
  32478. * this function is executed by the physics engine.
  32479. */
  32480. beforeStep: () => void;
  32481. /**
  32482. * this function is executed by the physics engine
  32483. */
  32484. afterStep: () => void;
  32485. /**
  32486. * Legacy collision detection event support
  32487. */
  32488. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32489. /**
  32490. * event and body object due to cannon's event-based architecture.
  32491. */
  32492. onCollide: (e: {
  32493. body: any;
  32494. point: Nullable<Vector3>;
  32495. }) => void;
  32496. /**
  32497. * Apply a force
  32498. * @param force The force to apply
  32499. * @param contactPoint The contact point for the force
  32500. * @returns The physics imposter
  32501. */
  32502. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32503. /**
  32504. * Apply an impulse
  32505. * @param force The impulse force
  32506. * @param contactPoint The contact point for the impulse force
  32507. * @returns The physics imposter
  32508. */
  32509. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32510. /**
  32511. * A help function to create a joint
  32512. * @param otherImpostor A physics imposter used to create a joint
  32513. * @param jointType The type of joint
  32514. * @param jointData The data for the joint
  32515. * @returns The physics imposter
  32516. */
  32517. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32518. /**
  32519. * Add a joint to this impostor with a different impostor
  32520. * @param otherImpostor A physics imposter used to add a joint
  32521. * @param joint The joint to add
  32522. * @returns The physics imposter
  32523. */
  32524. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32525. /**
  32526. * Add an anchor to a cloth impostor
  32527. * @param otherImpostor rigid impostor to anchor to
  32528. * @param width ratio across width from 0 to 1
  32529. * @param height ratio up height from 0 to 1
  32530. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32531. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32532. * @returns impostor the soft imposter
  32533. */
  32534. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32535. /**
  32536. * Add a hook to a rope impostor
  32537. * @param otherImpostor rigid impostor to anchor to
  32538. * @param length ratio across rope from 0 to 1
  32539. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32540. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32541. * @returns impostor the rope imposter
  32542. */
  32543. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32544. /**
  32545. * Will keep this body still, in a sleep mode.
  32546. * @returns the physics imposter
  32547. */
  32548. sleep(): PhysicsImpostor;
  32549. /**
  32550. * Wake the body up.
  32551. * @returns The physics imposter
  32552. */
  32553. wakeUp(): PhysicsImpostor;
  32554. /**
  32555. * Clones the physics imposter
  32556. * @param newObject The physics imposter clones to this physics-enabled object
  32557. * @returns A nullable physics imposter
  32558. */
  32559. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32560. /**
  32561. * Disposes the physics imposter
  32562. */
  32563. dispose(): void;
  32564. /**
  32565. * Sets the delta position
  32566. * @param position The delta position amount
  32567. */
  32568. setDeltaPosition(position: Vector3): void;
  32569. /**
  32570. * Sets the delta rotation
  32571. * @param rotation The delta rotation amount
  32572. */
  32573. setDeltaRotation(rotation: Quaternion): void;
  32574. /**
  32575. * Gets the box size of the physics imposter and stores the result in the input parameter
  32576. * @param result Stores the box size
  32577. * @returns The physics imposter
  32578. */
  32579. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32580. /**
  32581. * Gets the radius of the physics imposter
  32582. * @returns Radius of the physics imposter
  32583. */
  32584. getRadius(): number;
  32585. /**
  32586. * Sync a bone with this impostor
  32587. * @param bone The bone to sync to the impostor.
  32588. * @param boneMesh The mesh that the bone is influencing.
  32589. * @param jointPivot The pivot of the joint / bone in local space.
  32590. * @param distToJoint Optional distance from the impostor to the joint.
  32591. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32592. */
  32593. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32594. /**
  32595. * Sync impostor to a bone
  32596. * @param bone The bone that the impostor will be synced to.
  32597. * @param boneMesh The mesh that the bone is influencing.
  32598. * @param jointPivot The pivot of the joint / bone in local space.
  32599. * @param distToJoint Optional distance from the impostor to the joint.
  32600. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32601. * @param boneAxis Optional vector3 axis the bone is aligned with
  32602. */
  32603. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32604. /**
  32605. * No-Imposter type
  32606. */
  32607. static NoImpostor: number;
  32608. /**
  32609. * Sphere-Imposter type
  32610. */
  32611. static SphereImpostor: number;
  32612. /**
  32613. * Box-Imposter type
  32614. */
  32615. static BoxImpostor: number;
  32616. /**
  32617. * Plane-Imposter type
  32618. */
  32619. static PlaneImpostor: number;
  32620. /**
  32621. * Mesh-imposter type
  32622. */
  32623. static MeshImpostor: number;
  32624. /**
  32625. * Capsule-Impostor type (Ammo.js plugin only)
  32626. */
  32627. static CapsuleImpostor: number;
  32628. /**
  32629. * Cylinder-Imposter type
  32630. */
  32631. static CylinderImpostor: number;
  32632. /**
  32633. * Particle-Imposter type
  32634. */
  32635. static ParticleImpostor: number;
  32636. /**
  32637. * Heightmap-Imposter type
  32638. */
  32639. static HeightmapImpostor: number;
  32640. /**
  32641. * ConvexHull-Impostor type (Ammo.js plugin only)
  32642. */
  32643. static ConvexHullImpostor: number;
  32644. /**
  32645. * Custom-Imposter type (Ammo.js plugin only)
  32646. */
  32647. static CustomImpostor: number;
  32648. /**
  32649. * Rope-Imposter type
  32650. */
  32651. static RopeImpostor: number;
  32652. /**
  32653. * Cloth-Imposter type
  32654. */
  32655. static ClothImpostor: number;
  32656. /**
  32657. * Softbody-Imposter type
  32658. */
  32659. static SoftbodyImpostor: number;
  32660. }
  32661. }
  32662. declare module BABYLON {
  32663. /**
  32664. * @hidden
  32665. **/
  32666. export class _CreationDataStorage {
  32667. closePath?: boolean;
  32668. closeArray?: boolean;
  32669. idx: number[];
  32670. dashSize: number;
  32671. gapSize: number;
  32672. path3D: Path3D;
  32673. pathArray: Vector3[][];
  32674. arc: number;
  32675. radius: number;
  32676. cap: number;
  32677. tessellation: number;
  32678. }
  32679. /**
  32680. * @hidden
  32681. **/
  32682. class _InstanceDataStorage {
  32683. visibleInstances: any;
  32684. batchCache: _InstancesBatch;
  32685. instancesBufferSize: number;
  32686. instancesBuffer: Nullable<Buffer>;
  32687. instancesData: Float32Array;
  32688. overridenInstanceCount: number;
  32689. isFrozen: boolean;
  32690. previousBatch: Nullable<_InstancesBatch>;
  32691. hardwareInstancedRendering: boolean;
  32692. sideOrientation: number;
  32693. manualUpdate: boolean;
  32694. previousRenderId: number;
  32695. }
  32696. /**
  32697. * @hidden
  32698. **/
  32699. export class _InstancesBatch {
  32700. mustReturn: boolean;
  32701. visibleInstances: Nullable<InstancedMesh[]>[];
  32702. renderSelf: boolean[];
  32703. hardwareInstancedRendering: boolean[];
  32704. }
  32705. /**
  32706. * @hidden
  32707. **/
  32708. class _ThinInstanceDataStorage {
  32709. instancesCount: number;
  32710. matrixBuffer: Nullable<Buffer>;
  32711. matrixBufferSize: number;
  32712. matrixData: Nullable<Float32Array>;
  32713. boundingVectors: Array<Vector3>;
  32714. worldMatrices: Nullable<Matrix[]>;
  32715. }
  32716. /**
  32717. * Class used to represent renderable models
  32718. */
  32719. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32720. /**
  32721. * Mesh side orientation : usually the external or front surface
  32722. */
  32723. static readonly FRONTSIDE: number;
  32724. /**
  32725. * Mesh side orientation : usually the internal or back surface
  32726. */
  32727. static readonly BACKSIDE: number;
  32728. /**
  32729. * Mesh side orientation : both internal and external or front and back surfaces
  32730. */
  32731. static readonly DOUBLESIDE: number;
  32732. /**
  32733. * Mesh side orientation : by default, `FRONTSIDE`
  32734. */
  32735. static readonly DEFAULTSIDE: number;
  32736. /**
  32737. * Mesh cap setting : no cap
  32738. */
  32739. static readonly NO_CAP: number;
  32740. /**
  32741. * Mesh cap setting : one cap at the beginning of the mesh
  32742. */
  32743. static readonly CAP_START: number;
  32744. /**
  32745. * Mesh cap setting : one cap at the end of the mesh
  32746. */
  32747. static readonly CAP_END: number;
  32748. /**
  32749. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32750. */
  32751. static readonly CAP_ALL: number;
  32752. /**
  32753. * Mesh pattern setting : no flip or rotate
  32754. */
  32755. static readonly NO_FLIP: number;
  32756. /**
  32757. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32758. */
  32759. static readonly FLIP_TILE: number;
  32760. /**
  32761. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32762. */
  32763. static readonly ROTATE_TILE: number;
  32764. /**
  32765. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32766. */
  32767. static readonly FLIP_ROW: number;
  32768. /**
  32769. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32770. */
  32771. static readonly ROTATE_ROW: number;
  32772. /**
  32773. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32774. */
  32775. static readonly FLIP_N_ROTATE_TILE: number;
  32776. /**
  32777. * Mesh pattern setting : rotate pattern and rotate
  32778. */
  32779. static readonly FLIP_N_ROTATE_ROW: number;
  32780. /**
  32781. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32782. */
  32783. static readonly CENTER: number;
  32784. /**
  32785. * Mesh tile positioning : part tiles on left
  32786. */
  32787. static readonly LEFT: number;
  32788. /**
  32789. * Mesh tile positioning : part tiles on right
  32790. */
  32791. static readonly RIGHT: number;
  32792. /**
  32793. * Mesh tile positioning : part tiles on top
  32794. */
  32795. static readonly TOP: number;
  32796. /**
  32797. * Mesh tile positioning : part tiles on bottom
  32798. */
  32799. static readonly BOTTOM: number;
  32800. /**
  32801. * Gets the default side orientation.
  32802. * @param orientation the orientation to value to attempt to get
  32803. * @returns the default orientation
  32804. * @hidden
  32805. */
  32806. static _GetDefaultSideOrientation(orientation?: number): number;
  32807. private _internalMeshDataInfo;
  32808. get computeBonesUsingShaders(): boolean;
  32809. set computeBonesUsingShaders(value: boolean);
  32810. /**
  32811. * An event triggered before rendering the mesh
  32812. */
  32813. get onBeforeRenderObservable(): Observable<Mesh>;
  32814. /**
  32815. * An event triggered before binding the mesh
  32816. */
  32817. get onBeforeBindObservable(): Observable<Mesh>;
  32818. /**
  32819. * An event triggered after rendering the mesh
  32820. */
  32821. get onAfterRenderObservable(): Observable<Mesh>;
  32822. /**
  32823. * An event triggered before drawing the mesh
  32824. */
  32825. get onBeforeDrawObservable(): Observable<Mesh>;
  32826. private _onBeforeDrawObserver;
  32827. /**
  32828. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32829. */
  32830. set onBeforeDraw(callback: () => void);
  32831. get hasInstances(): boolean;
  32832. get hasThinInstances(): boolean;
  32833. /**
  32834. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32835. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32836. */
  32837. delayLoadState: number;
  32838. /**
  32839. * Gets the list of instances created from this mesh
  32840. * it is not supposed to be modified manually.
  32841. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32842. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32843. */
  32844. instances: InstancedMesh[];
  32845. /**
  32846. * Gets the file containing delay loading data for this mesh
  32847. */
  32848. delayLoadingFile: string;
  32849. /** @hidden */
  32850. _binaryInfo: any;
  32851. /**
  32852. * User defined function used to change how LOD level selection is done
  32853. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32854. */
  32855. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32856. /**
  32857. * Gets or sets the morph target manager
  32858. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32859. */
  32860. get morphTargetManager(): Nullable<MorphTargetManager>;
  32861. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32862. /** @hidden */
  32863. _creationDataStorage: Nullable<_CreationDataStorage>;
  32864. /** @hidden */
  32865. _geometry: Nullable<Geometry>;
  32866. /** @hidden */
  32867. _delayInfo: Array<string>;
  32868. /** @hidden */
  32869. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32870. /** @hidden */
  32871. _instanceDataStorage: _InstanceDataStorage;
  32872. /** @hidden */
  32873. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32874. private _effectiveMaterial;
  32875. /** @hidden */
  32876. _shouldGenerateFlatShading: boolean;
  32877. /** @hidden */
  32878. _originalBuilderSideOrientation: number;
  32879. /**
  32880. * Use this property to change the original side orientation defined at construction time
  32881. */
  32882. overrideMaterialSideOrientation: Nullable<number>;
  32883. /**
  32884. * Gets the source mesh (the one used to clone this one from)
  32885. */
  32886. get source(): Nullable<Mesh>;
  32887. /**
  32888. * Gets the list of clones of this mesh
  32889. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32890. * Note that useClonedMeshMap=true is the default setting
  32891. */
  32892. get cloneMeshMap(): Nullable<{
  32893. [id: string]: Mesh | undefined;
  32894. }>;
  32895. /**
  32896. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32897. */
  32898. get isUnIndexed(): boolean;
  32899. set isUnIndexed(value: boolean);
  32900. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32901. get worldMatrixInstancedBuffer(): Float32Array;
  32902. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32903. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32904. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32905. /**
  32906. * @constructor
  32907. * @param name The value used by scene.getMeshByName() to do a lookup.
  32908. * @param scene The scene to add this mesh to.
  32909. * @param parent The parent of this mesh, if it has one
  32910. * @param source An optional Mesh from which geometry is shared, cloned.
  32911. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32912. * When false, achieved by calling a clone(), also passing False.
  32913. * This will make creation of children, recursive.
  32914. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32915. */
  32916. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32917. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32918. doNotInstantiate: boolean;
  32919. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32920. /**
  32921. * Gets the class name
  32922. * @returns the string "Mesh".
  32923. */
  32924. getClassName(): string;
  32925. /** @hidden */
  32926. get _isMesh(): boolean;
  32927. /**
  32928. * Returns a description of this mesh
  32929. * @param fullDetails define if full details about this mesh must be used
  32930. * @returns a descriptive string representing this mesh
  32931. */
  32932. toString(fullDetails?: boolean): string;
  32933. /** @hidden */
  32934. _unBindEffect(): void;
  32935. /**
  32936. * Gets a boolean indicating if this mesh has LOD
  32937. */
  32938. get hasLODLevels(): boolean;
  32939. /**
  32940. * Gets the list of MeshLODLevel associated with the current mesh
  32941. * @returns an array of MeshLODLevel
  32942. */
  32943. getLODLevels(): MeshLODLevel[];
  32944. private _sortLODLevels;
  32945. /**
  32946. * Add a mesh as LOD level triggered at the given distance.
  32947. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32948. * @param distance The distance from the center of the object to show this level
  32949. * @param mesh The mesh to be added as LOD level (can be null)
  32950. * @return This mesh (for chaining)
  32951. */
  32952. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32953. /**
  32954. * Returns the LOD level mesh at the passed distance or null if not found.
  32955. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32956. * @param distance The distance from the center of the object to show this level
  32957. * @returns a Mesh or `null`
  32958. */
  32959. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32960. /**
  32961. * Remove a mesh from the LOD array
  32962. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32963. * @param mesh defines the mesh to be removed
  32964. * @return This mesh (for chaining)
  32965. */
  32966. removeLODLevel(mesh: Mesh): Mesh;
  32967. /**
  32968. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32969. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32970. * @param camera defines the camera to use to compute distance
  32971. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32972. * @return This mesh (for chaining)
  32973. */
  32974. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32975. /**
  32976. * Gets the mesh internal Geometry object
  32977. */
  32978. get geometry(): Nullable<Geometry>;
  32979. /**
  32980. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32981. * @returns the total number of vertices
  32982. */
  32983. getTotalVertices(): number;
  32984. /**
  32985. * Returns the content of an associated vertex buffer
  32986. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32987. * - VertexBuffer.PositionKind
  32988. * - VertexBuffer.UVKind
  32989. * - VertexBuffer.UV2Kind
  32990. * - VertexBuffer.UV3Kind
  32991. * - VertexBuffer.UV4Kind
  32992. * - VertexBuffer.UV5Kind
  32993. * - VertexBuffer.UV6Kind
  32994. * - VertexBuffer.ColorKind
  32995. * - VertexBuffer.MatricesIndicesKind
  32996. * - VertexBuffer.MatricesIndicesExtraKind
  32997. * - VertexBuffer.MatricesWeightsKind
  32998. * - VertexBuffer.MatricesWeightsExtraKind
  32999. * @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
  33000. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33001. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33002. */
  33003. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33004. /**
  33005. * Returns the mesh VertexBuffer object from the requested `kind`
  33006. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33007. * - VertexBuffer.PositionKind
  33008. * - VertexBuffer.NormalKind
  33009. * - VertexBuffer.UVKind
  33010. * - VertexBuffer.UV2Kind
  33011. * - VertexBuffer.UV3Kind
  33012. * - VertexBuffer.UV4Kind
  33013. * - VertexBuffer.UV5Kind
  33014. * - VertexBuffer.UV6Kind
  33015. * - VertexBuffer.ColorKind
  33016. * - VertexBuffer.MatricesIndicesKind
  33017. * - VertexBuffer.MatricesIndicesExtraKind
  33018. * - VertexBuffer.MatricesWeightsKind
  33019. * - VertexBuffer.MatricesWeightsExtraKind
  33020. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33021. */
  33022. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33023. /**
  33024. * Tests if a specific vertex buffer is associated with this mesh
  33025. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33026. * - VertexBuffer.PositionKind
  33027. * - VertexBuffer.NormalKind
  33028. * - VertexBuffer.UVKind
  33029. * - VertexBuffer.UV2Kind
  33030. * - VertexBuffer.UV3Kind
  33031. * - VertexBuffer.UV4Kind
  33032. * - VertexBuffer.UV5Kind
  33033. * - VertexBuffer.UV6Kind
  33034. * - VertexBuffer.ColorKind
  33035. * - VertexBuffer.MatricesIndicesKind
  33036. * - VertexBuffer.MatricesIndicesExtraKind
  33037. * - VertexBuffer.MatricesWeightsKind
  33038. * - VertexBuffer.MatricesWeightsExtraKind
  33039. * @returns a boolean
  33040. */
  33041. isVerticesDataPresent(kind: string): boolean;
  33042. /**
  33043. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33044. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33045. * - VertexBuffer.PositionKind
  33046. * - VertexBuffer.UVKind
  33047. * - VertexBuffer.UV2Kind
  33048. * - VertexBuffer.UV3Kind
  33049. * - VertexBuffer.UV4Kind
  33050. * - VertexBuffer.UV5Kind
  33051. * - VertexBuffer.UV6Kind
  33052. * - VertexBuffer.ColorKind
  33053. * - VertexBuffer.MatricesIndicesKind
  33054. * - VertexBuffer.MatricesIndicesExtraKind
  33055. * - VertexBuffer.MatricesWeightsKind
  33056. * - VertexBuffer.MatricesWeightsExtraKind
  33057. * @returns a boolean
  33058. */
  33059. isVertexBufferUpdatable(kind: string): boolean;
  33060. /**
  33061. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33062. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33063. * - VertexBuffer.PositionKind
  33064. * - VertexBuffer.NormalKind
  33065. * - VertexBuffer.UVKind
  33066. * - VertexBuffer.UV2Kind
  33067. * - VertexBuffer.UV3Kind
  33068. * - VertexBuffer.UV4Kind
  33069. * - VertexBuffer.UV5Kind
  33070. * - VertexBuffer.UV6Kind
  33071. * - VertexBuffer.ColorKind
  33072. * - VertexBuffer.MatricesIndicesKind
  33073. * - VertexBuffer.MatricesIndicesExtraKind
  33074. * - VertexBuffer.MatricesWeightsKind
  33075. * - VertexBuffer.MatricesWeightsExtraKind
  33076. * @returns an array of strings
  33077. */
  33078. getVerticesDataKinds(): string[];
  33079. /**
  33080. * Returns a positive integer : the total number of indices in this mesh geometry.
  33081. * @returns the numner of indices or zero if the mesh has no geometry.
  33082. */
  33083. getTotalIndices(): number;
  33084. /**
  33085. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33086. * @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.
  33087. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33088. * @returns the indices array or an empty array if the mesh has no geometry
  33089. */
  33090. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33091. get isBlocked(): boolean;
  33092. /**
  33093. * Determine if the current mesh is ready to be rendered
  33094. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33095. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33096. * @returns true if all associated assets are ready (material, textures, shaders)
  33097. */
  33098. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33099. /**
  33100. * 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.
  33101. */
  33102. get areNormalsFrozen(): boolean;
  33103. /**
  33104. * 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.
  33105. * @returns the current mesh
  33106. */
  33107. freezeNormals(): Mesh;
  33108. /**
  33109. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  33110. * @returns the current mesh
  33111. */
  33112. unfreezeNormals(): Mesh;
  33113. /**
  33114. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33115. */
  33116. set overridenInstanceCount(count: number);
  33117. /** @hidden */
  33118. _preActivate(): Mesh;
  33119. /** @hidden */
  33120. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33121. /** @hidden */
  33122. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33123. protected _afterComputeWorldMatrix(): void;
  33124. /** @hidden */
  33125. _postActivate(): void;
  33126. /**
  33127. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33128. * This means the mesh underlying bounding box and sphere are recomputed.
  33129. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33130. * @returns the current mesh
  33131. */
  33132. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33133. /** @hidden */
  33134. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33135. /**
  33136. * This function will subdivide the mesh into multiple submeshes
  33137. * @param count defines the expected number of submeshes
  33138. */
  33139. subdivide(count: number): void;
  33140. /**
  33141. * Copy a FloatArray into a specific associated vertex buffer
  33142. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33143. * - VertexBuffer.PositionKind
  33144. * - VertexBuffer.UVKind
  33145. * - VertexBuffer.UV2Kind
  33146. * - VertexBuffer.UV3Kind
  33147. * - VertexBuffer.UV4Kind
  33148. * - VertexBuffer.UV5Kind
  33149. * - VertexBuffer.UV6Kind
  33150. * - VertexBuffer.ColorKind
  33151. * - VertexBuffer.MatricesIndicesKind
  33152. * - VertexBuffer.MatricesIndicesExtraKind
  33153. * - VertexBuffer.MatricesWeightsKind
  33154. * - VertexBuffer.MatricesWeightsExtraKind
  33155. * @param data defines the data source
  33156. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33157. * @param stride defines the data stride size (can be null)
  33158. * @returns the current mesh
  33159. */
  33160. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33161. /**
  33162. * Delete a vertex buffer associated with this mesh
  33163. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33164. * - VertexBuffer.PositionKind
  33165. * - VertexBuffer.UVKind
  33166. * - VertexBuffer.UV2Kind
  33167. * - VertexBuffer.UV3Kind
  33168. * - VertexBuffer.UV4Kind
  33169. * - VertexBuffer.UV5Kind
  33170. * - VertexBuffer.UV6Kind
  33171. * - VertexBuffer.ColorKind
  33172. * - VertexBuffer.MatricesIndicesKind
  33173. * - VertexBuffer.MatricesIndicesExtraKind
  33174. * - VertexBuffer.MatricesWeightsKind
  33175. * - VertexBuffer.MatricesWeightsExtraKind
  33176. */
  33177. removeVerticesData(kind: string): void;
  33178. /**
  33179. * Flags an associated vertex buffer as updatable
  33180. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33181. * - VertexBuffer.PositionKind
  33182. * - VertexBuffer.UVKind
  33183. * - VertexBuffer.UV2Kind
  33184. * - VertexBuffer.UV3Kind
  33185. * - VertexBuffer.UV4Kind
  33186. * - VertexBuffer.UV5Kind
  33187. * - VertexBuffer.UV6Kind
  33188. * - VertexBuffer.ColorKind
  33189. * - VertexBuffer.MatricesIndicesKind
  33190. * - VertexBuffer.MatricesIndicesExtraKind
  33191. * - VertexBuffer.MatricesWeightsKind
  33192. * - VertexBuffer.MatricesWeightsExtraKind
  33193. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33194. */
  33195. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33196. /**
  33197. * Sets the mesh global Vertex Buffer
  33198. * @param buffer defines the buffer to use
  33199. * @returns the current mesh
  33200. */
  33201. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33202. /**
  33203. * Update a specific associated vertex buffer
  33204. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33205. * - VertexBuffer.PositionKind
  33206. * - VertexBuffer.UVKind
  33207. * - VertexBuffer.UV2Kind
  33208. * - VertexBuffer.UV3Kind
  33209. * - VertexBuffer.UV4Kind
  33210. * - VertexBuffer.UV5Kind
  33211. * - VertexBuffer.UV6Kind
  33212. * - VertexBuffer.ColorKind
  33213. * - VertexBuffer.MatricesIndicesKind
  33214. * - VertexBuffer.MatricesIndicesExtraKind
  33215. * - VertexBuffer.MatricesWeightsKind
  33216. * - VertexBuffer.MatricesWeightsExtraKind
  33217. * @param data defines the data source
  33218. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33219. * @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)
  33220. * @returns the current mesh
  33221. */
  33222. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33223. /**
  33224. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33225. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33226. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33227. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33228. * @returns the current mesh
  33229. */
  33230. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33231. /**
  33232. * Creates a un-shared specific occurence of the geometry for the mesh.
  33233. * @returns the current mesh
  33234. */
  33235. makeGeometryUnique(): Mesh;
  33236. /**
  33237. * Set the index buffer of this mesh
  33238. * @param indices defines the source data
  33239. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33240. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33241. * @returns the current mesh
  33242. */
  33243. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33244. /**
  33245. * Update the current index buffer
  33246. * @param indices defines the source data
  33247. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33248. * @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)
  33249. * @returns the current mesh
  33250. */
  33251. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33252. /**
  33253. * Invert the geometry to move from a right handed system to a left handed one.
  33254. * @returns the current mesh
  33255. */
  33256. toLeftHanded(): Mesh;
  33257. /** @hidden */
  33258. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33259. /** @hidden */
  33260. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33261. /**
  33262. * Registers for this mesh a javascript function called just before the rendering process
  33263. * @param func defines the function to call before rendering this mesh
  33264. * @returns the current mesh
  33265. */
  33266. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33267. /**
  33268. * Disposes a previously registered javascript function called before the rendering
  33269. * @param func defines the function to remove
  33270. * @returns the current mesh
  33271. */
  33272. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33273. /**
  33274. * Registers for this mesh a javascript function called just after the rendering is complete
  33275. * @param func defines the function to call after rendering this mesh
  33276. * @returns the current mesh
  33277. */
  33278. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33279. /**
  33280. * Disposes a previously registered javascript function called after the rendering.
  33281. * @param func defines the function to remove
  33282. * @returns the current mesh
  33283. */
  33284. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33285. /** @hidden */
  33286. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33287. /** @hidden */
  33288. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33289. /** @hidden */
  33290. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33291. /** @hidden */
  33292. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33293. /** @hidden */
  33294. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33295. /** @hidden */
  33296. _rebuild(): void;
  33297. /** @hidden */
  33298. _freeze(): void;
  33299. /** @hidden */
  33300. _unFreeze(): void;
  33301. /**
  33302. * 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
  33303. * @param subMesh defines the subMesh to render
  33304. * @param enableAlphaMode defines if alpha mode can be changed
  33305. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33306. * @returns the current mesh
  33307. */
  33308. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33309. private _onBeforeDraw;
  33310. /**
  33311. * Renormalize the mesh and patch it up if there are no weights
  33312. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33313. * However in the case of zero weights then we set just a single influence to 1.
  33314. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33315. */
  33316. cleanMatrixWeights(): void;
  33317. private normalizeSkinFourWeights;
  33318. private normalizeSkinWeightsAndExtra;
  33319. /**
  33320. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33321. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33322. * the user know there was an issue with importing the mesh
  33323. * @returns a validation object with skinned, valid and report string
  33324. */
  33325. validateSkinning(): {
  33326. skinned: boolean;
  33327. valid: boolean;
  33328. report: string;
  33329. };
  33330. /** @hidden */
  33331. _checkDelayState(): Mesh;
  33332. private _queueLoad;
  33333. /**
  33334. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33335. * A mesh is in the frustum if its bounding box intersects the frustum
  33336. * @param frustumPlanes defines the frustum to test
  33337. * @returns true if the mesh is in the frustum planes
  33338. */
  33339. isInFrustum(frustumPlanes: Plane[]): boolean;
  33340. /**
  33341. * Sets the mesh material by the material or multiMaterial `id` property
  33342. * @param id is a string identifying the material or the multiMaterial
  33343. * @returns the current mesh
  33344. */
  33345. setMaterialByID(id: string): Mesh;
  33346. /**
  33347. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33348. * @returns an array of IAnimatable
  33349. */
  33350. getAnimatables(): IAnimatable[];
  33351. /**
  33352. * Modifies the mesh geometry according to the passed transformation matrix.
  33353. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33354. * The mesh normals are modified using the same transformation.
  33355. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33356. * @param transform defines the transform matrix to use
  33357. * @see https://doc.babylonjs.com/resources/baking_transformations
  33358. * @returns the current mesh
  33359. */
  33360. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33361. /**
  33362. * Modifies the mesh geometry according to its own current World Matrix.
  33363. * The mesh World Matrix is then reset.
  33364. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33365. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33366. * @see https://doc.babylonjs.com/resources/baking_transformations
  33367. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33368. * @returns the current mesh
  33369. */
  33370. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33371. /** @hidden */
  33372. get _positions(): Nullable<Vector3[]>;
  33373. /** @hidden */
  33374. _resetPointsArrayCache(): Mesh;
  33375. /** @hidden */
  33376. _generatePointsArray(): boolean;
  33377. /**
  33378. * Returns a new Mesh object generated from the current mesh properties.
  33379. * This method must not get confused with createInstance()
  33380. * @param name is a string, the name given to the new mesh
  33381. * @param newParent can be any Node object (default `null`)
  33382. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33383. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33384. * @returns a new mesh
  33385. */
  33386. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33387. /**
  33388. * Releases resources associated with this mesh.
  33389. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33390. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33391. */
  33392. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33393. /** @hidden */
  33394. _disposeInstanceSpecificData(): void;
  33395. /** @hidden */
  33396. _disposeThinInstanceSpecificData(): void;
  33397. /**
  33398. * Modifies the mesh geometry according to a displacement map.
  33399. * 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.
  33400. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33401. * @param url is a string, the URL from the image file is to be downloaded.
  33402. * @param minHeight is the lower limit of the displacement.
  33403. * @param maxHeight is the upper limit of the displacement.
  33404. * @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.
  33405. * @param uvOffset is an optional vector2 used to offset UV.
  33406. * @param uvScale is an optional vector2 used to scale UV.
  33407. * @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.
  33408. * @returns the Mesh.
  33409. */
  33410. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33411. /**
  33412. * Modifies the mesh geometry according to a displacementMap buffer.
  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 buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33416. * @param heightMapWidth is the width of the buffer image.
  33417. * @param heightMapHeight is the height of the buffer image.
  33418. * @param minHeight is the lower limit of the displacement.
  33419. * @param maxHeight is the upper limit of the displacement.
  33420. * @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.
  33421. * @param uvOffset is an optional vector2 used to offset UV.
  33422. * @param uvScale is an optional vector2 used to scale UV.
  33423. * @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.
  33424. * @returns the Mesh.
  33425. */
  33426. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33427. /**
  33428. * Modify the mesh to get a flat shading rendering.
  33429. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33430. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33431. * @returns current mesh
  33432. */
  33433. convertToFlatShadedMesh(): Mesh;
  33434. /**
  33435. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33436. * In other words, more vertices, no more indices and a single bigger VBO.
  33437. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33438. * @returns current mesh
  33439. */
  33440. convertToUnIndexedMesh(): Mesh;
  33441. /**
  33442. * Inverses facet orientations.
  33443. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33444. * @param flipNormals will also inverts the normals
  33445. * @returns current mesh
  33446. */
  33447. flipFaces(flipNormals?: boolean): Mesh;
  33448. /**
  33449. * Increase the number of facets and hence vertices in a mesh
  33450. * Vertex normals are interpolated from existing vertex normals
  33451. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33452. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33453. */
  33454. increaseVertices(numberPerEdge: number): void;
  33455. /**
  33456. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33457. * This will undo any application of covertToFlatShadedMesh
  33458. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33459. */
  33460. forceSharedVertices(): void;
  33461. /** @hidden */
  33462. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33463. /** @hidden */
  33464. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33465. /**
  33466. * Creates a new InstancedMesh object from the mesh model.
  33467. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33468. * @param name defines the name of the new instance
  33469. * @returns a new InstancedMesh
  33470. */
  33471. createInstance(name: string): InstancedMesh;
  33472. /**
  33473. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33474. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33475. * @returns the current mesh
  33476. */
  33477. synchronizeInstances(): Mesh;
  33478. /**
  33479. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33480. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33481. * This should be used together with the simplification to avoid disappearing triangles.
  33482. * @param successCallback an optional success callback to be called after the optimization finished.
  33483. * @returns the current mesh
  33484. */
  33485. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33486. /**
  33487. * Serialize current mesh
  33488. * @param serializationObject defines the object which will receive the serialization data
  33489. */
  33490. serialize(serializationObject: any): void;
  33491. /** @hidden */
  33492. _syncGeometryWithMorphTargetManager(): void;
  33493. /** @hidden */
  33494. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33495. /**
  33496. * Returns a new Mesh object parsed from the source provided.
  33497. * @param parsedMesh is the source
  33498. * @param scene defines the hosting scene
  33499. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33500. * @returns a new Mesh
  33501. */
  33502. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33503. /**
  33504. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33505. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33506. * @param name defines the name of the mesh to create
  33507. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33508. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33509. * @param closePath creates a seam between the first and the last points of each path of the path array
  33510. * @param offset is taken in account only if the `pathArray` is containing a single path
  33511. * @param scene defines the hosting scene
  33512. * @param updatable defines if the mesh must be flagged as updatable
  33513. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33514. * @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)
  33515. * @returns a new Mesh
  33516. */
  33517. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33518. /**
  33519. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33520. * @param name defines the name of the mesh to create
  33521. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33522. * @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
  33523. * @param scene defines the hosting scene
  33524. * @param updatable defines if the mesh must be flagged as updatable
  33525. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33526. * @returns a new Mesh
  33527. */
  33528. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33529. /**
  33530. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33531. * @param name defines the name of the mesh to create
  33532. * @param size sets the size (float) of each box side (default 1)
  33533. * @param scene defines the hosting scene
  33534. * @param updatable defines if the mesh must be flagged as updatable
  33535. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33536. * @returns a new Mesh
  33537. */
  33538. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33539. /**
  33540. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33541. * @param name defines the name of the mesh to create
  33542. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33543. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33544. * @param scene defines the hosting scene
  33545. * @param updatable defines if the mesh must be flagged as updatable
  33546. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33547. * @returns a new Mesh
  33548. */
  33549. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33550. /**
  33551. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33552. * @param name defines the name of the mesh to create
  33553. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33554. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33555. * @param scene defines the hosting scene
  33556. * @returns a new Mesh
  33557. */
  33558. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33559. /**
  33560. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33561. * @param name defines the name of the mesh to create
  33562. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33563. * @param diameterTop set the top cap diameter (floats, default 1)
  33564. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33565. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33566. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33567. * @param scene defines the hosting scene
  33568. * @param updatable defines if the mesh must be flagged as updatable
  33569. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33570. * @returns a new Mesh
  33571. */
  33572. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33573. /**
  33574. * Creates a torus 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 diameter sets the diameter size (float) of the torus (default 1)
  33577. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33578. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33579. * @param scene defines the hosting scene
  33580. * @param updatable defines if the mesh must be flagged as updatable
  33581. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33582. * @returns a new Mesh
  33583. */
  33584. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33585. /**
  33586. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33587. * @param name defines the name of the mesh to create
  33588. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33589. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33590. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33591. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33592. * @param p the number of windings on X axis (positive integers, default 2)
  33593. * @param q the number of windings on Y axis (positive integers, default 3)
  33594. * @param scene defines the hosting scene
  33595. * @param updatable defines if the mesh must be flagged as updatable
  33596. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33597. * @returns a new Mesh
  33598. */
  33599. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33600. /**
  33601. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33602. * @param name defines the name of the mesh to create
  33603. * @param points is an array successive Vector3
  33604. * @param scene defines the hosting scene
  33605. * @param updatable defines if the mesh must be flagged as updatable
  33606. * @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).
  33607. * @returns a new Mesh
  33608. */
  33609. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33610. /**
  33611. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33612. * @param name defines the name of the mesh to create
  33613. * @param points is an array successive Vector3
  33614. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33615. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33616. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33617. * @param scene defines the hosting scene
  33618. * @param updatable defines if the mesh must be flagged as updatable
  33619. * @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)
  33620. * @returns a new Mesh
  33621. */
  33622. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33623. /**
  33624. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33625. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33626. * 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.
  33627. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33628. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33629. * Remember you can only change the shape positions, not their number when updating a polygon.
  33630. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33631. * @param name defines the name of the mesh to create
  33632. * @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
  33633. * @param scene defines the hosting scene
  33634. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33635. * @param updatable defines if the mesh must be flagged as updatable
  33636. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33637. * @param earcutInjection can be used to inject your own earcut reference
  33638. * @returns a new Mesh
  33639. */
  33640. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33641. /**
  33642. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33643. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33644. * @param name defines the name of the mesh to create
  33645. * @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
  33646. * @param depth defines the height of extrusion
  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 ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33655. /**
  33656. * Creates an extruded shape mesh.
  33657. * 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
  33658. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33659. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33660. * @param name defines the name of the mesh to create
  33661. * @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
  33662. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33663. * @param scale is the value to scale the shape
  33664. * @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
  33665. * @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
  33666. * @param scene defines the hosting scene
  33667. * @param updatable defines if the mesh must be flagged as updatable
  33668. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33669. * @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)
  33670. * @returns a new Mesh
  33671. */
  33672. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33673. /**
  33674. * Creates an custom extruded shape mesh.
  33675. * The custom extrusion is a parametric shape.
  33676. * It has no predefined shape. Its final shape will depend on the input parameters.
  33677. * Please consider using the same method from the MeshBuilder class instead
  33678. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33679. * @param name defines the name of the mesh to create
  33680. * @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
  33681. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33682. * @param scaleFunction is a custom Javascript function called on each path point
  33683. * @param rotationFunction is a custom Javascript function called on each path point
  33684. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33685. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33686. * @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
  33687. * @param scene defines the hosting scene
  33688. * @param updatable defines if the mesh must be flagged as updatable
  33689. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33690. * @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)
  33691. * @returns a new Mesh
  33692. */
  33693. 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;
  33694. /**
  33695. * Creates lathe mesh.
  33696. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33697. * Please consider using the same method from the MeshBuilder class instead
  33698. * @param name defines the name of the mesh to create
  33699. * @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
  33700. * @param radius is the radius value of the lathe
  33701. * @param tessellation is the side number of the lathe.
  33702. * @param scene defines the hosting scene
  33703. * @param updatable defines if the mesh must be flagged as updatable
  33704. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33705. * @returns a new Mesh
  33706. */
  33707. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33708. /**
  33709. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33710. * @param name defines the name of the mesh to create
  33711. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33712. * @param scene defines the hosting scene
  33713. * @param updatable defines if the mesh must be flagged as updatable
  33714. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33715. * @returns a new Mesh
  33716. */
  33717. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33718. /**
  33719. * Creates a ground mesh.
  33720. * Please consider using the same method from the MeshBuilder class instead
  33721. * @param name defines the name of the mesh to create
  33722. * @param width set the width of the ground
  33723. * @param height set the height of the ground
  33724. * @param subdivisions sets the number of subdivisions per side
  33725. * @param scene defines the hosting scene
  33726. * @param updatable defines if the mesh must be flagged as updatable
  33727. * @returns a new Mesh
  33728. */
  33729. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33730. /**
  33731. * Creates a tiled ground mesh.
  33732. * Please consider using the same method from the MeshBuilder class instead
  33733. * @param name defines the name of the mesh to create
  33734. * @param xmin set the ground minimum X coordinate
  33735. * @param zmin set the ground minimum Y coordinate
  33736. * @param xmax set the ground maximum X coordinate
  33737. * @param zmax set the ground maximum Z coordinate
  33738. * @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
  33739. * @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
  33740. * @param scene defines the hosting scene
  33741. * @param updatable defines if the mesh must be flagged as updatable
  33742. * @returns a new Mesh
  33743. */
  33744. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33745. w: number;
  33746. h: number;
  33747. }, precision: {
  33748. w: number;
  33749. h: number;
  33750. }, scene: Scene, updatable?: boolean): Mesh;
  33751. /**
  33752. * Creates a ground mesh from a height map.
  33753. * Please consider using the same method from the MeshBuilder class instead
  33754. * @see https://doc.babylonjs.com/babylon101/height_map
  33755. * @param name defines the name of the mesh to create
  33756. * @param url sets the URL of the height map image resource
  33757. * @param width set the ground width size
  33758. * @param height set the ground height size
  33759. * @param subdivisions sets the number of subdivision per side
  33760. * @param minHeight is the minimum altitude on the ground
  33761. * @param maxHeight is the maximum altitude on the ground
  33762. * @param scene defines the hosting scene
  33763. * @param updatable defines if the mesh must be flagged as updatable
  33764. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33765. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33766. * @returns a new Mesh
  33767. */
  33768. 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;
  33769. /**
  33770. * Creates a tube mesh.
  33771. * The tube is a parametric shape.
  33772. * It has no predefined shape. Its final shape will depend on the input parameters.
  33773. * Please consider using the same method from the MeshBuilder class instead
  33774. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33775. * @param name defines the name of the mesh to create
  33776. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33777. * @param radius sets the tube radius size
  33778. * @param tessellation is the number of sides on the tubular surface
  33779. * @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
  33780. * @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
  33781. * @param scene defines the hosting scene
  33782. * @param updatable defines if the mesh must be flagged as updatable
  33783. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33784. * @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)
  33785. * @returns a new Mesh
  33786. */
  33787. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33788. (i: number, distance: number): number;
  33789. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33790. /**
  33791. * Creates a polyhedron mesh.
  33792. * Please consider using the same method from the MeshBuilder class instead.
  33793. * * 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
  33794. * * The parameter `size` (positive float, default 1) sets the polygon size
  33795. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33796. * * 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`
  33797. * * 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
  33798. * * 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)`)
  33799. * * 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
  33800. * * 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
  33801. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33802. * * 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
  33803. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33804. * @param name defines the name of the mesh to create
  33805. * @param options defines the options used to create the mesh
  33806. * @param scene defines the hosting scene
  33807. * @returns a new Mesh
  33808. */
  33809. static CreatePolyhedron(name: string, options: {
  33810. type?: number;
  33811. size?: number;
  33812. sizeX?: number;
  33813. sizeY?: number;
  33814. sizeZ?: number;
  33815. custom?: any;
  33816. faceUV?: Vector4[];
  33817. faceColors?: Color4[];
  33818. updatable?: boolean;
  33819. sideOrientation?: number;
  33820. }, scene: Scene): Mesh;
  33821. /**
  33822. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33823. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33824. * * 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`)
  33825. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33826. * * 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
  33827. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33828. * * 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
  33829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33830. * @param name defines the name of the mesh
  33831. * @param options defines the options used to create the mesh
  33832. * @param scene defines the hosting scene
  33833. * @returns a new Mesh
  33834. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33835. */
  33836. static CreateIcoSphere(name: string, options: {
  33837. radius?: number;
  33838. flat?: boolean;
  33839. subdivisions?: number;
  33840. sideOrientation?: number;
  33841. updatable?: boolean;
  33842. }, scene: Scene): Mesh;
  33843. /**
  33844. * Creates a decal mesh.
  33845. * Please consider using the same method from the MeshBuilder class instead.
  33846. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33847. * @param name defines the name of the mesh
  33848. * @param sourceMesh defines the mesh receiving the decal
  33849. * @param position sets the position of the decal in world coordinates
  33850. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33851. * @param size sets the decal scaling
  33852. * @param angle sets the angle to rotate the decal
  33853. * @returns a new Mesh
  33854. */
  33855. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33856. /** Creates a Capsule Mesh
  33857. * @param name defines the name of the mesh.
  33858. * @param options the constructors options used to shape the mesh.
  33859. * @param scene defines the scene the mesh is scoped to.
  33860. * @returns the capsule mesh
  33861. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33862. */
  33863. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33864. /**
  33865. * Prepare internal position array for software CPU skinning
  33866. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33867. */
  33868. setPositionsForCPUSkinning(): Float32Array;
  33869. /**
  33870. * Prepare internal normal array for software CPU skinning
  33871. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33872. */
  33873. setNormalsForCPUSkinning(): Float32Array;
  33874. /**
  33875. * Updates the vertex buffer by applying transformation from the bones
  33876. * @param skeleton defines the skeleton to apply to current mesh
  33877. * @returns the current mesh
  33878. */
  33879. applySkeleton(skeleton: Skeleton): Mesh;
  33880. /**
  33881. * 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
  33882. * @param meshes defines the list of meshes to scan
  33883. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33884. */
  33885. static MinMax(meshes: AbstractMesh[]): {
  33886. min: Vector3;
  33887. max: Vector3;
  33888. };
  33889. /**
  33890. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33891. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33892. * @returns a vector3
  33893. */
  33894. static Center(meshesOrMinMaxVector: {
  33895. min: Vector3;
  33896. max: Vector3;
  33897. } | AbstractMesh[]): Vector3;
  33898. /**
  33899. * Merge the array of meshes into a single mesh for performance reasons.
  33900. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33901. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33902. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33903. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33904. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33905. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33906. * @returns a new mesh
  33907. */
  33908. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33909. /** @hidden */
  33910. addInstance(instance: InstancedMesh): void;
  33911. /** @hidden */
  33912. removeInstance(instance: InstancedMesh): void;
  33913. }
  33914. }
  33915. declare module BABYLON {
  33916. /**
  33917. * This is the base class of all the camera used in the application.
  33918. * @see https://doc.babylonjs.com/features/cameras
  33919. */
  33920. export class Camera extends Node {
  33921. /** @hidden */
  33922. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  33923. /**
  33924. * This is the default projection mode used by the cameras.
  33925. * It helps recreating a feeling of perspective and better appreciate depth.
  33926. * This is the best way to simulate real life cameras.
  33927. */
  33928. static readonly PERSPECTIVE_CAMERA: number;
  33929. /**
  33930. * This helps creating camera with an orthographic mode.
  33931. * 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.
  33932. */
  33933. static readonly ORTHOGRAPHIC_CAMERA: number;
  33934. /**
  33935. * This is the default FOV mode for perspective cameras.
  33936. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  33937. */
  33938. static readonly FOVMODE_VERTICAL_FIXED: number;
  33939. /**
  33940. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  33941. */
  33942. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  33943. /**
  33944. * This specifies ther is no need for a camera rig.
  33945. * Basically only one eye is rendered corresponding to the camera.
  33946. */
  33947. static readonly RIG_MODE_NONE: number;
  33948. /**
  33949. * Simulates a camera Rig with one blue eye and one red eye.
  33950. * This can be use with 3d blue and red glasses.
  33951. */
  33952. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  33953. /**
  33954. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  33955. */
  33956. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  33957. /**
  33958. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  33959. */
  33960. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  33961. /**
  33962. * Defines that both eyes of the camera will be rendered over under each other.
  33963. */
  33964. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  33965. /**
  33966. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  33967. */
  33968. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  33969. /**
  33970. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  33971. */
  33972. static readonly RIG_MODE_VR: number;
  33973. /**
  33974. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  33975. */
  33976. static readonly RIG_MODE_WEBVR: number;
  33977. /**
  33978. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  33979. */
  33980. static readonly RIG_MODE_CUSTOM: number;
  33981. /**
  33982. * Defines if by default attaching controls should prevent the default javascript event to continue.
  33983. */
  33984. static ForceAttachControlToAlwaysPreventDefault: boolean;
  33985. /**
  33986. * Define the input manager associated with the camera.
  33987. */
  33988. inputs: CameraInputsManager<Camera>;
  33989. /** @hidden */
  33990. _position: Vector3;
  33991. /**
  33992. * Define the current local position of the camera in the scene
  33993. */
  33994. get position(): Vector3;
  33995. set position(newPosition: Vector3);
  33996. protected _upVector: Vector3;
  33997. /**
  33998. * The vector the camera should consider as up.
  33999. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  34000. */
  34001. set upVector(vec: Vector3);
  34002. get upVector(): Vector3;
  34003. /**
  34004. * Define the current limit on the left side for an orthographic camera
  34005. * In scene unit
  34006. */
  34007. orthoLeft: Nullable<number>;
  34008. /**
  34009. * Define the current limit on the right side for an orthographic camera
  34010. * In scene unit
  34011. */
  34012. orthoRight: Nullable<number>;
  34013. /**
  34014. * Define the current limit on the bottom side for an orthographic camera
  34015. * In scene unit
  34016. */
  34017. orthoBottom: Nullable<number>;
  34018. /**
  34019. * Define the current limit on the top side for an orthographic camera
  34020. * In scene unit
  34021. */
  34022. orthoTop: Nullable<number>;
  34023. /**
  34024. * Field Of View is set in Radians. (default is 0.8)
  34025. */
  34026. fov: number;
  34027. /**
  34028. * Define the minimum distance the camera can see from.
  34029. * This is important to note that the depth buffer are not infinite and the closer it starts
  34030. * the more your scene might encounter depth fighting issue.
  34031. */
  34032. minZ: number;
  34033. /**
  34034. * Define the maximum distance the camera can see to.
  34035. * This is important to note that the depth buffer are not infinite and the further it end
  34036. * the more your scene might encounter depth fighting issue.
  34037. */
  34038. maxZ: number;
  34039. /**
  34040. * Define the default inertia of the camera.
  34041. * This helps giving a smooth feeling to the camera movement.
  34042. */
  34043. inertia: number;
  34044. /**
  34045. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  34046. */
  34047. mode: number;
  34048. /**
  34049. * Define whether the camera is intermediate.
  34050. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  34051. */
  34052. isIntermediate: boolean;
  34053. /**
  34054. * Define the viewport of the camera.
  34055. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  34056. */
  34057. viewport: Viewport;
  34058. /**
  34059. * Restricts the camera to viewing objects with the same layerMask.
  34060. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  34061. */
  34062. layerMask: number;
  34063. /**
  34064. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  34065. */
  34066. fovMode: number;
  34067. /**
  34068. * Rig mode of the camera.
  34069. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  34070. * This is normally controlled byt the camera themselves as internal use.
  34071. */
  34072. cameraRigMode: number;
  34073. /**
  34074. * Defines the distance between both "eyes" in case of a RIG
  34075. */
  34076. interaxialDistance: number;
  34077. /**
  34078. * Defines if stereoscopic rendering is done side by side or over under.
  34079. */
  34080. isStereoscopicSideBySide: boolean;
  34081. /**
  34082. * 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
  34083. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  34084. * else in the scene. (Eg. security camera)
  34085. *
  34086. * 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)
  34087. */
  34088. customRenderTargets: RenderTargetTexture[];
  34089. /**
  34090. * When set, the camera will render to this render target instead of the default canvas
  34091. *
  34092. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  34093. */
  34094. outputRenderTarget: Nullable<RenderTargetTexture>;
  34095. /**
  34096. * Observable triggered when the camera view matrix has changed.
  34097. */
  34098. onViewMatrixChangedObservable: Observable<Camera>;
  34099. /**
  34100. * Observable triggered when the camera Projection matrix has changed.
  34101. */
  34102. onProjectionMatrixChangedObservable: Observable<Camera>;
  34103. /**
  34104. * Observable triggered when the inputs have been processed.
  34105. */
  34106. onAfterCheckInputsObservable: Observable<Camera>;
  34107. /**
  34108. * Observable triggered when reset has been called and applied to the camera.
  34109. */
  34110. onRestoreStateObservable: Observable<Camera>;
  34111. /**
  34112. * Is this camera a part of a rig system?
  34113. */
  34114. isRigCamera: boolean;
  34115. /**
  34116. * If isRigCamera set to true this will be set with the parent camera.
  34117. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  34118. */
  34119. rigParent?: Camera;
  34120. /** @hidden */
  34121. _cameraRigParams: any;
  34122. /** @hidden */
  34123. _rigCameras: Camera[];
  34124. /** @hidden */
  34125. _rigPostProcess: Nullable<PostProcess>;
  34126. protected _webvrViewMatrix: Matrix;
  34127. /** @hidden */
  34128. _skipRendering: boolean;
  34129. /** @hidden */
  34130. _projectionMatrix: Matrix;
  34131. /** @hidden */
  34132. _postProcesses: Nullable<PostProcess>[];
  34133. /** @hidden */
  34134. _activeMeshes: SmartArray<AbstractMesh>;
  34135. protected _globalPosition: Vector3;
  34136. /** @hidden */
  34137. _computedViewMatrix: Matrix;
  34138. private _doNotComputeProjectionMatrix;
  34139. private _transformMatrix;
  34140. private _frustumPlanes;
  34141. private _refreshFrustumPlanes;
  34142. private _storedFov;
  34143. private _stateStored;
  34144. /**
  34145. * Instantiates a new camera object.
  34146. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  34147. * @see https://doc.babylonjs.com/features/cameras
  34148. * @param name Defines the name of the camera in the scene
  34149. * @param position Defines the position of the camera
  34150. * @param scene Defines the scene the camera belongs too
  34151. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  34152. */
  34153. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34154. /**
  34155. * Store current camera state (fov, position, etc..)
  34156. * @returns the camera
  34157. */
  34158. storeState(): Camera;
  34159. /**
  34160. * Restores the camera state values if it has been stored. You must call storeState() first
  34161. */
  34162. protected _restoreStateValues(): boolean;
  34163. /**
  34164. * Restored camera state. You must call storeState() first.
  34165. * @returns true if restored and false otherwise
  34166. */
  34167. restoreState(): boolean;
  34168. /**
  34169. * Gets the class name of the camera.
  34170. * @returns the class name
  34171. */
  34172. getClassName(): string;
  34173. /** @hidden */
  34174. readonly _isCamera: boolean;
  34175. /**
  34176. * Gets a string representation of the camera useful for debug purpose.
  34177. * @param fullDetails Defines that a more verboe level of logging is required
  34178. * @returns the string representation
  34179. */
  34180. toString(fullDetails?: boolean): string;
  34181. /**
  34182. * Gets the current world space position of the camera.
  34183. */
  34184. get globalPosition(): Vector3;
  34185. /**
  34186. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  34187. * @returns the active meshe list
  34188. */
  34189. getActiveMeshes(): SmartArray<AbstractMesh>;
  34190. /**
  34191. * Check whether a mesh is part of the current active mesh list of the camera
  34192. * @param mesh Defines the mesh to check
  34193. * @returns true if active, false otherwise
  34194. */
  34195. isActiveMesh(mesh: Mesh): boolean;
  34196. /**
  34197. * Is this camera ready to be used/rendered
  34198. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  34199. * @return true if the camera is ready
  34200. */
  34201. isReady(completeCheck?: boolean): boolean;
  34202. /** @hidden */
  34203. _initCache(): void;
  34204. /** @hidden */
  34205. _updateCache(ignoreParentClass?: boolean): void;
  34206. /** @hidden */
  34207. _isSynchronized(): boolean;
  34208. /** @hidden */
  34209. _isSynchronizedViewMatrix(): boolean;
  34210. /** @hidden */
  34211. _isSynchronizedProjectionMatrix(): boolean;
  34212. /**
  34213. * Attach the input controls to a specific dom element to get the input from.
  34214. * @param element Defines the element the controls should be listened from
  34215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34216. */
  34217. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34218. /**
  34219. * Detach the current controls from the specified dom element.
  34220. * @param element Defines the element to stop listening the inputs from
  34221. */
  34222. detachControl(element: HTMLElement): void;
  34223. /**
  34224. * Update the camera state according to the different inputs gathered during the frame.
  34225. */
  34226. update(): void;
  34227. /** @hidden */
  34228. _checkInputs(): void;
  34229. /** @hidden */
  34230. get rigCameras(): Camera[];
  34231. /**
  34232. * Gets the post process used by the rig cameras
  34233. */
  34234. get rigPostProcess(): Nullable<PostProcess>;
  34235. /**
  34236. * Internal, gets the first post proces.
  34237. * @returns the first post process to be run on this camera.
  34238. */
  34239. _getFirstPostProcess(): Nullable<PostProcess>;
  34240. private _cascadePostProcessesToRigCams;
  34241. /**
  34242. * Attach a post process to the camera.
  34243. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  34244. * @param postProcess The post process to attach to the camera
  34245. * @param insertAt The position of the post process in case several of them are in use in the scene
  34246. * @returns the position the post process has been inserted at
  34247. */
  34248. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  34249. /**
  34250. * Detach a post process to the camera.
  34251. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  34252. * @param postProcess The post process to detach from the camera
  34253. */
  34254. detachPostProcess(postProcess: PostProcess): void;
  34255. /**
  34256. * Gets the current world matrix of the camera
  34257. */
  34258. getWorldMatrix(): Matrix;
  34259. /** @hidden */
  34260. _getViewMatrix(): Matrix;
  34261. /**
  34262. * Gets the current view matrix of the camera.
  34263. * @param force forces the camera to recompute the matrix without looking at the cached state
  34264. * @returns the view matrix
  34265. */
  34266. getViewMatrix(force?: boolean): Matrix;
  34267. /**
  34268. * Freeze the projection matrix.
  34269. * It will prevent the cache check of the camera projection compute and can speed up perf
  34270. * if no parameter of the camera are meant to change
  34271. * @param projection Defines manually a projection if necessary
  34272. */
  34273. freezeProjectionMatrix(projection?: Matrix): void;
  34274. /**
  34275. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  34276. */
  34277. unfreezeProjectionMatrix(): void;
  34278. /**
  34279. * Gets the current projection matrix of the camera.
  34280. * @param force forces the camera to recompute the matrix without looking at the cached state
  34281. * @returns the projection matrix
  34282. */
  34283. getProjectionMatrix(force?: boolean): Matrix;
  34284. /**
  34285. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  34286. * @returns a Matrix
  34287. */
  34288. getTransformationMatrix(): Matrix;
  34289. private _updateFrustumPlanes;
  34290. /**
  34291. * Checks if a cullable object (mesh...) is in the camera frustum
  34292. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  34293. * @param target The object to check
  34294. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  34295. * @returns true if the object is in frustum otherwise false
  34296. */
  34297. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  34298. /**
  34299. * Checks if a cullable object (mesh...) is in the camera frustum
  34300. * Unlike isInFrustum this cheks the full bounding box
  34301. * @param target The object to check
  34302. * @returns true if the object is in frustum otherwise false
  34303. */
  34304. isCompletelyInFrustum(target: ICullable): boolean;
  34305. /**
  34306. * Gets a ray in the forward direction from the camera.
  34307. * @param length Defines the length of the ray to create
  34308. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34309. * @param origin Defines the start point of the ray which defaults to the camera position
  34310. * @returns the forward ray
  34311. */
  34312. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34313. /**
  34314. * Gets a ray in the forward direction from the camera.
  34315. * @param refRay the ray to (re)use when setting the values
  34316. * @param length Defines the length of the ray to create
  34317. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  34318. * @param origin Defines the start point of the ray which defaults to the camera position
  34319. * @returns the forward ray
  34320. */
  34321. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  34322. /**
  34323. * Releases resources associated with this node.
  34324. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34325. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34326. */
  34327. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34328. /** @hidden */
  34329. _isLeftCamera: boolean;
  34330. /**
  34331. * Gets the left camera of a rig setup in case of Rigged Camera
  34332. */
  34333. get isLeftCamera(): boolean;
  34334. /** @hidden */
  34335. _isRightCamera: boolean;
  34336. /**
  34337. * Gets the right camera of a rig setup in case of Rigged Camera
  34338. */
  34339. get isRightCamera(): boolean;
  34340. /**
  34341. * Gets the left camera of a rig setup in case of Rigged Camera
  34342. */
  34343. get leftCamera(): Nullable<FreeCamera>;
  34344. /**
  34345. * Gets the right camera of a rig setup in case of Rigged Camera
  34346. */
  34347. get rightCamera(): Nullable<FreeCamera>;
  34348. /**
  34349. * Gets the left camera target of a rig setup in case of Rigged Camera
  34350. * @returns the target position
  34351. */
  34352. getLeftTarget(): Nullable<Vector3>;
  34353. /**
  34354. * Gets the right camera target of a rig setup in case of Rigged Camera
  34355. * @returns the target position
  34356. */
  34357. getRightTarget(): Nullable<Vector3>;
  34358. /**
  34359. * @hidden
  34360. */
  34361. setCameraRigMode(mode: number, rigParams: any): void;
  34362. /** @hidden */
  34363. static _setStereoscopicRigMode(camera: Camera): void;
  34364. /** @hidden */
  34365. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  34366. /** @hidden */
  34367. static _setVRRigMode(camera: Camera, rigParams: any): void;
  34368. /** @hidden */
  34369. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  34370. /** @hidden */
  34371. _getVRProjectionMatrix(): Matrix;
  34372. protected _updateCameraRotationMatrix(): void;
  34373. protected _updateWebVRCameraRotationMatrix(): void;
  34374. /**
  34375. * This function MUST be overwritten by the different WebVR cameras available.
  34376. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34377. * @hidden
  34378. */
  34379. _getWebVRProjectionMatrix(): Matrix;
  34380. /**
  34381. * This function MUST be overwritten by the different WebVR cameras available.
  34382. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34383. * @hidden
  34384. */
  34385. _getWebVRViewMatrix(): Matrix;
  34386. /** @hidden */
  34387. setCameraRigParameter(name: string, value: any): void;
  34388. /**
  34389. * needs to be overridden by children so sub has required properties to be copied
  34390. * @hidden
  34391. */
  34392. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  34393. /**
  34394. * May need to be overridden by children
  34395. * @hidden
  34396. */
  34397. _updateRigCameras(): void;
  34398. /** @hidden */
  34399. _setupInputs(): void;
  34400. /**
  34401. * Serialiaze the camera setup to a json represention
  34402. * @returns the JSON representation
  34403. */
  34404. serialize(): any;
  34405. /**
  34406. * Clones the current camera.
  34407. * @param name The cloned camera name
  34408. * @returns the cloned camera
  34409. */
  34410. clone(name: string): Camera;
  34411. /**
  34412. * Gets the direction of the camera relative to a given local axis.
  34413. * @param localAxis Defines the reference axis to provide a relative direction.
  34414. * @return the direction
  34415. */
  34416. getDirection(localAxis: Vector3): Vector3;
  34417. /**
  34418. * Returns the current camera absolute rotation
  34419. */
  34420. get absoluteRotation(): Quaternion;
  34421. /**
  34422. * Gets the direction of the camera relative to a given local axis into a passed vector.
  34423. * @param localAxis Defines the reference axis to provide a relative direction.
  34424. * @param result Defines the vector to store the result in
  34425. */
  34426. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  34427. /**
  34428. * Gets a camera constructor for a given camera type
  34429. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  34430. * @param name The name of the camera the result will be able to instantiate
  34431. * @param scene The scene the result will construct the camera in
  34432. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  34433. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  34434. * @returns a factory method to construc the camera
  34435. */
  34436. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  34437. /**
  34438. * Compute the world matrix of the camera.
  34439. * @returns the camera world matrix
  34440. */
  34441. computeWorldMatrix(): Matrix;
  34442. /**
  34443. * Parse a JSON and creates the camera from the parsed information
  34444. * @param parsedCamera The JSON to parse
  34445. * @param scene The scene to instantiate the camera in
  34446. * @returns the newly constructed camera
  34447. */
  34448. static Parse(parsedCamera: any, scene: Scene): Camera;
  34449. }
  34450. }
  34451. declare module BABYLON {
  34452. /**
  34453. * Class containing static functions to help procedurally build meshes
  34454. */
  34455. export class DiscBuilder {
  34456. /**
  34457. * Creates a plane polygonal mesh. By default, this is a disc
  34458. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34459. * * 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
  34460. * * 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
  34461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34462. * * 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
  34463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34464. * @param name defines the name of the mesh
  34465. * @param options defines the options used to create the mesh
  34466. * @param scene defines the hosting scene
  34467. * @returns the plane polygonal mesh
  34468. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34469. */
  34470. static CreateDisc(name: string, options: {
  34471. radius?: number;
  34472. tessellation?: number;
  34473. arc?: number;
  34474. updatable?: boolean;
  34475. sideOrientation?: number;
  34476. frontUVs?: Vector4;
  34477. backUVs?: Vector4;
  34478. }, scene?: Nullable<Scene>): Mesh;
  34479. }
  34480. }
  34481. declare module BABYLON {
  34482. /**
  34483. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34484. *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.
  34485. * The SPS is also a particle system. It provides some methods to manage the particles.
  34486. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34487. *
  34488. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34489. */
  34490. export class SolidParticleSystem implements IDisposable {
  34491. /**
  34492. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34493. * Example : var p = SPS.particles[i];
  34494. */
  34495. particles: SolidParticle[];
  34496. /**
  34497. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34498. */
  34499. nbParticles: number;
  34500. /**
  34501. * If the particles must ever face the camera (default false). Useful for planar particles.
  34502. */
  34503. billboard: boolean;
  34504. /**
  34505. * Recompute normals when adding a shape
  34506. */
  34507. recomputeNormals: boolean;
  34508. /**
  34509. * This a counter ofr your own usage. It's not set by any SPS functions.
  34510. */
  34511. counter: number;
  34512. /**
  34513. * The SPS name. This name is also given to the underlying mesh.
  34514. */
  34515. name: string;
  34516. /**
  34517. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34518. */
  34519. mesh: Mesh;
  34520. /**
  34521. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34522. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34523. */
  34524. vars: any;
  34525. /**
  34526. * This array is populated when the SPS is set as 'pickable'.
  34527. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34528. * Each element of this array is an object `{idx: int, faceId: int}`.
  34529. * `idx` is the picked particle index in the `SPS.particles` array
  34530. * `faceId` is the picked face index counted within this particle.
  34531. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34532. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34533. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34534. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34535. */
  34536. pickedParticles: {
  34537. idx: number;
  34538. faceId: number;
  34539. }[];
  34540. /**
  34541. * This array is populated when the SPS is set as 'pickable'
  34542. * Each key of this array is a submesh index.
  34543. * Each element of this array is a second array defined like this :
  34544. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34545. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34546. * `idx` is the picked particle index in the `SPS.particles` array
  34547. * `faceId` is the picked face index counted within this particle.
  34548. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34549. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34550. */
  34551. pickedBySubMesh: {
  34552. idx: number;
  34553. faceId: number;
  34554. }[][];
  34555. /**
  34556. * This array is populated when `enableDepthSort` is set to true.
  34557. * Each element of this array is an instance of the class DepthSortedParticle.
  34558. */
  34559. depthSortedParticles: DepthSortedParticle[];
  34560. /**
  34561. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34562. * @hidden
  34563. */
  34564. _bSphereOnly: boolean;
  34565. /**
  34566. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34567. * @hidden
  34568. */
  34569. _bSphereRadiusFactor: number;
  34570. private _scene;
  34571. private _positions;
  34572. private _indices;
  34573. private _normals;
  34574. private _colors;
  34575. private _uvs;
  34576. private _indices32;
  34577. private _positions32;
  34578. private _normals32;
  34579. private _fixedNormal32;
  34580. private _colors32;
  34581. private _uvs32;
  34582. private _index;
  34583. private _updatable;
  34584. private _pickable;
  34585. private _isVisibilityBoxLocked;
  34586. private _alwaysVisible;
  34587. private _depthSort;
  34588. private _expandable;
  34589. private _shapeCounter;
  34590. private _copy;
  34591. private _color;
  34592. private _computeParticleColor;
  34593. private _computeParticleTexture;
  34594. private _computeParticleRotation;
  34595. private _computeParticleVertex;
  34596. private _computeBoundingBox;
  34597. private _depthSortParticles;
  34598. private _camera;
  34599. private _mustUnrotateFixedNormals;
  34600. private _particlesIntersect;
  34601. private _needs32Bits;
  34602. private _isNotBuilt;
  34603. private _lastParticleId;
  34604. private _idxOfId;
  34605. private _multimaterialEnabled;
  34606. private _useModelMaterial;
  34607. private _indicesByMaterial;
  34608. private _materialIndexes;
  34609. private _depthSortFunction;
  34610. private _materialSortFunction;
  34611. private _materials;
  34612. private _multimaterial;
  34613. private _materialIndexesById;
  34614. private _defaultMaterial;
  34615. private _autoUpdateSubMeshes;
  34616. private _tmpVertex;
  34617. /**
  34618. * Creates a SPS (Solid Particle System) object.
  34619. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34620. * @param scene (Scene) is the scene in which the SPS is added.
  34621. * @param options defines the options of the sps e.g.
  34622. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34623. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34624. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34625. * * 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.
  34626. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34627. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34628. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34629. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34630. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34631. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34632. */
  34633. constructor(name: string, scene: Scene, options?: {
  34634. updatable?: boolean;
  34635. isPickable?: boolean;
  34636. enableDepthSort?: boolean;
  34637. particleIntersection?: boolean;
  34638. boundingSphereOnly?: boolean;
  34639. bSphereRadiusFactor?: number;
  34640. expandable?: boolean;
  34641. useModelMaterial?: boolean;
  34642. enableMultiMaterial?: boolean;
  34643. });
  34644. /**
  34645. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34646. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34647. * @returns the created mesh
  34648. */
  34649. buildMesh(): Mesh;
  34650. /**
  34651. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34652. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34653. * Thus the particles generated from `digest()` have their property `position` set yet.
  34654. * @param mesh ( Mesh ) is the mesh to be digested
  34655. * @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
  34656. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34657. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34658. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34659. * @returns the current SPS
  34660. */
  34661. digest(mesh: Mesh, options?: {
  34662. facetNb?: number;
  34663. number?: number;
  34664. delta?: number;
  34665. storage?: [];
  34666. }): SolidParticleSystem;
  34667. /**
  34668. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34669. * @hidden
  34670. */
  34671. private _unrotateFixedNormals;
  34672. /**
  34673. * Resets the temporary working copy particle
  34674. * @hidden
  34675. */
  34676. private _resetCopy;
  34677. /**
  34678. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34679. * @param p the current index in the positions array to be updated
  34680. * @param ind the current index in the indices array
  34681. * @param shape a Vector3 array, the shape geometry
  34682. * @param positions the positions array to be updated
  34683. * @param meshInd the shape indices array
  34684. * @param indices the indices array to be updated
  34685. * @param meshUV the shape uv array
  34686. * @param uvs the uv array to be updated
  34687. * @param meshCol the shape color array
  34688. * @param colors the color array to be updated
  34689. * @param meshNor the shape normals array
  34690. * @param normals the normals array to be updated
  34691. * @param idx the particle index
  34692. * @param idxInShape the particle index in its shape
  34693. * @param options the addShape() method passed options
  34694. * @model the particle model
  34695. * @hidden
  34696. */
  34697. private _meshBuilder;
  34698. /**
  34699. * Returns a shape Vector3 array from positions float array
  34700. * @param positions float array
  34701. * @returns a vector3 array
  34702. * @hidden
  34703. */
  34704. private _posToShape;
  34705. /**
  34706. * Returns a shapeUV array from a float uvs (array deep copy)
  34707. * @param uvs as a float array
  34708. * @returns a shapeUV array
  34709. * @hidden
  34710. */
  34711. private _uvsToShapeUV;
  34712. /**
  34713. * Adds a new particle object in the particles array
  34714. * @param idx particle index in particles array
  34715. * @param id particle id
  34716. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34717. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34718. * @param model particle ModelShape object
  34719. * @param shapeId model shape identifier
  34720. * @param idxInShape index of the particle in the current model
  34721. * @param bInfo model bounding info object
  34722. * @param storage target storage array, if any
  34723. * @hidden
  34724. */
  34725. private _addParticle;
  34726. /**
  34727. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34728. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34729. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34730. * @param nb (positive integer) the number of particles to be created from this model
  34731. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34732. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34733. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34734. * @returns the number of shapes in the system
  34735. */
  34736. addShape(mesh: Mesh, nb: number, options?: {
  34737. positionFunction?: any;
  34738. vertexFunction?: any;
  34739. storage?: [];
  34740. }): number;
  34741. /**
  34742. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34743. * @hidden
  34744. */
  34745. private _rebuildParticle;
  34746. /**
  34747. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34748. * @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.
  34749. * @returns the SPS.
  34750. */
  34751. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34752. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34753. * Returns an array with the removed particles.
  34754. * 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.
  34755. * The SPS can't be empty so at least one particle needs to remain in place.
  34756. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34757. * @param start index of the first particle to remove
  34758. * @param end index of the last particle to remove (included)
  34759. * @returns an array populated with the removed particles
  34760. */
  34761. removeParticles(start: number, end: number): SolidParticle[];
  34762. /**
  34763. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34764. * @param solidParticleArray an array populated with Solid Particles objects
  34765. * @returns the SPS
  34766. */
  34767. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34768. /**
  34769. * Creates a new particle and modifies the SPS mesh geometry :
  34770. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34771. * - calls _addParticle() to populate the particle array
  34772. * factorized code from addShape() and insertParticlesFromArray()
  34773. * @param idx particle index in the particles array
  34774. * @param i particle index in its shape
  34775. * @param modelShape particle ModelShape object
  34776. * @param shape shape vertex array
  34777. * @param meshInd shape indices array
  34778. * @param meshUV shape uv array
  34779. * @param meshCol shape color array
  34780. * @param meshNor shape normals array
  34781. * @param bbInfo shape bounding info
  34782. * @param storage target particle storage
  34783. * @options addShape() passed options
  34784. * @hidden
  34785. */
  34786. private _insertNewParticle;
  34787. /**
  34788. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34789. * This method calls `updateParticle()` for each particle of the SPS.
  34790. * For an animated SPS, it is usually called within the render loop.
  34791. * 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.
  34792. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34793. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34794. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34795. * @returns the SPS.
  34796. */
  34797. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34798. /**
  34799. * Disposes the SPS.
  34800. */
  34801. dispose(): void;
  34802. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34803. * idx is the particle index in the SPS
  34804. * faceId is the picked face index counted within this particle.
  34805. * Returns null if the pickInfo can't identify a picked particle.
  34806. * @param pickingInfo (PickingInfo object)
  34807. * @returns {idx: number, faceId: number} or null
  34808. */
  34809. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34810. idx: number;
  34811. faceId: number;
  34812. }>;
  34813. /**
  34814. * Returns a SolidParticle object from its identifier : particle.id
  34815. * @param id (integer) the particle Id
  34816. * @returns the searched particle or null if not found in the SPS.
  34817. */
  34818. getParticleById(id: number): Nullable<SolidParticle>;
  34819. /**
  34820. * Returns a new array populated with the particles having the passed shapeId.
  34821. * @param shapeId (integer) the shape identifier
  34822. * @returns a new solid particle array
  34823. */
  34824. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34825. /**
  34826. * Populates the passed array "ref" with the particles having the passed shapeId.
  34827. * @param shapeId the shape identifier
  34828. * @returns the SPS
  34829. * @param ref
  34830. */
  34831. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34832. /**
  34833. * Computes the required SubMeshes according the materials assigned to the particles.
  34834. * @returns the solid particle system.
  34835. * Does nothing if called before the SPS mesh is built.
  34836. */
  34837. computeSubMeshes(): SolidParticleSystem;
  34838. /**
  34839. * Sorts the solid particles by material when MultiMaterial is enabled.
  34840. * Updates the indices32 array.
  34841. * Updates the indicesByMaterial array.
  34842. * Updates the mesh indices array.
  34843. * @returns the SPS
  34844. * @hidden
  34845. */
  34846. private _sortParticlesByMaterial;
  34847. /**
  34848. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34849. * @hidden
  34850. */
  34851. private _setMaterialIndexesById;
  34852. /**
  34853. * Returns an array with unique values of Materials from the passed array
  34854. * @param array the material array to be checked and filtered
  34855. * @hidden
  34856. */
  34857. private _filterUniqueMaterialId;
  34858. /**
  34859. * Sets a new Standard Material as _defaultMaterial if not already set.
  34860. * @hidden
  34861. */
  34862. private _setDefaultMaterial;
  34863. /**
  34864. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34865. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34866. * @returns the SPS.
  34867. */
  34868. refreshVisibleSize(): SolidParticleSystem;
  34869. /**
  34870. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34871. * @param size the size (float) of the visibility box
  34872. * note : this doesn't lock the SPS mesh bounding box.
  34873. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34874. */
  34875. setVisibilityBox(size: number): void;
  34876. /**
  34877. * Gets whether the SPS as always visible or not
  34878. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34879. */
  34880. get isAlwaysVisible(): boolean;
  34881. /**
  34882. * Sets the SPS as always visible or not
  34883. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34884. */
  34885. set isAlwaysVisible(val: boolean);
  34886. /**
  34887. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34888. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34889. */
  34890. set isVisibilityBoxLocked(val: boolean);
  34891. /**
  34892. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34893. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34894. */
  34895. get isVisibilityBoxLocked(): boolean;
  34896. /**
  34897. * Tells to `setParticles()` to compute the particle rotations or not.
  34898. * Default value : true. The SPS is faster when it's set to false.
  34899. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34900. */
  34901. set computeParticleRotation(val: boolean);
  34902. /**
  34903. * Tells to `setParticles()` to compute the particle colors or not.
  34904. * Default value : true. The SPS is faster when it's set to false.
  34905. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34906. */
  34907. set computeParticleColor(val: boolean);
  34908. set computeParticleTexture(val: boolean);
  34909. /**
  34910. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34911. * Default value : false. The SPS is faster when it's set to false.
  34912. * Note : the particle custom vertex positions aren't stored values.
  34913. */
  34914. set computeParticleVertex(val: boolean);
  34915. /**
  34916. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34917. */
  34918. set computeBoundingBox(val: boolean);
  34919. /**
  34920. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34921. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34922. * Default : `true`
  34923. */
  34924. set depthSortParticles(val: boolean);
  34925. /**
  34926. * Gets if `setParticles()` computes the particle rotations or not.
  34927. * Default value : true. The SPS is faster when it's set to false.
  34928. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34929. */
  34930. get computeParticleRotation(): boolean;
  34931. /**
  34932. * Gets if `setParticles()` computes the particle colors or not.
  34933. * Default value : true. The SPS is faster when it's set to false.
  34934. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34935. */
  34936. get computeParticleColor(): boolean;
  34937. /**
  34938. * Gets if `setParticles()` computes the particle textures or not.
  34939. * Default value : true. The SPS is faster when it's set to false.
  34940. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34941. */
  34942. get computeParticleTexture(): boolean;
  34943. /**
  34944. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34945. * Default value : false. The SPS is faster when it's set to false.
  34946. * Note : the particle custom vertex positions aren't stored values.
  34947. */
  34948. get computeParticleVertex(): boolean;
  34949. /**
  34950. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34951. */
  34952. get computeBoundingBox(): boolean;
  34953. /**
  34954. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34955. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34956. * Default : `true`
  34957. */
  34958. get depthSortParticles(): boolean;
  34959. /**
  34960. * Gets if the SPS is created as expandable at construction time.
  34961. * Default : `false`
  34962. */
  34963. get expandable(): boolean;
  34964. /**
  34965. * Gets if the SPS supports the Multi Materials
  34966. */
  34967. get multimaterialEnabled(): boolean;
  34968. /**
  34969. * Gets if the SPS uses the model materials for its own multimaterial.
  34970. */
  34971. get useModelMaterial(): boolean;
  34972. /**
  34973. * The SPS used material array.
  34974. */
  34975. get materials(): Material[];
  34976. /**
  34977. * Sets the SPS MultiMaterial from the passed materials.
  34978. * Note : the passed array is internally copied and not used then by reference.
  34979. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34980. */
  34981. setMultiMaterial(materials: Material[]): void;
  34982. /**
  34983. * The SPS computed multimaterial object
  34984. */
  34985. get multimaterial(): MultiMaterial;
  34986. set multimaterial(mm: MultiMaterial);
  34987. /**
  34988. * If the subMeshes must be updated on the next call to setParticles()
  34989. */
  34990. get autoUpdateSubMeshes(): boolean;
  34991. set autoUpdateSubMeshes(val: boolean);
  34992. /**
  34993. * This function does nothing. It may be overwritten to set all the particle first values.
  34994. * The SPS doesn't call this function, you may have to call it by your own.
  34995. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34996. */
  34997. initParticles(): void;
  34998. /**
  34999. * This function does nothing. It may be overwritten to recycle a particle.
  35000. * The SPS doesn't call this function, you may have to call it by your own.
  35001. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35002. * @param particle The particle to recycle
  35003. * @returns the recycled particle
  35004. */
  35005. recycleParticle(particle: SolidParticle): SolidParticle;
  35006. /**
  35007. * Updates a particle : this function should be overwritten by the user.
  35008. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35009. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35010. * @example : just set a particle position or velocity and recycle conditions
  35011. * @param particle The particle to update
  35012. * @returns the updated particle
  35013. */
  35014. updateParticle(particle: SolidParticle): SolidParticle;
  35015. /**
  35016. * Updates a vertex of a particle : it can be overwritten by the user.
  35017. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35018. * @param particle the current particle
  35019. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35020. * @param pt the index of the current vertex in the particle shape
  35021. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35022. * @example : just set a vertex particle position or color
  35023. * @returns the sps
  35024. */
  35025. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35026. /**
  35027. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35028. * This does nothing and may be overwritten by the user.
  35029. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35030. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35031. * @param update the boolean update value actually passed to setParticles()
  35032. */
  35033. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35034. /**
  35035. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35036. * This will be passed three parameters.
  35037. * This does nothing and may be overwritten by the user.
  35038. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35039. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35040. * @param update the boolean update value actually passed to setParticles()
  35041. */
  35042. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35043. }
  35044. }
  35045. declare module BABYLON {
  35046. /**
  35047. * Represents one particle of a solid particle system.
  35048. */
  35049. export class SolidParticle {
  35050. /**
  35051. * particle global index
  35052. */
  35053. idx: number;
  35054. /**
  35055. * particle identifier
  35056. */
  35057. id: number;
  35058. /**
  35059. * The color of the particle
  35060. */
  35061. color: Nullable<Color4>;
  35062. /**
  35063. * The world space position of the particle.
  35064. */
  35065. position: Vector3;
  35066. /**
  35067. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35068. */
  35069. rotation: Vector3;
  35070. /**
  35071. * The world space rotation quaternion of the particle.
  35072. */
  35073. rotationQuaternion: Nullable<Quaternion>;
  35074. /**
  35075. * The scaling of the particle.
  35076. */
  35077. scaling: Vector3;
  35078. /**
  35079. * The uvs of the particle.
  35080. */
  35081. uvs: Vector4;
  35082. /**
  35083. * The current speed of the particle.
  35084. */
  35085. velocity: Vector3;
  35086. /**
  35087. * The pivot point in the particle local space.
  35088. */
  35089. pivot: Vector3;
  35090. /**
  35091. * Must the particle be translated from its pivot point in its local space ?
  35092. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35093. * Default : false
  35094. */
  35095. translateFromPivot: boolean;
  35096. /**
  35097. * Is the particle active or not ?
  35098. */
  35099. alive: boolean;
  35100. /**
  35101. * Is the particle visible or not ?
  35102. */
  35103. isVisible: boolean;
  35104. /**
  35105. * Index of this particle in the global "positions" array (Internal use)
  35106. * @hidden
  35107. */
  35108. _pos: number;
  35109. /**
  35110. * @hidden Index of this particle in the global "indices" array (Internal use)
  35111. */
  35112. _ind: number;
  35113. /**
  35114. * @hidden ModelShape of this particle (Internal use)
  35115. */
  35116. _model: ModelShape;
  35117. /**
  35118. * ModelShape id of this particle
  35119. */
  35120. shapeId: number;
  35121. /**
  35122. * Index of the particle in its shape id
  35123. */
  35124. idxInShape: number;
  35125. /**
  35126. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35127. */
  35128. _modelBoundingInfo: BoundingInfo;
  35129. /**
  35130. * @hidden Particle BoundingInfo object (Internal use)
  35131. */
  35132. _boundingInfo: BoundingInfo;
  35133. /**
  35134. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35135. */
  35136. _sps: SolidParticleSystem;
  35137. /**
  35138. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35139. */
  35140. _stillInvisible: boolean;
  35141. /**
  35142. * @hidden Last computed particle rotation matrix
  35143. */
  35144. _rotationMatrix: number[];
  35145. /**
  35146. * Parent particle Id, if any.
  35147. * Default null.
  35148. */
  35149. parentId: Nullable<number>;
  35150. /**
  35151. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35152. */
  35153. materialIndex: Nullable<number>;
  35154. /**
  35155. * Custom object or properties.
  35156. */
  35157. props: Nullable<any>;
  35158. /**
  35159. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35160. * The possible values are :
  35161. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35162. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35163. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35164. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35165. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35166. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35167. * */
  35168. cullingStrategy: number;
  35169. /**
  35170. * @hidden Internal global position in the SPS.
  35171. */
  35172. _globalPosition: Vector3;
  35173. /**
  35174. * Creates a Solid Particle object.
  35175. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35176. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35177. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35178. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35179. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35180. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35181. * @param shapeId (integer) is the model shape identifier in the SPS.
  35182. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35183. * @param sps defines the sps it is associated to
  35184. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35185. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35186. */
  35187. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35188. /**
  35189. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35190. * @param target the particle target
  35191. * @returns the current particle
  35192. */
  35193. copyToRef(target: SolidParticle): SolidParticle;
  35194. /**
  35195. * Legacy support, changed scale to scaling
  35196. */
  35197. get scale(): Vector3;
  35198. /**
  35199. * Legacy support, changed scale to scaling
  35200. */
  35201. set scale(scale: Vector3);
  35202. /**
  35203. * Legacy support, changed quaternion to rotationQuaternion
  35204. */
  35205. get quaternion(): Nullable<Quaternion>;
  35206. /**
  35207. * Legacy support, changed quaternion to rotationQuaternion
  35208. */
  35209. set quaternion(q: Nullable<Quaternion>);
  35210. /**
  35211. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35212. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35213. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35214. * @returns true if it intersects
  35215. */
  35216. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35217. /**
  35218. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35219. * A particle is in the frustum if its bounding box intersects the frustum
  35220. * @param frustumPlanes defines the frustum to test
  35221. * @returns true if the particle is in the frustum planes
  35222. */
  35223. isInFrustum(frustumPlanes: Plane[]): boolean;
  35224. /**
  35225. * get the rotation matrix of the particle
  35226. * @hidden
  35227. */
  35228. getRotationMatrix(m: Matrix): void;
  35229. }
  35230. /**
  35231. * Represents the shape of the model used by one particle of a solid particle system.
  35232. * SPS internal tool, don't use it manually.
  35233. */
  35234. export class ModelShape {
  35235. /**
  35236. * The shape id
  35237. * @hidden
  35238. */
  35239. shapeID: number;
  35240. /**
  35241. * flat array of model positions (internal use)
  35242. * @hidden
  35243. */
  35244. _shape: Vector3[];
  35245. /**
  35246. * flat array of model UVs (internal use)
  35247. * @hidden
  35248. */
  35249. _shapeUV: number[];
  35250. /**
  35251. * color array of the model
  35252. * @hidden
  35253. */
  35254. _shapeColors: number[];
  35255. /**
  35256. * indices array of the model
  35257. * @hidden
  35258. */
  35259. _indices: number[];
  35260. /**
  35261. * normals array of the model
  35262. * @hidden
  35263. */
  35264. _normals: number[];
  35265. /**
  35266. * length of the shape in the model indices array (internal use)
  35267. * @hidden
  35268. */
  35269. _indicesLength: number;
  35270. /**
  35271. * Custom position function (internal use)
  35272. * @hidden
  35273. */
  35274. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  35275. /**
  35276. * Custom vertex function (internal use)
  35277. * @hidden
  35278. */
  35279. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35280. /**
  35281. * Model material (internal use)
  35282. * @hidden
  35283. */
  35284. _material: Nullable<Material>;
  35285. /**
  35286. * 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.
  35287. * SPS internal tool, don't use it manually.
  35288. * @hidden
  35289. */
  35290. 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>);
  35291. }
  35292. /**
  35293. * Represents a Depth Sorted Particle in the solid particle system.
  35294. * @hidden
  35295. */
  35296. export class DepthSortedParticle {
  35297. /**
  35298. * Particle index
  35299. */
  35300. idx: number;
  35301. /**
  35302. * Index of the particle in the "indices" array
  35303. */
  35304. ind: number;
  35305. /**
  35306. * Length of the particle shape in the "indices" array
  35307. */
  35308. indicesLength: number;
  35309. /**
  35310. * Squared distance from the particle to the camera
  35311. */
  35312. sqDistance: number;
  35313. /**
  35314. * Material index when used with MultiMaterials
  35315. */
  35316. materialIndex: number;
  35317. /**
  35318. * Creates a new sorted particle
  35319. * @param materialIndex
  35320. */
  35321. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35322. }
  35323. /**
  35324. * Represents a solid particle vertex
  35325. */
  35326. export class SolidParticleVertex {
  35327. /**
  35328. * Vertex position
  35329. */
  35330. position: Vector3;
  35331. /**
  35332. * Vertex color
  35333. */
  35334. color: Color4;
  35335. /**
  35336. * Vertex UV
  35337. */
  35338. uv: Vector2;
  35339. /**
  35340. * Creates a new solid particle vertex
  35341. */
  35342. constructor();
  35343. /** Vertex x coordinate */
  35344. get x(): number;
  35345. set x(val: number);
  35346. /** Vertex y coordinate */
  35347. get y(): number;
  35348. set y(val: number);
  35349. /** Vertex z coordinate */
  35350. get z(): number;
  35351. set z(val: number);
  35352. }
  35353. }
  35354. declare module BABYLON {
  35355. /**
  35356. * @hidden
  35357. */
  35358. export class _MeshCollisionData {
  35359. _checkCollisions: boolean;
  35360. _collisionMask: number;
  35361. _collisionGroup: number;
  35362. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35363. _collider: Nullable<Collider>;
  35364. _oldPositionForCollisions: Vector3;
  35365. _diffPositionForCollisions: Vector3;
  35366. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35367. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35368. _collisionResponse: boolean;
  35369. }
  35370. }
  35371. declare module BABYLON {
  35372. /** @hidden */
  35373. class _FacetDataStorage {
  35374. facetPositions: Vector3[];
  35375. facetNormals: Vector3[];
  35376. facetPartitioning: number[][];
  35377. facetNb: number;
  35378. partitioningSubdivisions: number;
  35379. partitioningBBoxRatio: number;
  35380. facetDataEnabled: boolean;
  35381. facetParameters: any;
  35382. bbSize: Vector3;
  35383. subDiv: {
  35384. max: number;
  35385. X: number;
  35386. Y: number;
  35387. Z: number;
  35388. };
  35389. facetDepthSort: boolean;
  35390. facetDepthSortEnabled: boolean;
  35391. depthSortedIndices: IndicesArray;
  35392. depthSortedFacets: {
  35393. ind: number;
  35394. sqDistance: number;
  35395. }[];
  35396. facetDepthSortFunction: (f1: {
  35397. ind: number;
  35398. sqDistance: number;
  35399. }, f2: {
  35400. ind: number;
  35401. sqDistance: number;
  35402. }) => number;
  35403. facetDepthSortFrom: Vector3;
  35404. facetDepthSortOrigin: Vector3;
  35405. invertedMatrix: Matrix;
  35406. }
  35407. /**
  35408. * @hidden
  35409. **/
  35410. class _InternalAbstractMeshDataInfo {
  35411. _hasVertexAlpha: boolean;
  35412. _useVertexColors: boolean;
  35413. _numBoneInfluencers: number;
  35414. _applyFog: boolean;
  35415. _receiveShadows: boolean;
  35416. _facetData: _FacetDataStorage;
  35417. _visibility: number;
  35418. _skeleton: Nullable<Skeleton>;
  35419. _layerMask: number;
  35420. _computeBonesUsingShaders: boolean;
  35421. _isActive: boolean;
  35422. _onlyForInstances: boolean;
  35423. _isActiveIntermediate: boolean;
  35424. _onlyForInstancesIntermediate: boolean;
  35425. _actAsRegularMesh: boolean;
  35426. _currentLOD: Nullable<AbstractMesh>;
  35427. }
  35428. /**
  35429. * Class used to store all common mesh properties
  35430. */
  35431. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35432. /** No occlusion */
  35433. static OCCLUSION_TYPE_NONE: number;
  35434. /** Occlusion set to optimisitic */
  35435. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35436. /** Occlusion set to strict */
  35437. static OCCLUSION_TYPE_STRICT: number;
  35438. /** Use an accurante occlusion algorithm */
  35439. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35440. /** Use a conservative occlusion algorithm */
  35441. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35442. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35443. * Test order :
  35444. * Is the bounding sphere outside the frustum ?
  35445. * If not, are the bounding box vertices outside the frustum ?
  35446. * It not, then the cullable object is in the frustum.
  35447. */
  35448. static readonly CULLINGSTRATEGY_STANDARD: number;
  35449. /** Culling strategy : Bounding Sphere Only.
  35450. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35451. * It's also less accurate than the standard because some not visible objects can still be selected.
  35452. * Test : is the bounding sphere outside the frustum ?
  35453. * If not, then the cullable object is in the frustum.
  35454. */
  35455. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35456. /** Culling strategy : Optimistic Inclusion.
  35457. * This in an inclusion test first, then the standard exclusion test.
  35458. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35459. * 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.
  35460. * Anyway, it's as accurate as the standard strategy.
  35461. * Test :
  35462. * Is the cullable object bounding sphere center in the frustum ?
  35463. * If not, apply the default culling strategy.
  35464. */
  35465. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35466. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35467. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35468. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35469. * 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.
  35470. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35471. * Test :
  35472. * Is the cullable object bounding sphere center in the frustum ?
  35473. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35474. */
  35475. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35476. /**
  35477. * No billboard
  35478. */
  35479. static get BILLBOARDMODE_NONE(): number;
  35480. /** Billboard on X axis */
  35481. static get BILLBOARDMODE_X(): number;
  35482. /** Billboard on Y axis */
  35483. static get BILLBOARDMODE_Y(): number;
  35484. /** Billboard on Z axis */
  35485. static get BILLBOARDMODE_Z(): number;
  35486. /** Billboard on all axes */
  35487. static get BILLBOARDMODE_ALL(): number;
  35488. /** Billboard on using position instead of orientation */
  35489. static get BILLBOARDMODE_USE_POSITION(): number;
  35490. /** @hidden */
  35491. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35492. /**
  35493. * The culling strategy to use to check whether the mesh must be rendered or not.
  35494. * This value can be changed at any time and will be used on the next render mesh selection.
  35495. * The possible values are :
  35496. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35497. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35498. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35499. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35500. * Please read each static variable documentation to get details about the culling process.
  35501. * */
  35502. cullingStrategy: number;
  35503. /**
  35504. * Gets the number of facets in the mesh
  35505. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35506. */
  35507. get facetNb(): number;
  35508. /**
  35509. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35510. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35511. */
  35512. get partitioningSubdivisions(): number;
  35513. set partitioningSubdivisions(nb: number);
  35514. /**
  35515. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35516. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35517. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35518. */
  35519. get partitioningBBoxRatio(): number;
  35520. set partitioningBBoxRatio(ratio: number);
  35521. /**
  35522. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35523. * Works only for updatable meshes.
  35524. * Doesn't work with multi-materials
  35525. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35526. */
  35527. get mustDepthSortFacets(): boolean;
  35528. set mustDepthSortFacets(sort: boolean);
  35529. /**
  35530. * The location (Vector3) where the facet depth sort must be computed from.
  35531. * By default, the active camera position.
  35532. * Used only when facet depth sort is enabled
  35533. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35534. */
  35535. get facetDepthSortFrom(): Vector3;
  35536. set facetDepthSortFrom(location: Vector3);
  35537. /**
  35538. * gets a boolean indicating if facetData is enabled
  35539. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35540. */
  35541. get isFacetDataEnabled(): boolean;
  35542. /** @hidden */
  35543. _updateNonUniformScalingState(value: boolean): boolean;
  35544. /**
  35545. * An event triggered when this mesh collides with another one
  35546. */
  35547. onCollideObservable: Observable<AbstractMesh>;
  35548. /** Set a function to call when this mesh collides with another one */
  35549. set onCollide(callback: () => void);
  35550. /**
  35551. * An event triggered when the collision's position changes
  35552. */
  35553. onCollisionPositionChangeObservable: Observable<Vector3>;
  35554. /** Set a function to call when the collision's position changes */
  35555. set onCollisionPositionChange(callback: () => void);
  35556. /**
  35557. * An event triggered when material is changed
  35558. */
  35559. onMaterialChangedObservable: Observable<AbstractMesh>;
  35560. /**
  35561. * Gets or sets the orientation for POV movement & rotation
  35562. */
  35563. definedFacingForward: boolean;
  35564. /** @hidden */
  35565. _occlusionQuery: Nullable<WebGLQuery>;
  35566. /** @hidden */
  35567. _renderingGroup: Nullable<RenderingGroup>;
  35568. /**
  35569. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35570. */
  35571. get visibility(): number;
  35572. /**
  35573. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35574. */
  35575. set visibility(value: number);
  35576. /** Gets or sets the alpha index used to sort transparent meshes
  35577. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35578. */
  35579. alphaIndex: number;
  35580. /**
  35581. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35582. */
  35583. isVisible: boolean;
  35584. /**
  35585. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35586. */
  35587. isPickable: boolean;
  35588. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35589. showSubMeshesBoundingBox: boolean;
  35590. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35591. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35592. */
  35593. isBlocker: boolean;
  35594. /**
  35595. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35596. */
  35597. enablePointerMoveEvents: boolean;
  35598. private _renderingGroupId;
  35599. /**
  35600. * Specifies the rendering group id for this mesh (0 by default)
  35601. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35602. */
  35603. get renderingGroupId(): number;
  35604. set renderingGroupId(value: number);
  35605. private _material;
  35606. /** Gets or sets current material */
  35607. get material(): Nullable<Material>;
  35608. set material(value: Nullable<Material>);
  35609. /**
  35610. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35611. * @see https://doc.babylonjs.com/babylon101/shadows
  35612. */
  35613. get receiveShadows(): boolean;
  35614. set receiveShadows(value: boolean);
  35615. /** Defines color to use when rendering outline */
  35616. outlineColor: Color3;
  35617. /** Define width to use when rendering outline */
  35618. outlineWidth: number;
  35619. /** Defines color to use when rendering overlay */
  35620. overlayColor: Color3;
  35621. /** Defines alpha to use when rendering overlay */
  35622. overlayAlpha: number;
  35623. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35624. get hasVertexAlpha(): boolean;
  35625. set hasVertexAlpha(value: boolean);
  35626. /** 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) */
  35627. get useVertexColors(): boolean;
  35628. set useVertexColors(value: boolean);
  35629. /**
  35630. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35631. */
  35632. get computeBonesUsingShaders(): boolean;
  35633. set computeBonesUsingShaders(value: boolean);
  35634. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35635. get numBoneInfluencers(): number;
  35636. set numBoneInfluencers(value: number);
  35637. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35638. get applyFog(): boolean;
  35639. set applyFog(value: boolean);
  35640. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35641. useOctreeForRenderingSelection: boolean;
  35642. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35643. useOctreeForPicking: boolean;
  35644. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35645. useOctreeForCollisions: boolean;
  35646. /**
  35647. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35648. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35649. */
  35650. get layerMask(): number;
  35651. set layerMask(value: number);
  35652. /**
  35653. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35654. */
  35655. alwaysSelectAsActiveMesh: boolean;
  35656. /**
  35657. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35658. */
  35659. doNotSyncBoundingInfo: boolean;
  35660. /**
  35661. * Gets or sets the current action manager
  35662. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35663. */
  35664. actionManager: Nullable<AbstractActionManager>;
  35665. private _meshCollisionData;
  35666. /**
  35667. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35668. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35669. */
  35670. ellipsoid: Vector3;
  35671. /**
  35672. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35673. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35674. */
  35675. ellipsoidOffset: Vector3;
  35676. /**
  35677. * Gets or sets a collision mask used to mask collisions (default is -1).
  35678. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35679. */
  35680. get collisionMask(): number;
  35681. set collisionMask(mask: number);
  35682. /**
  35683. * Gets or sets a collision response flag (default is true).
  35684. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35685. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35686. * to respond to the collision.
  35687. */
  35688. get collisionResponse(): boolean;
  35689. set collisionResponse(response: boolean);
  35690. /**
  35691. * Gets or sets the current collision group mask (-1 by default).
  35692. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35693. */
  35694. get collisionGroup(): number;
  35695. set collisionGroup(mask: number);
  35696. /**
  35697. * Gets or sets current surrounding meshes (null by default).
  35698. *
  35699. * By default collision detection is tested against every mesh in the scene.
  35700. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35701. * meshes will be tested for the collision.
  35702. *
  35703. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35704. */
  35705. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35706. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35707. /**
  35708. * Defines edge width used when edgesRenderer is enabled
  35709. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35710. */
  35711. edgesWidth: number;
  35712. /**
  35713. * Defines edge color used when edgesRenderer is enabled
  35714. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35715. */
  35716. edgesColor: Color4;
  35717. /** @hidden */
  35718. _edgesRenderer: Nullable<IEdgesRenderer>;
  35719. /** @hidden */
  35720. _masterMesh: Nullable<AbstractMesh>;
  35721. /** @hidden */
  35722. _boundingInfo: Nullable<BoundingInfo>;
  35723. /** @hidden */
  35724. _renderId: number;
  35725. /**
  35726. * Gets or sets the list of subMeshes
  35727. * @see https://doc.babylonjs.com/how_to/multi_materials
  35728. */
  35729. subMeshes: SubMesh[];
  35730. /** @hidden */
  35731. _intersectionsInProgress: AbstractMesh[];
  35732. /** @hidden */
  35733. _unIndexed: boolean;
  35734. /** @hidden */
  35735. _lightSources: Light[];
  35736. /** Gets the list of lights affecting that mesh */
  35737. get lightSources(): Light[];
  35738. /** @hidden */
  35739. get _positions(): Nullable<Vector3[]>;
  35740. /** @hidden */
  35741. _waitingData: {
  35742. lods: Nullable<any>;
  35743. actions: Nullable<any>;
  35744. freezeWorldMatrix: Nullable<boolean>;
  35745. };
  35746. /** @hidden */
  35747. _bonesTransformMatrices: Nullable<Float32Array>;
  35748. /** @hidden */
  35749. _transformMatrixTexture: Nullable<RawTexture>;
  35750. /**
  35751. * Gets or sets a skeleton to apply skining transformations
  35752. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35753. */
  35754. set skeleton(value: Nullable<Skeleton>);
  35755. get skeleton(): Nullable<Skeleton>;
  35756. /**
  35757. * An event triggered when the mesh is rebuilt.
  35758. */
  35759. onRebuildObservable: Observable<AbstractMesh>;
  35760. /**
  35761. * Creates a new AbstractMesh
  35762. * @param name defines the name of the mesh
  35763. * @param scene defines the hosting scene
  35764. */
  35765. constructor(name: string, scene?: Nullable<Scene>);
  35766. /**
  35767. * Returns the string "AbstractMesh"
  35768. * @returns "AbstractMesh"
  35769. */
  35770. getClassName(): string;
  35771. /**
  35772. * Gets a string representation of the current mesh
  35773. * @param fullDetails defines a boolean indicating if full details must be included
  35774. * @returns a string representation of the current mesh
  35775. */
  35776. toString(fullDetails?: boolean): string;
  35777. /**
  35778. * @hidden
  35779. */
  35780. protected _getEffectiveParent(): Nullable<Node>;
  35781. /** @hidden */
  35782. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35783. /** @hidden */
  35784. _rebuild(): void;
  35785. /** @hidden */
  35786. _resyncLightSources(): void;
  35787. /** @hidden */
  35788. _resyncLightSource(light: Light): void;
  35789. /** @hidden */
  35790. _unBindEffect(): void;
  35791. /** @hidden */
  35792. _removeLightSource(light: Light, dispose: boolean): void;
  35793. private _markSubMeshesAsDirty;
  35794. /** @hidden */
  35795. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35796. /** @hidden */
  35797. _markSubMeshesAsAttributesDirty(): void;
  35798. /** @hidden */
  35799. _markSubMeshesAsMiscDirty(): void;
  35800. /**
  35801. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35802. */
  35803. get scaling(): Vector3;
  35804. set scaling(newScaling: Vector3);
  35805. /**
  35806. * Returns true if the mesh is blocked. Implemented by child classes
  35807. */
  35808. get isBlocked(): boolean;
  35809. /**
  35810. * Returns the mesh itself by default. Implemented by child classes
  35811. * @param camera defines the camera to use to pick the right LOD level
  35812. * @returns the currentAbstractMesh
  35813. */
  35814. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35815. /**
  35816. * Returns 0 by default. Implemented by child classes
  35817. * @returns an integer
  35818. */
  35819. getTotalVertices(): number;
  35820. /**
  35821. * Returns a positive integer : the total number of indices in this mesh geometry.
  35822. * @returns the numner of indices or zero if the mesh has no geometry.
  35823. */
  35824. getTotalIndices(): number;
  35825. /**
  35826. * Returns null by default. Implemented by child classes
  35827. * @returns null
  35828. */
  35829. getIndices(): Nullable<IndicesArray>;
  35830. /**
  35831. * Returns the array of the requested vertex data kind. Implemented by child classes
  35832. * @param kind defines the vertex data kind to use
  35833. * @returns null
  35834. */
  35835. getVerticesData(kind: string): Nullable<FloatArray>;
  35836. /**
  35837. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35838. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35839. * Note that a new underlying VertexBuffer object is created each call.
  35840. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35841. * @param kind defines vertex data kind:
  35842. * * VertexBuffer.PositionKind
  35843. * * VertexBuffer.UVKind
  35844. * * VertexBuffer.UV2Kind
  35845. * * VertexBuffer.UV3Kind
  35846. * * VertexBuffer.UV4Kind
  35847. * * VertexBuffer.UV5Kind
  35848. * * VertexBuffer.UV6Kind
  35849. * * VertexBuffer.ColorKind
  35850. * * VertexBuffer.MatricesIndicesKind
  35851. * * VertexBuffer.MatricesIndicesExtraKind
  35852. * * VertexBuffer.MatricesWeightsKind
  35853. * * VertexBuffer.MatricesWeightsExtraKind
  35854. * @param data defines the data source
  35855. * @param updatable defines if the data must be flagged as updatable (or static)
  35856. * @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
  35857. * @returns the current mesh
  35858. */
  35859. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35860. /**
  35861. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35862. * If the mesh has no geometry, it is simply returned as it is.
  35863. * @param kind defines vertex data kind:
  35864. * * VertexBuffer.PositionKind
  35865. * * VertexBuffer.UVKind
  35866. * * VertexBuffer.UV2Kind
  35867. * * VertexBuffer.UV3Kind
  35868. * * VertexBuffer.UV4Kind
  35869. * * VertexBuffer.UV5Kind
  35870. * * VertexBuffer.UV6Kind
  35871. * * VertexBuffer.ColorKind
  35872. * * VertexBuffer.MatricesIndicesKind
  35873. * * VertexBuffer.MatricesIndicesExtraKind
  35874. * * VertexBuffer.MatricesWeightsKind
  35875. * * VertexBuffer.MatricesWeightsExtraKind
  35876. * @param data defines the data source
  35877. * @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
  35878. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35879. * @returns the current mesh
  35880. */
  35881. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35882. /**
  35883. * Sets the mesh indices,
  35884. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35885. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35886. * @param totalVertices Defines the total number of vertices
  35887. * @returns the current mesh
  35888. */
  35889. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35890. /**
  35891. * Gets a boolean indicating if specific vertex data is present
  35892. * @param kind defines the vertex data kind to use
  35893. * @returns true is data kind is present
  35894. */
  35895. isVerticesDataPresent(kind: string): boolean;
  35896. /**
  35897. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35898. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35899. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35900. * @returns a BoundingInfo
  35901. */
  35902. getBoundingInfo(): BoundingInfo;
  35903. /**
  35904. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35905. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35906. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35907. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35908. * @returns the current mesh
  35909. */
  35910. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35911. /**
  35912. * Overwrite the current bounding info
  35913. * @param boundingInfo defines the new bounding info
  35914. * @returns the current mesh
  35915. */
  35916. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35917. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35918. get useBones(): boolean;
  35919. /** @hidden */
  35920. _preActivate(): void;
  35921. /** @hidden */
  35922. _preActivateForIntermediateRendering(renderId: number): void;
  35923. /** @hidden */
  35924. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35925. /** @hidden */
  35926. _postActivate(): void;
  35927. /** @hidden */
  35928. _freeze(): void;
  35929. /** @hidden */
  35930. _unFreeze(): void;
  35931. /**
  35932. * Gets the current world matrix
  35933. * @returns a Matrix
  35934. */
  35935. getWorldMatrix(): Matrix;
  35936. /** @hidden */
  35937. _getWorldMatrixDeterminant(): number;
  35938. /**
  35939. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35940. */
  35941. get isAnInstance(): boolean;
  35942. /**
  35943. * Gets a boolean indicating if this mesh has instances
  35944. */
  35945. get hasInstances(): boolean;
  35946. /**
  35947. * Gets a boolean indicating if this mesh has thin instances
  35948. */
  35949. get hasThinInstances(): boolean;
  35950. /**
  35951. * Perform relative position change from the point of view of behind the front of the mesh.
  35952. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35953. * Supports definition of mesh facing forward or backward
  35954. * @param amountRight defines the distance on the right axis
  35955. * @param amountUp defines the distance on the up axis
  35956. * @param amountForward defines the distance on the forward axis
  35957. * @returns the current mesh
  35958. */
  35959. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35960. /**
  35961. * Calculate relative position change from the point of view of behind the front of the mesh.
  35962. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35963. * Supports definition of mesh facing forward or backward
  35964. * @param amountRight defines the distance on the right axis
  35965. * @param amountUp defines the distance on the up axis
  35966. * @param amountForward defines the distance on the forward axis
  35967. * @returns the new displacement vector
  35968. */
  35969. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35970. /**
  35971. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35972. * Supports definition of mesh facing forward or backward
  35973. * @param flipBack defines the flip
  35974. * @param twirlClockwise defines the twirl
  35975. * @param tiltRight defines the tilt
  35976. * @returns the current mesh
  35977. */
  35978. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35979. /**
  35980. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35981. * Supports definition of mesh facing forward or backward.
  35982. * @param flipBack defines the flip
  35983. * @param twirlClockwise defines the twirl
  35984. * @param tiltRight defines the tilt
  35985. * @returns the new rotation vector
  35986. */
  35987. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35988. /**
  35989. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35990. * This means the mesh underlying bounding box and sphere are recomputed.
  35991. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35992. * @returns the current mesh
  35993. */
  35994. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35995. /** @hidden */
  35996. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35997. /** @hidden */
  35998. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35999. /** @hidden */
  36000. _updateBoundingInfo(): AbstractMesh;
  36001. /** @hidden */
  36002. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36003. /** @hidden */
  36004. protected _afterComputeWorldMatrix(): void;
  36005. /** @hidden */
  36006. get _effectiveMesh(): AbstractMesh;
  36007. /**
  36008. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36009. * A mesh is in the frustum if its bounding box intersects the frustum
  36010. * @param frustumPlanes defines the frustum to test
  36011. * @returns true if the mesh is in the frustum planes
  36012. */
  36013. isInFrustum(frustumPlanes: Plane[]): boolean;
  36014. /**
  36015. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36016. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36017. * @param frustumPlanes defines the frustum to test
  36018. * @returns true if the mesh is completely in the frustum planes
  36019. */
  36020. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36021. /**
  36022. * True if the mesh intersects another mesh or a SolidParticle object
  36023. * @param mesh defines a target mesh or SolidParticle to test
  36024. * @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)
  36025. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36026. * @returns true if there is an intersection
  36027. */
  36028. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36029. /**
  36030. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36031. * @param point defines the point to test
  36032. * @returns true if there is an intersection
  36033. */
  36034. intersectsPoint(point: Vector3): boolean;
  36035. /**
  36036. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36037. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36038. */
  36039. get checkCollisions(): boolean;
  36040. set checkCollisions(collisionEnabled: boolean);
  36041. /**
  36042. * Gets Collider object used to compute collisions (not physics)
  36043. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36044. */
  36045. get collider(): Nullable<Collider>;
  36046. /**
  36047. * Move the mesh using collision engine
  36048. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36049. * @param displacement defines the requested displacement vector
  36050. * @returns the current mesh
  36051. */
  36052. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36053. private _onCollisionPositionChange;
  36054. /** @hidden */
  36055. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36056. /** @hidden */
  36057. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36058. /** @hidden */
  36059. _checkCollision(collider: Collider): AbstractMesh;
  36060. /** @hidden */
  36061. _generatePointsArray(): boolean;
  36062. /**
  36063. * Checks if the passed Ray intersects with the mesh
  36064. * @param ray defines the ray to use
  36065. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36066. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36067. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36068. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36069. * @returns the picking info
  36070. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36071. */
  36072. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  36073. /**
  36074. * Clones the current mesh
  36075. * @param name defines the mesh name
  36076. * @param newParent defines the new mesh parent
  36077. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36078. * @returns the new mesh
  36079. */
  36080. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36081. /**
  36082. * Disposes all the submeshes of the current meshnp
  36083. * @returns the current mesh
  36084. */
  36085. releaseSubMeshes(): AbstractMesh;
  36086. /**
  36087. * Releases resources associated with this abstract mesh.
  36088. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36089. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36090. */
  36091. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36092. /**
  36093. * Adds the passed mesh as a child to the current mesh
  36094. * @param mesh defines the child mesh
  36095. * @returns the current mesh
  36096. */
  36097. addChild(mesh: AbstractMesh): AbstractMesh;
  36098. /**
  36099. * Removes the passed mesh from the current mesh children list
  36100. * @param mesh defines the child mesh
  36101. * @returns the current mesh
  36102. */
  36103. removeChild(mesh: AbstractMesh): AbstractMesh;
  36104. /** @hidden */
  36105. private _initFacetData;
  36106. /**
  36107. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36108. * This method can be called within the render loop.
  36109. * 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
  36110. * @returns the current mesh
  36111. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36112. */
  36113. updateFacetData(): AbstractMesh;
  36114. /**
  36115. * Returns the facetLocalNormals array.
  36116. * The normals are expressed in the mesh local spac
  36117. * @returns an array of Vector3
  36118. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36119. */
  36120. getFacetLocalNormals(): Vector3[];
  36121. /**
  36122. * Returns the facetLocalPositions array.
  36123. * The facet positions are expressed in the mesh local space
  36124. * @returns an array of Vector3
  36125. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36126. */
  36127. getFacetLocalPositions(): Vector3[];
  36128. /**
  36129. * Returns the facetLocalPartioning array
  36130. * @returns an array of array of numbers
  36131. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36132. */
  36133. getFacetLocalPartitioning(): number[][];
  36134. /**
  36135. * Returns the i-th facet position in the world system.
  36136. * This method allocates a new Vector3 per call
  36137. * @param i defines the facet index
  36138. * @returns a new Vector3
  36139. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36140. */
  36141. getFacetPosition(i: number): Vector3;
  36142. /**
  36143. * Sets the reference Vector3 with the i-th facet position in the world system
  36144. * @param i defines the facet index
  36145. * @param ref defines the target vector
  36146. * @returns the current mesh
  36147. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36148. */
  36149. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36150. /**
  36151. * Returns the i-th facet normal in the world system.
  36152. * This method allocates a new Vector3 per call
  36153. * @param i defines the facet index
  36154. * @returns a new Vector3
  36155. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36156. */
  36157. getFacetNormal(i: number): Vector3;
  36158. /**
  36159. * Sets the reference Vector3 with the i-th facet normal in the world system
  36160. * @param i defines the facet index
  36161. * @param ref defines the target vector
  36162. * @returns the current mesh
  36163. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36164. */
  36165. getFacetNormalToRef(i: number, ref: Vector3): this;
  36166. /**
  36167. * 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)
  36168. * @param x defines x coordinate
  36169. * @param y defines y coordinate
  36170. * @param z defines z coordinate
  36171. * @returns the array of facet indexes
  36172. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36173. */
  36174. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36175. /**
  36176. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36177. * @param projected sets as the (x,y,z) world projection on the facet
  36178. * @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
  36179. * @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
  36180. * @param x defines x coordinate
  36181. * @param y defines y coordinate
  36182. * @param z defines z coordinate
  36183. * @returns the face index if found (or null instead)
  36184. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36185. */
  36186. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36187. /**
  36188. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36189. * @param projected sets as the (x,y,z) local projection on the facet
  36190. * @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
  36191. * @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
  36192. * @param x defines x coordinate
  36193. * @param y defines y coordinate
  36194. * @param z defines z coordinate
  36195. * @returns the face index if found (or null instead)
  36196. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36197. */
  36198. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36199. /**
  36200. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36201. * @returns the parameters
  36202. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36203. */
  36204. getFacetDataParameters(): any;
  36205. /**
  36206. * Disables the feature FacetData and frees the related memory
  36207. * @returns the current mesh
  36208. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36209. */
  36210. disableFacetData(): AbstractMesh;
  36211. /**
  36212. * Updates the AbstractMesh indices array
  36213. * @param indices defines the data source
  36214. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36215. * @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)
  36216. * @returns the current mesh
  36217. */
  36218. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36219. /**
  36220. * Creates new normals data for the mesh
  36221. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36222. * @returns the current mesh
  36223. */
  36224. createNormals(updatable: boolean): AbstractMesh;
  36225. /**
  36226. * Align the mesh with a normal
  36227. * @param normal defines the normal to use
  36228. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  36229. * @returns the current mesh
  36230. */
  36231. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  36232. /** @hidden */
  36233. _checkOcclusionQuery(): boolean;
  36234. /**
  36235. * Disables the mesh edge rendering mode
  36236. * @returns the currentAbstractMesh
  36237. */
  36238. disableEdgesRendering(): AbstractMesh;
  36239. /**
  36240. * Enables the edge rendering mode on the mesh.
  36241. * This mode makes the mesh edges visible
  36242. * @param epsilon defines the maximal distance between two angles to detect a face
  36243. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36244. * @returns the currentAbstractMesh
  36245. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36246. */
  36247. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  36248. /**
  36249. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  36250. * @returns an array of particle systems in the scene that use the mesh as an emitter
  36251. */
  36252. getConnectedParticleSystems(): IParticleSystem[];
  36253. }
  36254. }
  36255. declare module BABYLON {
  36256. /**
  36257. * Interface used to define ActionEvent
  36258. */
  36259. export interface IActionEvent {
  36260. /** The mesh or sprite that triggered the action */
  36261. source: any;
  36262. /** The X mouse cursor position at the time of the event */
  36263. pointerX: number;
  36264. /** The Y mouse cursor position at the time of the event */
  36265. pointerY: number;
  36266. /** The mesh that is currently pointed at (can be null) */
  36267. meshUnderPointer: Nullable<AbstractMesh>;
  36268. /** the original (browser) event that triggered the ActionEvent */
  36269. sourceEvent?: any;
  36270. /** additional data for the event */
  36271. additionalData?: any;
  36272. }
  36273. /**
  36274. * ActionEvent is the event being sent when an action is triggered.
  36275. */
  36276. export class ActionEvent implements IActionEvent {
  36277. /** The mesh or sprite that triggered the action */
  36278. source: any;
  36279. /** The X mouse cursor position at the time of the event */
  36280. pointerX: number;
  36281. /** The Y mouse cursor position at the time of the event */
  36282. pointerY: number;
  36283. /** The mesh that is currently pointed at (can be null) */
  36284. meshUnderPointer: Nullable<AbstractMesh>;
  36285. /** the original (browser) event that triggered the ActionEvent */
  36286. sourceEvent?: any;
  36287. /** additional data for the event */
  36288. additionalData?: any;
  36289. /**
  36290. * Creates a new ActionEvent
  36291. * @param source The mesh or sprite that triggered the action
  36292. * @param pointerX The X mouse cursor position at the time of the event
  36293. * @param pointerY The Y mouse cursor position at the time of the event
  36294. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36295. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36296. * @param additionalData additional data for the event
  36297. */
  36298. constructor(
  36299. /** The mesh or sprite that triggered the action */
  36300. source: any,
  36301. /** The X mouse cursor position at the time of the event */
  36302. pointerX: number,
  36303. /** The Y mouse cursor position at the time of the event */
  36304. pointerY: number,
  36305. /** The mesh that is currently pointed at (can be null) */
  36306. meshUnderPointer: Nullable<AbstractMesh>,
  36307. /** the original (browser) event that triggered the ActionEvent */
  36308. sourceEvent?: any,
  36309. /** additional data for the event */
  36310. additionalData?: any);
  36311. /**
  36312. * Helper function to auto-create an ActionEvent from a source mesh.
  36313. * @param source The source mesh that triggered the event
  36314. * @param evt The original (browser) event
  36315. * @param additionalData additional data for the event
  36316. * @returns the new ActionEvent
  36317. */
  36318. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36319. /**
  36320. * Helper function to auto-create an ActionEvent from a source sprite
  36321. * @param source The source sprite that triggered the event
  36322. * @param scene Scene associated with the sprite
  36323. * @param evt The original (browser) event
  36324. * @param additionalData additional data for the event
  36325. * @returns the new ActionEvent
  36326. */
  36327. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36328. /**
  36329. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36330. * @param scene the scene where the event occurred
  36331. * @param evt The original (browser) event
  36332. * @returns the new ActionEvent
  36333. */
  36334. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36335. /**
  36336. * Helper function to auto-create an ActionEvent from a primitive
  36337. * @param prim defines the target primitive
  36338. * @param pointerPos defines the pointer position
  36339. * @param evt The original (browser) event
  36340. * @param additionalData additional data for the event
  36341. * @returns the new ActionEvent
  36342. */
  36343. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36344. }
  36345. }
  36346. declare module BABYLON {
  36347. /**
  36348. * Abstract class used to decouple action Manager from scene and meshes.
  36349. * Do not instantiate.
  36350. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36351. */
  36352. export abstract class AbstractActionManager implements IDisposable {
  36353. /** Gets the list of active triggers */
  36354. static Triggers: {
  36355. [key: string]: number;
  36356. };
  36357. /** Gets the cursor to use when hovering items */
  36358. hoverCursor: string;
  36359. /** Gets the list of actions */
  36360. actions: IAction[];
  36361. /**
  36362. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36363. */
  36364. isRecursive: boolean;
  36365. /**
  36366. * Releases all associated resources
  36367. */
  36368. abstract dispose(): void;
  36369. /**
  36370. * Does this action manager has pointer triggers
  36371. */
  36372. abstract get hasPointerTriggers(): boolean;
  36373. /**
  36374. * Does this action manager has pick triggers
  36375. */
  36376. abstract get hasPickTriggers(): boolean;
  36377. /**
  36378. * Process a specific trigger
  36379. * @param trigger defines the trigger to process
  36380. * @param evt defines the event details to be processed
  36381. */
  36382. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36383. /**
  36384. * Does this action manager handles actions of any of the given triggers
  36385. * @param triggers defines the triggers to be tested
  36386. * @return a boolean indicating whether one (or more) of the triggers is handled
  36387. */
  36388. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36389. /**
  36390. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36391. * speed.
  36392. * @param triggerA defines the trigger to be tested
  36393. * @param triggerB defines the trigger to be tested
  36394. * @return a boolean indicating whether one (or more) of the triggers is handled
  36395. */
  36396. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36397. /**
  36398. * Does this action manager handles actions of a given trigger
  36399. * @param trigger defines the trigger to be tested
  36400. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36401. * @return whether the trigger is handled
  36402. */
  36403. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36404. /**
  36405. * Serialize this manager to a JSON object
  36406. * @param name defines the property name to store this manager
  36407. * @returns a JSON representation of this manager
  36408. */
  36409. abstract serialize(name: string): any;
  36410. /**
  36411. * Registers an action to this action manager
  36412. * @param action defines the action to be registered
  36413. * @return the action amended (prepared) after registration
  36414. */
  36415. abstract registerAction(action: IAction): Nullable<IAction>;
  36416. /**
  36417. * Unregisters an action to this action manager
  36418. * @param action defines the action to be unregistered
  36419. * @return a boolean indicating whether the action has been unregistered
  36420. */
  36421. abstract unregisterAction(action: IAction): Boolean;
  36422. /**
  36423. * Does exist one action manager with at least one trigger
  36424. **/
  36425. static get HasTriggers(): boolean;
  36426. /**
  36427. * Does exist one action manager with at least one pick trigger
  36428. **/
  36429. static get HasPickTriggers(): boolean;
  36430. /**
  36431. * Does exist one action manager that handles actions of a given trigger
  36432. * @param trigger defines the trigger to be tested
  36433. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36434. **/
  36435. static HasSpecificTrigger(trigger: number): boolean;
  36436. }
  36437. }
  36438. declare module BABYLON {
  36439. /**
  36440. * Defines how a node can be built from a string name.
  36441. */
  36442. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36443. /**
  36444. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36445. */
  36446. export class Node implements IBehaviorAware<Node> {
  36447. /** @hidden */
  36448. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36449. private static _NodeConstructors;
  36450. /**
  36451. * Add a new node constructor
  36452. * @param type defines the type name of the node to construct
  36453. * @param constructorFunc defines the constructor function
  36454. */
  36455. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36456. /**
  36457. * Returns a node constructor based on type name
  36458. * @param type defines the type name
  36459. * @param name defines the new node name
  36460. * @param scene defines the hosting scene
  36461. * @param options defines optional options to transmit to constructors
  36462. * @returns the new constructor or null
  36463. */
  36464. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36465. /**
  36466. * Gets or sets the name of the node
  36467. */
  36468. name: string;
  36469. /**
  36470. * Gets or sets the id of the node
  36471. */
  36472. id: string;
  36473. /**
  36474. * Gets or sets the unique id of the node
  36475. */
  36476. uniqueId: number;
  36477. /**
  36478. * Gets or sets a string used to store user defined state for the node
  36479. */
  36480. state: string;
  36481. /**
  36482. * Gets or sets an object used to store user defined information for the node
  36483. */
  36484. metadata: any;
  36485. /**
  36486. * For internal use only. Please do not use.
  36487. */
  36488. reservedDataStore: any;
  36489. /**
  36490. * List of inspectable custom properties (used by the Inspector)
  36491. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36492. */
  36493. inspectableCustomProperties: IInspectable[];
  36494. private _doNotSerialize;
  36495. /**
  36496. * Gets or sets a boolean used to define if the node must be serialized
  36497. */
  36498. get doNotSerialize(): boolean;
  36499. set doNotSerialize(value: boolean);
  36500. /** @hidden */
  36501. _isDisposed: boolean;
  36502. /**
  36503. * Gets a list of Animations associated with the node
  36504. */
  36505. animations: Animation[];
  36506. protected _ranges: {
  36507. [name: string]: Nullable<AnimationRange>;
  36508. };
  36509. /**
  36510. * Callback raised when the node is ready to be used
  36511. */
  36512. onReady: Nullable<(node: Node) => void>;
  36513. private _isEnabled;
  36514. private _isParentEnabled;
  36515. private _isReady;
  36516. /** @hidden */
  36517. _currentRenderId: number;
  36518. private _parentUpdateId;
  36519. /** @hidden */
  36520. _childUpdateId: number;
  36521. /** @hidden */
  36522. _waitingParentId: Nullable<string>;
  36523. /** @hidden */
  36524. _scene: Scene;
  36525. /** @hidden */
  36526. _cache: any;
  36527. private _parentNode;
  36528. private _children;
  36529. /** @hidden */
  36530. _worldMatrix: Matrix;
  36531. /** @hidden */
  36532. _worldMatrixDeterminant: number;
  36533. /** @hidden */
  36534. _worldMatrixDeterminantIsDirty: boolean;
  36535. /** @hidden */
  36536. private _sceneRootNodesIndex;
  36537. /**
  36538. * Gets a boolean indicating if the node has been disposed
  36539. * @returns true if the node was disposed
  36540. */
  36541. isDisposed(): boolean;
  36542. /**
  36543. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36544. * @see https://doc.babylonjs.com/how_to/parenting
  36545. */
  36546. set parent(parent: Nullable<Node>);
  36547. get parent(): Nullable<Node>;
  36548. /** @hidden */
  36549. _addToSceneRootNodes(): void;
  36550. /** @hidden */
  36551. _removeFromSceneRootNodes(): void;
  36552. private _animationPropertiesOverride;
  36553. /**
  36554. * Gets or sets the animation properties override
  36555. */
  36556. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36557. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36558. /**
  36559. * Gets a string identifying the name of the class
  36560. * @returns "Node" string
  36561. */
  36562. getClassName(): string;
  36563. /** @hidden */
  36564. readonly _isNode: boolean;
  36565. /**
  36566. * An event triggered when the mesh is disposed
  36567. */
  36568. onDisposeObservable: Observable<Node>;
  36569. private _onDisposeObserver;
  36570. /**
  36571. * Sets a callback that will be raised when the node will be disposed
  36572. */
  36573. set onDispose(callback: () => void);
  36574. /**
  36575. * Creates a new Node
  36576. * @param name the name and id to be given to this node
  36577. * @param scene the scene this node will be added to
  36578. */
  36579. constructor(name: string, scene?: Nullable<Scene>);
  36580. /**
  36581. * Gets the scene of the node
  36582. * @returns a scene
  36583. */
  36584. getScene(): Scene;
  36585. /**
  36586. * Gets the engine of the node
  36587. * @returns a Engine
  36588. */
  36589. getEngine(): Engine;
  36590. private _behaviors;
  36591. /**
  36592. * Attach a behavior to the node
  36593. * @see https://doc.babylonjs.com/features/behaviour
  36594. * @param behavior defines the behavior to attach
  36595. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36596. * @returns the current Node
  36597. */
  36598. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36599. /**
  36600. * Remove an attached behavior
  36601. * @see https://doc.babylonjs.com/features/behaviour
  36602. * @param behavior defines the behavior to attach
  36603. * @returns the current Node
  36604. */
  36605. removeBehavior(behavior: Behavior<Node>): Node;
  36606. /**
  36607. * Gets the list of attached behaviors
  36608. * @see https://doc.babylonjs.com/features/behaviour
  36609. */
  36610. get behaviors(): Behavior<Node>[];
  36611. /**
  36612. * Gets an attached behavior by name
  36613. * @param name defines the name of the behavior to look for
  36614. * @see https://doc.babylonjs.com/features/behaviour
  36615. * @returns null if behavior was not found else the requested behavior
  36616. */
  36617. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36618. /**
  36619. * Returns the latest update of the World matrix
  36620. * @returns a Matrix
  36621. */
  36622. getWorldMatrix(): Matrix;
  36623. /** @hidden */
  36624. _getWorldMatrixDeterminant(): number;
  36625. /**
  36626. * Returns directly the latest state of the mesh World matrix.
  36627. * A Matrix is returned.
  36628. */
  36629. get worldMatrixFromCache(): Matrix;
  36630. /** @hidden */
  36631. _initCache(): void;
  36632. /** @hidden */
  36633. updateCache(force?: boolean): void;
  36634. /** @hidden */
  36635. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36636. /** @hidden */
  36637. _updateCache(ignoreParentClass?: boolean): void;
  36638. /** @hidden */
  36639. _isSynchronized(): boolean;
  36640. /** @hidden */
  36641. _markSyncedWithParent(): void;
  36642. /** @hidden */
  36643. isSynchronizedWithParent(): boolean;
  36644. /** @hidden */
  36645. isSynchronized(): boolean;
  36646. /**
  36647. * Is this node ready to be used/rendered
  36648. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36649. * @return true if the node is ready
  36650. */
  36651. isReady(completeCheck?: boolean): boolean;
  36652. /**
  36653. * Is this node enabled?
  36654. * 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
  36655. * @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
  36656. * @return whether this node (and its parent) is enabled
  36657. */
  36658. isEnabled(checkAncestors?: boolean): boolean;
  36659. /** @hidden */
  36660. protected _syncParentEnabledState(): void;
  36661. /**
  36662. * Set the enabled state of this node
  36663. * @param value defines the new enabled state
  36664. */
  36665. setEnabled(value: boolean): void;
  36666. /**
  36667. * Is this node a descendant of the given node?
  36668. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36669. * @param ancestor defines the parent node to inspect
  36670. * @returns a boolean indicating if this node is a descendant of the given node
  36671. */
  36672. isDescendantOf(ancestor: Node): boolean;
  36673. /** @hidden */
  36674. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36675. /**
  36676. * Will return all nodes that have this node as ascendant
  36677. * @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
  36678. * @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
  36679. * @return all children nodes of all types
  36680. */
  36681. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36682. /**
  36683. * Get all child-meshes of this node
  36684. * @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)
  36685. * @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
  36686. * @returns an array of AbstractMesh
  36687. */
  36688. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36689. /**
  36690. * Get all direct children of this node
  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. * @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)
  36693. * @returns an array of Node
  36694. */
  36695. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36696. /** @hidden */
  36697. _setReady(state: boolean): void;
  36698. /**
  36699. * Get an animation by name
  36700. * @param name defines the name of the animation to look for
  36701. * @returns null if not found else the requested animation
  36702. */
  36703. getAnimationByName(name: string): Nullable<Animation>;
  36704. /**
  36705. * Creates an animation range for this node
  36706. * @param name defines the name of the range
  36707. * @param from defines the starting key
  36708. * @param to defines the end key
  36709. */
  36710. createAnimationRange(name: string, from: number, to: number): void;
  36711. /**
  36712. * Delete a specific animation range
  36713. * @param name defines the name of the range to delete
  36714. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36715. */
  36716. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36717. /**
  36718. * Get an animation range by name
  36719. * @param name defines the name of the animation range to look for
  36720. * @returns null if not found else the requested animation range
  36721. */
  36722. getAnimationRange(name: string): Nullable<AnimationRange>;
  36723. /**
  36724. * Gets the list of all animation ranges defined on this node
  36725. * @returns an array
  36726. */
  36727. getAnimationRanges(): Nullable<AnimationRange>[];
  36728. /**
  36729. * Will start the animation sequence
  36730. * @param name defines the range frames for animation sequence
  36731. * @param loop defines if the animation should loop (false by default)
  36732. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36733. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36734. * @returns the object created for this animation. If range does not exist, it will return null
  36735. */
  36736. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36737. /**
  36738. * Serialize animation ranges into a JSON compatible object
  36739. * @returns serialization object
  36740. */
  36741. serializeAnimationRanges(): any;
  36742. /**
  36743. * Computes the world matrix of the node
  36744. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36745. * @returns the world matrix
  36746. */
  36747. computeWorldMatrix(force?: boolean): Matrix;
  36748. /**
  36749. * Releases resources associated with this node.
  36750. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36751. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36752. */
  36753. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36754. /**
  36755. * Parse animation range data from a serialization object and store them into a given node
  36756. * @param node defines where to store the animation ranges
  36757. * @param parsedNode defines the serialization object to read data from
  36758. * @param scene defines the hosting scene
  36759. */
  36760. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36761. /**
  36762. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36763. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36764. * @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
  36765. * @returns the new bounding vectors
  36766. */
  36767. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36768. min: Vector3;
  36769. max: Vector3;
  36770. };
  36771. }
  36772. }
  36773. declare module BABYLON {
  36774. /**
  36775. * @hidden
  36776. */
  36777. export class _IAnimationState {
  36778. key: number;
  36779. repeatCount: number;
  36780. workValue?: any;
  36781. loopMode?: number;
  36782. offsetValue?: any;
  36783. highLimitValue?: any;
  36784. }
  36785. /**
  36786. * Class used to store any kind of animation
  36787. */
  36788. export class Animation {
  36789. /**Name of the animation */
  36790. name: string;
  36791. /**Property to animate */
  36792. targetProperty: string;
  36793. /**The frames per second of the animation */
  36794. framePerSecond: number;
  36795. /**The data type of the animation */
  36796. dataType: number;
  36797. /**The loop mode of the animation */
  36798. loopMode?: number | undefined;
  36799. /**Specifies if blending should be enabled */
  36800. enableBlending?: boolean | undefined;
  36801. /**
  36802. * Use matrix interpolation instead of using direct key value when animating matrices
  36803. */
  36804. static AllowMatricesInterpolation: boolean;
  36805. /**
  36806. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36807. */
  36808. static AllowMatrixDecomposeForInterpolation: boolean;
  36809. /** Define the Url to load snippets */
  36810. static SnippetUrl: string;
  36811. /** Snippet ID if the animation was created from the snippet server */
  36812. snippetId: string;
  36813. /**
  36814. * Stores the key frames of the animation
  36815. */
  36816. private _keys;
  36817. /**
  36818. * Stores the easing function of the animation
  36819. */
  36820. private _easingFunction;
  36821. /**
  36822. * @hidden Internal use only
  36823. */
  36824. _runtimeAnimations: RuntimeAnimation[];
  36825. /**
  36826. * The set of event that will be linked to this animation
  36827. */
  36828. private _events;
  36829. /**
  36830. * Stores an array of target property paths
  36831. */
  36832. targetPropertyPath: string[];
  36833. /**
  36834. * Stores the blending speed of the animation
  36835. */
  36836. blendingSpeed: number;
  36837. /**
  36838. * Stores the animation ranges for the animation
  36839. */
  36840. private _ranges;
  36841. /**
  36842. * @hidden Internal use
  36843. */
  36844. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36845. /**
  36846. * Sets up an animation
  36847. * @param property The property to animate
  36848. * @param animationType The animation type to apply
  36849. * @param framePerSecond The frames per second of the animation
  36850. * @param easingFunction The easing function used in the animation
  36851. * @returns The created animation
  36852. */
  36853. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36854. /**
  36855. * Create and start an animation on a node
  36856. * @param name defines the name of the global animation that will be run on all nodes
  36857. * @param node defines the root node where the animation will take place
  36858. * @param targetProperty defines property to animate
  36859. * @param framePerSecond defines the number of frame per second yo use
  36860. * @param totalFrame defines the number of frames in total
  36861. * @param from defines the initial value
  36862. * @param to defines the final value
  36863. * @param loopMode defines which loop mode you want to use (off by default)
  36864. * @param easingFunction defines the easing function to use (linear by default)
  36865. * @param onAnimationEnd defines the callback to call when animation end
  36866. * @returns the animatable created for this animation
  36867. */
  36868. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36869. /**
  36870. * Create and start an animation on a node and its descendants
  36871. * @param name defines the name of the global animation that will be run on all nodes
  36872. * @param node defines the root node where the animation will take place
  36873. * @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
  36874. * @param targetProperty defines property to animate
  36875. * @param framePerSecond defines the number of frame per second to use
  36876. * @param totalFrame defines the number of frames in total
  36877. * @param from defines the initial value
  36878. * @param to defines the final value
  36879. * @param loopMode defines which loop mode you want to use (off by default)
  36880. * @param easingFunction defines the easing function to use (linear by default)
  36881. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36882. * @returns the list of animatables created for all nodes
  36883. * @example https://www.babylonjs-playground.com/#MH0VLI
  36884. */
  36885. 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[]>;
  36886. /**
  36887. * Creates a new animation, merges it with the existing animations and starts it
  36888. * @param name Name of the animation
  36889. * @param node Node which contains the scene that begins the animations
  36890. * @param targetProperty Specifies which property to animate
  36891. * @param framePerSecond The frames per second of the animation
  36892. * @param totalFrame The total number of frames
  36893. * @param from The frame at the beginning of the animation
  36894. * @param to The frame at the end of the animation
  36895. * @param loopMode Specifies the loop mode of the animation
  36896. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36897. * @param onAnimationEnd Callback to run once the animation is complete
  36898. * @returns Nullable animation
  36899. */
  36900. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36901. /**
  36902. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36903. * @param sourceAnimation defines the Animation containing keyframes to convert
  36904. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36905. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36906. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36907. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36908. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36909. */
  36910. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36911. /**
  36912. * Transition property of an host to the target Value
  36913. * @param property The property to transition
  36914. * @param targetValue The target Value of the property
  36915. * @param host The object where the property to animate belongs
  36916. * @param scene Scene used to run the animation
  36917. * @param frameRate Framerate (in frame/s) to use
  36918. * @param transition The transition type we want to use
  36919. * @param duration The duration of the animation, in milliseconds
  36920. * @param onAnimationEnd Callback trigger at the end of the animation
  36921. * @returns Nullable animation
  36922. */
  36923. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36924. /**
  36925. * Return the array of runtime animations currently using this animation
  36926. */
  36927. get runtimeAnimations(): RuntimeAnimation[];
  36928. /**
  36929. * Specifies if any of the runtime animations are currently running
  36930. */
  36931. get hasRunningRuntimeAnimations(): boolean;
  36932. /**
  36933. * Initializes the animation
  36934. * @param name Name of the animation
  36935. * @param targetProperty Property to animate
  36936. * @param framePerSecond The frames per second of the animation
  36937. * @param dataType The data type of the animation
  36938. * @param loopMode The loop mode of the animation
  36939. * @param enableBlending Specifies if blending should be enabled
  36940. */
  36941. constructor(
  36942. /**Name of the animation */
  36943. name: string,
  36944. /**Property to animate */
  36945. targetProperty: string,
  36946. /**The frames per second of the animation */
  36947. framePerSecond: number,
  36948. /**The data type of the animation */
  36949. dataType: number,
  36950. /**The loop mode of the animation */
  36951. loopMode?: number | undefined,
  36952. /**Specifies if blending should be enabled */
  36953. enableBlending?: boolean | undefined);
  36954. /**
  36955. * Converts the animation to a string
  36956. * @param fullDetails support for multiple levels of logging within scene loading
  36957. * @returns String form of the animation
  36958. */
  36959. toString(fullDetails?: boolean): string;
  36960. /**
  36961. * Add an event to this animation
  36962. * @param event Event to add
  36963. */
  36964. addEvent(event: AnimationEvent): void;
  36965. /**
  36966. * Remove all events found at the given frame
  36967. * @param frame The frame to remove events from
  36968. */
  36969. removeEvents(frame: number): void;
  36970. /**
  36971. * Retrieves all the events from the animation
  36972. * @returns Events from the animation
  36973. */
  36974. getEvents(): AnimationEvent[];
  36975. /**
  36976. * Creates an animation range
  36977. * @param name Name of the animation range
  36978. * @param from Starting frame of the animation range
  36979. * @param to Ending frame of the animation
  36980. */
  36981. createRange(name: string, from: number, to: number): void;
  36982. /**
  36983. * Deletes an animation range by name
  36984. * @param name Name of the animation range to delete
  36985. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36986. */
  36987. deleteRange(name: string, deleteFrames?: boolean): void;
  36988. /**
  36989. * Gets the animation range by name, or null if not defined
  36990. * @param name Name of the animation range
  36991. * @returns Nullable animation range
  36992. */
  36993. getRange(name: string): Nullable<AnimationRange>;
  36994. /**
  36995. * Gets the key frames from the animation
  36996. * @returns The key frames of the animation
  36997. */
  36998. getKeys(): Array<IAnimationKey>;
  36999. /**
  37000. * Gets the highest frame rate of the animation
  37001. * @returns Highest frame rate of the animation
  37002. */
  37003. getHighestFrame(): number;
  37004. /**
  37005. * Gets the easing function of the animation
  37006. * @returns Easing function of the animation
  37007. */
  37008. getEasingFunction(): IEasingFunction;
  37009. /**
  37010. * Sets the easing function of the animation
  37011. * @param easingFunction A custom mathematical formula for animation
  37012. */
  37013. setEasingFunction(easingFunction: EasingFunction): void;
  37014. /**
  37015. * Interpolates a scalar linearly
  37016. * @param startValue Start value of the animation curve
  37017. * @param endValue End value of the animation curve
  37018. * @param gradient Scalar amount to interpolate
  37019. * @returns Interpolated scalar value
  37020. */
  37021. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37022. /**
  37023. * Interpolates a scalar cubically
  37024. * @param startValue Start value of the animation curve
  37025. * @param outTangent End tangent of the animation
  37026. * @param endValue End value of the animation curve
  37027. * @param inTangent Start tangent of the animation curve
  37028. * @param gradient Scalar amount to interpolate
  37029. * @returns Interpolated scalar value
  37030. */
  37031. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37032. /**
  37033. * Interpolates a quaternion using a spherical linear interpolation
  37034. * @param startValue Start value of the animation curve
  37035. * @param endValue End value of the animation curve
  37036. * @param gradient Scalar amount to interpolate
  37037. * @returns Interpolated quaternion value
  37038. */
  37039. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37040. /**
  37041. * Interpolates a quaternion cubically
  37042. * @param startValue Start value of the animation curve
  37043. * @param outTangent End tangent of the animation curve
  37044. * @param endValue End value of the animation curve
  37045. * @param inTangent Start tangent of the animation curve
  37046. * @param gradient Scalar amount to interpolate
  37047. * @returns Interpolated quaternion value
  37048. */
  37049. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37050. /**
  37051. * Interpolates a Vector3 linearl
  37052. * @param startValue Start value of the animation curve
  37053. * @param endValue End value of the animation curve
  37054. * @param gradient Scalar amount to interpolate
  37055. * @returns Interpolated scalar value
  37056. */
  37057. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37058. /**
  37059. * Interpolates a Vector3 cubically
  37060. * @param startValue Start value of the animation curve
  37061. * @param outTangent End tangent of the animation
  37062. * @param endValue End value of the animation curve
  37063. * @param inTangent Start tangent of the animation curve
  37064. * @param gradient Scalar amount to interpolate
  37065. * @returns InterpolatedVector3 value
  37066. */
  37067. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37068. /**
  37069. * Interpolates a Vector2 linearly
  37070. * @param startValue Start value of the animation curve
  37071. * @param endValue End value of the animation curve
  37072. * @param gradient Scalar amount to interpolate
  37073. * @returns Interpolated Vector2 value
  37074. */
  37075. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37076. /**
  37077. * Interpolates a Vector2 cubically
  37078. * @param startValue Start value of the animation curve
  37079. * @param outTangent End tangent of the animation
  37080. * @param endValue End value of the animation curve
  37081. * @param inTangent Start tangent of the animation curve
  37082. * @param gradient Scalar amount to interpolate
  37083. * @returns Interpolated Vector2 value
  37084. */
  37085. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37086. /**
  37087. * Interpolates a size linearly
  37088. * @param startValue Start value of the animation curve
  37089. * @param endValue End value of the animation curve
  37090. * @param gradient Scalar amount to interpolate
  37091. * @returns Interpolated Size value
  37092. */
  37093. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37094. /**
  37095. * Interpolates a Color3 linearly
  37096. * @param startValue Start value of the animation curve
  37097. * @param endValue End value of the animation curve
  37098. * @param gradient Scalar amount to interpolate
  37099. * @returns Interpolated Color3 value
  37100. */
  37101. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37102. /**
  37103. * Interpolates a Color4 linearly
  37104. * @param startValue Start value of the animation curve
  37105. * @param endValue End value of the animation curve
  37106. * @param gradient Scalar amount to interpolate
  37107. * @returns Interpolated Color3 value
  37108. */
  37109. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37110. /**
  37111. * @hidden Internal use only
  37112. */
  37113. _getKeyValue(value: any): any;
  37114. /**
  37115. * @hidden Internal use only
  37116. */
  37117. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37118. /**
  37119. * Defines the function to use to interpolate matrices
  37120. * @param startValue defines the start matrix
  37121. * @param endValue defines the end matrix
  37122. * @param gradient defines the gradient between both matrices
  37123. * @param result defines an optional target matrix where to store the interpolation
  37124. * @returns the interpolated matrix
  37125. */
  37126. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37127. /**
  37128. * Makes a copy of the animation
  37129. * @returns Cloned animation
  37130. */
  37131. clone(): Animation;
  37132. /**
  37133. * Sets the key frames of the animation
  37134. * @param values The animation key frames to set
  37135. */
  37136. setKeys(values: Array<IAnimationKey>): void;
  37137. /**
  37138. * Serializes the animation to an object
  37139. * @returns Serialized object
  37140. */
  37141. serialize(): any;
  37142. /**
  37143. * Float animation type
  37144. */
  37145. static readonly ANIMATIONTYPE_FLOAT: number;
  37146. /**
  37147. * Vector3 animation type
  37148. */
  37149. static readonly ANIMATIONTYPE_VECTOR3: number;
  37150. /**
  37151. * Quaternion animation type
  37152. */
  37153. static readonly ANIMATIONTYPE_QUATERNION: number;
  37154. /**
  37155. * Matrix animation type
  37156. */
  37157. static readonly ANIMATIONTYPE_MATRIX: number;
  37158. /**
  37159. * Color3 animation type
  37160. */
  37161. static readonly ANIMATIONTYPE_COLOR3: number;
  37162. /**
  37163. * Color3 animation type
  37164. */
  37165. static readonly ANIMATIONTYPE_COLOR4: number;
  37166. /**
  37167. * Vector2 animation type
  37168. */
  37169. static readonly ANIMATIONTYPE_VECTOR2: number;
  37170. /**
  37171. * Size animation type
  37172. */
  37173. static readonly ANIMATIONTYPE_SIZE: number;
  37174. /**
  37175. * Relative Loop Mode
  37176. */
  37177. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37178. /**
  37179. * Cycle Loop Mode
  37180. */
  37181. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37182. /**
  37183. * Constant Loop Mode
  37184. */
  37185. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37186. /** @hidden */
  37187. static _UniversalLerp(left: any, right: any, amount: number): any;
  37188. /**
  37189. * Parses an animation object and creates an animation
  37190. * @param parsedAnimation Parsed animation object
  37191. * @returns Animation object
  37192. */
  37193. static Parse(parsedAnimation: any): Animation;
  37194. /**
  37195. * Appends the serialized animations from the source animations
  37196. * @param source Source containing the animations
  37197. * @param destination Target to store the animations
  37198. */
  37199. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37200. /**
  37201. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37202. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37203. * @param url defines the url to load from
  37204. * @returns a promise that will resolve to the new animation or an array of animations
  37205. */
  37206. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37207. /**
  37208. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37209. * @param snippetId defines the snippet to load
  37210. * @returns a promise that will resolve to the new animation or a new array of animations
  37211. */
  37212. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37213. }
  37214. }
  37215. declare module BABYLON {
  37216. /**
  37217. * Interface containing an array of animations
  37218. */
  37219. export interface IAnimatable {
  37220. /**
  37221. * Array of animations
  37222. */
  37223. animations: Nullable<Array<Animation>>;
  37224. }
  37225. }
  37226. declare module BABYLON {
  37227. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37228. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37229. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37230. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37231. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37232. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37233. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37234. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37235. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37236. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37237. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37238. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37239. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37240. /**
  37241. * Decorator used to define property that can be serialized as reference to a camera
  37242. * @param sourceName defines the name of the property to decorate
  37243. */
  37244. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37245. /**
  37246. * Class used to help serialization objects
  37247. */
  37248. export class SerializationHelper {
  37249. /** @hidden */
  37250. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  37251. /** @hidden */
  37252. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  37253. /** @hidden */
  37254. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  37255. /** @hidden */
  37256. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  37257. /**
  37258. * Appends the serialized animations from the source animations
  37259. * @param source Source containing the animations
  37260. * @param destination Target to store the animations
  37261. */
  37262. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37263. /**
  37264. * Static function used to serialized a specific entity
  37265. * @param entity defines the entity to serialize
  37266. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37267. * @returns a JSON compatible object representing the serialization of the entity
  37268. */
  37269. static Serialize<T>(entity: T, serializationObject?: any): any;
  37270. /**
  37271. * Creates a new entity from a serialization data object
  37272. * @param creationFunction defines a function used to instanciated the new entity
  37273. * @param source defines the source serialization data
  37274. * @param scene defines the hosting scene
  37275. * @param rootUrl defines the root url for resources
  37276. * @returns a new entity
  37277. */
  37278. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37279. /**
  37280. * Clones an object
  37281. * @param creationFunction defines the function used to instanciate the new object
  37282. * @param source defines the source object
  37283. * @returns the cloned object
  37284. */
  37285. static Clone<T>(creationFunction: () => T, source: T): T;
  37286. /**
  37287. * Instanciates a new object based on a source one (some data will be shared between both object)
  37288. * @param creationFunction defines the function used to instanciate the new object
  37289. * @param source defines the source object
  37290. * @returns the new object
  37291. */
  37292. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37293. }
  37294. }
  37295. declare module BABYLON {
  37296. /**
  37297. * Base class of all the textures in babylon.
  37298. * It groups all the common properties the materials, post process, lights... might need
  37299. * in order to make a correct use of the texture.
  37300. */
  37301. export class BaseTexture implements IAnimatable {
  37302. /**
  37303. * Default anisotropic filtering level for the application.
  37304. * It is set to 4 as a good tradeoff between perf and quality.
  37305. */
  37306. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  37307. /**
  37308. * Gets or sets the unique id of the texture
  37309. */
  37310. uniqueId: number;
  37311. /**
  37312. * Define the name of the texture.
  37313. */
  37314. name: string;
  37315. /**
  37316. * Gets or sets an object used to store user defined information.
  37317. */
  37318. metadata: any;
  37319. /**
  37320. * For internal use only. Please do not use.
  37321. */
  37322. reservedDataStore: any;
  37323. private _hasAlpha;
  37324. /**
  37325. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  37326. */
  37327. set hasAlpha(value: boolean);
  37328. get hasAlpha(): boolean;
  37329. /**
  37330. * Defines if the alpha value should be determined via the rgb values.
  37331. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  37332. */
  37333. getAlphaFromRGB: boolean;
  37334. /**
  37335. * Intensity or strength of the texture.
  37336. * It is commonly used by materials to fine tune the intensity of the texture
  37337. */
  37338. level: number;
  37339. /**
  37340. * Define the UV chanel to use starting from 0 and defaulting to 0.
  37341. * This is part of the texture as textures usually maps to one uv set.
  37342. */
  37343. coordinatesIndex: number;
  37344. protected _coordinatesMode: number;
  37345. /**
  37346. * How a texture is mapped.
  37347. *
  37348. * | Value | Type | Description |
  37349. * | ----- | ----------------------------------- | ----------- |
  37350. * | 0 | EXPLICIT_MODE | |
  37351. * | 1 | SPHERICAL_MODE | |
  37352. * | 2 | PLANAR_MODE | |
  37353. * | 3 | CUBIC_MODE | |
  37354. * | 4 | PROJECTION_MODE | |
  37355. * | 5 | SKYBOX_MODE | |
  37356. * | 6 | INVCUBIC_MODE | |
  37357. * | 7 | EQUIRECTANGULAR_MODE | |
  37358. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  37359. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  37360. */
  37361. set coordinatesMode(value: number);
  37362. get coordinatesMode(): number;
  37363. private _wrapU;
  37364. /**
  37365. * | Value | Type | Description |
  37366. * | ----- | ------------------ | ----------- |
  37367. * | 0 | CLAMP_ADDRESSMODE | |
  37368. * | 1 | WRAP_ADDRESSMODE | |
  37369. * | 2 | MIRROR_ADDRESSMODE | |
  37370. */
  37371. get wrapU(): number;
  37372. set wrapU(value: number);
  37373. private _wrapV;
  37374. /**
  37375. * | Value | Type | Description |
  37376. * | ----- | ------------------ | ----------- |
  37377. * | 0 | CLAMP_ADDRESSMODE | |
  37378. * | 1 | WRAP_ADDRESSMODE | |
  37379. * | 2 | MIRROR_ADDRESSMODE | |
  37380. */
  37381. get wrapV(): number;
  37382. set wrapV(value: number);
  37383. /**
  37384. * | Value | Type | Description |
  37385. * | ----- | ------------------ | ----------- |
  37386. * | 0 | CLAMP_ADDRESSMODE | |
  37387. * | 1 | WRAP_ADDRESSMODE | |
  37388. * | 2 | MIRROR_ADDRESSMODE | |
  37389. */
  37390. wrapR: number;
  37391. /**
  37392. * With compliant hardware and browser (supporting anisotropic filtering)
  37393. * this defines the level of anisotropic filtering in the texture.
  37394. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  37395. */
  37396. anisotropicFilteringLevel: number;
  37397. /**
  37398. * Define if the texture is a cube texture or if false a 2d texture.
  37399. */
  37400. get isCube(): boolean;
  37401. set isCube(value: boolean);
  37402. /**
  37403. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  37404. */
  37405. get is3D(): boolean;
  37406. set is3D(value: boolean);
  37407. /**
  37408. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  37409. */
  37410. get is2DArray(): boolean;
  37411. set is2DArray(value: boolean);
  37412. private _gammaSpace;
  37413. /**
  37414. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  37415. * HDR texture are usually stored in linear space.
  37416. * This only impacts the PBR and Background materials
  37417. */
  37418. get gammaSpace(): boolean;
  37419. set gammaSpace(gamma: boolean);
  37420. /**
  37421. * Gets or sets whether or not the texture contains RGBD data.
  37422. */
  37423. get isRGBD(): boolean;
  37424. set isRGBD(value: boolean);
  37425. /**
  37426. * Is Z inverted in the texture (useful in a cube texture).
  37427. */
  37428. invertZ: boolean;
  37429. /**
  37430. * Are mip maps generated for this texture or not.
  37431. */
  37432. get noMipmap(): boolean;
  37433. /**
  37434. * @hidden
  37435. */
  37436. lodLevelInAlpha: boolean;
  37437. /**
  37438. * With prefiltered texture, defined the offset used during the prefiltering steps.
  37439. */
  37440. get lodGenerationOffset(): number;
  37441. set lodGenerationOffset(value: number);
  37442. /**
  37443. * With prefiltered texture, defined the scale used during the prefiltering steps.
  37444. */
  37445. get lodGenerationScale(): number;
  37446. set lodGenerationScale(value: number);
  37447. /**
  37448. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  37449. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  37450. * average roughness values.
  37451. */
  37452. get linearSpecularLOD(): boolean;
  37453. set linearSpecularLOD(value: boolean);
  37454. /**
  37455. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  37456. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  37457. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  37458. */
  37459. get irradianceTexture(): Nullable<BaseTexture>;
  37460. set irradianceTexture(value: Nullable<BaseTexture>);
  37461. /**
  37462. * Define if the texture is a render target.
  37463. */
  37464. isRenderTarget: boolean;
  37465. /**
  37466. * Define the unique id of the texture in the scene.
  37467. */
  37468. get uid(): string;
  37469. /** @hidden */
  37470. _prefiltered: boolean;
  37471. /**
  37472. * Return a string representation of the texture.
  37473. * @returns the texture as a string
  37474. */
  37475. toString(): string;
  37476. /**
  37477. * Get the class name of the texture.
  37478. * @returns "BaseTexture"
  37479. */
  37480. getClassName(): string;
  37481. /**
  37482. * Define the list of animation attached to the texture.
  37483. */
  37484. animations: Animation[];
  37485. /**
  37486. * An event triggered when the texture is disposed.
  37487. */
  37488. onDisposeObservable: Observable<BaseTexture>;
  37489. private _onDisposeObserver;
  37490. /**
  37491. * Callback triggered when the texture has been disposed.
  37492. * Kept for back compatibility, you can use the onDisposeObservable instead.
  37493. */
  37494. set onDispose(callback: () => void);
  37495. /**
  37496. * Define the current state of the loading sequence when in delayed load mode.
  37497. */
  37498. delayLoadState: number;
  37499. protected _scene: Nullable<Scene>;
  37500. protected _engine: Nullable<ThinEngine>;
  37501. /** @hidden */
  37502. _texture: Nullable<InternalTexture>;
  37503. private _uid;
  37504. /**
  37505. * Define if the texture is preventinga material to render or not.
  37506. * If not and the texture is not ready, the engine will use a default black texture instead.
  37507. */
  37508. get isBlocking(): boolean;
  37509. /**
  37510. * Instantiates a new BaseTexture.
  37511. * Base class of all the textures in babylon.
  37512. * It groups all the common properties the materials, post process, lights... might need
  37513. * in order to make a correct use of the texture.
  37514. * @param sceneOrEngine Define the scene or engine the texture blongs to
  37515. */
  37516. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  37517. /**
  37518. * Get the scene the texture belongs to.
  37519. * @returns the scene or null if undefined
  37520. */
  37521. getScene(): Nullable<Scene>;
  37522. /** @hidden */
  37523. protected _getEngine(): Nullable<ThinEngine>;
  37524. /**
  37525. * Checks if the texture has the same transform matrix than another texture
  37526. * @param texture texture to check against
  37527. * @returns true if the transforms are the same, else false
  37528. */
  37529. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  37530. /**
  37531. * Get the texture transform matrix used to offset tile the texture for istance.
  37532. * @returns the transformation matrix
  37533. */
  37534. getTextureMatrix(): Matrix;
  37535. /**
  37536. * Get the texture reflection matrix used to rotate/transform the reflection.
  37537. * @returns the reflection matrix
  37538. */
  37539. getReflectionTextureMatrix(): Matrix;
  37540. /**
  37541. * Get the underlying lower level texture from Babylon.
  37542. * @returns the insternal texture
  37543. */
  37544. getInternalTexture(): Nullable<InternalTexture>;
  37545. /**
  37546. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  37547. * @returns true if ready or not blocking
  37548. */
  37549. isReadyOrNotBlocking(): boolean;
  37550. /**
  37551. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  37552. * @returns true if fully ready
  37553. */
  37554. isReady(): boolean;
  37555. private _cachedSize;
  37556. /**
  37557. * Get the size of the texture.
  37558. * @returns the texture size.
  37559. */
  37560. getSize(): ISize;
  37561. /**
  37562. * Get the base size of the texture.
  37563. * It can be different from the size if the texture has been resized for POT for instance
  37564. * @returns the base size
  37565. */
  37566. getBaseSize(): ISize;
  37567. /**
  37568. * Update the sampling mode of the texture.
  37569. * Default is Trilinear mode.
  37570. *
  37571. * | Value | Type | Description |
  37572. * | ----- | ------------------ | ----------- |
  37573. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37574. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37575. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37576. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37577. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37578. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37579. * | 7 | NEAREST_LINEAR | |
  37580. * | 8 | NEAREST_NEAREST | |
  37581. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37582. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37583. * | 11 | LINEAR_LINEAR | |
  37584. * | 12 | LINEAR_NEAREST | |
  37585. *
  37586. * > _mag_: magnification filter (close to the viewer)
  37587. * > _min_: minification filter (far from the viewer)
  37588. * > _mip_: filter used between mip map levels
  37589. *@param samplingMode Define the new sampling mode of the texture
  37590. */
  37591. updateSamplingMode(samplingMode: number): void;
  37592. /**
  37593. * Scales the texture if is `canRescale()`
  37594. * @param ratio the resize factor we want to use to rescale
  37595. */
  37596. scale(ratio: number): void;
  37597. /**
  37598. * Get if the texture can rescale.
  37599. */
  37600. get canRescale(): boolean;
  37601. /** @hidden */
  37602. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  37603. /** @hidden */
  37604. _rebuild(): void;
  37605. /**
  37606. * Triggers the load sequence in delayed load mode.
  37607. */
  37608. delayLoad(): void;
  37609. /**
  37610. * Clones the texture.
  37611. * @returns the cloned texture
  37612. */
  37613. clone(): Nullable<BaseTexture>;
  37614. /**
  37615. * Get the texture underlying type (INT, FLOAT...)
  37616. */
  37617. get textureType(): number;
  37618. /**
  37619. * Get the texture underlying format (RGB, RGBA...)
  37620. */
  37621. get textureFormat(): number;
  37622. /**
  37623. * Indicates that textures need to be re-calculated for all materials
  37624. */
  37625. protected _markAllSubMeshesAsTexturesDirty(): void;
  37626. /**
  37627. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  37628. * This will returns an RGBA array buffer containing either in values (0-255) or
  37629. * float values (0-1) depending of the underlying buffer type.
  37630. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  37631. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  37632. * @param buffer defines a user defined buffer to fill with data (can be null)
  37633. * @returns The Array buffer containing the pixels data.
  37634. */
  37635. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  37636. /**
  37637. * Release and destroy the underlying lower level texture aka internalTexture.
  37638. */
  37639. releaseInternalTexture(): void;
  37640. /** @hidden */
  37641. get _lodTextureHigh(): Nullable<BaseTexture>;
  37642. /** @hidden */
  37643. get _lodTextureMid(): Nullable<BaseTexture>;
  37644. /** @hidden */
  37645. get _lodTextureLow(): Nullable<BaseTexture>;
  37646. /**
  37647. * Dispose the texture and release its associated resources.
  37648. */
  37649. dispose(): void;
  37650. /**
  37651. * Serialize the texture into a JSON representation that can be parsed later on.
  37652. * @returns the JSON representation of the texture
  37653. */
  37654. serialize(): any;
  37655. /**
  37656. * Helper function to be called back once a list of texture contains only ready textures.
  37657. * @param textures Define the list of textures to wait for
  37658. * @param callback Define the callback triggered once the entire list will be ready
  37659. */
  37660. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  37661. private static _isScene;
  37662. }
  37663. }
  37664. declare module BABYLON {
  37665. /**
  37666. * Options to be used when creating an effect.
  37667. */
  37668. export interface IEffectCreationOptions {
  37669. /**
  37670. * Atrributes that will be used in the shader.
  37671. */
  37672. attributes: string[];
  37673. /**
  37674. * Uniform varible names that will be set in the shader.
  37675. */
  37676. uniformsNames: string[];
  37677. /**
  37678. * Uniform buffer variable names that will be set in the shader.
  37679. */
  37680. uniformBuffersNames: string[];
  37681. /**
  37682. * Sampler texture variable names that will be set in the shader.
  37683. */
  37684. samplers: string[];
  37685. /**
  37686. * Define statements that will be set in the shader.
  37687. */
  37688. defines: any;
  37689. /**
  37690. * Possible fallbacks for this effect to improve performance when needed.
  37691. */
  37692. fallbacks: Nullable<IEffectFallbacks>;
  37693. /**
  37694. * Callback that will be called when the shader is compiled.
  37695. */
  37696. onCompiled: Nullable<(effect: Effect) => void>;
  37697. /**
  37698. * Callback that will be called if an error occurs during shader compilation.
  37699. */
  37700. onError: Nullable<(effect: Effect, errors: string) => void>;
  37701. /**
  37702. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37703. */
  37704. indexParameters?: any;
  37705. /**
  37706. * Max number of lights that can be used in the shader.
  37707. */
  37708. maxSimultaneousLights?: number;
  37709. /**
  37710. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37711. */
  37712. transformFeedbackVaryings?: Nullable<string[]>;
  37713. /**
  37714. * 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
  37715. */
  37716. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37717. /**
  37718. * Is this effect rendering to several color attachments ?
  37719. */
  37720. multiTarget?: boolean;
  37721. }
  37722. /**
  37723. * Effect containing vertex and fragment shader that can be executed on an object.
  37724. */
  37725. export class Effect implements IDisposable {
  37726. /**
  37727. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37728. */
  37729. static ShadersRepository: string;
  37730. /**
  37731. * Enable logging of the shader code when a compilation error occurs
  37732. */
  37733. static LogShaderCodeOnCompilationError: boolean;
  37734. /**
  37735. * Name of the effect.
  37736. */
  37737. name: any;
  37738. /**
  37739. * String container all the define statements that should be set on the shader.
  37740. */
  37741. defines: string;
  37742. /**
  37743. * Callback that will be called when the shader is compiled.
  37744. */
  37745. onCompiled: Nullable<(effect: Effect) => void>;
  37746. /**
  37747. * Callback that will be called if an error occurs during shader compilation.
  37748. */
  37749. onError: Nullable<(effect: Effect, errors: string) => void>;
  37750. /**
  37751. * Callback that will be called when effect is bound.
  37752. */
  37753. onBind: Nullable<(effect: Effect) => void>;
  37754. /**
  37755. * Unique ID of the effect.
  37756. */
  37757. uniqueId: number;
  37758. /**
  37759. * Observable that will be called when the shader is compiled.
  37760. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  37761. */
  37762. onCompileObservable: Observable<Effect>;
  37763. /**
  37764. * Observable that will be called if an error occurs during shader compilation.
  37765. */
  37766. onErrorObservable: Observable<Effect>;
  37767. /** @hidden */
  37768. _onBindObservable: Nullable<Observable<Effect>>;
  37769. /**
  37770. * @hidden
  37771. * Specifies if the effect was previously ready
  37772. */
  37773. _wasPreviouslyReady: boolean;
  37774. /**
  37775. * Observable that will be called when effect is bound.
  37776. */
  37777. get onBindObservable(): Observable<Effect>;
  37778. /** @hidden */
  37779. _bonesComputationForcedToCPU: boolean;
  37780. /** @hidden */
  37781. _multiTarget: boolean;
  37782. private static _uniqueIdSeed;
  37783. private _engine;
  37784. private _uniformBuffersNames;
  37785. private _uniformBuffersNamesList;
  37786. private _uniformsNames;
  37787. private _samplerList;
  37788. private _samplers;
  37789. private _isReady;
  37790. private _compilationError;
  37791. private _allFallbacksProcessed;
  37792. private _attributesNames;
  37793. private _attributes;
  37794. private _attributeLocationByName;
  37795. private _uniforms;
  37796. /**
  37797. * Key for the effect.
  37798. * @hidden
  37799. */
  37800. _key: string;
  37801. private _indexParameters;
  37802. private _fallbacks;
  37803. private _vertexSourceCode;
  37804. private _fragmentSourceCode;
  37805. private _vertexSourceCodeOverride;
  37806. private _fragmentSourceCodeOverride;
  37807. private _transformFeedbackVaryings;
  37808. /**
  37809. * Compiled shader to webGL program.
  37810. * @hidden
  37811. */
  37812. _pipelineContext: Nullable<IPipelineContext>;
  37813. private _valueCache;
  37814. private static _baseCache;
  37815. /**
  37816. * Instantiates an effect.
  37817. * An effect can be used to create/manage/execute vertex and fragment shaders.
  37818. * @param baseName Name of the effect.
  37819. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  37820. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  37821. * @param samplers List of sampler variables that will be passed to the shader.
  37822. * @param engine Engine to be used to render the effect
  37823. * @param defines Define statements to be added to the shader.
  37824. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  37825. * @param onCompiled Callback that will be called when the shader is compiled.
  37826. * @param onError Callback that will be called if an error occurs during shader compilation.
  37827. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37828. */
  37829. 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);
  37830. private _useFinalCode;
  37831. /**
  37832. * Unique key for this effect
  37833. */
  37834. get key(): string;
  37835. /**
  37836. * If the effect has been compiled and prepared.
  37837. * @returns if the effect is compiled and prepared.
  37838. */
  37839. isReady(): boolean;
  37840. private _isReadyInternal;
  37841. /**
  37842. * The engine the effect was initialized with.
  37843. * @returns the engine.
  37844. */
  37845. getEngine(): Engine;
  37846. /**
  37847. * The pipeline context for this effect
  37848. * @returns the associated pipeline context
  37849. */
  37850. getPipelineContext(): Nullable<IPipelineContext>;
  37851. /**
  37852. * The set of names of attribute variables for the shader.
  37853. * @returns An array of attribute names.
  37854. */
  37855. getAttributesNames(): string[];
  37856. /**
  37857. * Returns the attribute at the given index.
  37858. * @param index The index of the attribute.
  37859. * @returns The location of the attribute.
  37860. */
  37861. getAttributeLocation(index: number): number;
  37862. /**
  37863. * Returns the attribute based on the name of the variable.
  37864. * @param name of the attribute to look up.
  37865. * @returns the attribute location.
  37866. */
  37867. getAttributeLocationByName(name: string): number;
  37868. /**
  37869. * The number of attributes.
  37870. * @returns the numnber of attributes.
  37871. */
  37872. getAttributesCount(): number;
  37873. /**
  37874. * Gets the index of a uniform variable.
  37875. * @param uniformName of the uniform to look up.
  37876. * @returns the index.
  37877. */
  37878. getUniformIndex(uniformName: string): number;
  37879. /**
  37880. * Returns the attribute based on the name of the variable.
  37881. * @param uniformName of the uniform to look up.
  37882. * @returns the location of the uniform.
  37883. */
  37884. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  37885. /**
  37886. * Returns an array of sampler variable names
  37887. * @returns The array of sampler variable names.
  37888. */
  37889. getSamplers(): string[];
  37890. /**
  37891. * Returns an array of uniform variable names
  37892. * @returns The array of uniform variable names.
  37893. */
  37894. getUniformNames(): string[];
  37895. /**
  37896. * Returns an array of uniform buffer variable names
  37897. * @returns The array of uniform buffer variable names.
  37898. */
  37899. getUniformBuffersNames(): string[];
  37900. /**
  37901. * Returns the index parameters used to create the effect
  37902. * @returns The index parameters object
  37903. */
  37904. getIndexParameters(): any;
  37905. /**
  37906. * The error from the last compilation.
  37907. * @returns the error string.
  37908. */
  37909. getCompilationError(): string;
  37910. /**
  37911. * Gets a boolean indicating that all fallbacks were used during compilation
  37912. * @returns true if all fallbacks were used
  37913. */
  37914. allFallbacksProcessed(): boolean;
  37915. /**
  37916. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  37917. * @param func The callback to be used.
  37918. */
  37919. executeWhenCompiled(func: (effect: Effect) => void): void;
  37920. private _checkIsReady;
  37921. private _loadShader;
  37922. /**
  37923. * Gets the vertex shader source code of this effect
  37924. */
  37925. get vertexSourceCode(): string;
  37926. /**
  37927. * Gets the fragment shader source code of this effect
  37928. */
  37929. get fragmentSourceCode(): string;
  37930. /**
  37931. * Recompiles the webGL program
  37932. * @param vertexSourceCode The source code for the vertex shader.
  37933. * @param fragmentSourceCode The source code for the fragment shader.
  37934. * @param onCompiled Callback called when completed.
  37935. * @param onError Callback called on error.
  37936. * @hidden
  37937. */
  37938. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  37939. /**
  37940. * Prepares the effect
  37941. * @hidden
  37942. */
  37943. _prepareEffect(): void;
  37944. private _getShaderCodeAndErrorLine;
  37945. private _processCompilationErrors;
  37946. /**
  37947. * Checks if the effect is supported. (Must be called after compilation)
  37948. */
  37949. get isSupported(): boolean;
  37950. /**
  37951. * Binds a texture to the engine to be used as output of the shader.
  37952. * @param channel Name of the output variable.
  37953. * @param texture Texture to bind.
  37954. * @hidden
  37955. */
  37956. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  37957. /**
  37958. * Sets a texture on the engine to be used in the shader.
  37959. * @param channel Name of the sampler variable.
  37960. * @param texture Texture to set.
  37961. */
  37962. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  37963. /**
  37964. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  37965. * @param channel Name of the sampler variable.
  37966. * @param texture Texture to set.
  37967. */
  37968. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  37969. /**
  37970. * Sets an array of textures on the engine to be used in the shader.
  37971. * @param channel Name of the variable.
  37972. * @param textures Textures to set.
  37973. */
  37974. setTextureArray(channel: string, textures: BaseTexture[]): void;
  37975. /**
  37976. * 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)
  37977. * @param channel Name of the sampler variable.
  37978. * @param postProcess Post process to get the input texture from.
  37979. */
  37980. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  37981. /**
  37982. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  37983. * 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)
  37984. * @param channel Name of the sampler variable.
  37985. * @param postProcess Post process to get the output texture from.
  37986. */
  37987. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  37988. /** @hidden */
  37989. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  37990. /** @hidden */
  37991. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  37992. /** @hidden */
  37993. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  37994. /** @hidden */
  37995. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  37996. /**
  37997. * Binds a buffer to a uniform.
  37998. * @param buffer Buffer to bind.
  37999. * @param name Name of the uniform variable to bind to.
  38000. */
  38001. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  38002. /**
  38003. * Binds block to a uniform.
  38004. * @param blockName Name of the block to bind.
  38005. * @param index Index to bind.
  38006. */
  38007. bindUniformBlock(blockName: string, index: number): void;
  38008. /**
  38009. * Sets an interger value on a uniform variable.
  38010. * @param uniformName Name of the variable.
  38011. * @param value Value to be set.
  38012. * @returns this effect.
  38013. */
  38014. setInt(uniformName: string, value: number): Effect;
  38015. /**
  38016. * Sets an int array on a uniform variable.
  38017. * @param uniformName Name of the variable.
  38018. * @param array array to be set.
  38019. * @returns this effect.
  38020. */
  38021. setIntArray(uniformName: string, array: Int32Array): Effect;
  38022. /**
  38023. * 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)
  38024. * @param uniformName Name of the variable.
  38025. * @param array array to be set.
  38026. * @returns this effect.
  38027. */
  38028. setIntArray2(uniformName: string, array: Int32Array): Effect;
  38029. /**
  38030. * 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)
  38031. * @param uniformName Name of the variable.
  38032. * @param array array to be set.
  38033. * @returns this effect.
  38034. */
  38035. setIntArray3(uniformName: string, array: Int32Array): Effect;
  38036. /**
  38037. * 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)
  38038. * @param uniformName Name of the variable.
  38039. * @param array array to be set.
  38040. * @returns this effect.
  38041. */
  38042. setIntArray4(uniformName: string, array: Int32Array): Effect;
  38043. /**
  38044. * Sets an float array on a uniform variable.
  38045. * @param uniformName Name of the variable.
  38046. * @param array array to be set.
  38047. * @returns this effect.
  38048. */
  38049. setFloatArray(uniformName: string, array: Float32Array): Effect;
  38050. /**
  38051. * 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)
  38052. * @param uniformName Name of the variable.
  38053. * @param array array to be set.
  38054. * @returns this effect.
  38055. */
  38056. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  38057. /**
  38058. * 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)
  38059. * @param uniformName Name of the variable.
  38060. * @param array array to be set.
  38061. * @returns this effect.
  38062. */
  38063. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  38064. /**
  38065. * 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)
  38066. * @param uniformName Name of the variable.
  38067. * @param array array to be set.
  38068. * @returns this effect.
  38069. */
  38070. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  38071. /**
  38072. * Sets an array on a uniform variable.
  38073. * @param uniformName Name of the variable.
  38074. * @param array array to be set.
  38075. * @returns this effect.
  38076. */
  38077. setArray(uniformName: string, array: number[]): Effect;
  38078. /**
  38079. * 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)
  38080. * @param uniformName Name of the variable.
  38081. * @param array array to be set.
  38082. * @returns this effect.
  38083. */
  38084. setArray2(uniformName: string, array: number[]): Effect;
  38085. /**
  38086. * 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)
  38087. * @param uniformName Name of the variable.
  38088. * @param array array to be set.
  38089. * @returns this effect.
  38090. */
  38091. setArray3(uniformName: string, array: number[]): Effect;
  38092. /**
  38093. * 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)
  38094. * @param uniformName Name of the variable.
  38095. * @param array array to be set.
  38096. * @returns this effect.
  38097. */
  38098. setArray4(uniformName: string, array: number[]): Effect;
  38099. /**
  38100. * Sets matrices on a uniform variable.
  38101. * @param uniformName Name of the variable.
  38102. * @param matrices matrices to be set.
  38103. * @returns this effect.
  38104. */
  38105. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  38106. /**
  38107. * Sets matrix on a uniform variable.
  38108. * @param uniformName Name of the variable.
  38109. * @param matrix matrix to be set.
  38110. * @returns this effect.
  38111. */
  38112. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  38113. /**
  38114. * 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)
  38115. * @param uniformName Name of the variable.
  38116. * @param matrix matrix to be set.
  38117. * @returns this effect.
  38118. */
  38119. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38120. /**
  38121. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  38122. * @param uniformName Name of the variable.
  38123. * @param matrix matrix to be set.
  38124. * @returns this effect.
  38125. */
  38126. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38127. /**
  38128. * Sets a float on a uniform variable.
  38129. * @param uniformName Name of the variable.
  38130. * @param value value to be set.
  38131. * @returns this effect.
  38132. */
  38133. setFloat(uniformName: string, value: number): Effect;
  38134. /**
  38135. * Sets a boolean on a uniform variable.
  38136. * @param uniformName Name of the variable.
  38137. * @param bool value to be set.
  38138. * @returns this effect.
  38139. */
  38140. setBool(uniformName: string, bool: boolean): Effect;
  38141. /**
  38142. * Sets a Vector2 on a uniform variable.
  38143. * @param uniformName Name of the variable.
  38144. * @param vector2 vector2 to be set.
  38145. * @returns this effect.
  38146. */
  38147. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  38148. /**
  38149. * Sets a float2 on a uniform variable.
  38150. * @param uniformName Name of the variable.
  38151. * @param x First float in float2.
  38152. * @param y Second float in float2.
  38153. * @returns this effect.
  38154. */
  38155. setFloat2(uniformName: string, x: number, y: number): Effect;
  38156. /**
  38157. * Sets a Vector3 on a uniform variable.
  38158. * @param uniformName Name of the variable.
  38159. * @param vector3 Value to be set.
  38160. * @returns this effect.
  38161. */
  38162. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  38163. /**
  38164. * Sets a float3 on a uniform variable.
  38165. * @param uniformName Name of the variable.
  38166. * @param x First float in float3.
  38167. * @param y Second float in float3.
  38168. * @param z Third float in float3.
  38169. * @returns this effect.
  38170. */
  38171. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  38172. /**
  38173. * Sets a Vector4 on a uniform variable.
  38174. * @param uniformName Name of the variable.
  38175. * @param vector4 Value to be set.
  38176. * @returns this effect.
  38177. */
  38178. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  38179. /**
  38180. * Sets a float4 on a uniform variable.
  38181. * @param uniformName Name of the variable.
  38182. * @param x First float in float4.
  38183. * @param y Second float in float4.
  38184. * @param z Third float in float4.
  38185. * @param w Fourth float in float4.
  38186. * @returns this effect.
  38187. */
  38188. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  38189. /**
  38190. * Sets a Color3 on a uniform variable.
  38191. * @param uniformName Name of the variable.
  38192. * @param color3 Value to be set.
  38193. * @returns this effect.
  38194. */
  38195. setColor3(uniformName: string, color3: IColor3Like): Effect;
  38196. /**
  38197. * Sets a Color4 on a uniform variable.
  38198. * @param uniformName Name of the variable.
  38199. * @param color3 Value to be set.
  38200. * @param alpha Alpha value to be set.
  38201. * @returns this effect.
  38202. */
  38203. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  38204. /**
  38205. * Sets a Color4 on a uniform variable
  38206. * @param uniformName defines the name of the variable
  38207. * @param color4 defines the value to be set
  38208. * @returns this effect.
  38209. */
  38210. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  38211. /** Release all associated resources */
  38212. dispose(): void;
  38213. /**
  38214. * This function will add a new shader to the shader store
  38215. * @param name the name of the shader
  38216. * @param pixelShader optional pixel shader content
  38217. * @param vertexShader optional vertex shader content
  38218. */
  38219. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  38220. /**
  38221. * Store of each shader (The can be looked up using effect.key)
  38222. */
  38223. static ShadersStore: {
  38224. [key: string]: string;
  38225. };
  38226. /**
  38227. * Store of each included file for a shader (The can be looked up using effect.key)
  38228. */
  38229. static IncludesShadersStore: {
  38230. [key: string]: string;
  38231. };
  38232. /**
  38233. * Resets the cache of effects.
  38234. */
  38235. static ResetCache(): void;
  38236. }
  38237. }
  38238. declare module BABYLON {
  38239. /**
  38240. * Interface used to describe the capabilities of the engine relatively to the current browser
  38241. */
  38242. export interface EngineCapabilities {
  38243. /** Maximum textures units per fragment shader */
  38244. maxTexturesImageUnits: number;
  38245. /** Maximum texture units per vertex shader */
  38246. maxVertexTextureImageUnits: number;
  38247. /** Maximum textures units in the entire pipeline */
  38248. maxCombinedTexturesImageUnits: number;
  38249. /** Maximum texture size */
  38250. maxTextureSize: number;
  38251. /** Maximum texture samples */
  38252. maxSamples?: number;
  38253. /** Maximum cube texture size */
  38254. maxCubemapTextureSize: number;
  38255. /** Maximum render texture size */
  38256. maxRenderTextureSize: number;
  38257. /** Maximum number of vertex attributes */
  38258. maxVertexAttribs: number;
  38259. /** Maximum number of varyings */
  38260. maxVaryingVectors: number;
  38261. /** Maximum number of uniforms per vertex shader */
  38262. maxVertexUniformVectors: number;
  38263. /** Maximum number of uniforms per fragment shader */
  38264. maxFragmentUniformVectors: number;
  38265. /** Defines if standard derivates (dx/dy) are supported */
  38266. standardDerivatives: boolean;
  38267. /** Defines if s3tc texture compression is supported */
  38268. s3tc?: WEBGL_compressed_texture_s3tc;
  38269. /** Defines if pvrtc texture compression is supported */
  38270. pvrtc: any;
  38271. /** Defines if etc1 texture compression is supported */
  38272. etc1: any;
  38273. /** Defines if etc2 texture compression is supported */
  38274. etc2: any;
  38275. /** Defines if astc texture compression is supported */
  38276. astc: any;
  38277. /** Defines if bptc texture compression is supported */
  38278. bptc: any;
  38279. /** Defines if float textures are supported */
  38280. textureFloat: boolean;
  38281. /** Defines if vertex array objects are supported */
  38282. vertexArrayObject: boolean;
  38283. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38284. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38285. /** Gets the maximum level of anisotropy supported */
  38286. maxAnisotropy: number;
  38287. /** Defines if instancing is supported */
  38288. instancedArrays: boolean;
  38289. /** Defines if 32 bits indices are supported */
  38290. uintIndices: boolean;
  38291. /** Defines if high precision shaders are supported */
  38292. highPrecisionShaderSupported: boolean;
  38293. /** Defines if depth reading in the fragment shader is supported */
  38294. fragmentDepthSupported: boolean;
  38295. /** Defines if float texture linear filtering is supported*/
  38296. textureFloatLinearFiltering: boolean;
  38297. /** Defines if rendering to float textures is supported */
  38298. textureFloatRender: boolean;
  38299. /** Defines if half float textures are supported*/
  38300. textureHalfFloat: boolean;
  38301. /** Defines if half float texture linear filtering is supported*/
  38302. textureHalfFloatLinearFiltering: boolean;
  38303. /** Defines if rendering to half float textures is supported */
  38304. textureHalfFloatRender: boolean;
  38305. /** Defines if textureLOD shader command is supported */
  38306. textureLOD: boolean;
  38307. /** Defines if draw buffers extension is supported */
  38308. drawBuffersExtension: boolean;
  38309. /** Defines if depth textures are supported */
  38310. depthTextureExtension: boolean;
  38311. /** Defines if float color buffer are supported */
  38312. colorBufferFloat: boolean;
  38313. /** Gets disjoint timer query extension (null if not supported) */
  38314. timerQuery?: EXT_disjoint_timer_query;
  38315. /** Defines if timestamp can be used with timer query */
  38316. canUseTimestampForTimerQuery: boolean;
  38317. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38318. multiview?: any;
  38319. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38320. oculusMultiview?: any;
  38321. /** Function used to let the system compiles shaders in background */
  38322. parallelShaderCompile?: {
  38323. COMPLETION_STATUS_KHR: number;
  38324. };
  38325. /** Max number of texture samples for MSAA */
  38326. maxMSAASamples: number;
  38327. /** Defines if the blend min max extension is supported */
  38328. blendMinMax: boolean;
  38329. }
  38330. }
  38331. declare module BABYLON {
  38332. /**
  38333. * @hidden
  38334. **/
  38335. export class DepthCullingState {
  38336. private _isDepthTestDirty;
  38337. private _isDepthMaskDirty;
  38338. private _isDepthFuncDirty;
  38339. private _isCullFaceDirty;
  38340. private _isCullDirty;
  38341. private _isZOffsetDirty;
  38342. private _isFrontFaceDirty;
  38343. private _depthTest;
  38344. private _depthMask;
  38345. private _depthFunc;
  38346. private _cull;
  38347. private _cullFace;
  38348. private _zOffset;
  38349. private _frontFace;
  38350. /**
  38351. * Initializes the state.
  38352. */
  38353. constructor();
  38354. get isDirty(): boolean;
  38355. get zOffset(): number;
  38356. set zOffset(value: number);
  38357. get cullFace(): Nullable<number>;
  38358. set cullFace(value: Nullable<number>);
  38359. get cull(): Nullable<boolean>;
  38360. set cull(value: Nullable<boolean>);
  38361. get depthFunc(): Nullable<number>;
  38362. set depthFunc(value: Nullable<number>);
  38363. get depthMask(): boolean;
  38364. set depthMask(value: boolean);
  38365. get depthTest(): boolean;
  38366. set depthTest(value: boolean);
  38367. get frontFace(): Nullable<number>;
  38368. set frontFace(value: Nullable<number>);
  38369. reset(): void;
  38370. apply(gl: WebGLRenderingContext): void;
  38371. }
  38372. }
  38373. declare module BABYLON {
  38374. /**
  38375. * @hidden
  38376. **/
  38377. export class StencilState {
  38378. /** 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 */
  38379. static readonly ALWAYS: number;
  38380. /** Passed to stencilOperation to specify that stencil value must be kept */
  38381. static readonly KEEP: number;
  38382. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38383. static readonly REPLACE: number;
  38384. private _isStencilTestDirty;
  38385. private _isStencilMaskDirty;
  38386. private _isStencilFuncDirty;
  38387. private _isStencilOpDirty;
  38388. private _stencilTest;
  38389. private _stencilMask;
  38390. private _stencilFunc;
  38391. private _stencilFuncRef;
  38392. private _stencilFuncMask;
  38393. private _stencilOpStencilFail;
  38394. private _stencilOpDepthFail;
  38395. private _stencilOpStencilDepthPass;
  38396. get isDirty(): boolean;
  38397. get stencilFunc(): number;
  38398. set stencilFunc(value: number);
  38399. get stencilFuncRef(): number;
  38400. set stencilFuncRef(value: number);
  38401. get stencilFuncMask(): number;
  38402. set stencilFuncMask(value: number);
  38403. get stencilOpStencilFail(): number;
  38404. set stencilOpStencilFail(value: number);
  38405. get stencilOpDepthFail(): number;
  38406. set stencilOpDepthFail(value: number);
  38407. get stencilOpStencilDepthPass(): number;
  38408. set stencilOpStencilDepthPass(value: number);
  38409. get stencilMask(): number;
  38410. set stencilMask(value: number);
  38411. get stencilTest(): boolean;
  38412. set stencilTest(value: boolean);
  38413. constructor();
  38414. reset(): void;
  38415. apply(gl: WebGLRenderingContext): void;
  38416. }
  38417. }
  38418. declare module BABYLON {
  38419. /**
  38420. * @hidden
  38421. **/
  38422. export class AlphaState {
  38423. private _isAlphaBlendDirty;
  38424. private _isBlendFunctionParametersDirty;
  38425. private _isBlendEquationParametersDirty;
  38426. private _isBlendConstantsDirty;
  38427. private _alphaBlend;
  38428. private _blendFunctionParameters;
  38429. private _blendEquationParameters;
  38430. private _blendConstants;
  38431. /**
  38432. * Initializes the state.
  38433. */
  38434. constructor();
  38435. get isDirty(): boolean;
  38436. get alphaBlend(): boolean;
  38437. set alphaBlend(value: boolean);
  38438. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38439. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38440. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38441. reset(): void;
  38442. apply(gl: WebGLRenderingContext): void;
  38443. }
  38444. }
  38445. declare module BABYLON {
  38446. /** @hidden */
  38447. export class WebGLShaderProcessor implements IShaderProcessor {
  38448. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38449. }
  38450. }
  38451. declare module BABYLON {
  38452. /** @hidden */
  38453. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38454. attributeProcessor(attribute: string): string;
  38455. varyingProcessor(varying: string, isFragment: boolean): string;
  38456. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38457. }
  38458. }
  38459. declare module BABYLON {
  38460. /**
  38461. * Interface for attribute information associated with buffer instanciation
  38462. */
  38463. export interface InstancingAttributeInfo {
  38464. /**
  38465. * Name of the GLSL attribute
  38466. * if attribute index is not specified, this is used to retrieve the index from the effect
  38467. */
  38468. attributeName: string;
  38469. /**
  38470. * Index/offset of the attribute in the vertex shader
  38471. * if not specified, this will be computes from the name.
  38472. */
  38473. index?: number;
  38474. /**
  38475. * size of the attribute, 1, 2, 3 or 4
  38476. */
  38477. attributeSize: number;
  38478. /**
  38479. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38480. */
  38481. offset: number;
  38482. /**
  38483. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38484. * default to 1
  38485. */
  38486. divisor?: number;
  38487. /**
  38488. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38489. * default is FLOAT
  38490. */
  38491. attributeType?: number;
  38492. /**
  38493. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38494. */
  38495. normalized?: boolean;
  38496. }
  38497. }
  38498. declare module BABYLON {
  38499. interface ThinEngine {
  38500. /**
  38501. * Update a video texture
  38502. * @param texture defines the texture to update
  38503. * @param video defines the video element to use
  38504. * @param invertY defines if data must be stored with Y axis inverted
  38505. */
  38506. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38507. }
  38508. }
  38509. declare module BABYLON {
  38510. interface ThinEngine {
  38511. /**
  38512. * Creates a dynamic texture
  38513. * @param width defines the width of the texture
  38514. * @param height defines the height of the texture
  38515. * @param generateMipMaps defines if the engine should generate the mip levels
  38516. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38517. * @returns the dynamic texture inside an InternalTexture
  38518. */
  38519. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38520. /**
  38521. * Update the content of a dynamic texture
  38522. * @param texture defines the texture to update
  38523. * @param canvas defines the canvas containing the source
  38524. * @param invertY defines if data must be stored with Y axis inverted
  38525. * @param premulAlpha defines if alpha is stored as premultiplied
  38526. * @param format defines the format of the data
  38527. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38528. */
  38529. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38530. }
  38531. }
  38532. declare module BABYLON {
  38533. /**
  38534. * Settings for finer control over video usage
  38535. */
  38536. export interface VideoTextureSettings {
  38537. /**
  38538. * Applies `autoplay` to video, if specified
  38539. */
  38540. autoPlay?: boolean;
  38541. /**
  38542. * Applies `muted` to video, if specified
  38543. */
  38544. muted?: boolean;
  38545. /**
  38546. * Applies `loop` to video, if specified
  38547. */
  38548. loop?: boolean;
  38549. /**
  38550. * Automatically updates internal texture from video at every frame in the render loop
  38551. */
  38552. autoUpdateTexture: boolean;
  38553. /**
  38554. * Image src displayed during the video loading or until the user interacts with the video.
  38555. */
  38556. poster?: string;
  38557. }
  38558. /**
  38559. * If you want to display a video in your scene, this is the special texture for that.
  38560. * This special texture works similar to other textures, with the exception of a few parameters.
  38561. * @see https://doc.babylonjs.com/how_to/video_texture
  38562. */
  38563. export class VideoTexture extends Texture {
  38564. /**
  38565. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38566. */
  38567. readonly autoUpdateTexture: boolean;
  38568. /**
  38569. * The video instance used by the texture internally
  38570. */
  38571. readonly video: HTMLVideoElement;
  38572. private _onUserActionRequestedObservable;
  38573. /**
  38574. * Event triggerd when a dom action is required by the user to play the video.
  38575. * This happens due to recent changes in browser policies preventing video to auto start.
  38576. */
  38577. get onUserActionRequestedObservable(): Observable<Texture>;
  38578. private _generateMipMaps;
  38579. private _stillImageCaptured;
  38580. private _displayingPosterTexture;
  38581. private _settings;
  38582. private _createInternalTextureOnEvent;
  38583. private _frameId;
  38584. private _currentSrc;
  38585. /**
  38586. * Creates a video texture.
  38587. * If you want to display a video in your scene, this is the special texture for that.
  38588. * This special texture works similar to other textures, with the exception of a few parameters.
  38589. * @see https://doc.babylonjs.com/how_to/video_texture
  38590. * @param name optional name, will detect from video source, if not defined
  38591. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38592. * @param scene is obviously the current scene.
  38593. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38594. * @param invertY is false by default but can be used to invert video on Y axis
  38595. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38596. * @param settings allows finer control over video usage
  38597. */
  38598. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38599. private _getName;
  38600. private _getVideo;
  38601. private _createInternalTexture;
  38602. private reset;
  38603. /**
  38604. * @hidden Internal method to initiate `update`.
  38605. */
  38606. _rebuild(): void;
  38607. /**
  38608. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38609. */
  38610. update(): void;
  38611. /**
  38612. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38613. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38614. */
  38615. updateTexture(isVisible: boolean): void;
  38616. protected _updateInternalTexture: () => void;
  38617. /**
  38618. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38619. * @param url New url.
  38620. */
  38621. updateURL(url: string): void;
  38622. /**
  38623. * Clones the texture.
  38624. * @returns the cloned texture
  38625. */
  38626. clone(): VideoTexture;
  38627. /**
  38628. * Dispose the texture and release its associated resources.
  38629. */
  38630. dispose(): void;
  38631. /**
  38632. * Creates a video texture straight from a stream.
  38633. * @param scene Define the scene the texture should be created in
  38634. * @param stream Define the stream the texture should be created from
  38635. * @returns The created video texture as a promise
  38636. */
  38637. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38638. /**
  38639. * Creates a video texture straight from your WebCam video feed.
  38640. * @param scene Define the scene the texture should be created in
  38641. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38642. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38643. * @returns The created video texture as a promise
  38644. */
  38645. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38646. minWidth: number;
  38647. maxWidth: number;
  38648. minHeight: number;
  38649. maxHeight: number;
  38650. deviceId: string;
  38651. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38652. /**
  38653. * Creates a video texture straight from your WebCam video feed.
  38654. * @param scene Define the scene the texture should be created in
  38655. * @param onReady Define a callback to triggered once the texture will be ready
  38656. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38657. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38658. */
  38659. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38660. minWidth: number;
  38661. maxWidth: number;
  38662. minHeight: number;
  38663. maxHeight: number;
  38664. deviceId: string;
  38665. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38666. }
  38667. }
  38668. declare module BABYLON {
  38669. /**
  38670. * Defines the interface used by objects working like Scene
  38671. * @hidden
  38672. */
  38673. export interface ISceneLike {
  38674. _addPendingData(data: any): void;
  38675. _removePendingData(data: any): void;
  38676. offlineProvider: IOfflineProvider;
  38677. }
  38678. /**
  38679. * Information about the current host
  38680. */
  38681. export interface HostInformation {
  38682. /**
  38683. * Defines if the current host is a mobile
  38684. */
  38685. isMobile: boolean;
  38686. }
  38687. /** Interface defining initialization parameters for Engine class */
  38688. export interface EngineOptions extends WebGLContextAttributes {
  38689. /**
  38690. * Defines if the engine should no exceed a specified device ratio
  38691. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38692. */
  38693. limitDeviceRatio?: number;
  38694. /**
  38695. * Defines if webvr should be enabled automatically
  38696. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38697. */
  38698. autoEnableWebVR?: boolean;
  38699. /**
  38700. * Defines if webgl2 should be turned off even if supported
  38701. * @see https://doc.babylonjs.com/features/webgl2
  38702. */
  38703. disableWebGL2Support?: boolean;
  38704. /**
  38705. * Defines if webaudio should be initialized as well
  38706. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38707. */
  38708. audioEngine?: boolean;
  38709. /**
  38710. * Defines if animations should run using a deterministic lock step
  38711. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38712. */
  38713. deterministicLockstep?: boolean;
  38714. /** Defines the maximum steps to use with deterministic lock step mode */
  38715. lockstepMaxSteps?: number;
  38716. /** Defines the seconds between each deterministic lock step */
  38717. timeStep?: number;
  38718. /**
  38719. * Defines that engine should ignore context lost events
  38720. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38721. */
  38722. doNotHandleContextLost?: boolean;
  38723. /**
  38724. * Defines that engine should ignore modifying touch action attribute and style
  38725. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  38726. */
  38727. doNotHandleTouchAction?: boolean;
  38728. /**
  38729. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  38730. */
  38731. useHighPrecisionFloats?: boolean;
  38732. /**
  38733. * Make the canvas XR Compatible for XR sessions
  38734. */
  38735. xrCompatible?: boolean;
  38736. /**
  38737. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  38738. */
  38739. useHighPrecisionMatrix?: boolean;
  38740. /**
  38741. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  38742. */
  38743. failIfMajorPerformanceCaveat?: boolean;
  38744. }
  38745. /**
  38746. * The base engine class (root of all engines)
  38747. */
  38748. export class ThinEngine {
  38749. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  38750. static ExceptionList: ({
  38751. key: string;
  38752. capture: string;
  38753. captureConstraint: number;
  38754. targets: string[];
  38755. } | {
  38756. key: string;
  38757. capture: null;
  38758. captureConstraint: null;
  38759. targets: string[];
  38760. })[];
  38761. /** @hidden */
  38762. static _TextureLoaders: IInternalTextureLoader[];
  38763. /**
  38764. * Returns the current npm package of the sdk
  38765. */
  38766. static get NpmPackage(): string;
  38767. /**
  38768. * Returns the current version of the framework
  38769. */
  38770. static get Version(): string;
  38771. /**
  38772. * Returns a string describing the current engine
  38773. */
  38774. get description(): string;
  38775. /**
  38776. * Gets or sets the epsilon value used by collision engine
  38777. */
  38778. static CollisionsEpsilon: number;
  38779. /**
  38780. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38781. */
  38782. static get ShadersRepository(): string;
  38783. static set ShadersRepository(value: string);
  38784. /** @hidden */
  38785. _shaderProcessor: IShaderProcessor;
  38786. /**
  38787. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  38788. */
  38789. forcePOTTextures: boolean;
  38790. /**
  38791. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  38792. */
  38793. isFullscreen: boolean;
  38794. /**
  38795. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  38796. */
  38797. cullBackFaces: boolean;
  38798. /**
  38799. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  38800. */
  38801. renderEvenInBackground: boolean;
  38802. /**
  38803. * Gets or sets a boolean indicating that cache can be kept between frames
  38804. */
  38805. preventCacheWipeBetweenFrames: boolean;
  38806. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  38807. validateShaderPrograms: boolean;
  38808. /**
  38809. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  38810. * This can provide greater z depth for distant objects.
  38811. */
  38812. useReverseDepthBuffer: boolean;
  38813. /**
  38814. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  38815. */
  38816. disableUniformBuffers: boolean;
  38817. /** @hidden */
  38818. _uniformBuffers: UniformBuffer[];
  38819. /**
  38820. * Gets a boolean indicating that the engine supports uniform buffers
  38821. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  38822. */
  38823. get supportsUniformBuffers(): boolean;
  38824. /** @hidden */
  38825. _gl: WebGLRenderingContext;
  38826. /** @hidden */
  38827. _webGLVersion: number;
  38828. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  38829. protected _windowIsBackground: boolean;
  38830. protected _creationOptions: EngineOptions;
  38831. protected _highPrecisionShadersAllowed: boolean;
  38832. /** @hidden */
  38833. get _shouldUseHighPrecisionShader(): boolean;
  38834. /**
  38835. * Gets a boolean indicating that only power of 2 textures are supported
  38836. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  38837. */
  38838. get needPOTTextures(): boolean;
  38839. /** @hidden */
  38840. _badOS: boolean;
  38841. /** @hidden */
  38842. _badDesktopOS: boolean;
  38843. private _hardwareScalingLevel;
  38844. /** @hidden */
  38845. _caps: EngineCapabilities;
  38846. private _isStencilEnable;
  38847. private _glVersion;
  38848. private _glRenderer;
  38849. private _glVendor;
  38850. /** @hidden */
  38851. _videoTextureSupported: boolean;
  38852. protected _renderingQueueLaunched: boolean;
  38853. protected _activeRenderLoops: (() => void)[];
  38854. /**
  38855. * Observable signaled when a context lost event is raised
  38856. */
  38857. onContextLostObservable: Observable<ThinEngine>;
  38858. /**
  38859. * Observable signaled when a context restored event is raised
  38860. */
  38861. onContextRestoredObservable: Observable<ThinEngine>;
  38862. private _onContextLost;
  38863. private _onContextRestored;
  38864. protected _contextWasLost: boolean;
  38865. /** @hidden */
  38866. _doNotHandleContextLost: boolean;
  38867. /**
  38868. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  38869. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  38870. */
  38871. get doNotHandleContextLost(): boolean;
  38872. set doNotHandleContextLost(value: boolean);
  38873. /**
  38874. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  38875. */
  38876. disableVertexArrayObjects: boolean;
  38877. /** @hidden */
  38878. protected _colorWrite: boolean;
  38879. /** @hidden */
  38880. protected _colorWriteChanged: boolean;
  38881. /** @hidden */
  38882. protected _depthCullingState: DepthCullingState;
  38883. /** @hidden */
  38884. protected _stencilState: StencilState;
  38885. /** @hidden */
  38886. _alphaState: AlphaState;
  38887. /** @hidden */
  38888. _alphaMode: number;
  38889. /** @hidden */
  38890. _alphaEquation: number;
  38891. /** @hidden */
  38892. _internalTexturesCache: InternalTexture[];
  38893. /** @hidden */
  38894. protected _activeChannel: number;
  38895. private _currentTextureChannel;
  38896. /** @hidden */
  38897. protected _boundTexturesCache: {
  38898. [key: string]: Nullable<InternalTexture>;
  38899. };
  38900. /** @hidden */
  38901. protected _currentEffect: Nullable<Effect>;
  38902. /** @hidden */
  38903. protected _currentProgram: Nullable<WebGLProgram>;
  38904. private _compiledEffects;
  38905. private _vertexAttribArraysEnabled;
  38906. /** @hidden */
  38907. protected _cachedViewport: Nullable<IViewportLike>;
  38908. private _cachedVertexArrayObject;
  38909. /** @hidden */
  38910. protected _cachedVertexBuffers: any;
  38911. /** @hidden */
  38912. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  38913. /** @hidden */
  38914. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  38915. /** @hidden */
  38916. _currentRenderTarget: Nullable<InternalTexture>;
  38917. private _uintIndicesCurrentlySet;
  38918. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  38919. /** @hidden */
  38920. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  38921. /** @hidden */
  38922. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  38923. private _currentBufferPointers;
  38924. private _currentInstanceLocations;
  38925. private _currentInstanceBuffers;
  38926. private _textureUnits;
  38927. /** @hidden */
  38928. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38929. /** @hidden */
  38930. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38931. /** @hidden */
  38932. _boundRenderFunction: any;
  38933. private _vaoRecordInProgress;
  38934. private _mustWipeVertexAttributes;
  38935. private _emptyTexture;
  38936. private _emptyCubeTexture;
  38937. private _emptyTexture3D;
  38938. private _emptyTexture2DArray;
  38939. /** @hidden */
  38940. _frameHandler: number;
  38941. private _nextFreeTextureSlots;
  38942. private _maxSimultaneousTextures;
  38943. private _activeRequests;
  38944. /** @hidden */
  38945. _transformTextureUrl: Nullable<(url: string) => string>;
  38946. /**
  38947. * Gets information about the current host
  38948. */
  38949. hostInformation: HostInformation;
  38950. protected get _supportsHardwareTextureRescaling(): boolean;
  38951. private _framebufferDimensionsObject;
  38952. /**
  38953. * sets the object from which width and height will be taken from when getting render width and height
  38954. * Will fallback to the gl object
  38955. * @param dimensions the framebuffer width and height that will be used.
  38956. */
  38957. set framebufferDimensionsObject(dimensions: Nullable<{
  38958. framebufferWidth: number;
  38959. framebufferHeight: number;
  38960. }>);
  38961. /**
  38962. * Gets the current viewport
  38963. */
  38964. get currentViewport(): Nullable<IViewportLike>;
  38965. /**
  38966. * Gets the default empty texture
  38967. */
  38968. get emptyTexture(): InternalTexture;
  38969. /**
  38970. * Gets the default empty 3D texture
  38971. */
  38972. get emptyTexture3D(): InternalTexture;
  38973. /**
  38974. * Gets the default empty 2D array texture
  38975. */
  38976. get emptyTexture2DArray(): InternalTexture;
  38977. /**
  38978. * Gets the default empty cube texture
  38979. */
  38980. get emptyCubeTexture(): InternalTexture;
  38981. /**
  38982. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  38983. */
  38984. readonly premultipliedAlpha: boolean;
  38985. /**
  38986. * Observable event triggered before each texture is initialized
  38987. */
  38988. onBeforeTextureInitObservable: Observable<Texture>;
  38989. /**
  38990. * Creates a new engine
  38991. * @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
  38992. * @param antialias defines enable antialiasing (default: false)
  38993. * @param options defines further options to be sent to the getContext() function
  38994. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38995. */
  38996. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38997. private _rebuildInternalTextures;
  38998. private _rebuildEffects;
  38999. /**
  39000. * Gets a boolean indicating if all created effects are ready
  39001. * @returns true if all effects are ready
  39002. */
  39003. areAllEffectsReady(): boolean;
  39004. protected _rebuildBuffers(): void;
  39005. protected _initGLContext(): void;
  39006. /**
  39007. * Gets version of the current webGL context
  39008. */
  39009. get webGLVersion(): number;
  39010. /**
  39011. * Gets a string identifying the name of the class
  39012. * @returns "Engine" string
  39013. */
  39014. getClassName(): string;
  39015. /**
  39016. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  39017. */
  39018. get isStencilEnable(): boolean;
  39019. /** @hidden */
  39020. _prepareWorkingCanvas(): void;
  39021. /**
  39022. * Reset the texture cache to empty state
  39023. */
  39024. resetTextureCache(): void;
  39025. /**
  39026. * Gets an object containing information about the current webGL context
  39027. * @returns an object containing the vender, the renderer and the version of the current webGL context
  39028. */
  39029. getGlInfo(): {
  39030. vendor: string;
  39031. renderer: string;
  39032. version: string;
  39033. };
  39034. /**
  39035. * Defines the hardware scaling level.
  39036. * By default the hardware scaling level is computed from the window device ratio.
  39037. * 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.
  39038. * @param level defines the level to use
  39039. */
  39040. setHardwareScalingLevel(level: number): void;
  39041. /**
  39042. * Gets the current hardware scaling level.
  39043. * By default the hardware scaling level is computed from the window device ratio.
  39044. * 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.
  39045. * @returns a number indicating the current hardware scaling level
  39046. */
  39047. getHardwareScalingLevel(): number;
  39048. /**
  39049. * Gets the list of loaded textures
  39050. * @returns an array containing all loaded textures
  39051. */
  39052. getLoadedTexturesCache(): InternalTexture[];
  39053. /**
  39054. * Gets the object containing all engine capabilities
  39055. * @returns the EngineCapabilities object
  39056. */
  39057. getCaps(): EngineCapabilities;
  39058. /**
  39059. * stop executing a render loop function and remove it from the execution array
  39060. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  39061. */
  39062. stopRenderLoop(renderFunction?: () => void): void;
  39063. /** @hidden */
  39064. _renderLoop(): void;
  39065. /**
  39066. * Gets the HTML canvas attached with the current webGL context
  39067. * @returns a HTML canvas
  39068. */
  39069. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  39070. /**
  39071. * Gets host window
  39072. * @returns the host window object
  39073. */
  39074. getHostWindow(): Nullable<Window>;
  39075. /**
  39076. * Gets the current render width
  39077. * @param useScreen defines if screen size must be used (or the current render target if any)
  39078. * @returns a number defining the current render width
  39079. */
  39080. getRenderWidth(useScreen?: boolean): number;
  39081. /**
  39082. * Gets the current render height
  39083. * @param useScreen defines if screen size must be used (or the current render target if any)
  39084. * @returns a number defining the current render height
  39085. */
  39086. getRenderHeight(useScreen?: boolean): number;
  39087. /**
  39088. * Can be used to override the current requestAnimationFrame requester.
  39089. * @hidden
  39090. */
  39091. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  39092. /**
  39093. * Register and execute a render loop. The engine can have more than one render function
  39094. * @param renderFunction defines the function to continuously execute
  39095. */
  39096. runRenderLoop(renderFunction: () => void): void;
  39097. /**
  39098. * Clear the current render buffer or the current render target (if any is set up)
  39099. * @param color defines the color to use
  39100. * @param backBuffer defines if the back buffer must be cleared
  39101. * @param depth defines if the depth buffer must be cleared
  39102. * @param stencil defines if the stencil buffer must be cleared
  39103. */
  39104. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39105. private _viewportCached;
  39106. /** @hidden */
  39107. _viewport(x: number, y: number, width: number, height: number): void;
  39108. /**
  39109. * Set the WebGL's viewport
  39110. * @param viewport defines the viewport element to be used
  39111. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  39112. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  39113. */
  39114. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  39115. /**
  39116. * Begin a new frame
  39117. */
  39118. beginFrame(): void;
  39119. /**
  39120. * Enf the current frame
  39121. */
  39122. endFrame(): void;
  39123. /**
  39124. * Resize the view according to the canvas' size
  39125. */
  39126. resize(): void;
  39127. /**
  39128. * Force a specific size of the canvas
  39129. * @param width defines the new canvas' width
  39130. * @param height defines the new canvas' height
  39131. * @returns true if the size was changed
  39132. */
  39133. setSize(width: number, height: number): boolean;
  39134. /**
  39135. * Binds the frame buffer to the specified texture.
  39136. * @param texture The texture to render to or null for the default canvas
  39137. * @param faceIndex The face of the texture to render to in case of cube texture
  39138. * @param requiredWidth The width of the target to render to
  39139. * @param requiredHeight The height of the target to render to
  39140. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  39141. * @param lodLevel defines the lod level to bind to the frame buffer
  39142. * @param layer defines the 2d array index to bind to frame buffer to
  39143. */
  39144. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  39145. /** @hidden */
  39146. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  39147. /**
  39148. * Unbind the current render target texture from the webGL context
  39149. * @param texture defines the render target texture to unbind
  39150. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  39151. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  39152. */
  39153. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39154. /**
  39155. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  39156. */
  39157. flushFramebuffer(): void;
  39158. /**
  39159. * Unbind the current render target and bind the default framebuffer
  39160. */
  39161. restoreDefaultFramebuffer(): void;
  39162. /** @hidden */
  39163. protected _resetVertexBufferBinding(): void;
  39164. /**
  39165. * Creates a vertex buffer
  39166. * @param data the data for the vertex buffer
  39167. * @returns the new WebGL static buffer
  39168. */
  39169. createVertexBuffer(data: DataArray): DataBuffer;
  39170. private _createVertexBuffer;
  39171. /**
  39172. * Creates a dynamic vertex buffer
  39173. * @param data the data for the dynamic vertex buffer
  39174. * @returns the new WebGL dynamic buffer
  39175. */
  39176. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  39177. protected _resetIndexBufferBinding(): void;
  39178. /**
  39179. * Creates a new index buffer
  39180. * @param indices defines the content of the index buffer
  39181. * @param updatable defines if the index buffer must be updatable
  39182. * @returns a new webGL buffer
  39183. */
  39184. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  39185. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  39186. /**
  39187. * Bind a webGL buffer to the webGL context
  39188. * @param buffer defines the buffer to bind
  39189. */
  39190. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  39191. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  39192. private bindBuffer;
  39193. /**
  39194. * update the bound buffer with the given data
  39195. * @param data defines the data to update
  39196. */
  39197. updateArrayBuffer(data: Float32Array): void;
  39198. private _vertexAttribPointer;
  39199. /** @hidden */
  39200. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  39201. private _bindVertexBuffersAttributes;
  39202. /**
  39203. * Records a vertex array object
  39204. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39205. * @param vertexBuffers defines the list of vertex buffers to store
  39206. * @param indexBuffer defines the index buffer to store
  39207. * @param effect defines the effect to store
  39208. * @returns the new vertex array object
  39209. */
  39210. recordVertexArrayObject(vertexBuffers: {
  39211. [key: string]: VertexBuffer;
  39212. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  39213. /**
  39214. * Bind a specific vertex array object
  39215. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39216. * @param vertexArrayObject defines the vertex array object to bind
  39217. * @param indexBuffer defines the index buffer to bind
  39218. */
  39219. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  39220. /**
  39221. * Bind webGl buffers directly to the webGL context
  39222. * @param vertexBuffer defines the vertex buffer to bind
  39223. * @param indexBuffer defines the index buffer to bind
  39224. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  39225. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  39226. * @param effect defines the effect associated with the vertex buffer
  39227. */
  39228. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  39229. private _unbindVertexArrayObject;
  39230. /**
  39231. * Bind a list of vertex buffers to the webGL context
  39232. * @param vertexBuffers defines the list of vertex buffers to bind
  39233. * @param indexBuffer defines the index buffer to bind
  39234. * @param effect defines the effect associated with the vertex buffers
  39235. */
  39236. bindBuffers(vertexBuffers: {
  39237. [key: string]: Nullable<VertexBuffer>;
  39238. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  39239. /**
  39240. * Unbind all instance attributes
  39241. */
  39242. unbindInstanceAttributes(): void;
  39243. /**
  39244. * Release and free the memory of a vertex array object
  39245. * @param vao defines the vertex array object to delete
  39246. */
  39247. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  39248. /** @hidden */
  39249. _releaseBuffer(buffer: DataBuffer): boolean;
  39250. protected _deleteBuffer(buffer: DataBuffer): void;
  39251. /**
  39252. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  39253. * @param instancesBuffer defines the webGL buffer to update and bind
  39254. * @param data defines the data to store in the buffer
  39255. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  39256. */
  39257. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  39258. /**
  39259. * Bind the content of a webGL buffer used with instantiation
  39260. * @param instancesBuffer defines the webGL buffer to bind
  39261. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  39262. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  39263. */
  39264. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  39265. /**
  39266. * Disable the instance attribute corresponding to the name in parameter
  39267. * @param name defines the name of the attribute to disable
  39268. */
  39269. disableInstanceAttributeByName(name: string): void;
  39270. /**
  39271. * Disable the instance attribute corresponding to the location in parameter
  39272. * @param attributeLocation defines the attribute location of the attribute to disable
  39273. */
  39274. disableInstanceAttribute(attributeLocation: number): void;
  39275. /**
  39276. * Disable the attribute corresponding to the location in parameter
  39277. * @param attributeLocation defines the attribute location of the attribute to disable
  39278. */
  39279. disableAttributeByIndex(attributeLocation: number): void;
  39280. /**
  39281. * Send a draw order
  39282. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39283. * @param indexStart defines the starting index
  39284. * @param indexCount defines the number of index to draw
  39285. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39286. */
  39287. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39288. /**
  39289. * Draw a list of points
  39290. * @param verticesStart defines the index of first vertex to draw
  39291. * @param verticesCount defines the count of vertices to draw
  39292. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39293. */
  39294. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39295. /**
  39296. * Draw a list of unindexed primitives
  39297. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39298. * @param verticesStart defines the index of first vertex to draw
  39299. * @param verticesCount defines the count of vertices to draw
  39300. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39301. */
  39302. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39303. /**
  39304. * Draw a list of indexed primitives
  39305. * @param fillMode defines the primitive to use
  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. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39311. /**
  39312. * Draw a list of unindexed primitives
  39313. * @param fillMode defines the primitive to use
  39314. * @param verticesStart defines the index of first vertex to draw
  39315. * @param verticesCount defines the count of vertices to draw
  39316. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39317. */
  39318. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39319. private _drawMode;
  39320. /** @hidden */
  39321. protected _reportDrawCall(): void;
  39322. /** @hidden */
  39323. _releaseEffect(effect: Effect): void;
  39324. /** @hidden */
  39325. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39326. /**
  39327. * Create a new effect (used to store vertex/fragment shaders)
  39328. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39329. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39330. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39331. * @param samplers defines an array of string used to represent textures
  39332. * @param defines defines the string containing the defines to use to compile the shaders
  39333. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39334. * @param onCompiled defines a function to call when the effect creation is successful
  39335. * @param onError defines a function to call when the effect creation has failed
  39336. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39337. * @returns the new Effect
  39338. */
  39339. 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;
  39340. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39341. private _compileShader;
  39342. private _compileRawShader;
  39343. /** @hidden */
  39344. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39345. /**
  39346. * Directly creates a webGL program
  39347. * @param pipelineContext defines the pipeline context to attach to
  39348. * @param vertexCode defines the vertex shader code to use
  39349. * @param fragmentCode defines the fragment shader code to use
  39350. * @param context defines the webGL context to use (if not set, the current one will be used)
  39351. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39352. * @returns the new webGL program
  39353. */
  39354. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39355. /**
  39356. * Creates a webGL program
  39357. * @param pipelineContext defines the pipeline context to attach to
  39358. * @param vertexCode defines the vertex shader code to use
  39359. * @param fragmentCode defines the fragment shader code to use
  39360. * @param defines defines the string containing the defines to use to compile the shaders
  39361. * @param context defines the webGL context to use (if not set, the current one will be used)
  39362. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39363. * @returns the new webGL program
  39364. */
  39365. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39366. /**
  39367. * Creates a new pipeline context
  39368. * @returns the new pipeline
  39369. */
  39370. createPipelineContext(): IPipelineContext;
  39371. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39372. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39373. /** @hidden */
  39374. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39375. /** @hidden */
  39376. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39377. /** @hidden */
  39378. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39379. /**
  39380. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39381. * @param pipelineContext defines the pipeline context to use
  39382. * @param uniformsNames defines the list of uniform names
  39383. * @returns an array of webGL uniform locations
  39384. */
  39385. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39386. /**
  39387. * Gets the lsit of active attributes for a given webGL program
  39388. * @param pipelineContext defines the pipeline context to use
  39389. * @param attributesNames defines the list of attribute names to get
  39390. * @returns an array of indices indicating the offset of each attribute
  39391. */
  39392. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39393. /**
  39394. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39395. * @param effect defines the effect to activate
  39396. */
  39397. enableEffect(effect: Nullable<Effect>): void;
  39398. /**
  39399. * Set the value of an uniform to a number (int)
  39400. * @param uniform defines the webGL uniform location where to store the value
  39401. * @param value defines the int number to store
  39402. * @returns true if the value was set
  39403. */
  39404. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39405. /**
  39406. * Set the value of an uniform to an array of int32
  39407. * @param uniform defines the webGL uniform location where to store the value
  39408. * @param array defines the array of int32 to store
  39409. * @returns true if the value was set
  39410. */
  39411. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39412. /**
  39413. * Set the value of an uniform to an array of int32 (stored as vec2)
  39414. * @param uniform defines the webGL uniform location where to store the value
  39415. * @param array defines the array of int32 to store
  39416. * @returns true if the value was set
  39417. */
  39418. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39419. /**
  39420. * Set the value of an uniform to an array of int32 (stored as vec3)
  39421. * @param uniform defines the webGL uniform location where to store the value
  39422. * @param array defines the array of int32 to store
  39423. * @returns true if the value was set
  39424. */
  39425. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39426. /**
  39427. * Set the value of an uniform to an array of int32 (stored as vec4)
  39428. * @param uniform defines the webGL uniform location where to store the value
  39429. * @param array defines the array of int32 to store
  39430. * @returns true if the value was set
  39431. */
  39432. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39433. /**
  39434. * Set the value of an uniform to an array of number
  39435. * @param uniform defines the webGL uniform location where to store the value
  39436. * @param array defines the array of number to store
  39437. * @returns true if the value was set
  39438. */
  39439. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39440. /**
  39441. * Set the value of an uniform to an array of number (stored as vec2)
  39442. * @param uniform defines the webGL uniform location where to store the value
  39443. * @param array defines the array of number to store
  39444. * @returns true if the value was set
  39445. */
  39446. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39447. /**
  39448. * Set the value of an uniform to an array of number (stored as vec3)
  39449. * @param uniform defines the webGL uniform location where to store the value
  39450. * @param array defines the array of number to store
  39451. * @returns true if the value was set
  39452. */
  39453. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39454. /**
  39455. * Set the value of an uniform to an array of number (stored as vec4)
  39456. * @param uniform defines the webGL uniform location where to store the value
  39457. * @param array defines the array of number to store
  39458. * @returns true if the value was set
  39459. */
  39460. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39461. /**
  39462. * Set the value of an uniform to an array of float32 (stored as matrices)
  39463. * @param uniform defines the webGL uniform location where to store the value
  39464. * @param matrices defines the array of float32 to store
  39465. * @returns true if the value was set
  39466. */
  39467. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39468. /**
  39469. * Set the value of an uniform to a matrix (3x3)
  39470. * @param uniform defines the webGL uniform location where to store the value
  39471. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39472. * @returns true if the value was set
  39473. */
  39474. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39475. /**
  39476. * Set the value of an uniform to a matrix (2x2)
  39477. * @param uniform defines the webGL uniform location where to store the value
  39478. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39479. * @returns true if the value was set
  39480. */
  39481. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39482. /**
  39483. * Set the value of an uniform to a number (float)
  39484. * @param uniform defines the webGL uniform location where to store the value
  39485. * @param value defines the float number to store
  39486. * @returns true if the value was transfered
  39487. */
  39488. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39489. /**
  39490. * Set the value of an uniform to a vec2
  39491. * @param uniform defines the webGL uniform location where to store the value
  39492. * @param x defines the 1st component of the value
  39493. * @param y defines the 2nd component of the value
  39494. * @returns true if the value was set
  39495. */
  39496. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39497. /**
  39498. * Set the value of an uniform to a vec3
  39499. * @param uniform defines the webGL uniform location where to store the value
  39500. * @param x defines the 1st component of the value
  39501. * @param y defines the 2nd component of the value
  39502. * @param z defines the 3rd component of the value
  39503. * @returns true if the value was set
  39504. */
  39505. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39506. /**
  39507. * Set the value of an uniform to a vec4
  39508. * @param uniform defines the webGL uniform location where to store the value
  39509. * @param x defines the 1st component of the value
  39510. * @param y defines the 2nd component of the value
  39511. * @param z defines the 3rd component of the value
  39512. * @param w defines the 4th component of the value
  39513. * @returns true if the value was set
  39514. */
  39515. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39516. /**
  39517. * Apply all cached states (depth, culling, stencil and alpha)
  39518. */
  39519. applyStates(): void;
  39520. /**
  39521. * Enable or disable color writing
  39522. * @param enable defines the state to set
  39523. */
  39524. setColorWrite(enable: boolean): void;
  39525. /**
  39526. * Gets a boolean indicating if color writing is enabled
  39527. * @returns the current color writing state
  39528. */
  39529. getColorWrite(): boolean;
  39530. /**
  39531. * Gets the depth culling state manager
  39532. */
  39533. get depthCullingState(): DepthCullingState;
  39534. /**
  39535. * Gets the alpha state manager
  39536. */
  39537. get alphaState(): AlphaState;
  39538. /**
  39539. * Gets the stencil state manager
  39540. */
  39541. get stencilState(): StencilState;
  39542. /**
  39543. * Clears the list of texture accessible through engine.
  39544. * This can help preventing texture load conflict due to name collision.
  39545. */
  39546. clearInternalTexturesCache(): void;
  39547. /**
  39548. * Force the entire cache to be cleared
  39549. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39550. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39551. */
  39552. wipeCaches(bruteForce?: boolean): void;
  39553. /** @hidden */
  39554. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39555. min: number;
  39556. mag: number;
  39557. };
  39558. /** @hidden */
  39559. _createTexture(): WebGLTexture;
  39560. /**
  39561. * Usually called from Texture.ts.
  39562. * Passed information to create a WebGLTexture
  39563. * @param url defines a value which contains one of the following:
  39564. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39565. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39566. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39567. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39568. * @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)
  39569. * @param scene needed for loading to the correct scene
  39570. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39571. * @param onLoad optional callback to be called upon successful completion
  39572. * @param onError optional callback to be called upon failure
  39573. * @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
  39574. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39575. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39576. * @param forcedExtension defines the extension to use to pick the right loader
  39577. * @param mimeType defines an optional mime type
  39578. * @param loaderOptions options to be passed to the loader
  39579. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39580. */
  39581. 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;
  39582. /**
  39583. * Loads an image as an HTMLImageElement.
  39584. * @param input url string, ArrayBuffer, or Blob to load
  39585. * @param onLoad callback called when the image successfully loads
  39586. * @param onError callback called when the image fails to load
  39587. * @param offlineProvider offline provider for caching
  39588. * @param mimeType optional mime type
  39589. * @returns the HTMLImageElement of the loaded image
  39590. * @hidden
  39591. */
  39592. 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>;
  39593. /**
  39594. * @hidden
  39595. */
  39596. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39597. private _unpackFlipYCached;
  39598. /**
  39599. * In case you are sharing the context with other applications, it might
  39600. * be interested to not cache the unpack flip y state to ensure a consistent
  39601. * value would be set.
  39602. */
  39603. enableUnpackFlipYCached: boolean;
  39604. /** @hidden */
  39605. _unpackFlipY(value: boolean): void;
  39606. /** @hidden */
  39607. _getUnpackAlignement(): number;
  39608. private _getTextureTarget;
  39609. /**
  39610. * Update the sampling mode of a given texture
  39611. * @param samplingMode defines the required sampling mode
  39612. * @param texture defines the texture to update
  39613. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39614. */
  39615. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39616. /**
  39617. * Update the sampling mode of a given texture
  39618. * @param texture defines the texture to update
  39619. * @param wrapU defines the texture wrap mode of the u coordinates
  39620. * @param wrapV defines the texture wrap mode of the v coordinates
  39621. * @param wrapR defines the texture wrap mode of the r coordinates
  39622. */
  39623. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39624. /** @hidden */
  39625. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39626. width: number;
  39627. height: number;
  39628. layers?: number;
  39629. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39630. /** @hidden */
  39631. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39632. /** @hidden */
  39633. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39634. /**
  39635. * Update a portion of an internal texture
  39636. * @param texture defines the texture to update
  39637. * @param imageData defines the data to store into the texture
  39638. * @param xOffset defines the x coordinates of the update rectangle
  39639. * @param yOffset defines the y coordinates of the update rectangle
  39640. * @param width defines the width of the update rectangle
  39641. * @param height defines the height of the update rectangle
  39642. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39643. * @param lod defines the lod level to update (0 by default)
  39644. */
  39645. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39646. /** @hidden */
  39647. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39648. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39649. private _prepareWebGLTexture;
  39650. /** @hidden */
  39651. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39652. private _getDepthStencilBuffer;
  39653. /** @hidden */
  39654. _releaseFramebufferObjects(texture: InternalTexture): void;
  39655. /** @hidden */
  39656. _releaseTexture(texture: InternalTexture): void;
  39657. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39658. protected _setProgram(program: WebGLProgram): void;
  39659. protected _boundUniforms: {
  39660. [key: number]: WebGLUniformLocation;
  39661. };
  39662. /**
  39663. * Binds an effect to the webGL context
  39664. * @param effect defines the effect to bind
  39665. */
  39666. bindSamplers(effect: Effect): void;
  39667. private _activateCurrentTexture;
  39668. /** @hidden */
  39669. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39670. /** @hidden */
  39671. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39672. /**
  39673. * Unbind all textures from the webGL context
  39674. */
  39675. unbindAllTextures(): void;
  39676. /**
  39677. * Sets a texture to the according uniform.
  39678. * @param channel The texture channel
  39679. * @param uniform The uniform to set
  39680. * @param texture The texture to apply
  39681. */
  39682. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  39683. private _bindSamplerUniformToChannel;
  39684. private _getTextureWrapMode;
  39685. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39686. /**
  39687. * Sets an array of texture to the webGL context
  39688. * @param channel defines the channel where the texture array must be set
  39689. * @param uniform defines the associated uniform location
  39690. * @param textures defines the array of textures to bind
  39691. */
  39692. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  39693. /** @hidden */
  39694. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39695. private _setTextureParameterFloat;
  39696. private _setTextureParameterInteger;
  39697. /**
  39698. * Unbind all vertex attributes from the webGL context
  39699. */
  39700. unbindAllAttributes(): void;
  39701. /**
  39702. * 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
  39703. */
  39704. releaseEffects(): void;
  39705. /**
  39706. * Dispose and release all associated resources
  39707. */
  39708. dispose(): void;
  39709. /**
  39710. * Attach a new callback raised when context lost event is fired
  39711. * @param callback defines the callback to call
  39712. */
  39713. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39714. /**
  39715. * Attach a new callback raised when context restored event is fired
  39716. * @param callback defines the callback to call
  39717. */
  39718. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39719. /**
  39720. * Get the current error code of the webGL context
  39721. * @returns the error code
  39722. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39723. */
  39724. getError(): number;
  39725. private _canRenderToFloatFramebuffer;
  39726. private _canRenderToHalfFloatFramebuffer;
  39727. private _canRenderToFramebuffer;
  39728. /** @hidden */
  39729. _getWebGLTextureType(type: number): number;
  39730. /** @hidden */
  39731. _getInternalFormat(format: number): number;
  39732. /** @hidden */
  39733. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  39734. /** @hidden */
  39735. _getRGBAMultiSampleBufferFormat(type: number): number;
  39736. /** @hidden */
  39737. _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;
  39738. /**
  39739. * Loads a file from a url
  39740. * @param url url to load
  39741. * @param onSuccess callback called when the file successfully loads
  39742. * @param onProgress callback called while file is loading (if the server supports this mode)
  39743. * @param offlineProvider defines the offline provider for caching
  39744. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39745. * @param onError callback called when the file fails to load
  39746. * @returns a file request object
  39747. * @hidden
  39748. */
  39749. 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;
  39750. /**
  39751. * Reads pixels from the current frame buffer. Please note that this function can be slow
  39752. * @param x defines the x coordinate of the rectangle where pixels must be read
  39753. * @param y defines the y coordinate of the rectangle where pixels must be read
  39754. * @param width defines the width of the rectangle where pixels must be read
  39755. * @param height defines the height of the rectangle where pixels must be read
  39756. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  39757. * @returns a Uint8Array containing RGBA colors
  39758. */
  39759. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  39760. private static _IsSupported;
  39761. private static _HasMajorPerformanceCaveat;
  39762. /**
  39763. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39764. */
  39765. static get IsSupported(): boolean;
  39766. /**
  39767. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39768. * @returns true if the engine can be created
  39769. * @ignorenaming
  39770. */
  39771. static isSupported(): boolean;
  39772. /**
  39773. * 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)
  39774. */
  39775. static get HasMajorPerformanceCaveat(): boolean;
  39776. /**
  39777. * Find the next highest power of two.
  39778. * @param x Number to start search from.
  39779. * @return Next highest power of two.
  39780. */
  39781. static CeilingPOT(x: number): number;
  39782. /**
  39783. * Find the next lowest power of two.
  39784. * @param x Number to start search from.
  39785. * @return Next lowest power of two.
  39786. */
  39787. static FloorPOT(x: number): number;
  39788. /**
  39789. * Find the nearest power of two.
  39790. * @param x Number to start search from.
  39791. * @return Next nearest power of two.
  39792. */
  39793. static NearestPOT(x: number): number;
  39794. /**
  39795. * Get the closest exponent of two
  39796. * @param value defines the value to approximate
  39797. * @param max defines the maximum value to return
  39798. * @param mode defines how to define the closest value
  39799. * @returns closest exponent of two of the given value
  39800. */
  39801. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39802. /**
  39803. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39804. * @param func - the function to be called
  39805. * @param requester - the object that will request the next frame. Falls back to window.
  39806. * @returns frame number
  39807. */
  39808. static QueueNewFrame(func: () => void, requester?: any): number;
  39809. /**
  39810. * Gets host document
  39811. * @returns the host document object
  39812. */
  39813. getHostDocument(): Nullable<Document>;
  39814. }
  39815. }
  39816. declare module BABYLON {
  39817. /**
  39818. * Defines the source of the internal texture
  39819. */
  39820. export enum InternalTextureSource {
  39821. /**
  39822. * The source of the texture data is unknown
  39823. */
  39824. Unknown = 0,
  39825. /**
  39826. * Texture data comes from an URL
  39827. */
  39828. Url = 1,
  39829. /**
  39830. * Texture data is only used for temporary storage
  39831. */
  39832. Temp = 2,
  39833. /**
  39834. * Texture data comes from raw data (ArrayBuffer)
  39835. */
  39836. Raw = 3,
  39837. /**
  39838. * Texture content is dynamic (video or dynamic texture)
  39839. */
  39840. Dynamic = 4,
  39841. /**
  39842. * Texture content is generated by rendering to it
  39843. */
  39844. RenderTarget = 5,
  39845. /**
  39846. * Texture content is part of a multi render target process
  39847. */
  39848. MultiRenderTarget = 6,
  39849. /**
  39850. * Texture data comes from a cube data file
  39851. */
  39852. Cube = 7,
  39853. /**
  39854. * Texture data comes from a raw cube data
  39855. */
  39856. CubeRaw = 8,
  39857. /**
  39858. * Texture data come from a prefiltered cube data file
  39859. */
  39860. CubePrefiltered = 9,
  39861. /**
  39862. * Texture content is raw 3D data
  39863. */
  39864. Raw3D = 10,
  39865. /**
  39866. * Texture content is raw 2D array data
  39867. */
  39868. Raw2DArray = 11,
  39869. /**
  39870. * Texture content is a depth texture
  39871. */
  39872. Depth = 12,
  39873. /**
  39874. * Texture data comes from a raw cube data encoded with RGBD
  39875. */
  39876. CubeRawRGBD = 13
  39877. }
  39878. /**
  39879. * Class used to store data associated with WebGL texture data for the engine
  39880. * This class should not be used directly
  39881. */
  39882. export class InternalTexture {
  39883. /** @hidden */
  39884. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  39885. /**
  39886. * Defines if the texture is ready
  39887. */
  39888. isReady: boolean;
  39889. /**
  39890. * Defines if the texture is a cube texture
  39891. */
  39892. isCube: boolean;
  39893. /**
  39894. * Defines if the texture contains 3D data
  39895. */
  39896. is3D: boolean;
  39897. /**
  39898. * Defines if the texture contains 2D array data
  39899. */
  39900. is2DArray: boolean;
  39901. /**
  39902. * Defines if the texture contains multiview data
  39903. */
  39904. isMultiview: boolean;
  39905. /**
  39906. * Gets the URL used to load this texture
  39907. */
  39908. url: string;
  39909. /**
  39910. * Gets the sampling mode of the texture
  39911. */
  39912. samplingMode: number;
  39913. /**
  39914. * Gets a boolean indicating if the texture needs mipmaps generation
  39915. */
  39916. generateMipMaps: boolean;
  39917. /**
  39918. * Gets the number of samples used by the texture (WebGL2+ only)
  39919. */
  39920. samples: number;
  39921. /**
  39922. * Gets the type of the texture (int, float...)
  39923. */
  39924. type: number;
  39925. /**
  39926. * Gets the format of the texture (RGB, RGBA...)
  39927. */
  39928. format: number;
  39929. /**
  39930. * Observable called when the texture is loaded
  39931. */
  39932. onLoadedObservable: Observable<InternalTexture>;
  39933. /**
  39934. * Gets the width of the texture
  39935. */
  39936. width: number;
  39937. /**
  39938. * Gets the height of the texture
  39939. */
  39940. height: number;
  39941. /**
  39942. * Gets the depth of the texture
  39943. */
  39944. depth: number;
  39945. /**
  39946. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  39947. */
  39948. baseWidth: number;
  39949. /**
  39950. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  39951. */
  39952. baseHeight: number;
  39953. /**
  39954. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  39955. */
  39956. baseDepth: number;
  39957. /**
  39958. * Gets a boolean indicating if the texture is inverted on Y axis
  39959. */
  39960. invertY: boolean;
  39961. /** @hidden */
  39962. _invertVScale: boolean;
  39963. /** @hidden */
  39964. _associatedChannel: number;
  39965. /** @hidden */
  39966. _source: InternalTextureSource;
  39967. /** @hidden */
  39968. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  39969. /** @hidden */
  39970. _bufferView: Nullable<ArrayBufferView>;
  39971. /** @hidden */
  39972. _bufferViewArray: Nullable<ArrayBufferView[]>;
  39973. /** @hidden */
  39974. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  39975. /** @hidden */
  39976. _size: number;
  39977. /** @hidden */
  39978. _extension: string;
  39979. /** @hidden */
  39980. _files: Nullable<string[]>;
  39981. /** @hidden */
  39982. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39983. /** @hidden */
  39984. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39985. /** @hidden */
  39986. _framebuffer: Nullable<WebGLFramebuffer>;
  39987. /** @hidden */
  39988. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  39989. /** @hidden */
  39990. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  39991. /** @hidden */
  39992. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  39993. /** @hidden */
  39994. _attachments: Nullable<number[]>;
  39995. /** @hidden */
  39996. _textureArray: Nullable<InternalTexture[]>;
  39997. /** @hidden */
  39998. _cachedCoordinatesMode: Nullable<number>;
  39999. /** @hidden */
  40000. _cachedWrapU: Nullable<number>;
  40001. /** @hidden */
  40002. _cachedWrapV: Nullable<number>;
  40003. /** @hidden */
  40004. _cachedWrapR: Nullable<number>;
  40005. /** @hidden */
  40006. _cachedAnisotropicFilteringLevel: Nullable<number>;
  40007. /** @hidden */
  40008. _isDisabled: boolean;
  40009. /** @hidden */
  40010. _compression: Nullable<string>;
  40011. /** @hidden */
  40012. _generateStencilBuffer: boolean;
  40013. /** @hidden */
  40014. _generateDepthBuffer: boolean;
  40015. /** @hidden */
  40016. _comparisonFunction: number;
  40017. /** @hidden */
  40018. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  40019. /** @hidden */
  40020. _lodGenerationScale: number;
  40021. /** @hidden */
  40022. _lodGenerationOffset: number;
  40023. /** @hidden */
  40024. _depthStencilTexture: Nullable<InternalTexture>;
  40025. /** @hidden */
  40026. _colorTextureArray: Nullable<WebGLTexture>;
  40027. /** @hidden */
  40028. _depthStencilTextureArray: Nullable<WebGLTexture>;
  40029. /** @hidden */
  40030. _lodTextureHigh: Nullable<BaseTexture>;
  40031. /** @hidden */
  40032. _lodTextureMid: Nullable<BaseTexture>;
  40033. /** @hidden */
  40034. _lodTextureLow: Nullable<BaseTexture>;
  40035. /** @hidden */
  40036. _isRGBD: boolean;
  40037. /** @hidden */
  40038. _linearSpecularLOD: boolean;
  40039. /** @hidden */
  40040. _irradianceTexture: Nullable<BaseTexture>;
  40041. /** @hidden */
  40042. _webGLTexture: Nullable<WebGLTexture>;
  40043. /** @hidden */
  40044. _references: number;
  40045. /** @hidden */
  40046. _gammaSpace: Nullable<boolean>;
  40047. private _engine;
  40048. /**
  40049. * Gets the Engine the texture belongs to.
  40050. * @returns The babylon engine
  40051. */
  40052. getEngine(): ThinEngine;
  40053. /**
  40054. * Gets the data source type of the texture
  40055. */
  40056. get source(): InternalTextureSource;
  40057. /**
  40058. * Creates a new InternalTexture
  40059. * @param engine defines the engine to use
  40060. * @param source defines the type of data that will be used
  40061. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40062. */
  40063. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  40064. /**
  40065. * Increments the number of references (ie. the number of Texture that point to it)
  40066. */
  40067. incrementReferences(): void;
  40068. /**
  40069. * Change the size of the texture (not the size of the content)
  40070. * @param width defines the new width
  40071. * @param height defines the new height
  40072. * @param depth defines the new depth (1 by default)
  40073. */
  40074. updateSize(width: int, height: int, depth?: int): void;
  40075. /** @hidden */
  40076. _rebuild(): void;
  40077. /** @hidden */
  40078. _swapAndDie(target: InternalTexture): void;
  40079. /**
  40080. * Dispose the current allocated resources
  40081. */
  40082. dispose(): void;
  40083. }
  40084. }
  40085. declare module BABYLON {
  40086. /**
  40087. * Class used to work with sound analyzer using fast fourier transform (FFT)
  40088. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40089. */
  40090. export class Analyser {
  40091. /**
  40092. * Gets or sets the smoothing
  40093. * @ignorenaming
  40094. */
  40095. SMOOTHING: number;
  40096. /**
  40097. * Gets or sets the FFT table size
  40098. * @ignorenaming
  40099. */
  40100. FFT_SIZE: number;
  40101. /**
  40102. * Gets or sets the bar graph amplitude
  40103. * @ignorenaming
  40104. */
  40105. BARGRAPHAMPLITUDE: number;
  40106. /**
  40107. * Gets or sets the position of the debug canvas
  40108. * @ignorenaming
  40109. */
  40110. DEBUGCANVASPOS: {
  40111. x: number;
  40112. y: number;
  40113. };
  40114. /**
  40115. * Gets or sets the debug canvas size
  40116. * @ignorenaming
  40117. */
  40118. DEBUGCANVASSIZE: {
  40119. width: number;
  40120. height: number;
  40121. };
  40122. private _byteFreqs;
  40123. private _byteTime;
  40124. private _floatFreqs;
  40125. private _webAudioAnalyser;
  40126. private _debugCanvas;
  40127. private _debugCanvasContext;
  40128. private _scene;
  40129. private _registerFunc;
  40130. private _audioEngine;
  40131. /**
  40132. * Creates a new analyser
  40133. * @param scene defines hosting scene
  40134. */
  40135. constructor(scene: Scene);
  40136. /**
  40137. * Get the number of data values you will have to play with for the visualization
  40138. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  40139. * @returns a number
  40140. */
  40141. getFrequencyBinCount(): number;
  40142. /**
  40143. * Gets the current frequency data as a byte array
  40144. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40145. * @returns a Uint8Array
  40146. */
  40147. getByteFrequencyData(): Uint8Array;
  40148. /**
  40149. * Gets the current waveform as a byte array
  40150. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  40151. * @returns a Uint8Array
  40152. */
  40153. getByteTimeDomainData(): Uint8Array;
  40154. /**
  40155. * Gets the current frequency data as a float array
  40156. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40157. * @returns a Float32Array
  40158. */
  40159. getFloatFrequencyData(): Float32Array;
  40160. /**
  40161. * Renders the debug canvas
  40162. */
  40163. drawDebugCanvas(): void;
  40164. /**
  40165. * Stops rendering the debug canvas and removes it
  40166. */
  40167. stopDebugCanvas(): void;
  40168. /**
  40169. * Connects two audio nodes
  40170. * @param inputAudioNode defines first node to connect
  40171. * @param outputAudioNode defines second node to connect
  40172. */
  40173. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  40174. /**
  40175. * Releases all associated resources
  40176. */
  40177. dispose(): void;
  40178. }
  40179. }
  40180. declare module BABYLON {
  40181. /**
  40182. * This represents an audio engine and it is responsible
  40183. * to play, synchronize and analyse sounds throughout the application.
  40184. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40185. */
  40186. export interface IAudioEngine extends IDisposable {
  40187. /**
  40188. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40189. */
  40190. readonly canUseWebAudio: boolean;
  40191. /**
  40192. * Gets the current AudioContext if available.
  40193. */
  40194. readonly audioContext: Nullable<AudioContext>;
  40195. /**
  40196. * The master gain node defines the global audio volume of your audio engine.
  40197. */
  40198. readonly masterGain: GainNode;
  40199. /**
  40200. * Gets whether or not mp3 are supported by your browser.
  40201. */
  40202. readonly isMP3supported: boolean;
  40203. /**
  40204. * Gets whether or not ogg are supported by your browser.
  40205. */
  40206. readonly isOGGsupported: boolean;
  40207. /**
  40208. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40209. * @ignoreNaming
  40210. */
  40211. WarnedWebAudioUnsupported: boolean;
  40212. /**
  40213. * Defines if the audio engine relies on a custom unlocked button.
  40214. * In this case, the embedded button will not be displayed.
  40215. */
  40216. useCustomUnlockedButton: boolean;
  40217. /**
  40218. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  40219. */
  40220. readonly unlocked: boolean;
  40221. /**
  40222. * Event raised when audio has been unlocked on the browser.
  40223. */
  40224. onAudioUnlockedObservable: Observable<AudioEngine>;
  40225. /**
  40226. * Event raised when audio has been locked on the browser.
  40227. */
  40228. onAudioLockedObservable: Observable<AudioEngine>;
  40229. /**
  40230. * Flags the audio engine in Locked state.
  40231. * This happens due to new browser policies preventing audio to autoplay.
  40232. */
  40233. lock(): void;
  40234. /**
  40235. * Unlocks the audio engine once a user action has been done on the dom.
  40236. * This is helpful to resume play once browser policies have been satisfied.
  40237. */
  40238. unlock(): void;
  40239. /**
  40240. * Gets the global volume sets on the master gain.
  40241. * @returns the global volume if set or -1 otherwise
  40242. */
  40243. getGlobalVolume(): number;
  40244. /**
  40245. * Sets the global volume of your experience (sets on the master gain).
  40246. * @param newVolume Defines the new global volume of the application
  40247. */
  40248. setGlobalVolume(newVolume: number): void;
  40249. /**
  40250. * Connect the audio engine to an audio analyser allowing some amazing
  40251. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40252. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40253. * @param analyser The analyser to connect to the engine
  40254. */
  40255. connectToAnalyser(analyser: Analyser): void;
  40256. }
  40257. /**
  40258. * This represents the default audio engine used in babylon.
  40259. * It is responsible to play, synchronize and analyse sounds throughout the application.
  40260. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40261. */
  40262. export class AudioEngine implements IAudioEngine {
  40263. private _audioContext;
  40264. private _audioContextInitialized;
  40265. private _muteButton;
  40266. private _hostElement;
  40267. /**
  40268. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40269. */
  40270. canUseWebAudio: boolean;
  40271. /**
  40272. * The master gain node defines the global audio volume of your audio engine.
  40273. */
  40274. masterGain: GainNode;
  40275. /**
  40276. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40277. * @ignoreNaming
  40278. */
  40279. WarnedWebAudioUnsupported: boolean;
  40280. /**
  40281. * Gets whether or not mp3 are supported by your browser.
  40282. */
  40283. isMP3supported: boolean;
  40284. /**
  40285. * Gets whether or not ogg are supported by your browser.
  40286. */
  40287. isOGGsupported: boolean;
  40288. /**
  40289. * Gets whether audio has been unlocked on the device.
  40290. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  40291. * a user interaction has happened.
  40292. */
  40293. unlocked: boolean;
  40294. /**
  40295. * Defines if the audio engine relies on a custom unlocked button.
  40296. * In this case, the embedded button will not be displayed.
  40297. */
  40298. useCustomUnlockedButton: boolean;
  40299. /**
  40300. * Event raised when audio has been unlocked on the browser.
  40301. */
  40302. onAudioUnlockedObservable: Observable<AudioEngine>;
  40303. /**
  40304. * Event raised when audio has been locked on the browser.
  40305. */
  40306. onAudioLockedObservable: Observable<AudioEngine>;
  40307. /**
  40308. * Gets the current AudioContext if available.
  40309. */
  40310. get audioContext(): Nullable<AudioContext>;
  40311. private _connectedAnalyser;
  40312. /**
  40313. * Instantiates a new audio engine.
  40314. *
  40315. * There should be only one per page as some browsers restrict the number
  40316. * of audio contexts you can create.
  40317. * @param hostElement defines the host element where to display the mute icon if necessary
  40318. */
  40319. constructor(hostElement?: Nullable<HTMLElement>);
  40320. /**
  40321. * Flags the audio engine in Locked state.
  40322. * This happens due to new browser policies preventing audio to autoplay.
  40323. */
  40324. lock(): void;
  40325. /**
  40326. * Unlocks the audio engine once a user action has been done on the dom.
  40327. * This is helpful to resume play once browser policies have been satisfied.
  40328. */
  40329. unlock(): void;
  40330. private _resumeAudioContext;
  40331. private _initializeAudioContext;
  40332. private _tryToRun;
  40333. private _triggerRunningState;
  40334. private _triggerSuspendedState;
  40335. private _displayMuteButton;
  40336. private _moveButtonToTopLeft;
  40337. private _onResize;
  40338. private _hideMuteButton;
  40339. /**
  40340. * Destroy and release the resources associated with the audio ccontext.
  40341. */
  40342. dispose(): void;
  40343. /**
  40344. * Gets the global volume sets on the master gain.
  40345. * @returns the global volume if set or -1 otherwise
  40346. */
  40347. getGlobalVolume(): number;
  40348. /**
  40349. * Sets the global volume of your experience (sets on the master gain).
  40350. * @param newVolume Defines the new global volume of the application
  40351. */
  40352. setGlobalVolume(newVolume: number): void;
  40353. /**
  40354. * Connect the audio engine to an audio analyser allowing some amazing
  40355. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40356. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40357. * @param analyser The analyser to connect to the engine
  40358. */
  40359. connectToAnalyser(analyser: Analyser): void;
  40360. }
  40361. }
  40362. declare module BABYLON {
  40363. /**
  40364. * Interface used to present a loading screen while loading a scene
  40365. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40366. */
  40367. export interface ILoadingScreen {
  40368. /**
  40369. * Function called to display the loading screen
  40370. */
  40371. displayLoadingUI: () => void;
  40372. /**
  40373. * Function called to hide the loading screen
  40374. */
  40375. hideLoadingUI: () => void;
  40376. /**
  40377. * Gets or sets the color to use for the background
  40378. */
  40379. loadingUIBackgroundColor: string;
  40380. /**
  40381. * Gets or sets the text to display while loading
  40382. */
  40383. loadingUIText: string;
  40384. }
  40385. /**
  40386. * Class used for the default loading screen
  40387. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40388. */
  40389. export class DefaultLoadingScreen implements ILoadingScreen {
  40390. private _renderingCanvas;
  40391. private _loadingText;
  40392. private _loadingDivBackgroundColor;
  40393. private _loadingDiv;
  40394. private _loadingTextDiv;
  40395. /** Gets or sets the logo url to use for the default loading screen */
  40396. static DefaultLogoUrl: string;
  40397. /** Gets or sets the spinner url to use for the default loading screen */
  40398. static DefaultSpinnerUrl: string;
  40399. /**
  40400. * Creates a new default loading screen
  40401. * @param _renderingCanvas defines the canvas used to render the scene
  40402. * @param _loadingText defines the default text to display
  40403. * @param _loadingDivBackgroundColor defines the default background color
  40404. */
  40405. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40406. /**
  40407. * Function called to display the loading screen
  40408. */
  40409. displayLoadingUI(): void;
  40410. /**
  40411. * Function called to hide the loading screen
  40412. */
  40413. hideLoadingUI(): void;
  40414. /**
  40415. * Gets or sets the text to display while loading
  40416. */
  40417. set loadingUIText(text: string);
  40418. get loadingUIText(): string;
  40419. /**
  40420. * Gets or sets the color to use for the background
  40421. */
  40422. get loadingUIBackgroundColor(): string;
  40423. set loadingUIBackgroundColor(color: string);
  40424. private _resizeLoadingUI;
  40425. }
  40426. }
  40427. declare module BABYLON {
  40428. /**
  40429. * Interface for any object that can request an animation frame
  40430. */
  40431. export interface ICustomAnimationFrameRequester {
  40432. /**
  40433. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40434. */
  40435. renderFunction?: Function;
  40436. /**
  40437. * Called to request the next frame to render to
  40438. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40439. */
  40440. requestAnimationFrame: Function;
  40441. /**
  40442. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40443. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40444. */
  40445. requestID?: number;
  40446. }
  40447. }
  40448. declare module BABYLON {
  40449. /**
  40450. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40451. */
  40452. export class PerformanceMonitor {
  40453. private _enabled;
  40454. private _rollingFrameTime;
  40455. private _lastFrameTimeMs;
  40456. /**
  40457. * constructor
  40458. * @param frameSampleSize The number of samples required to saturate the sliding window
  40459. */
  40460. constructor(frameSampleSize?: number);
  40461. /**
  40462. * Samples current frame
  40463. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40464. */
  40465. sampleFrame(timeMs?: number): void;
  40466. /**
  40467. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40468. */
  40469. get averageFrameTime(): number;
  40470. /**
  40471. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40472. */
  40473. get averageFrameTimeVariance(): number;
  40474. /**
  40475. * Returns the frame time of the most recent frame
  40476. */
  40477. get instantaneousFrameTime(): number;
  40478. /**
  40479. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40480. */
  40481. get averageFPS(): number;
  40482. /**
  40483. * Returns the average framerate in frames per second using the most recent frame time
  40484. */
  40485. get instantaneousFPS(): number;
  40486. /**
  40487. * Returns true if enough samples have been taken to completely fill the sliding window
  40488. */
  40489. get isSaturated(): boolean;
  40490. /**
  40491. * Enables contributions to the sliding window sample set
  40492. */
  40493. enable(): void;
  40494. /**
  40495. * Disables contributions to the sliding window sample set
  40496. * Samples will not be interpolated over the disabled period
  40497. */
  40498. disable(): void;
  40499. /**
  40500. * Returns true if sampling is enabled
  40501. */
  40502. get isEnabled(): boolean;
  40503. /**
  40504. * Resets performance monitor
  40505. */
  40506. reset(): void;
  40507. }
  40508. /**
  40509. * RollingAverage
  40510. *
  40511. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40512. */
  40513. export class RollingAverage {
  40514. /**
  40515. * Current average
  40516. */
  40517. average: number;
  40518. /**
  40519. * Current variance
  40520. */
  40521. variance: number;
  40522. protected _samples: Array<number>;
  40523. protected _sampleCount: number;
  40524. protected _pos: number;
  40525. protected _m2: number;
  40526. /**
  40527. * constructor
  40528. * @param length The number of samples required to saturate the sliding window
  40529. */
  40530. constructor(length: number);
  40531. /**
  40532. * Adds a sample to the sample set
  40533. * @param v The sample value
  40534. */
  40535. add(v: number): void;
  40536. /**
  40537. * Returns previously added values or null if outside of history or outside the sliding window domain
  40538. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40539. * @return Value previously recorded with add() or null if outside of range
  40540. */
  40541. history(i: number): number;
  40542. /**
  40543. * Returns true if enough samples have been taken to completely fill the sliding window
  40544. * @return true if sample-set saturated
  40545. */
  40546. isSaturated(): boolean;
  40547. /**
  40548. * Resets the rolling average (equivalent to 0 samples taken so far)
  40549. */
  40550. reset(): void;
  40551. /**
  40552. * Wraps a value around the sample range boundaries
  40553. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40554. * @return Wrapped position in sample range
  40555. */
  40556. protected _wrapPosition(i: number): number;
  40557. }
  40558. }
  40559. declare module BABYLON {
  40560. /**
  40561. * This class is used to track a performance counter which is number based.
  40562. * The user has access to many properties which give statistics of different nature.
  40563. *
  40564. * The implementer can track two kinds of Performance Counter: time and count.
  40565. * 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.
  40566. * 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.
  40567. */
  40568. export class PerfCounter {
  40569. /**
  40570. * Gets or sets a global boolean to turn on and off all the counters
  40571. */
  40572. static Enabled: boolean;
  40573. /**
  40574. * Returns the smallest value ever
  40575. */
  40576. get min(): number;
  40577. /**
  40578. * Returns the biggest value ever
  40579. */
  40580. get max(): number;
  40581. /**
  40582. * Returns the average value since the performance counter is running
  40583. */
  40584. get average(): number;
  40585. /**
  40586. * Returns the average value of the last second the counter was monitored
  40587. */
  40588. get lastSecAverage(): number;
  40589. /**
  40590. * Returns the current value
  40591. */
  40592. get current(): number;
  40593. /**
  40594. * Gets the accumulated total
  40595. */
  40596. get total(): number;
  40597. /**
  40598. * Gets the total value count
  40599. */
  40600. get count(): number;
  40601. /**
  40602. * Creates a new counter
  40603. */
  40604. constructor();
  40605. /**
  40606. * Call this method to start monitoring a new frame.
  40607. * 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.
  40608. */
  40609. fetchNewFrame(): void;
  40610. /**
  40611. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40612. * @param newCount the count value to add to the monitored count
  40613. * @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.
  40614. */
  40615. addCount(newCount: number, fetchResult: boolean): void;
  40616. /**
  40617. * Start monitoring this performance counter
  40618. */
  40619. beginMonitoring(): void;
  40620. /**
  40621. * Compute the time lapsed since the previous beginMonitoring() call.
  40622. * @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
  40623. */
  40624. endMonitoring(newFrame?: boolean): void;
  40625. private _fetchResult;
  40626. private _startMonitoringTime;
  40627. private _min;
  40628. private _max;
  40629. private _average;
  40630. private _current;
  40631. private _totalValueCount;
  40632. private _totalAccumulated;
  40633. private _lastSecAverage;
  40634. private _lastSecAccumulated;
  40635. private _lastSecTime;
  40636. private _lastSecValueCount;
  40637. }
  40638. }
  40639. declare module BABYLON {
  40640. interface ThinEngine {
  40641. /** @hidden */
  40642. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40643. }
  40644. }
  40645. declare module BABYLON {
  40646. /**
  40647. * Defines the interface used by display changed events
  40648. */
  40649. export interface IDisplayChangedEventArgs {
  40650. /** Gets the vrDisplay object (if any) */
  40651. vrDisplay: Nullable<any>;
  40652. /** Gets a boolean indicating if webVR is supported */
  40653. vrSupported: boolean;
  40654. }
  40655. /**
  40656. * Defines the interface used by objects containing a viewport (like a camera)
  40657. */
  40658. interface IViewportOwnerLike {
  40659. /**
  40660. * Gets or sets the viewport
  40661. */
  40662. viewport: IViewportLike;
  40663. }
  40664. /**
  40665. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40666. */
  40667. export class Engine extends ThinEngine {
  40668. /** Defines that alpha blending is disabled */
  40669. static readonly ALPHA_DISABLE: number;
  40670. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40671. static readonly ALPHA_ADD: number;
  40672. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40673. static readonly ALPHA_COMBINE: number;
  40674. /** Defines that alpha blending to DEST - SRC * DEST */
  40675. static readonly ALPHA_SUBTRACT: number;
  40676. /** Defines that alpha blending to SRC * DEST */
  40677. static readonly ALPHA_MULTIPLY: number;
  40678. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40679. static readonly ALPHA_MAXIMIZED: number;
  40680. /** Defines that alpha blending to SRC + DEST */
  40681. static readonly ALPHA_ONEONE: number;
  40682. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40683. static readonly ALPHA_PREMULTIPLIED: number;
  40684. /**
  40685. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40686. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40687. */
  40688. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40689. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40690. static readonly ALPHA_INTERPOLATE: number;
  40691. /**
  40692. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40693. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40694. */
  40695. static readonly ALPHA_SCREENMODE: number;
  40696. /** Defines that the ressource is not delayed*/
  40697. static readonly DELAYLOADSTATE_NONE: number;
  40698. /** Defines that the ressource was successfully delay loaded */
  40699. static readonly DELAYLOADSTATE_LOADED: number;
  40700. /** Defines that the ressource is currently delay loading */
  40701. static readonly DELAYLOADSTATE_LOADING: number;
  40702. /** Defines that the ressource is delayed and has not started loading */
  40703. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40704. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40705. static readonly NEVER: number;
  40706. /** 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 */
  40707. static readonly ALWAYS: number;
  40708. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40709. static readonly LESS: number;
  40710. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40711. static readonly EQUAL: number;
  40712. /** 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 */
  40713. static readonly LEQUAL: number;
  40714. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40715. static readonly GREATER: number;
  40716. /** 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 */
  40717. static readonly GEQUAL: number;
  40718. /** 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 */
  40719. static readonly NOTEQUAL: number;
  40720. /** Passed to stencilOperation to specify that stencil value must be kept */
  40721. static readonly KEEP: number;
  40722. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40723. static readonly REPLACE: number;
  40724. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40725. static readonly INCR: number;
  40726. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40727. static readonly DECR: number;
  40728. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40729. static readonly INVERT: number;
  40730. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40731. static readonly INCR_WRAP: number;
  40732. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40733. static readonly DECR_WRAP: number;
  40734. /** Texture is not repeating outside of 0..1 UVs */
  40735. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40736. /** Texture is repeating outside of 0..1 UVs */
  40737. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40738. /** Texture is repeating and mirrored */
  40739. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40740. /** ALPHA */
  40741. static readonly TEXTUREFORMAT_ALPHA: number;
  40742. /** LUMINANCE */
  40743. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40744. /** LUMINANCE_ALPHA */
  40745. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40746. /** RGB */
  40747. static readonly TEXTUREFORMAT_RGB: number;
  40748. /** RGBA */
  40749. static readonly TEXTUREFORMAT_RGBA: number;
  40750. /** RED */
  40751. static readonly TEXTUREFORMAT_RED: number;
  40752. /** RED (2nd reference) */
  40753. static readonly TEXTUREFORMAT_R: number;
  40754. /** RG */
  40755. static readonly TEXTUREFORMAT_RG: number;
  40756. /** RED_INTEGER */
  40757. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40758. /** RED_INTEGER (2nd reference) */
  40759. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40760. /** RG_INTEGER */
  40761. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40762. /** RGB_INTEGER */
  40763. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40764. /** RGBA_INTEGER */
  40765. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40766. /** UNSIGNED_BYTE */
  40767. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40768. /** UNSIGNED_BYTE (2nd reference) */
  40769. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40770. /** FLOAT */
  40771. static readonly TEXTURETYPE_FLOAT: number;
  40772. /** HALF_FLOAT */
  40773. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40774. /** BYTE */
  40775. static readonly TEXTURETYPE_BYTE: number;
  40776. /** SHORT */
  40777. static readonly TEXTURETYPE_SHORT: number;
  40778. /** UNSIGNED_SHORT */
  40779. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40780. /** INT */
  40781. static readonly TEXTURETYPE_INT: number;
  40782. /** UNSIGNED_INT */
  40783. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40784. /** UNSIGNED_SHORT_4_4_4_4 */
  40785. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40786. /** UNSIGNED_SHORT_5_5_5_1 */
  40787. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40788. /** UNSIGNED_SHORT_5_6_5 */
  40789. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40790. /** UNSIGNED_INT_2_10_10_10_REV */
  40791. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40792. /** UNSIGNED_INT_24_8 */
  40793. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40794. /** UNSIGNED_INT_10F_11F_11F_REV */
  40795. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40796. /** UNSIGNED_INT_5_9_9_9_REV */
  40797. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40798. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40799. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40800. /** nearest is mag = nearest and min = nearest and mip = linear */
  40801. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40802. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40803. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40804. /** Trilinear is mag = linear and min = linear and mip = linear */
  40805. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40806. /** nearest is mag = nearest and min = nearest and mip = linear */
  40807. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40808. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40809. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40810. /** Trilinear is mag = linear and min = linear and mip = linear */
  40811. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40812. /** mag = nearest and min = nearest and mip = nearest */
  40813. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40814. /** mag = nearest and min = linear and mip = nearest */
  40815. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40816. /** mag = nearest and min = linear and mip = linear */
  40817. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40818. /** mag = nearest and min = linear and mip = none */
  40819. static readonly TEXTURE_NEAREST_LINEAR: number;
  40820. /** mag = nearest and min = nearest and mip = none */
  40821. static readonly TEXTURE_NEAREST_NEAREST: number;
  40822. /** mag = linear and min = nearest and mip = nearest */
  40823. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40824. /** mag = linear and min = nearest and mip = linear */
  40825. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  40826. /** mag = linear and min = linear and mip = none */
  40827. static readonly TEXTURE_LINEAR_LINEAR: number;
  40828. /** mag = linear and min = nearest and mip = none */
  40829. static readonly TEXTURE_LINEAR_NEAREST: number;
  40830. /** Explicit coordinates mode */
  40831. static readonly TEXTURE_EXPLICIT_MODE: number;
  40832. /** Spherical coordinates mode */
  40833. static readonly TEXTURE_SPHERICAL_MODE: number;
  40834. /** Planar coordinates mode */
  40835. static readonly TEXTURE_PLANAR_MODE: number;
  40836. /** Cubic coordinates mode */
  40837. static readonly TEXTURE_CUBIC_MODE: number;
  40838. /** Projection coordinates mode */
  40839. static readonly TEXTURE_PROJECTION_MODE: number;
  40840. /** Skybox coordinates mode */
  40841. static readonly TEXTURE_SKYBOX_MODE: number;
  40842. /** Inverse Cubic coordinates mode */
  40843. static readonly TEXTURE_INVCUBIC_MODE: number;
  40844. /** Equirectangular coordinates mode */
  40845. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  40846. /** Equirectangular Fixed coordinates mode */
  40847. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  40848. /** Equirectangular Fixed Mirrored coordinates mode */
  40849. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  40850. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  40851. static readonly SCALEMODE_FLOOR: number;
  40852. /** Defines that texture rescaling will look for the nearest power of 2 size */
  40853. static readonly SCALEMODE_NEAREST: number;
  40854. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  40855. static readonly SCALEMODE_CEILING: number;
  40856. /**
  40857. * Returns the current npm package of the sdk
  40858. */
  40859. static get NpmPackage(): string;
  40860. /**
  40861. * Returns the current version of the framework
  40862. */
  40863. static get Version(): string;
  40864. /** Gets the list of created engines */
  40865. static get Instances(): Engine[];
  40866. /**
  40867. * Gets the latest created engine
  40868. */
  40869. static get LastCreatedEngine(): Nullable<Engine>;
  40870. /**
  40871. * Gets the latest created scene
  40872. */
  40873. static get LastCreatedScene(): Nullable<Scene>;
  40874. /**
  40875. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  40876. * @param flag defines which part of the materials must be marked as dirty
  40877. * @param predicate defines a predicate used to filter which materials should be affected
  40878. */
  40879. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40880. /**
  40881. * Method called to create the default loading screen.
  40882. * This can be overriden in your own app.
  40883. * @param canvas The rendering canvas element
  40884. * @returns The loading screen
  40885. */
  40886. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  40887. /**
  40888. * Method called to create the default rescale post process on each engine.
  40889. */
  40890. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  40891. /**
  40892. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  40893. **/
  40894. enableOfflineSupport: boolean;
  40895. /**
  40896. * 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)
  40897. **/
  40898. disableManifestCheck: boolean;
  40899. /**
  40900. * Gets the list of created scenes
  40901. */
  40902. scenes: Scene[];
  40903. /**
  40904. * Event raised when a new scene is created
  40905. */
  40906. onNewSceneAddedObservable: Observable<Scene>;
  40907. /**
  40908. * Gets the list of created postprocesses
  40909. */
  40910. postProcesses: PostProcess[];
  40911. /**
  40912. * Gets a boolean indicating if the pointer is currently locked
  40913. */
  40914. isPointerLock: boolean;
  40915. /**
  40916. * Observable event triggered each time the rendering canvas is resized
  40917. */
  40918. onResizeObservable: Observable<Engine>;
  40919. /**
  40920. * Observable event triggered each time the canvas loses focus
  40921. */
  40922. onCanvasBlurObservable: Observable<Engine>;
  40923. /**
  40924. * Observable event triggered each time the canvas gains focus
  40925. */
  40926. onCanvasFocusObservable: Observable<Engine>;
  40927. /**
  40928. * Observable event triggered each time the canvas receives pointerout event
  40929. */
  40930. onCanvasPointerOutObservable: Observable<PointerEvent>;
  40931. /**
  40932. * Observable raised when the engine begins a new frame
  40933. */
  40934. onBeginFrameObservable: Observable<Engine>;
  40935. /**
  40936. * If set, will be used to request the next animation frame for the render loop
  40937. */
  40938. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  40939. /**
  40940. * Observable raised when the engine ends the current frame
  40941. */
  40942. onEndFrameObservable: Observable<Engine>;
  40943. /**
  40944. * Observable raised when the engine is about to compile a shader
  40945. */
  40946. onBeforeShaderCompilationObservable: Observable<Engine>;
  40947. /**
  40948. * Observable raised when the engine has jsut compiled a shader
  40949. */
  40950. onAfterShaderCompilationObservable: Observable<Engine>;
  40951. /**
  40952. * Gets the audio engine
  40953. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40954. * @ignorenaming
  40955. */
  40956. static audioEngine: IAudioEngine;
  40957. /**
  40958. * Default AudioEngine factory responsible of creating the Audio Engine.
  40959. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  40960. */
  40961. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  40962. /**
  40963. * Default offline support factory responsible of creating a tool used to store data locally.
  40964. * By default, this will create a Database object if the workload has been embedded.
  40965. */
  40966. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  40967. private _loadingScreen;
  40968. private _pointerLockRequested;
  40969. private _rescalePostProcess;
  40970. private _deterministicLockstep;
  40971. private _lockstepMaxSteps;
  40972. private _timeStep;
  40973. protected get _supportsHardwareTextureRescaling(): boolean;
  40974. private _fps;
  40975. private _deltaTime;
  40976. /** @hidden */
  40977. _drawCalls: PerfCounter;
  40978. /** 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 */
  40979. canvasTabIndex: number;
  40980. /**
  40981. * Turn this value on if you want to pause FPS computation when in background
  40982. */
  40983. disablePerformanceMonitorInBackground: boolean;
  40984. private _performanceMonitor;
  40985. /**
  40986. * Gets the performance monitor attached to this engine
  40987. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40988. */
  40989. get performanceMonitor(): PerformanceMonitor;
  40990. private _onFocus;
  40991. private _onBlur;
  40992. private _onCanvasPointerOut;
  40993. private _onCanvasBlur;
  40994. private _onCanvasFocus;
  40995. private _onFullscreenChange;
  40996. private _onPointerLockChange;
  40997. /**
  40998. * Gets the HTML element used to attach event listeners
  40999. * @returns a HTML element
  41000. */
  41001. getInputElement(): Nullable<HTMLElement>;
  41002. /**
  41003. * Creates a new engine
  41004. * @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
  41005. * @param antialias defines enable antialiasing (default: false)
  41006. * @param options defines further options to be sent to the getContext() function
  41007. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  41008. */
  41009. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  41010. /**
  41011. * Gets current aspect ratio
  41012. * @param viewportOwner defines the camera to use to get the aspect ratio
  41013. * @param useScreen defines if screen size must be used (or the current render target if any)
  41014. * @returns a number defining the aspect ratio
  41015. */
  41016. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  41017. /**
  41018. * Gets current screen aspect ratio
  41019. * @returns a number defining the aspect ratio
  41020. */
  41021. getScreenAspectRatio(): number;
  41022. /**
  41023. * Gets the client rect of the HTML canvas attached with the current webGL context
  41024. * @returns a client rectanglee
  41025. */
  41026. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  41027. /**
  41028. * Gets the client rect of the HTML element used for events
  41029. * @returns a client rectanglee
  41030. */
  41031. getInputElementClientRect(): Nullable<ClientRect>;
  41032. /**
  41033. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  41034. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41035. * @returns true if engine is in deterministic lock step mode
  41036. */
  41037. isDeterministicLockStep(): boolean;
  41038. /**
  41039. * Gets the max steps when engine is running in deterministic lock step
  41040. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41041. * @returns the max steps
  41042. */
  41043. getLockstepMaxSteps(): number;
  41044. /**
  41045. * Returns the time in ms between steps when using deterministic lock step.
  41046. * @returns time step in (ms)
  41047. */
  41048. getTimeStep(): number;
  41049. /**
  41050. * Force the mipmap generation for the given render target texture
  41051. * @param texture defines the render target texture to use
  41052. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  41053. */
  41054. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  41055. /** States */
  41056. /**
  41057. * Set various states to the webGL context
  41058. * @param culling defines backface culling state
  41059. * @param zOffset defines the value to apply to zOffset (0 by default)
  41060. * @param force defines if states must be applied even if cache is up to date
  41061. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  41062. */
  41063. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41064. /**
  41065. * Set the z offset to apply to current rendering
  41066. * @param value defines the offset to apply
  41067. */
  41068. setZOffset(value: number): void;
  41069. /**
  41070. * Gets the current value of the zOffset
  41071. * @returns the current zOffset state
  41072. */
  41073. getZOffset(): number;
  41074. /**
  41075. * Enable or disable depth buffering
  41076. * @param enable defines the state to set
  41077. */
  41078. setDepthBuffer(enable: boolean): void;
  41079. /**
  41080. * Gets a boolean indicating if depth writing is enabled
  41081. * @returns the current depth writing state
  41082. */
  41083. getDepthWrite(): boolean;
  41084. /**
  41085. * Enable or disable depth writing
  41086. * @param enable defines the state to set
  41087. */
  41088. setDepthWrite(enable: boolean): void;
  41089. /**
  41090. * Gets a boolean indicating if stencil buffer is enabled
  41091. * @returns the current stencil buffer state
  41092. */
  41093. getStencilBuffer(): boolean;
  41094. /**
  41095. * Enable or disable the stencil buffer
  41096. * @param enable defines if the stencil buffer must be enabled or disabled
  41097. */
  41098. setStencilBuffer(enable: boolean): void;
  41099. /**
  41100. * Gets the current stencil mask
  41101. * @returns a number defining the new stencil mask to use
  41102. */
  41103. getStencilMask(): number;
  41104. /**
  41105. * Sets the current stencil mask
  41106. * @param mask defines the new stencil mask to use
  41107. */
  41108. setStencilMask(mask: number): void;
  41109. /**
  41110. * Gets the current stencil function
  41111. * @returns a number defining the stencil function to use
  41112. */
  41113. getStencilFunction(): number;
  41114. /**
  41115. * Gets the current stencil reference value
  41116. * @returns a number defining the stencil reference value to use
  41117. */
  41118. getStencilFunctionReference(): number;
  41119. /**
  41120. * Gets the current stencil mask
  41121. * @returns a number defining the stencil mask to use
  41122. */
  41123. getStencilFunctionMask(): number;
  41124. /**
  41125. * Sets the current stencil function
  41126. * @param stencilFunc defines the new stencil function to use
  41127. */
  41128. setStencilFunction(stencilFunc: number): void;
  41129. /**
  41130. * Sets the current stencil reference
  41131. * @param reference defines the new stencil reference to use
  41132. */
  41133. setStencilFunctionReference(reference: number): void;
  41134. /**
  41135. * Sets the current stencil mask
  41136. * @param mask defines the new stencil mask to use
  41137. */
  41138. setStencilFunctionMask(mask: number): void;
  41139. /**
  41140. * Gets the current stencil operation when stencil fails
  41141. * @returns a number defining stencil operation to use when stencil fails
  41142. */
  41143. getStencilOperationFail(): number;
  41144. /**
  41145. * Gets the current stencil operation when depth fails
  41146. * @returns a number defining stencil operation to use when depth fails
  41147. */
  41148. getStencilOperationDepthFail(): number;
  41149. /**
  41150. * Gets the current stencil operation when stencil passes
  41151. * @returns a number defining stencil operation to use when stencil passes
  41152. */
  41153. getStencilOperationPass(): number;
  41154. /**
  41155. * Sets the stencil operation to use when stencil fails
  41156. * @param operation defines the stencil operation to use when stencil fails
  41157. */
  41158. setStencilOperationFail(operation: number): void;
  41159. /**
  41160. * Sets the stencil operation to use when depth fails
  41161. * @param operation defines the stencil operation to use when depth fails
  41162. */
  41163. setStencilOperationDepthFail(operation: number): void;
  41164. /**
  41165. * Sets the stencil operation to use when stencil passes
  41166. * @param operation defines the stencil operation to use when stencil passes
  41167. */
  41168. setStencilOperationPass(operation: number): void;
  41169. /**
  41170. * Sets a boolean indicating if the dithering state is enabled or disabled
  41171. * @param value defines the dithering state
  41172. */
  41173. setDitheringState(value: boolean): void;
  41174. /**
  41175. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  41176. * @param value defines the rasterizer state
  41177. */
  41178. setRasterizerState(value: boolean): void;
  41179. /**
  41180. * Gets the current depth function
  41181. * @returns a number defining the depth function
  41182. */
  41183. getDepthFunction(): Nullable<number>;
  41184. /**
  41185. * Sets the current depth function
  41186. * @param depthFunc defines the function to use
  41187. */
  41188. setDepthFunction(depthFunc: number): void;
  41189. /**
  41190. * Sets the current depth function to GREATER
  41191. */
  41192. setDepthFunctionToGreater(): void;
  41193. /**
  41194. * Sets the current depth function to GEQUAL
  41195. */
  41196. setDepthFunctionToGreaterOrEqual(): void;
  41197. /**
  41198. * Sets the current depth function to LESS
  41199. */
  41200. setDepthFunctionToLess(): void;
  41201. /**
  41202. * Sets the current depth function to LEQUAL
  41203. */
  41204. setDepthFunctionToLessOrEqual(): void;
  41205. private _cachedStencilBuffer;
  41206. private _cachedStencilFunction;
  41207. private _cachedStencilMask;
  41208. private _cachedStencilOperationPass;
  41209. private _cachedStencilOperationFail;
  41210. private _cachedStencilOperationDepthFail;
  41211. private _cachedStencilReference;
  41212. /**
  41213. * Caches the the state of the stencil buffer
  41214. */
  41215. cacheStencilState(): void;
  41216. /**
  41217. * Restores the state of the stencil buffer
  41218. */
  41219. restoreStencilState(): void;
  41220. /**
  41221. * Directly set the WebGL Viewport
  41222. * @param x defines the x coordinate of the viewport (in screen space)
  41223. * @param y defines the y coordinate of the viewport (in screen space)
  41224. * @param width defines the width of the viewport (in screen space)
  41225. * @param height defines the height of the viewport (in screen space)
  41226. * @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
  41227. */
  41228. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  41229. /**
  41230. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  41231. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41232. * @param y defines the y-coordinate of the corner of the clear rectangle
  41233. * @param width defines the width of the clear rectangle
  41234. * @param height defines the height of the clear rectangle
  41235. * @param clearColor defines the clear color
  41236. */
  41237. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  41238. /**
  41239. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  41240. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41241. * @param y defines the y-coordinate of the corner of the clear rectangle
  41242. * @param width defines the width of the clear rectangle
  41243. * @param height defines the height of the clear rectangle
  41244. */
  41245. enableScissor(x: number, y: number, width: number, height: number): void;
  41246. /**
  41247. * Disable previously set scissor test rectangle
  41248. */
  41249. disableScissor(): void;
  41250. protected _reportDrawCall(): void;
  41251. /**
  41252. * Initializes a webVR display and starts listening to display change events
  41253. * The onVRDisplayChangedObservable will be notified upon these changes
  41254. * @returns The onVRDisplayChangedObservable
  41255. */
  41256. initWebVR(): Observable<IDisplayChangedEventArgs>;
  41257. /** @hidden */
  41258. _prepareVRComponent(): void;
  41259. /** @hidden */
  41260. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  41261. /** @hidden */
  41262. _submitVRFrame(): void;
  41263. /**
  41264. * Call this function to leave webVR mode
  41265. * Will do nothing if webVR is not supported or if there is no webVR device
  41266. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41267. */
  41268. disableVR(): void;
  41269. /**
  41270. * Gets a boolean indicating that the system is in VR mode and is presenting
  41271. * @returns true if VR mode is engaged
  41272. */
  41273. isVRPresenting(): boolean;
  41274. /** @hidden */
  41275. _requestVRFrame(): void;
  41276. /** @hidden */
  41277. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41278. /**
  41279. * Gets the source code of the vertex shader associated with a specific webGL program
  41280. * @param program defines the program to use
  41281. * @returns a string containing the source code of the vertex shader associated with the program
  41282. */
  41283. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41284. /**
  41285. * Gets the source code of the fragment shader associated with a specific webGL program
  41286. * @param program defines the program to use
  41287. * @returns a string containing the source code of the fragment shader associated with the program
  41288. */
  41289. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41290. /**
  41291. * Sets a depth stencil texture from a render target to the according uniform.
  41292. * @param channel The texture channel
  41293. * @param uniform The uniform to set
  41294. * @param texture The render target texture containing the depth stencil texture to apply
  41295. */
  41296. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41297. /**
  41298. * Sets a texture to the webGL context from a postprocess
  41299. * @param channel defines the channel to use
  41300. * @param postProcess defines the source postprocess
  41301. */
  41302. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41303. /**
  41304. * Binds the output of the passed in post process to the texture channel specified
  41305. * @param channel The channel the texture should be bound to
  41306. * @param postProcess The post process which's output should be bound
  41307. */
  41308. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41309. protected _rebuildBuffers(): void;
  41310. /** @hidden */
  41311. _renderFrame(): void;
  41312. _renderLoop(): void;
  41313. /** @hidden */
  41314. _renderViews(): boolean;
  41315. /**
  41316. * Toggle full screen mode
  41317. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41318. */
  41319. switchFullscreen(requestPointerLock: boolean): void;
  41320. /**
  41321. * Enters full screen mode
  41322. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41323. */
  41324. enterFullscreen(requestPointerLock: boolean): void;
  41325. /**
  41326. * Exits full screen mode
  41327. */
  41328. exitFullscreen(): void;
  41329. /**
  41330. * Enters Pointerlock mode
  41331. */
  41332. enterPointerlock(): void;
  41333. /**
  41334. * Exits Pointerlock mode
  41335. */
  41336. exitPointerlock(): void;
  41337. /**
  41338. * Begin a new frame
  41339. */
  41340. beginFrame(): void;
  41341. /**
  41342. * Enf the current frame
  41343. */
  41344. endFrame(): void;
  41345. resize(): void;
  41346. /**
  41347. * Force a specific size of the canvas
  41348. * @param width defines the new canvas' width
  41349. * @param height defines the new canvas' height
  41350. * @returns true if the size was changed
  41351. */
  41352. setSize(width: number, height: number): boolean;
  41353. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41354. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41355. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41356. _releaseTexture(texture: InternalTexture): void;
  41357. /**
  41358. * @hidden
  41359. * Rescales a texture
  41360. * @param source input texutre
  41361. * @param destination destination texture
  41362. * @param scene scene to use to render the resize
  41363. * @param internalFormat format to use when resizing
  41364. * @param onComplete callback to be called when resize has completed
  41365. */
  41366. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41367. /**
  41368. * Gets the current framerate
  41369. * @returns a number representing the framerate
  41370. */
  41371. getFps(): number;
  41372. /**
  41373. * Gets the time spent between current and previous frame
  41374. * @returns a number representing the delta time in ms
  41375. */
  41376. getDeltaTime(): number;
  41377. private _measureFps;
  41378. /** @hidden */
  41379. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41380. /**
  41381. * Updates the sample count of a render target texture
  41382. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41383. * @param texture defines the texture to update
  41384. * @param samples defines the sample count to set
  41385. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41386. */
  41387. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41388. /**
  41389. * Updates a depth texture Comparison Mode and Function.
  41390. * If the comparison Function is equal to 0, the mode will be set to none.
  41391. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41392. * @param texture The texture to set the comparison function for
  41393. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41394. */
  41395. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41396. /**
  41397. * Creates a webGL buffer to use with instanciation
  41398. * @param capacity defines the size of the buffer
  41399. * @returns the webGL buffer
  41400. */
  41401. createInstancesBuffer(capacity: number): DataBuffer;
  41402. /**
  41403. * Delete a webGL buffer used with instanciation
  41404. * @param buffer defines the webGL buffer to delete
  41405. */
  41406. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41407. private _clientWaitAsync;
  41408. /** @hidden */
  41409. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41410. dispose(): void;
  41411. private _disableTouchAction;
  41412. /**
  41413. * Display the loading screen
  41414. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41415. */
  41416. displayLoadingUI(): void;
  41417. /**
  41418. * Hide the loading screen
  41419. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41420. */
  41421. hideLoadingUI(): void;
  41422. /**
  41423. * Gets the current loading screen object
  41424. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41425. */
  41426. get loadingScreen(): ILoadingScreen;
  41427. /**
  41428. * Sets the current loading screen object
  41429. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41430. */
  41431. set loadingScreen(loadingScreen: ILoadingScreen);
  41432. /**
  41433. * Sets the current loading screen text
  41434. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41435. */
  41436. set loadingUIText(text: string);
  41437. /**
  41438. * Sets the current loading screen background color
  41439. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41440. */
  41441. set loadingUIBackgroundColor(color: string);
  41442. /** Pointerlock and fullscreen */
  41443. /**
  41444. * Ask the browser to promote the current element to pointerlock mode
  41445. * @param element defines the DOM element to promote
  41446. */
  41447. static _RequestPointerlock(element: HTMLElement): void;
  41448. /**
  41449. * Asks the browser to exit pointerlock mode
  41450. */
  41451. static _ExitPointerlock(): void;
  41452. /**
  41453. * Ask the browser to promote the current element to fullscreen rendering mode
  41454. * @param element defines the DOM element to promote
  41455. */
  41456. static _RequestFullscreen(element: HTMLElement): void;
  41457. /**
  41458. * Asks the browser to exit fullscreen mode
  41459. */
  41460. static _ExitFullscreen(): void;
  41461. }
  41462. }
  41463. declare module BABYLON {
  41464. /**
  41465. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41466. * during the life time of the application.
  41467. */
  41468. export class EngineStore {
  41469. /** Gets the list of created engines */
  41470. static Instances: Engine[];
  41471. /** @hidden */
  41472. static _LastCreatedScene: Nullable<Scene>;
  41473. /**
  41474. * Gets the latest created engine
  41475. */
  41476. static get LastCreatedEngine(): Nullable<Engine>;
  41477. /**
  41478. * Gets the latest created scene
  41479. */
  41480. static get LastCreatedScene(): Nullable<Scene>;
  41481. /**
  41482. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41483. * @ignorenaming
  41484. */
  41485. static UseFallbackTexture: boolean;
  41486. /**
  41487. * Texture content used if a texture cannot loaded
  41488. * @ignorenaming
  41489. */
  41490. static FallbackTexture: string;
  41491. }
  41492. }
  41493. declare module BABYLON {
  41494. /**
  41495. * Helper class that provides a small promise polyfill
  41496. */
  41497. export class PromisePolyfill {
  41498. /**
  41499. * Static function used to check if the polyfill is required
  41500. * If this is the case then the function will inject the polyfill to window.Promise
  41501. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41502. */
  41503. static Apply(force?: boolean): void;
  41504. }
  41505. }
  41506. declare module BABYLON {
  41507. /**
  41508. * Interface for screenshot methods with describe argument called `size` as object with options
  41509. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41510. */
  41511. export interface IScreenshotSize {
  41512. /**
  41513. * number in pixels for canvas height
  41514. */
  41515. height?: number;
  41516. /**
  41517. * multiplier allowing render at a higher or lower resolution
  41518. * If value is defined then height and width will be ignored and taken from camera
  41519. */
  41520. precision?: number;
  41521. /**
  41522. * number in pixels for canvas width
  41523. */
  41524. width?: number;
  41525. }
  41526. }
  41527. declare module BABYLON {
  41528. interface IColor4Like {
  41529. r: float;
  41530. g: float;
  41531. b: float;
  41532. a: float;
  41533. }
  41534. /**
  41535. * Class containing a set of static utilities functions
  41536. */
  41537. export class Tools {
  41538. /**
  41539. * Gets or sets the base URL to use to load assets
  41540. */
  41541. static get BaseUrl(): string;
  41542. static set BaseUrl(value: string);
  41543. /**
  41544. * Enable/Disable Custom HTTP Request Headers globally.
  41545. * default = false
  41546. * @see CustomRequestHeaders
  41547. */
  41548. static UseCustomRequestHeaders: boolean;
  41549. /**
  41550. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41551. * i.e. when loading files, where the server/service expects an Authorization header
  41552. */
  41553. static CustomRequestHeaders: {
  41554. [key: string]: string;
  41555. };
  41556. /**
  41557. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41558. */
  41559. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41560. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41561. /**
  41562. * Default behaviour for cors in the application.
  41563. * It can be a string if the expected behavior is identical in the entire app.
  41564. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41565. */
  41566. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41567. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41568. /**
  41569. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41570. * @ignorenaming
  41571. */
  41572. static get UseFallbackTexture(): boolean;
  41573. static set UseFallbackTexture(value: boolean);
  41574. /**
  41575. * Use this object to register external classes like custom textures or material
  41576. * to allow the laoders to instantiate them
  41577. */
  41578. static get RegisteredExternalClasses(): {
  41579. [key: string]: Object;
  41580. };
  41581. static set RegisteredExternalClasses(classes: {
  41582. [key: string]: Object;
  41583. });
  41584. /**
  41585. * Texture content used if a texture cannot loaded
  41586. * @ignorenaming
  41587. */
  41588. static get fallbackTexture(): string;
  41589. static set fallbackTexture(value: string);
  41590. /**
  41591. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41592. * @param u defines the coordinate on X axis
  41593. * @param v defines the coordinate on Y axis
  41594. * @param width defines the width of the source data
  41595. * @param height defines the height of the source data
  41596. * @param pixels defines the source byte array
  41597. * @param color defines the output color
  41598. */
  41599. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41600. /**
  41601. * Interpolates between a and b via alpha
  41602. * @param a The lower value (returned when alpha = 0)
  41603. * @param b The upper value (returned when alpha = 1)
  41604. * @param alpha The interpolation-factor
  41605. * @return The mixed value
  41606. */
  41607. static Mix(a: number, b: number, alpha: number): number;
  41608. /**
  41609. * Tries to instantiate a new object from a given class name
  41610. * @param className defines the class name to instantiate
  41611. * @returns the new object or null if the system was not able to do the instantiation
  41612. */
  41613. static Instantiate(className: string): any;
  41614. /**
  41615. * Provides a slice function that will work even on IE
  41616. * @param data defines the array to slice
  41617. * @param start defines the start of the data (optional)
  41618. * @param end defines the end of the data (optional)
  41619. * @returns the new sliced array
  41620. */
  41621. static Slice<T>(data: T, start?: number, end?: number): T;
  41622. /**
  41623. * Provides a slice function that will work even on IE
  41624. * The difference between this and Slice is that this will force-convert to array
  41625. * @param data defines the array to slice
  41626. * @param start defines the start of the data (optional)
  41627. * @param end defines the end of the data (optional)
  41628. * @returns the new sliced array
  41629. */
  41630. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41631. /**
  41632. * Polyfill for setImmediate
  41633. * @param action defines the action to execute after the current execution block
  41634. */
  41635. static SetImmediate(action: () => void): void;
  41636. /**
  41637. * Function indicating if a number is an exponent of 2
  41638. * @param value defines the value to test
  41639. * @returns true if the value is an exponent of 2
  41640. */
  41641. static IsExponentOfTwo(value: number): boolean;
  41642. private static _tmpFloatArray;
  41643. /**
  41644. * Returns the nearest 32-bit single precision float representation of a Number
  41645. * @param value A Number. If the parameter is of a different type, it will get converted
  41646. * to a number or to NaN if it cannot be converted
  41647. * @returns number
  41648. */
  41649. static FloatRound(value: number): number;
  41650. /**
  41651. * Extracts the filename from a path
  41652. * @param path defines the path to use
  41653. * @returns the filename
  41654. */
  41655. static GetFilename(path: string): string;
  41656. /**
  41657. * Extracts the "folder" part of a path (everything before the filename).
  41658. * @param uri The URI to extract the info from
  41659. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41660. * @returns The "folder" part of the path
  41661. */
  41662. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41663. /**
  41664. * Extracts text content from a DOM element hierarchy
  41665. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41666. */
  41667. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41668. /**
  41669. * Convert an angle in radians to degrees
  41670. * @param angle defines the angle to convert
  41671. * @returns the angle in degrees
  41672. */
  41673. static ToDegrees(angle: number): number;
  41674. /**
  41675. * Convert an angle in degrees to radians
  41676. * @param angle defines the angle to convert
  41677. * @returns the angle in radians
  41678. */
  41679. static ToRadians(angle: number): number;
  41680. /**
  41681. * Returns an array if obj is not an array
  41682. * @param obj defines the object to evaluate as an array
  41683. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41684. * @returns either obj directly if obj is an array or a new array containing obj
  41685. */
  41686. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41687. /**
  41688. * Gets the pointer prefix to use
  41689. * @param engine defines the engine we are finding the prefix for
  41690. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41691. */
  41692. static GetPointerPrefix(engine: Engine): string;
  41693. /**
  41694. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41695. * @param url define the url we are trying
  41696. * @param element define the dom element where to configure the cors policy
  41697. */
  41698. static SetCorsBehavior(url: string | string[], element: {
  41699. crossOrigin: string | null;
  41700. }): void;
  41701. /**
  41702. * Removes unwanted characters from an url
  41703. * @param url defines the url to clean
  41704. * @returns the cleaned url
  41705. */
  41706. static CleanUrl(url: string): string;
  41707. /**
  41708. * Gets or sets a function used to pre-process url before using them to load assets
  41709. */
  41710. static get PreprocessUrl(): (url: string) => string;
  41711. static set PreprocessUrl(processor: (url: string) => string);
  41712. /**
  41713. * Loads an image as an HTMLImageElement.
  41714. * @param input url string, ArrayBuffer, or Blob to load
  41715. * @param onLoad callback called when the image successfully loads
  41716. * @param onError callback called when the image fails to load
  41717. * @param offlineProvider offline provider for caching
  41718. * @param mimeType optional mime type
  41719. * @returns the HTMLImageElement of the loaded image
  41720. */
  41721. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41722. /**
  41723. * Loads a file from a url
  41724. * @param url url string, ArrayBuffer, or Blob to load
  41725. * @param onSuccess callback called when the file successfully loads
  41726. * @param onProgress callback called while file is loading (if the server supports this mode)
  41727. * @param offlineProvider defines the offline provider for caching
  41728. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41729. * @param onError callback called when the file fails to load
  41730. * @returns a file request object
  41731. */
  41732. 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;
  41733. /**
  41734. * Loads a file from a url
  41735. * @param url the file url to load
  41736. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41737. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41738. */
  41739. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41740. /**
  41741. * Load a script (identified by an url). When the url returns, the
  41742. * content of this file is added into a new script element, attached to the DOM (body element)
  41743. * @param scriptUrl defines the url of the script to laod
  41744. * @param onSuccess defines the callback called when the script is loaded
  41745. * @param onError defines the callback to call if an error occurs
  41746. * @param scriptId defines the id of the script element
  41747. */
  41748. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41749. /**
  41750. * Load an asynchronous script (identified by an url). When the url returns, the
  41751. * content of this file is added into a new script element, attached to the DOM (body element)
  41752. * @param scriptUrl defines the url of the script to laod
  41753. * @param scriptId defines the id of the script element
  41754. * @returns a promise request object
  41755. */
  41756. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41757. /**
  41758. * Loads a file from a blob
  41759. * @param fileToLoad defines the blob to use
  41760. * @param callback defines the callback to call when data is loaded
  41761. * @param progressCallback defines the callback to call during loading process
  41762. * @returns a file request object
  41763. */
  41764. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41765. /**
  41766. * Reads a file from a File object
  41767. * @param file defines the file to load
  41768. * @param onSuccess defines the callback to call when data is loaded
  41769. * @param onProgress defines the callback to call during loading process
  41770. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41771. * @param onError defines the callback to call when an error occurs
  41772. * @returns a file request object
  41773. */
  41774. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41775. /**
  41776. * Creates a data url from a given string content
  41777. * @param content defines the content to convert
  41778. * @returns the new data url link
  41779. */
  41780. static FileAsURL(content: string): string;
  41781. /**
  41782. * Format the given number to a specific decimal format
  41783. * @param value defines the number to format
  41784. * @param decimals defines the number of decimals to use
  41785. * @returns the formatted string
  41786. */
  41787. static Format(value: number, decimals?: number): string;
  41788. /**
  41789. * Tries to copy an object by duplicating every property
  41790. * @param source defines the source object
  41791. * @param destination defines the target object
  41792. * @param doNotCopyList defines a list of properties to avoid
  41793. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41794. */
  41795. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41796. /**
  41797. * Gets a boolean indicating if the given object has no own property
  41798. * @param obj defines the object to test
  41799. * @returns true if object has no own property
  41800. */
  41801. static IsEmpty(obj: any): boolean;
  41802. /**
  41803. * Function used to register events at window level
  41804. * @param windowElement defines the Window object to use
  41805. * @param events defines the events to register
  41806. */
  41807. static RegisterTopRootEvents(windowElement: Window, events: {
  41808. name: string;
  41809. handler: Nullable<(e: FocusEvent) => any>;
  41810. }[]): void;
  41811. /**
  41812. * Function used to unregister events from window level
  41813. * @param windowElement defines the Window object to use
  41814. * @param events defines the events to unregister
  41815. */
  41816. static UnregisterTopRootEvents(windowElement: Window, events: {
  41817. name: string;
  41818. handler: Nullable<(e: FocusEvent) => any>;
  41819. }[]): void;
  41820. /**
  41821. * @ignore
  41822. */
  41823. static _ScreenshotCanvas: HTMLCanvasElement;
  41824. /**
  41825. * Dumps the current bound framebuffer
  41826. * @param width defines the rendering width
  41827. * @param height defines the rendering height
  41828. * @param engine defines the hosting engine
  41829. * @param successCallback defines the callback triggered once the data are available
  41830. * @param mimeType defines the mime type of the result
  41831. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  41832. */
  41833. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41834. /**
  41835. * Converts the canvas data to blob.
  41836. * This acts as a polyfill for browsers not supporting the to blob function.
  41837. * @param canvas Defines the canvas to extract the data from
  41838. * @param successCallback Defines the callback triggered once the data are available
  41839. * @param mimeType Defines the mime type of the result
  41840. */
  41841. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  41842. /**
  41843. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  41844. * @param successCallback defines the callback triggered once the data are available
  41845. * @param mimeType defines the mime type of the result
  41846. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  41847. */
  41848. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41849. /**
  41850. * Downloads a blob in the browser
  41851. * @param blob defines the blob to download
  41852. * @param fileName defines the name of the downloaded file
  41853. */
  41854. static Download(blob: Blob, fileName: string): void;
  41855. /**
  41856. * Captures a screenshot of the current rendering
  41857. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41858. * @param engine defines the rendering engine
  41859. * @param camera defines the source camera
  41860. * @param size This parameter can be set to a single number or to an object with the
  41861. * following (optional) properties: precision, width, height. If a single number is passed,
  41862. * it will be used for both width and height. If an object is passed, the screenshot size
  41863. * will be derived from the parameters. The precision property is a multiplier allowing
  41864. * rendering at a higher or lower resolution
  41865. * @param successCallback defines the callback receives a single parameter which contains the
  41866. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41867. * src parameter of an <img> to display it
  41868. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41869. * Check your browser for supported MIME types
  41870. */
  41871. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  41872. /**
  41873. * Captures a screenshot of the current rendering
  41874. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41875. * @param engine defines the rendering engine
  41876. * @param camera defines the source camera
  41877. * @param size This parameter can be set to a single number or to an object with the
  41878. * following (optional) properties: precision, width, height. If a single number is passed,
  41879. * it will be used for both width and height. If an object is passed, the screenshot size
  41880. * will be derived from the parameters. The precision property is a multiplier allowing
  41881. * rendering at a higher or lower resolution
  41882. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41883. * Check your browser for supported MIME types
  41884. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41885. * to the src parameter of an <img> to display it
  41886. */
  41887. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  41888. /**
  41889. * Generates an image screenshot from the specified camera.
  41890. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41891. * @param engine The engine to use for rendering
  41892. * @param camera The camera to use for rendering
  41893. * @param size This parameter can be set to a single number or to an object with the
  41894. * following (optional) properties: precision, width, height. If a single number is passed,
  41895. * it will be used for both width and height. If an object is passed, the screenshot size
  41896. * will be derived from the parameters. The precision property is a multiplier allowing
  41897. * rendering at a higher or lower resolution
  41898. * @param successCallback The callback receives a single parameter which contains the
  41899. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41900. * src parameter of an <img> to display it
  41901. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41902. * Check your browser for supported MIME types
  41903. * @param samples Texture samples (default: 1)
  41904. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41905. * @param fileName A name for for the downloaded file.
  41906. */
  41907. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  41908. /**
  41909. * Generates an image screenshot from the specified camera.
  41910. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41911. * @param engine The engine to use for rendering
  41912. * @param camera The camera to use for rendering
  41913. * @param size This parameter can be set to a single number or to an object with the
  41914. * following (optional) properties: precision, width, height. If a single number is passed,
  41915. * it will be used for both width and height. If an object is passed, the screenshot size
  41916. * will be derived from the parameters. The precision property is a multiplier allowing
  41917. * rendering at a higher or lower resolution
  41918. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41919. * Check your browser for supported MIME types
  41920. * @param samples Texture samples (default: 1)
  41921. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41922. * @param fileName A name for for the downloaded file.
  41923. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41924. * to the src parameter of an <img> to display it
  41925. */
  41926. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  41927. /**
  41928. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  41929. * Be aware Math.random() could cause collisions, but:
  41930. * "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"
  41931. * @returns a pseudo random id
  41932. */
  41933. static RandomId(): string;
  41934. /**
  41935. * Test if the given uri is a base64 string
  41936. * @param uri The uri to test
  41937. * @return True if the uri is a base64 string or false otherwise
  41938. */
  41939. static IsBase64(uri: string): boolean;
  41940. /**
  41941. * Decode the given base64 uri.
  41942. * @param uri The uri to decode
  41943. * @return The decoded base64 data.
  41944. */
  41945. static DecodeBase64(uri: string): ArrayBuffer;
  41946. /**
  41947. * Gets the absolute url.
  41948. * @param url the input url
  41949. * @return the absolute url
  41950. */
  41951. static GetAbsoluteUrl(url: string): string;
  41952. /**
  41953. * No log
  41954. */
  41955. static readonly NoneLogLevel: number;
  41956. /**
  41957. * Only message logs
  41958. */
  41959. static readonly MessageLogLevel: number;
  41960. /**
  41961. * Only warning logs
  41962. */
  41963. static readonly WarningLogLevel: number;
  41964. /**
  41965. * Only error logs
  41966. */
  41967. static readonly ErrorLogLevel: number;
  41968. /**
  41969. * All logs
  41970. */
  41971. static readonly AllLogLevel: number;
  41972. /**
  41973. * Gets a value indicating the number of loading errors
  41974. * @ignorenaming
  41975. */
  41976. static get errorsCount(): number;
  41977. /**
  41978. * Callback called when a new log is added
  41979. */
  41980. static OnNewCacheEntry: (entry: string) => void;
  41981. /**
  41982. * Log a message to the console
  41983. * @param message defines the message to log
  41984. */
  41985. static Log(message: string): void;
  41986. /**
  41987. * Write a warning message to the console
  41988. * @param message defines the message to log
  41989. */
  41990. static Warn(message: string): void;
  41991. /**
  41992. * Write an error message to the console
  41993. * @param message defines the message to log
  41994. */
  41995. static Error(message: string): void;
  41996. /**
  41997. * Gets current log cache (list of logs)
  41998. */
  41999. static get LogCache(): string;
  42000. /**
  42001. * Clears the log cache
  42002. */
  42003. static ClearLogCache(): void;
  42004. /**
  42005. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  42006. */
  42007. static set LogLevels(level: number);
  42008. /**
  42009. * Checks if the window object exists
  42010. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  42011. */
  42012. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  42013. /**
  42014. * No performance log
  42015. */
  42016. static readonly PerformanceNoneLogLevel: number;
  42017. /**
  42018. * Use user marks to log performance
  42019. */
  42020. static readonly PerformanceUserMarkLogLevel: number;
  42021. /**
  42022. * Log performance to the console
  42023. */
  42024. static readonly PerformanceConsoleLogLevel: number;
  42025. private static _performance;
  42026. /**
  42027. * Sets the current performance log level
  42028. */
  42029. static set PerformanceLogLevel(level: number);
  42030. private static _StartPerformanceCounterDisabled;
  42031. private static _EndPerformanceCounterDisabled;
  42032. private static _StartUserMark;
  42033. private static _EndUserMark;
  42034. private static _StartPerformanceConsole;
  42035. private static _EndPerformanceConsole;
  42036. /**
  42037. * Starts a performance counter
  42038. */
  42039. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42040. /**
  42041. * Ends a specific performance coutner
  42042. */
  42043. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42044. /**
  42045. * Gets either window.performance.now() if supported or Date.now() else
  42046. */
  42047. static get Now(): number;
  42048. /**
  42049. * This method will return the name of the class used to create the instance of the given object.
  42050. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  42051. * @param object the object to get the class name from
  42052. * @param isType defines if the object is actually a type
  42053. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  42054. */
  42055. static GetClassName(object: any, isType?: boolean): string;
  42056. /**
  42057. * Gets the first element of an array satisfying a given predicate
  42058. * @param array defines the array to browse
  42059. * @param predicate defines the predicate to use
  42060. * @returns null if not found or the element
  42061. */
  42062. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  42063. /**
  42064. * This method will return the name of the full name of the class, including its owning module (if any).
  42065. * 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).
  42066. * @param object the object to get the class name from
  42067. * @param isType defines if the object is actually a type
  42068. * @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.
  42069. * @ignorenaming
  42070. */
  42071. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  42072. /**
  42073. * Returns a promise that resolves after the given amount of time.
  42074. * @param delay Number of milliseconds to delay
  42075. * @returns Promise that resolves after the given amount of time
  42076. */
  42077. static DelayAsync(delay: number): Promise<void>;
  42078. /**
  42079. * Utility function to detect if the current user agent is Safari
  42080. * @returns whether or not the current user agent is safari
  42081. */
  42082. static IsSafari(): boolean;
  42083. }
  42084. /**
  42085. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  42086. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  42087. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  42088. * @param name The name of the class, case should be preserved
  42089. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  42090. */
  42091. export function className(name: string, module?: string): (target: Object) => void;
  42092. /**
  42093. * An implementation of a loop for asynchronous functions.
  42094. */
  42095. export class AsyncLoop {
  42096. /**
  42097. * Defines the number of iterations for the loop
  42098. */
  42099. iterations: number;
  42100. /**
  42101. * Defines the current index of the loop.
  42102. */
  42103. index: number;
  42104. private _done;
  42105. private _fn;
  42106. private _successCallback;
  42107. /**
  42108. * Constructor.
  42109. * @param iterations the number of iterations.
  42110. * @param func the function to run each iteration
  42111. * @param successCallback the callback that will be called upon succesful execution
  42112. * @param offset starting offset.
  42113. */
  42114. constructor(
  42115. /**
  42116. * Defines the number of iterations for the loop
  42117. */
  42118. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  42119. /**
  42120. * Execute the next iteration. Must be called after the last iteration was finished.
  42121. */
  42122. executeNext(): void;
  42123. /**
  42124. * Break the loop and run the success callback.
  42125. */
  42126. breakLoop(): void;
  42127. /**
  42128. * Create and run an async loop.
  42129. * @param iterations the number of iterations.
  42130. * @param fn the function to run each iteration
  42131. * @param successCallback the callback that will be called upon succesful execution
  42132. * @param offset starting offset.
  42133. * @returns the created async loop object
  42134. */
  42135. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  42136. /**
  42137. * A for-loop that will run a given number of iterations synchronous and the rest async.
  42138. * @param iterations total number of iterations
  42139. * @param syncedIterations number of synchronous iterations in each async iteration.
  42140. * @param fn the function to call each iteration.
  42141. * @param callback a success call back that will be called when iterating stops.
  42142. * @param breakFunction a break condition (optional)
  42143. * @param timeout timeout settings for the setTimeout function. default - 0.
  42144. * @returns the created async loop object
  42145. */
  42146. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  42147. }
  42148. }
  42149. declare module BABYLON {
  42150. /**
  42151. * This class implement a typical dictionary using a string as key and the generic type T as value.
  42152. * The underlying implementation relies on an associative array to ensure the best performances.
  42153. * The value can be anything including 'null' but except 'undefined'
  42154. */
  42155. export class StringDictionary<T> {
  42156. /**
  42157. * This will clear this dictionary and copy the content from the 'source' one.
  42158. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  42159. * @param source the dictionary to take the content from and copy to this dictionary
  42160. */
  42161. copyFrom(source: StringDictionary<T>): void;
  42162. /**
  42163. * Get a value based from its key
  42164. * @param key the given key to get the matching value from
  42165. * @return the value if found, otherwise undefined is returned
  42166. */
  42167. get(key: string): T | undefined;
  42168. /**
  42169. * Get a value from its key or add it if it doesn't exist.
  42170. * This method will ensure you that a given key/data will be present in the dictionary.
  42171. * @param key the given key to get the matching value from
  42172. * @param factory the factory that will create the value if the key is not present in the dictionary.
  42173. * The factory will only be invoked if there's no data for the given key.
  42174. * @return the value corresponding to the key.
  42175. */
  42176. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  42177. /**
  42178. * Get a value from its key if present in the dictionary otherwise add it
  42179. * @param key the key to get the value from
  42180. * @param val if there's no such key/value pair in the dictionary add it with this value
  42181. * @return the value corresponding to the key
  42182. */
  42183. getOrAdd(key: string, val: T): T;
  42184. /**
  42185. * Check if there's a given key in the dictionary
  42186. * @param key the key to check for
  42187. * @return true if the key is present, false otherwise
  42188. */
  42189. contains(key: string): boolean;
  42190. /**
  42191. * Add a new key and its corresponding value
  42192. * @param key the key to add
  42193. * @param value the value corresponding to the key
  42194. * @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
  42195. */
  42196. add(key: string, value: T): boolean;
  42197. /**
  42198. * Update a specific value associated to a key
  42199. * @param key defines the key to use
  42200. * @param value defines the value to store
  42201. * @returns true if the value was updated (or false if the key was not found)
  42202. */
  42203. set(key: string, value: T): boolean;
  42204. /**
  42205. * Get the element of the given key and remove it from the dictionary
  42206. * @param key defines the key to search
  42207. * @returns the value associated with the key or null if not found
  42208. */
  42209. getAndRemove(key: string): Nullable<T>;
  42210. /**
  42211. * Remove a key/value from the dictionary.
  42212. * @param key the key to remove
  42213. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  42214. */
  42215. remove(key: string): boolean;
  42216. /**
  42217. * Clear the whole content of the dictionary
  42218. */
  42219. clear(): void;
  42220. /**
  42221. * Gets the current count
  42222. */
  42223. get count(): number;
  42224. /**
  42225. * Execute a callback on each key/val of the dictionary.
  42226. * Note that you can remove any element in this dictionary in the callback implementation
  42227. * @param callback the callback to execute on a given key/value pair
  42228. */
  42229. forEach(callback: (key: string, val: T) => void): void;
  42230. /**
  42231. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  42232. * If the callback returns null or undefined the method will iterate to the next key/value pair
  42233. * Note that you can remove any element in this dictionary in the callback implementation
  42234. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  42235. * @returns the first item
  42236. */
  42237. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  42238. private _count;
  42239. private _data;
  42240. }
  42241. }
  42242. declare module BABYLON {
  42243. /** @hidden */
  42244. export interface ICollisionCoordinator {
  42245. createCollider(): Collider;
  42246. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42247. init(scene: Scene): void;
  42248. }
  42249. /** @hidden */
  42250. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  42251. private _scene;
  42252. private _scaledPosition;
  42253. private _scaledVelocity;
  42254. private _finalPosition;
  42255. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42256. createCollider(): Collider;
  42257. init(scene: Scene): void;
  42258. private _collideWithWorld;
  42259. }
  42260. }
  42261. declare module BABYLON {
  42262. /**
  42263. * Class used to manage all inputs for the scene.
  42264. */
  42265. export class InputManager {
  42266. /** The distance in pixel that you have to move to prevent some events */
  42267. static DragMovementThreshold: number;
  42268. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42269. static LongPressDelay: number;
  42270. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42271. static DoubleClickDelay: number;
  42272. /** If you need to check double click without raising a single click at first click, enable this flag */
  42273. static ExclusiveDoubleClickMode: boolean;
  42274. /** 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. */
  42275. private _alreadyAttached;
  42276. private _alreadyAttachedTo;
  42277. private _wheelEventName;
  42278. private _onPointerMove;
  42279. private _onPointerDown;
  42280. private _onPointerUp;
  42281. private _initClickEvent;
  42282. private _initActionManager;
  42283. private _delayedSimpleClick;
  42284. private _delayedSimpleClickTimeout;
  42285. private _previousDelayedSimpleClickTimeout;
  42286. private _meshPickProceed;
  42287. private _previousButtonPressed;
  42288. private _currentPickResult;
  42289. private _previousPickResult;
  42290. private _totalPointersPressed;
  42291. private _doubleClickOccured;
  42292. private _pointerOverMesh;
  42293. private _pickedDownMesh;
  42294. private _pickedUpMesh;
  42295. private _pointerX;
  42296. private _pointerY;
  42297. private _unTranslatedPointerX;
  42298. private _unTranslatedPointerY;
  42299. private _startingPointerPosition;
  42300. private _previousStartingPointerPosition;
  42301. private _startingPointerTime;
  42302. private _previousStartingPointerTime;
  42303. private _pointerCaptures;
  42304. private _meshUnderPointerId;
  42305. private _onKeyDown;
  42306. private _onKeyUp;
  42307. private _keyboardIsAttached;
  42308. private _onCanvasFocusObserver;
  42309. private _onCanvasBlurObserver;
  42310. private _scene;
  42311. /**
  42312. * Creates a new InputManager
  42313. * @param scene defines the hosting scene
  42314. */
  42315. constructor(scene: Scene);
  42316. /**
  42317. * Gets the mesh that is currently under the pointer
  42318. */
  42319. get meshUnderPointer(): Nullable<AbstractMesh>;
  42320. /**
  42321. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42322. * @param pointerId the pointer id to use
  42323. * @returns The mesh under this pointer id or null if not found
  42324. */
  42325. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42326. /**
  42327. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42328. */
  42329. get unTranslatedPointer(): Vector2;
  42330. /**
  42331. * Gets or sets the current on-screen X position of the pointer
  42332. */
  42333. get pointerX(): number;
  42334. set pointerX(value: number);
  42335. /**
  42336. * Gets or sets the current on-screen Y position of the pointer
  42337. */
  42338. get pointerY(): number;
  42339. set pointerY(value: number);
  42340. private _updatePointerPosition;
  42341. private _processPointerMove;
  42342. private _setRayOnPointerInfo;
  42343. private _checkPrePointerObservable;
  42344. /**
  42345. * Use this method to simulate a pointer move on a mesh
  42346. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42347. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42348. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42349. */
  42350. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42351. /**
  42352. * Use this method to simulate a pointer down on a mesh
  42353. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42354. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42355. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42356. */
  42357. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42358. private _processPointerDown;
  42359. /** @hidden */
  42360. _isPointerSwiping(): boolean;
  42361. /**
  42362. * Use this method to simulate a pointer up on a mesh
  42363. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42364. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42365. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42366. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42367. */
  42368. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42369. private _processPointerUp;
  42370. /**
  42371. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42372. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42373. * @returns true if the pointer was captured
  42374. */
  42375. isPointerCaptured(pointerId?: number): boolean;
  42376. /**
  42377. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42378. * @param attachUp defines if you want to attach events to pointerup
  42379. * @param attachDown defines if you want to attach events to pointerdown
  42380. * @param attachMove defines if you want to attach events to pointermove
  42381. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42382. */
  42383. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42384. /**
  42385. * Detaches all event handlers
  42386. */
  42387. detachControl(): void;
  42388. /**
  42389. * Force the value of meshUnderPointer
  42390. * @param mesh defines the mesh to use
  42391. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42392. */
  42393. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42394. /**
  42395. * Gets the mesh under the pointer
  42396. * @returns a Mesh or null if no mesh is under the pointer
  42397. */
  42398. getPointerOverMesh(): Nullable<AbstractMesh>;
  42399. }
  42400. }
  42401. declare module BABYLON {
  42402. /**
  42403. * This class defines the direct association between an animation and a target
  42404. */
  42405. export class TargetedAnimation {
  42406. /**
  42407. * Animation to perform
  42408. */
  42409. animation: Animation;
  42410. /**
  42411. * Target to animate
  42412. */
  42413. target: any;
  42414. /**
  42415. * Returns the string "TargetedAnimation"
  42416. * @returns "TargetedAnimation"
  42417. */
  42418. getClassName(): string;
  42419. /**
  42420. * Serialize the object
  42421. * @returns the JSON object representing the current entity
  42422. */
  42423. serialize(): any;
  42424. }
  42425. /**
  42426. * Use this class to create coordinated animations on multiple targets
  42427. */
  42428. export class AnimationGroup implements IDisposable {
  42429. /** The name of the animation group */
  42430. name: string;
  42431. private _scene;
  42432. private _targetedAnimations;
  42433. private _animatables;
  42434. private _from;
  42435. private _to;
  42436. private _isStarted;
  42437. private _isPaused;
  42438. private _speedRatio;
  42439. private _loopAnimation;
  42440. private _isAdditive;
  42441. /**
  42442. * Gets or sets the unique id of the node
  42443. */
  42444. uniqueId: number;
  42445. /**
  42446. * This observable will notify when one animation have ended
  42447. */
  42448. onAnimationEndObservable: Observable<TargetedAnimation>;
  42449. /**
  42450. * Observer raised when one animation loops
  42451. */
  42452. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42453. /**
  42454. * Observer raised when all animations have looped
  42455. */
  42456. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42457. /**
  42458. * This observable will notify when all animations have ended.
  42459. */
  42460. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42461. /**
  42462. * This observable will notify when all animations have paused.
  42463. */
  42464. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42465. /**
  42466. * This observable will notify when all animations are playing.
  42467. */
  42468. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42469. /**
  42470. * Gets the first frame
  42471. */
  42472. get from(): number;
  42473. /**
  42474. * Gets the last frame
  42475. */
  42476. get to(): number;
  42477. /**
  42478. * Define if the animations are started
  42479. */
  42480. get isStarted(): boolean;
  42481. /**
  42482. * Gets a value indicating that the current group is playing
  42483. */
  42484. get isPlaying(): boolean;
  42485. /**
  42486. * Gets or sets the speed ratio to use for all animations
  42487. */
  42488. get speedRatio(): number;
  42489. /**
  42490. * Gets or sets the speed ratio to use for all animations
  42491. */
  42492. set speedRatio(value: number);
  42493. /**
  42494. * Gets or sets if all animations should loop or not
  42495. */
  42496. get loopAnimation(): boolean;
  42497. set loopAnimation(value: boolean);
  42498. /**
  42499. * Gets or sets if all animations should be evaluated additively
  42500. */
  42501. get isAdditive(): boolean;
  42502. set isAdditive(value: boolean);
  42503. /**
  42504. * Gets the targeted animations for this animation group
  42505. */
  42506. get targetedAnimations(): Array<TargetedAnimation>;
  42507. /**
  42508. * returning the list of animatables controlled by this animation group.
  42509. */
  42510. get animatables(): Array<Animatable>;
  42511. /**
  42512. * Gets the list of target animations
  42513. */
  42514. get children(): TargetedAnimation[];
  42515. /**
  42516. * Instantiates a new Animation Group.
  42517. * This helps managing several animations at once.
  42518. * @see https://doc.babylonjs.com/how_to/group
  42519. * @param name Defines the name of the group
  42520. * @param scene Defines the scene the group belongs to
  42521. */
  42522. constructor(
  42523. /** The name of the animation group */
  42524. name: string, scene?: Nullable<Scene>);
  42525. /**
  42526. * Add an animation (with its target) in the group
  42527. * @param animation defines the animation we want to add
  42528. * @param target defines the target of the animation
  42529. * @returns the TargetedAnimation object
  42530. */
  42531. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42532. /**
  42533. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42534. * It can add constant keys at begin or end
  42535. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42536. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42537. * @returns the animation group
  42538. */
  42539. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42540. private _animationLoopCount;
  42541. private _animationLoopFlags;
  42542. private _processLoop;
  42543. /**
  42544. * Start all animations on given targets
  42545. * @param loop defines if animations must loop
  42546. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42547. * @param from defines the from key (optional)
  42548. * @param to defines the to key (optional)
  42549. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42550. * @returns the current animation group
  42551. */
  42552. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42553. /**
  42554. * Pause all animations
  42555. * @returns the animation group
  42556. */
  42557. pause(): AnimationGroup;
  42558. /**
  42559. * Play all animations to initial state
  42560. * This function will start() the animations if they were not started or will restart() them if they were paused
  42561. * @param loop defines if animations must loop
  42562. * @returns the animation group
  42563. */
  42564. play(loop?: boolean): AnimationGroup;
  42565. /**
  42566. * Reset all animations to initial state
  42567. * @returns the animation group
  42568. */
  42569. reset(): AnimationGroup;
  42570. /**
  42571. * Restart animations from key 0
  42572. * @returns the animation group
  42573. */
  42574. restart(): AnimationGroup;
  42575. /**
  42576. * Stop all animations
  42577. * @returns the animation group
  42578. */
  42579. stop(): AnimationGroup;
  42580. /**
  42581. * Set animation weight for all animatables
  42582. * @param weight defines the weight to use
  42583. * @return the animationGroup
  42584. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42585. */
  42586. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42587. /**
  42588. * Synchronize and normalize all animatables with a source animatable
  42589. * @param root defines the root animatable to synchronize with
  42590. * @return the animationGroup
  42591. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42592. */
  42593. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42594. /**
  42595. * Goes to a specific frame in this animation group
  42596. * @param frame the frame number to go to
  42597. * @return the animationGroup
  42598. */
  42599. goToFrame(frame: number): AnimationGroup;
  42600. /**
  42601. * Dispose all associated resources
  42602. */
  42603. dispose(): void;
  42604. private _checkAnimationGroupEnded;
  42605. /**
  42606. * Clone the current animation group and returns a copy
  42607. * @param newName defines the name of the new group
  42608. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42609. * @returns the new aniamtion group
  42610. */
  42611. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42612. /**
  42613. * Serializes the animationGroup to an object
  42614. * @returns Serialized object
  42615. */
  42616. serialize(): any;
  42617. /**
  42618. * Returns a new AnimationGroup object parsed from the source provided.
  42619. * @param parsedAnimationGroup defines the source
  42620. * @param scene defines the scene that will receive the animationGroup
  42621. * @returns a new AnimationGroup
  42622. */
  42623. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42624. /**
  42625. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42626. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42627. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42628. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42629. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42630. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42631. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42632. */
  42633. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42634. /**
  42635. * Returns the string "AnimationGroup"
  42636. * @returns "AnimationGroup"
  42637. */
  42638. getClassName(): string;
  42639. /**
  42640. * Creates a detailled string about the object
  42641. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42642. * @returns a string representing the object
  42643. */
  42644. toString(fullDetails?: boolean): string;
  42645. }
  42646. }
  42647. declare module BABYLON {
  42648. /**
  42649. * Define an interface for all classes that will hold resources
  42650. */
  42651. export interface IDisposable {
  42652. /**
  42653. * Releases all held resources
  42654. */
  42655. dispose(): void;
  42656. }
  42657. /** Interface defining initialization parameters for Scene class */
  42658. export interface SceneOptions {
  42659. /**
  42660. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42661. * It will improve performance when the number of geometries becomes important.
  42662. */
  42663. useGeometryUniqueIdsMap?: boolean;
  42664. /**
  42665. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42666. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42667. */
  42668. useMaterialMeshMap?: boolean;
  42669. /**
  42670. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42671. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42672. */
  42673. useClonedMeshMap?: boolean;
  42674. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42675. virtual?: boolean;
  42676. }
  42677. /**
  42678. * Represents a scene to be rendered by the engine.
  42679. * @see https://doc.babylonjs.com/features/scene
  42680. */
  42681. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42682. /** The fog is deactivated */
  42683. static readonly FOGMODE_NONE: number;
  42684. /** The fog density is following an exponential function */
  42685. static readonly FOGMODE_EXP: number;
  42686. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42687. static readonly FOGMODE_EXP2: number;
  42688. /** The fog density is following a linear function. */
  42689. static readonly FOGMODE_LINEAR: number;
  42690. /**
  42691. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42692. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42693. */
  42694. static MinDeltaTime: number;
  42695. /**
  42696. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42697. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42698. */
  42699. static MaxDeltaTime: number;
  42700. /**
  42701. * Factory used to create the default material.
  42702. * @param name The name of the material to create
  42703. * @param scene The scene to create the material for
  42704. * @returns The default material
  42705. */
  42706. static DefaultMaterialFactory(scene: Scene): Material;
  42707. /**
  42708. * Factory used to create the a collision coordinator.
  42709. * @returns The collision coordinator
  42710. */
  42711. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42712. /** @hidden */
  42713. _inputManager: InputManager;
  42714. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42715. cameraToUseForPointers: Nullable<Camera>;
  42716. /** @hidden */
  42717. readonly _isScene: boolean;
  42718. /** @hidden */
  42719. _blockEntityCollection: boolean;
  42720. /**
  42721. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42722. */
  42723. autoClear: boolean;
  42724. /**
  42725. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42726. */
  42727. autoClearDepthAndStencil: boolean;
  42728. /**
  42729. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42730. */
  42731. clearColor: Color4;
  42732. /**
  42733. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42734. */
  42735. ambientColor: Color3;
  42736. /**
  42737. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42738. * It should only be one of the following (if not the default embedded one):
  42739. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42740. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42741. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42742. * The material properties need to be setup according to the type of texture in use.
  42743. */
  42744. environmentBRDFTexture: BaseTexture;
  42745. /**
  42746. * Texture used in all pbr material as the reflection texture.
  42747. * As in the majority of the scene they are the same (exception for multi room and so on),
  42748. * this is easier to reference from here than from all the materials.
  42749. */
  42750. get environmentTexture(): Nullable<BaseTexture>;
  42751. /**
  42752. * Texture used in all pbr material as the reflection texture.
  42753. * As in the majority of the scene they are the same (exception for multi room and so on),
  42754. * this is easier to set here than in all the materials.
  42755. */
  42756. set environmentTexture(value: Nullable<BaseTexture>);
  42757. /** @hidden */
  42758. protected _environmentIntensity: number;
  42759. /**
  42760. * Intensity of the environment in all pbr material.
  42761. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42762. * As in the majority of the scene they are the same (exception for multi room and so on),
  42763. * this is easier to reference from here than from all the materials.
  42764. */
  42765. get environmentIntensity(): number;
  42766. /**
  42767. * Intensity of the environment in all pbr material.
  42768. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42769. * As in the majority of the scene they are the same (exception for multi room and so on),
  42770. * this is easier to set here than in all the materials.
  42771. */
  42772. set environmentIntensity(value: number);
  42773. /** @hidden */
  42774. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42775. /**
  42776. * Default image processing configuration used either in the rendering
  42777. * Forward main pass or through the imageProcessingPostProcess if present.
  42778. * As in the majority of the scene they are the same (exception for multi camera),
  42779. * this is easier to reference from here than from all the materials and post process.
  42780. *
  42781. * No setter as we it is a shared configuration, you can set the values instead.
  42782. */
  42783. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42784. private _forceWireframe;
  42785. /**
  42786. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42787. */
  42788. set forceWireframe(value: boolean);
  42789. get forceWireframe(): boolean;
  42790. private _skipFrustumClipping;
  42791. /**
  42792. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42793. */
  42794. set skipFrustumClipping(value: boolean);
  42795. get skipFrustumClipping(): boolean;
  42796. private _forcePointsCloud;
  42797. /**
  42798. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42799. */
  42800. set forcePointsCloud(value: boolean);
  42801. get forcePointsCloud(): boolean;
  42802. /**
  42803. * Gets or sets the active clipplane 1
  42804. */
  42805. clipPlane: Nullable<Plane>;
  42806. /**
  42807. * Gets or sets the active clipplane 2
  42808. */
  42809. clipPlane2: Nullable<Plane>;
  42810. /**
  42811. * Gets or sets the active clipplane 3
  42812. */
  42813. clipPlane3: Nullable<Plane>;
  42814. /**
  42815. * Gets or sets the active clipplane 4
  42816. */
  42817. clipPlane4: Nullable<Plane>;
  42818. /**
  42819. * Gets or sets the active clipplane 5
  42820. */
  42821. clipPlane5: Nullable<Plane>;
  42822. /**
  42823. * Gets or sets the active clipplane 6
  42824. */
  42825. clipPlane6: Nullable<Plane>;
  42826. /**
  42827. * Gets or sets a boolean indicating if animations are enabled
  42828. */
  42829. animationsEnabled: boolean;
  42830. private _animationPropertiesOverride;
  42831. /**
  42832. * Gets or sets the animation properties override
  42833. */
  42834. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  42835. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  42836. /**
  42837. * Gets or sets a boolean indicating if a constant deltatime has to be used
  42838. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  42839. */
  42840. useConstantAnimationDeltaTime: boolean;
  42841. /**
  42842. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  42843. * Please note that it requires to run a ray cast through the scene on every frame
  42844. */
  42845. constantlyUpdateMeshUnderPointer: boolean;
  42846. /**
  42847. * Defines the HTML cursor to use when hovering over interactive elements
  42848. */
  42849. hoverCursor: string;
  42850. /**
  42851. * Defines the HTML default cursor to use (empty by default)
  42852. */
  42853. defaultCursor: string;
  42854. /**
  42855. * Defines whether cursors are handled by the scene.
  42856. */
  42857. doNotHandleCursors: boolean;
  42858. /**
  42859. * This is used to call preventDefault() on pointer down
  42860. * in order to block unwanted artifacts like system double clicks
  42861. */
  42862. preventDefaultOnPointerDown: boolean;
  42863. /**
  42864. * This is used to call preventDefault() on pointer up
  42865. * in order to block unwanted artifacts like system double clicks
  42866. */
  42867. preventDefaultOnPointerUp: boolean;
  42868. /**
  42869. * Gets or sets user defined metadata
  42870. */
  42871. metadata: any;
  42872. /**
  42873. * For internal use only. Please do not use.
  42874. */
  42875. reservedDataStore: any;
  42876. /**
  42877. * Gets the name of the plugin used to load this scene (null by default)
  42878. */
  42879. loadingPluginName: string;
  42880. /**
  42881. * Use this array to add regular expressions used to disable offline support for specific urls
  42882. */
  42883. disableOfflineSupportExceptionRules: RegExp[];
  42884. /**
  42885. * An event triggered when the scene is disposed.
  42886. */
  42887. onDisposeObservable: Observable<Scene>;
  42888. private _onDisposeObserver;
  42889. /** Sets a function to be executed when this scene is disposed. */
  42890. set onDispose(callback: () => void);
  42891. /**
  42892. * An event triggered before rendering the scene (right after animations and physics)
  42893. */
  42894. onBeforeRenderObservable: Observable<Scene>;
  42895. private _onBeforeRenderObserver;
  42896. /** Sets a function to be executed before rendering this scene */
  42897. set beforeRender(callback: Nullable<() => void>);
  42898. /**
  42899. * An event triggered after rendering the scene
  42900. */
  42901. onAfterRenderObservable: Observable<Scene>;
  42902. /**
  42903. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  42904. */
  42905. onAfterRenderCameraObservable: Observable<Camera>;
  42906. private _onAfterRenderObserver;
  42907. /** Sets a function to be executed after rendering this scene */
  42908. set afterRender(callback: Nullable<() => void>);
  42909. /**
  42910. * An event triggered before animating the scene
  42911. */
  42912. onBeforeAnimationsObservable: Observable<Scene>;
  42913. /**
  42914. * An event triggered after animations processing
  42915. */
  42916. onAfterAnimationsObservable: Observable<Scene>;
  42917. /**
  42918. * An event triggered before draw calls are ready to be sent
  42919. */
  42920. onBeforeDrawPhaseObservable: Observable<Scene>;
  42921. /**
  42922. * An event triggered after draw calls have been sent
  42923. */
  42924. onAfterDrawPhaseObservable: Observable<Scene>;
  42925. /**
  42926. * An event triggered when the scene is ready
  42927. */
  42928. onReadyObservable: Observable<Scene>;
  42929. /**
  42930. * An event triggered before rendering a camera
  42931. */
  42932. onBeforeCameraRenderObservable: Observable<Camera>;
  42933. private _onBeforeCameraRenderObserver;
  42934. /** Sets a function to be executed before rendering a camera*/
  42935. set beforeCameraRender(callback: () => void);
  42936. /**
  42937. * An event triggered after rendering a camera
  42938. */
  42939. onAfterCameraRenderObservable: Observable<Camera>;
  42940. private _onAfterCameraRenderObserver;
  42941. /** Sets a function to be executed after rendering a camera*/
  42942. set afterCameraRender(callback: () => void);
  42943. /**
  42944. * An event triggered when active meshes evaluation is about to start
  42945. */
  42946. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  42947. /**
  42948. * An event triggered when active meshes evaluation is done
  42949. */
  42950. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  42951. /**
  42952. * An event triggered when particles rendering is about to start
  42953. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42954. */
  42955. onBeforeParticlesRenderingObservable: Observable<Scene>;
  42956. /**
  42957. * An event triggered when particles rendering is done
  42958. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42959. */
  42960. onAfterParticlesRenderingObservable: Observable<Scene>;
  42961. /**
  42962. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  42963. */
  42964. onDataLoadedObservable: Observable<Scene>;
  42965. /**
  42966. * An event triggered when a camera is created
  42967. */
  42968. onNewCameraAddedObservable: Observable<Camera>;
  42969. /**
  42970. * An event triggered when a camera is removed
  42971. */
  42972. onCameraRemovedObservable: Observable<Camera>;
  42973. /**
  42974. * An event triggered when a light is created
  42975. */
  42976. onNewLightAddedObservable: Observable<Light>;
  42977. /**
  42978. * An event triggered when a light is removed
  42979. */
  42980. onLightRemovedObservable: Observable<Light>;
  42981. /**
  42982. * An event triggered when a geometry is created
  42983. */
  42984. onNewGeometryAddedObservable: Observable<Geometry>;
  42985. /**
  42986. * An event triggered when a geometry is removed
  42987. */
  42988. onGeometryRemovedObservable: Observable<Geometry>;
  42989. /**
  42990. * An event triggered when a transform node is created
  42991. */
  42992. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  42993. /**
  42994. * An event triggered when a transform node is removed
  42995. */
  42996. onTransformNodeRemovedObservable: Observable<TransformNode>;
  42997. /**
  42998. * An event triggered when a mesh is created
  42999. */
  43000. onNewMeshAddedObservable: Observable<AbstractMesh>;
  43001. /**
  43002. * An event triggered when a mesh is removed
  43003. */
  43004. onMeshRemovedObservable: Observable<AbstractMesh>;
  43005. /**
  43006. * An event triggered when a skeleton is created
  43007. */
  43008. onNewSkeletonAddedObservable: Observable<Skeleton>;
  43009. /**
  43010. * An event triggered when a skeleton is removed
  43011. */
  43012. onSkeletonRemovedObservable: Observable<Skeleton>;
  43013. /**
  43014. * An event triggered when a material is created
  43015. */
  43016. onNewMaterialAddedObservable: Observable<Material>;
  43017. /**
  43018. * An event triggered when a material is removed
  43019. */
  43020. onMaterialRemovedObservable: Observable<Material>;
  43021. /**
  43022. * An event triggered when a texture is created
  43023. */
  43024. onNewTextureAddedObservable: Observable<BaseTexture>;
  43025. /**
  43026. * An event triggered when a texture is removed
  43027. */
  43028. onTextureRemovedObservable: Observable<BaseTexture>;
  43029. /**
  43030. * An event triggered when render targets are about to be rendered
  43031. * Can happen multiple times per frame.
  43032. */
  43033. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  43034. /**
  43035. * An event triggered when render targets were rendered.
  43036. * Can happen multiple times per frame.
  43037. */
  43038. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  43039. /**
  43040. * An event triggered before calculating deterministic simulation step
  43041. */
  43042. onBeforeStepObservable: Observable<Scene>;
  43043. /**
  43044. * An event triggered after calculating deterministic simulation step
  43045. */
  43046. onAfterStepObservable: Observable<Scene>;
  43047. /**
  43048. * An event triggered when the activeCamera property is updated
  43049. */
  43050. onActiveCameraChanged: Observable<Scene>;
  43051. /**
  43052. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  43053. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43054. * 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)
  43055. */
  43056. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43057. /**
  43058. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  43059. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43060. * 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)
  43061. */
  43062. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43063. /**
  43064. * This Observable will when a mesh has been imported into the scene.
  43065. */
  43066. onMeshImportedObservable: Observable<AbstractMesh>;
  43067. /**
  43068. * This Observable will when an animation file has been imported into the scene.
  43069. */
  43070. onAnimationFileImportedObservable: Observable<Scene>;
  43071. /**
  43072. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  43073. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  43074. */
  43075. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  43076. /** @hidden */
  43077. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  43078. /**
  43079. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  43080. */
  43081. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  43082. /**
  43083. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  43084. */
  43085. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  43086. /**
  43087. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  43088. */
  43089. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  43090. /** Callback called when a pointer move is detected */
  43091. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43092. /** Callback called when a pointer down is detected */
  43093. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43094. /** Callback called when a pointer up is detected */
  43095. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  43096. /** Callback called when a pointer pick is detected */
  43097. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  43098. /**
  43099. * 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).
  43100. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  43101. */
  43102. onPrePointerObservable: Observable<PointerInfoPre>;
  43103. /**
  43104. * Observable event triggered each time an input event is received from the rendering canvas
  43105. */
  43106. onPointerObservable: Observable<PointerInfo>;
  43107. /**
  43108. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  43109. */
  43110. get unTranslatedPointer(): Vector2;
  43111. /**
  43112. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  43113. */
  43114. static get DragMovementThreshold(): number;
  43115. static set DragMovementThreshold(value: number);
  43116. /**
  43117. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  43118. */
  43119. static get LongPressDelay(): number;
  43120. static set LongPressDelay(value: number);
  43121. /**
  43122. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  43123. */
  43124. static get DoubleClickDelay(): number;
  43125. static set DoubleClickDelay(value: number);
  43126. /** If you need to check double click without raising a single click at first click, enable this flag */
  43127. static get ExclusiveDoubleClickMode(): boolean;
  43128. static set ExclusiveDoubleClickMode(value: boolean);
  43129. /** @hidden */
  43130. _mirroredCameraPosition: Nullable<Vector3>;
  43131. /**
  43132. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  43133. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  43134. */
  43135. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  43136. /**
  43137. * Observable event triggered each time an keyboard event is received from the hosting window
  43138. */
  43139. onKeyboardObservable: Observable<KeyboardInfo>;
  43140. private _useRightHandedSystem;
  43141. /**
  43142. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  43143. */
  43144. set useRightHandedSystem(value: boolean);
  43145. get useRightHandedSystem(): boolean;
  43146. private _timeAccumulator;
  43147. private _currentStepId;
  43148. private _currentInternalStep;
  43149. /**
  43150. * Sets the step Id used by deterministic lock step
  43151. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43152. * @param newStepId defines the step Id
  43153. */
  43154. setStepId(newStepId: number): void;
  43155. /**
  43156. * Gets the step Id used by deterministic lock step
  43157. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43158. * @returns the step Id
  43159. */
  43160. getStepId(): number;
  43161. /**
  43162. * Gets the internal step used by deterministic lock step
  43163. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43164. * @returns the internal step
  43165. */
  43166. getInternalStep(): number;
  43167. private _fogEnabled;
  43168. /**
  43169. * Gets or sets a boolean indicating if fog is enabled on this scene
  43170. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43171. * (Default is true)
  43172. */
  43173. set fogEnabled(value: boolean);
  43174. get fogEnabled(): boolean;
  43175. private _fogMode;
  43176. /**
  43177. * Gets or sets the fog mode to use
  43178. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43179. * | mode | value |
  43180. * | --- | --- |
  43181. * | FOGMODE_NONE | 0 |
  43182. * | FOGMODE_EXP | 1 |
  43183. * | FOGMODE_EXP2 | 2 |
  43184. * | FOGMODE_LINEAR | 3 |
  43185. */
  43186. set fogMode(value: number);
  43187. get fogMode(): number;
  43188. /**
  43189. * Gets or sets the fog color to use
  43190. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43191. * (Default is Color3(0.2, 0.2, 0.3))
  43192. */
  43193. fogColor: Color3;
  43194. /**
  43195. * Gets or sets the fog density to use
  43196. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43197. * (Default is 0.1)
  43198. */
  43199. fogDensity: number;
  43200. /**
  43201. * Gets or sets the fog start distance to use
  43202. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43203. * (Default is 0)
  43204. */
  43205. fogStart: number;
  43206. /**
  43207. * Gets or sets the fog end distance to use
  43208. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43209. * (Default is 1000)
  43210. */
  43211. fogEnd: number;
  43212. /**
  43213. * Flag indicating that the frame buffer binding is handled by another component
  43214. */
  43215. prePass: boolean;
  43216. private _shadowsEnabled;
  43217. /**
  43218. * Gets or sets a boolean indicating if shadows are enabled on this scene
  43219. */
  43220. set shadowsEnabled(value: boolean);
  43221. get shadowsEnabled(): boolean;
  43222. private _lightsEnabled;
  43223. /**
  43224. * Gets or sets a boolean indicating if lights are enabled on this scene
  43225. */
  43226. set lightsEnabled(value: boolean);
  43227. get lightsEnabled(): boolean;
  43228. /** All of the active cameras added to this scene. */
  43229. activeCameras: Camera[];
  43230. /** @hidden */
  43231. _activeCamera: Nullable<Camera>;
  43232. /** Gets or sets the current active camera */
  43233. get activeCamera(): Nullable<Camera>;
  43234. set activeCamera(value: Nullable<Camera>);
  43235. private _defaultMaterial;
  43236. /** The default material used on meshes when no material is affected */
  43237. get defaultMaterial(): Material;
  43238. /** The default material used on meshes when no material is affected */
  43239. set defaultMaterial(value: Material);
  43240. private _texturesEnabled;
  43241. /**
  43242. * Gets or sets a boolean indicating if textures are enabled on this scene
  43243. */
  43244. set texturesEnabled(value: boolean);
  43245. get texturesEnabled(): boolean;
  43246. /**
  43247. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  43248. */
  43249. physicsEnabled: boolean;
  43250. /**
  43251. * Gets or sets a boolean indicating if particles are enabled on this scene
  43252. */
  43253. particlesEnabled: boolean;
  43254. /**
  43255. * Gets or sets a boolean indicating if sprites are enabled on this scene
  43256. */
  43257. spritesEnabled: boolean;
  43258. private _skeletonsEnabled;
  43259. /**
  43260. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  43261. */
  43262. set skeletonsEnabled(value: boolean);
  43263. get skeletonsEnabled(): boolean;
  43264. /**
  43265. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  43266. */
  43267. lensFlaresEnabled: boolean;
  43268. /**
  43269. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43270. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43271. */
  43272. collisionsEnabled: boolean;
  43273. private _collisionCoordinator;
  43274. /** @hidden */
  43275. get collisionCoordinator(): ICollisionCoordinator;
  43276. /**
  43277. * Defines the gravity applied to this scene (used only for collisions)
  43278. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43279. */
  43280. gravity: Vector3;
  43281. /**
  43282. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43283. */
  43284. postProcessesEnabled: boolean;
  43285. /**
  43286. * Gets the current postprocess manager
  43287. */
  43288. postProcessManager: PostProcessManager;
  43289. /**
  43290. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43291. */
  43292. renderTargetsEnabled: boolean;
  43293. /**
  43294. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43295. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43296. */
  43297. dumpNextRenderTargets: boolean;
  43298. /**
  43299. * The list of user defined render targets added to the scene
  43300. */
  43301. customRenderTargets: RenderTargetTexture[];
  43302. /**
  43303. * Defines if texture loading must be delayed
  43304. * If true, textures will only be loaded when they need to be rendered
  43305. */
  43306. useDelayedTextureLoading: boolean;
  43307. /**
  43308. * Gets the list of meshes imported to the scene through SceneLoader
  43309. */
  43310. importedMeshesFiles: String[];
  43311. /**
  43312. * Gets or sets a boolean indicating if probes are enabled on this scene
  43313. */
  43314. probesEnabled: boolean;
  43315. /**
  43316. * Gets or sets the current offline provider to use to store scene data
  43317. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43318. */
  43319. offlineProvider: IOfflineProvider;
  43320. /**
  43321. * Gets or sets the action manager associated with the scene
  43322. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43323. */
  43324. actionManager: AbstractActionManager;
  43325. private _meshesForIntersections;
  43326. /**
  43327. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43328. */
  43329. proceduralTexturesEnabled: boolean;
  43330. private _engine;
  43331. private _totalVertices;
  43332. /** @hidden */
  43333. _activeIndices: PerfCounter;
  43334. /** @hidden */
  43335. _activeParticles: PerfCounter;
  43336. /** @hidden */
  43337. _activeBones: PerfCounter;
  43338. private _animationRatio;
  43339. /** @hidden */
  43340. _animationTimeLast: number;
  43341. /** @hidden */
  43342. _animationTime: number;
  43343. /**
  43344. * Gets or sets a general scale for animation speed
  43345. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43346. */
  43347. animationTimeScale: number;
  43348. /** @hidden */
  43349. _cachedMaterial: Nullable<Material>;
  43350. /** @hidden */
  43351. _cachedEffect: Nullable<Effect>;
  43352. /** @hidden */
  43353. _cachedVisibility: Nullable<number>;
  43354. private _renderId;
  43355. private _frameId;
  43356. private _executeWhenReadyTimeoutId;
  43357. private _intermediateRendering;
  43358. private _viewUpdateFlag;
  43359. private _projectionUpdateFlag;
  43360. /** @hidden */
  43361. _toBeDisposed: Nullable<IDisposable>[];
  43362. private _activeRequests;
  43363. /** @hidden */
  43364. _pendingData: any[];
  43365. private _isDisposed;
  43366. /**
  43367. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43368. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43369. */
  43370. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43371. private _activeMeshes;
  43372. private _processedMaterials;
  43373. private _renderTargets;
  43374. /** @hidden */
  43375. _activeParticleSystems: SmartArray<IParticleSystem>;
  43376. private _activeSkeletons;
  43377. private _softwareSkinnedMeshes;
  43378. private _renderingManager;
  43379. /** @hidden */
  43380. _activeAnimatables: Animatable[];
  43381. private _transformMatrix;
  43382. private _sceneUbo;
  43383. /** @hidden */
  43384. _viewMatrix: Matrix;
  43385. private _projectionMatrix;
  43386. /** @hidden */
  43387. _forcedViewPosition: Nullable<Vector3>;
  43388. /** @hidden */
  43389. _frustumPlanes: Plane[];
  43390. /**
  43391. * Gets the list of frustum planes (built from the active camera)
  43392. */
  43393. get frustumPlanes(): Plane[];
  43394. /**
  43395. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43396. * This is useful if there are more lights that the maximum simulteanous authorized
  43397. */
  43398. requireLightSorting: boolean;
  43399. /** @hidden */
  43400. readonly useMaterialMeshMap: boolean;
  43401. /** @hidden */
  43402. readonly useClonedMeshMap: boolean;
  43403. private _externalData;
  43404. private _uid;
  43405. /**
  43406. * @hidden
  43407. * Backing store of defined scene components.
  43408. */
  43409. _components: ISceneComponent[];
  43410. /**
  43411. * @hidden
  43412. * Backing store of defined scene components.
  43413. */
  43414. _serializableComponents: ISceneSerializableComponent[];
  43415. /**
  43416. * List of components to register on the next registration step.
  43417. */
  43418. private _transientComponents;
  43419. /**
  43420. * Registers the transient components if needed.
  43421. */
  43422. private _registerTransientComponents;
  43423. /**
  43424. * @hidden
  43425. * Add a component to the scene.
  43426. * Note that the ccomponent could be registered on th next frame if this is called after
  43427. * the register component stage.
  43428. * @param component Defines the component to add to the scene
  43429. */
  43430. _addComponent(component: ISceneComponent): void;
  43431. /**
  43432. * @hidden
  43433. * Gets a component from the scene.
  43434. * @param name defines the name of the component to retrieve
  43435. * @returns the component or null if not present
  43436. */
  43437. _getComponent(name: string): Nullable<ISceneComponent>;
  43438. /**
  43439. * @hidden
  43440. * Defines the actions happening before camera updates.
  43441. */
  43442. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43443. /**
  43444. * @hidden
  43445. * Defines the actions happening before clear the canvas.
  43446. */
  43447. _beforeClearStage: Stage<SimpleStageAction>;
  43448. /**
  43449. * @hidden
  43450. * Defines the actions when collecting render targets for the frame.
  43451. */
  43452. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43453. /**
  43454. * @hidden
  43455. * Defines the actions happening for one camera in the frame.
  43456. */
  43457. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43458. /**
  43459. * @hidden
  43460. * Defines the actions happening during the per mesh ready checks.
  43461. */
  43462. _isReadyForMeshStage: Stage<MeshStageAction>;
  43463. /**
  43464. * @hidden
  43465. * Defines the actions happening before evaluate active mesh checks.
  43466. */
  43467. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43468. /**
  43469. * @hidden
  43470. * Defines the actions happening during the evaluate sub mesh checks.
  43471. */
  43472. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43473. /**
  43474. * @hidden
  43475. * Defines the actions happening during the active mesh stage.
  43476. */
  43477. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43478. /**
  43479. * @hidden
  43480. * Defines the actions happening during the per camera render target step.
  43481. */
  43482. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43483. /**
  43484. * @hidden
  43485. * Defines the actions happening just before the active camera is drawing.
  43486. */
  43487. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43488. /**
  43489. * @hidden
  43490. * Defines the actions happening just before a render target is drawing.
  43491. */
  43492. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43493. /**
  43494. * @hidden
  43495. * Defines the actions happening just before a rendering group is drawing.
  43496. */
  43497. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43498. /**
  43499. * @hidden
  43500. * Defines the actions happening just before a mesh is drawing.
  43501. */
  43502. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43503. /**
  43504. * @hidden
  43505. * Defines the actions happening just after a mesh has been drawn.
  43506. */
  43507. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43508. /**
  43509. * @hidden
  43510. * Defines the actions happening just after a rendering group has been drawn.
  43511. */
  43512. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43513. /**
  43514. * @hidden
  43515. * Defines the actions happening just after the active camera has been drawn.
  43516. */
  43517. _afterCameraDrawStage: Stage<CameraStageAction>;
  43518. /**
  43519. * @hidden
  43520. * Defines the actions happening just after a render target has been drawn.
  43521. */
  43522. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43523. /**
  43524. * @hidden
  43525. * Defines the actions happening just after rendering all cameras and computing intersections.
  43526. */
  43527. _afterRenderStage: Stage<SimpleStageAction>;
  43528. /**
  43529. * @hidden
  43530. * Defines the actions happening when a pointer move event happens.
  43531. */
  43532. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43533. /**
  43534. * @hidden
  43535. * Defines the actions happening when a pointer down event happens.
  43536. */
  43537. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43538. /**
  43539. * @hidden
  43540. * Defines the actions happening when a pointer up event happens.
  43541. */
  43542. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43543. /**
  43544. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43545. */
  43546. private geometriesByUniqueId;
  43547. /**
  43548. * Creates a new Scene
  43549. * @param engine defines the engine to use to render this scene
  43550. * @param options defines the scene options
  43551. */
  43552. constructor(engine: Engine, options?: SceneOptions);
  43553. /**
  43554. * Gets a string identifying the name of the class
  43555. * @returns "Scene" string
  43556. */
  43557. getClassName(): string;
  43558. private _defaultMeshCandidates;
  43559. /**
  43560. * @hidden
  43561. */
  43562. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43563. private _defaultSubMeshCandidates;
  43564. /**
  43565. * @hidden
  43566. */
  43567. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43568. /**
  43569. * Sets the default candidate providers for the scene.
  43570. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43571. * and getCollidingSubMeshCandidates to their default function
  43572. */
  43573. setDefaultCandidateProviders(): void;
  43574. /**
  43575. * Gets the mesh that is currently under the pointer
  43576. */
  43577. get meshUnderPointer(): Nullable<AbstractMesh>;
  43578. /**
  43579. * Gets or sets the current on-screen X position of the pointer
  43580. */
  43581. get pointerX(): number;
  43582. set pointerX(value: number);
  43583. /**
  43584. * Gets or sets the current on-screen Y position of the pointer
  43585. */
  43586. get pointerY(): number;
  43587. set pointerY(value: number);
  43588. /**
  43589. * Gets the cached material (ie. the latest rendered one)
  43590. * @returns the cached material
  43591. */
  43592. getCachedMaterial(): Nullable<Material>;
  43593. /**
  43594. * Gets the cached effect (ie. the latest rendered one)
  43595. * @returns the cached effect
  43596. */
  43597. getCachedEffect(): Nullable<Effect>;
  43598. /**
  43599. * Gets the cached visibility state (ie. the latest rendered one)
  43600. * @returns the cached visibility state
  43601. */
  43602. getCachedVisibility(): Nullable<number>;
  43603. /**
  43604. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43605. * @param material defines the current material
  43606. * @param effect defines the current effect
  43607. * @param visibility defines the current visibility state
  43608. * @returns true if one parameter is not cached
  43609. */
  43610. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43611. /**
  43612. * Gets the engine associated with the scene
  43613. * @returns an Engine
  43614. */
  43615. getEngine(): Engine;
  43616. /**
  43617. * Gets the total number of vertices rendered per frame
  43618. * @returns the total number of vertices rendered per frame
  43619. */
  43620. getTotalVertices(): number;
  43621. /**
  43622. * Gets the performance counter for total vertices
  43623. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43624. */
  43625. get totalVerticesPerfCounter(): PerfCounter;
  43626. /**
  43627. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43628. * @returns the total number of active indices rendered per frame
  43629. */
  43630. getActiveIndices(): number;
  43631. /**
  43632. * Gets the performance counter for active indices
  43633. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43634. */
  43635. get totalActiveIndicesPerfCounter(): PerfCounter;
  43636. /**
  43637. * Gets the total number of active particles rendered per frame
  43638. * @returns the total number of active particles rendered per frame
  43639. */
  43640. getActiveParticles(): number;
  43641. /**
  43642. * Gets the performance counter for active particles
  43643. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43644. */
  43645. get activeParticlesPerfCounter(): PerfCounter;
  43646. /**
  43647. * Gets the total number of active bones rendered per frame
  43648. * @returns the total number of active bones rendered per frame
  43649. */
  43650. getActiveBones(): number;
  43651. /**
  43652. * Gets the performance counter for active bones
  43653. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43654. */
  43655. get activeBonesPerfCounter(): PerfCounter;
  43656. /**
  43657. * Gets the array of active meshes
  43658. * @returns an array of AbstractMesh
  43659. */
  43660. getActiveMeshes(): SmartArray<AbstractMesh>;
  43661. /**
  43662. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43663. * @returns a number
  43664. */
  43665. getAnimationRatio(): number;
  43666. /**
  43667. * Gets an unique Id for the current render phase
  43668. * @returns a number
  43669. */
  43670. getRenderId(): number;
  43671. /**
  43672. * Gets an unique Id for the current frame
  43673. * @returns a number
  43674. */
  43675. getFrameId(): number;
  43676. /** Call this function if you want to manually increment the render Id*/
  43677. incrementRenderId(): void;
  43678. private _createUbo;
  43679. /**
  43680. * Use this method to simulate a pointer move on a mesh
  43681. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43682. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43683. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43684. * @returns the current scene
  43685. */
  43686. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43687. /**
  43688. * Use this method to simulate a pointer down on a mesh
  43689. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43690. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43691. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43692. * @returns the current scene
  43693. */
  43694. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43695. /**
  43696. * Use this method to simulate a pointer up on a mesh
  43697. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43698. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43699. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43700. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43701. * @returns the current scene
  43702. */
  43703. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43704. /**
  43705. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43706. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43707. * @returns true if the pointer was captured
  43708. */
  43709. isPointerCaptured(pointerId?: number): boolean;
  43710. /**
  43711. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43712. * @param attachUp defines if you want to attach events to pointerup
  43713. * @param attachDown defines if you want to attach events to pointerdown
  43714. * @param attachMove defines if you want to attach events to pointermove
  43715. */
  43716. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43717. /** Detaches all event handlers*/
  43718. detachControl(): void;
  43719. /**
  43720. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43721. * Delay loaded resources are not taking in account
  43722. * @return true if all required resources are ready
  43723. */
  43724. isReady(): boolean;
  43725. /** Resets all cached information relative to material (including effect and visibility) */
  43726. resetCachedMaterial(): void;
  43727. /**
  43728. * Registers a function to be called before every frame render
  43729. * @param func defines the function to register
  43730. */
  43731. registerBeforeRender(func: () => void): void;
  43732. /**
  43733. * Unregisters a function called before every frame render
  43734. * @param func defines the function to unregister
  43735. */
  43736. unregisterBeforeRender(func: () => void): void;
  43737. /**
  43738. * Registers a function to be called after every frame render
  43739. * @param func defines the function to register
  43740. */
  43741. registerAfterRender(func: () => void): void;
  43742. /**
  43743. * Unregisters a function called after every frame render
  43744. * @param func defines the function to unregister
  43745. */
  43746. unregisterAfterRender(func: () => void): void;
  43747. private _executeOnceBeforeRender;
  43748. /**
  43749. * The provided function will run before render once and will be disposed afterwards.
  43750. * A timeout delay can be provided so that the function will be executed in N ms.
  43751. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43752. * @param func The function to be executed.
  43753. * @param timeout optional delay in ms
  43754. */
  43755. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43756. /** @hidden */
  43757. _addPendingData(data: any): void;
  43758. /** @hidden */
  43759. _removePendingData(data: any): void;
  43760. /**
  43761. * Returns the number of items waiting to be loaded
  43762. * @returns the number of items waiting to be loaded
  43763. */
  43764. getWaitingItemsCount(): number;
  43765. /**
  43766. * Returns a boolean indicating if the scene is still loading data
  43767. */
  43768. get isLoading(): boolean;
  43769. /**
  43770. * Registers a function to be executed when the scene is ready
  43771. * @param {Function} func - the function to be executed
  43772. */
  43773. executeWhenReady(func: () => void): void;
  43774. /**
  43775. * Returns a promise that resolves when the scene is ready
  43776. * @returns A promise that resolves when the scene is ready
  43777. */
  43778. whenReadyAsync(): Promise<void>;
  43779. /** @hidden */
  43780. _checkIsReady(): void;
  43781. /**
  43782. * Gets all animatable attached to the scene
  43783. */
  43784. get animatables(): Animatable[];
  43785. /**
  43786. * Resets the last animation time frame.
  43787. * Useful to override when animations start running when loading a scene for the first time.
  43788. */
  43789. resetLastAnimationTimeFrame(): void;
  43790. /**
  43791. * Gets the current view matrix
  43792. * @returns a Matrix
  43793. */
  43794. getViewMatrix(): Matrix;
  43795. /**
  43796. * Gets the current projection matrix
  43797. * @returns a Matrix
  43798. */
  43799. getProjectionMatrix(): Matrix;
  43800. /**
  43801. * Gets the current transform matrix
  43802. * @returns a Matrix made of View * Projection
  43803. */
  43804. getTransformMatrix(): Matrix;
  43805. /**
  43806. * Sets the current transform matrix
  43807. * @param viewL defines the View matrix to use
  43808. * @param projectionL defines the Projection matrix to use
  43809. * @param viewR defines the right View matrix to use (if provided)
  43810. * @param projectionR defines the right Projection matrix to use (if provided)
  43811. */
  43812. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  43813. /**
  43814. * Gets the uniform buffer used to store scene data
  43815. * @returns a UniformBuffer
  43816. */
  43817. getSceneUniformBuffer(): UniformBuffer;
  43818. /**
  43819. * Gets an unique (relatively to the current scene) Id
  43820. * @returns an unique number for the scene
  43821. */
  43822. getUniqueId(): number;
  43823. /**
  43824. * Add a mesh to the list of scene's meshes
  43825. * @param newMesh defines the mesh to add
  43826. * @param recursive if all child meshes should also be added to the scene
  43827. */
  43828. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  43829. /**
  43830. * Remove a mesh for the list of scene's meshes
  43831. * @param toRemove defines the mesh to remove
  43832. * @param recursive if all child meshes should also be removed from the scene
  43833. * @returns the index where the mesh was in the mesh list
  43834. */
  43835. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  43836. /**
  43837. * Add a transform node to the list of scene's transform nodes
  43838. * @param newTransformNode defines the transform node to add
  43839. */
  43840. addTransformNode(newTransformNode: TransformNode): void;
  43841. /**
  43842. * Remove a transform node for the list of scene's transform nodes
  43843. * @param toRemove defines the transform node to remove
  43844. * @returns the index where the transform node was in the transform node list
  43845. */
  43846. removeTransformNode(toRemove: TransformNode): number;
  43847. /**
  43848. * Remove a skeleton for the list of scene's skeletons
  43849. * @param toRemove defines the skeleton to remove
  43850. * @returns the index where the skeleton was in the skeleton list
  43851. */
  43852. removeSkeleton(toRemove: Skeleton): number;
  43853. /**
  43854. * Remove a morph target for the list of scene's morph targets
  43855. * @param toRemove defines the morph target to remove
  43856. * @returns the index where the morph target was in the morph target list
  43857. */
  43858. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  43859. /**
  43860. * Remove a light for the list of scene's lights
  43861. * @param toRemove defines the light to remove
  43862. * @returns the index where the light was in the light list
  43863. */
  43864. removeLight(toRemove: Light): number;
  43865. /**
  43866. * Remove a camera for the list of scene's cameras
  43867. * @param toRemove defines the camera to remove
  43868. * @returns the index where the camera was in the camera list
  43869. */
  43870. removeCamera(toRemove: Camera): number;
  43871. /**
  43872. * Remove a particle system for the list of scene's particle systems
  43873. * @param toRemove defines the particle system to remove
  43874. * @returns the index where the particle system was in the particle system list
  43875. */
  43876. removeParticleSystem(toRemove: IParticleSystem): number;
  43877. /**
  43878. * Remove a animation for the list of scene's animations
  43879. * @param toRemove defines the animation to remove
  43880. * @returns the index where the animation was in the animation list
  43881. */
  43882. removeAnimation(toRemove: Animation): number;
  43883. /**
  43884. * Will stop the animation of the given target
  43885. * @param target - the target
  43886. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  43887. * @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)
  43888. */
  43889. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  43890. /**
  43891. * Removes the given animation group from this scene.
  43892. * @param toRemove The animation group to remove
  43893. * @returns The index of the removed animation group
  43894. */
  43895. removeAnimationGroup(toRemove: AnimationGroup): number;
  43896. /**
  43897. * Removes the given multi-material from this scene.
  43898. * @param toRemove The multi-material to remove
  43899. * @returns The index of the removed multi-material
  43900. */
  43901. removeMultiMaterial(toRemove: MultiMaterial): number;
  43902. /**
  43903. * Removes the given material from this scene.
  43904. * @param toRemove The material to remove
  43905. * @returns The index of the removed material
  43906. */
  43907. removeMaterial(toRemove: Material): number;
  43908. /**
  43909. * Removes the given action manager from this scene.
  43910. * @param toRemove The action manager to remove
  43911. * @returns The index of the removed action manager
  43912. */
  43913. removeActionManager(toRemove: AbstractActionManager): number;
  43914. /**
  43915. * Removes the given texture from this scene.
  43916. * @param toRemove The texture to remove
  43917. * @returns The index of the removed texture
  43918. */
  43919. removeTexture(toRemove: BaseTexture): number;
  43920. /**
  43921. * Adds the given light to this scene
  43922. * @param newLight The light to add
  43923. */
  43924. addLight(newLight: Light): void;
  43925. /**
  43926. * Sorts the list list based on light priorities
  43927. */
  43928. sortLightsByPriority(): void;
  43929. /**
  43930. * Adds the given camera to this scene
  43931. * @param newCamera The camera to add
  43932. */
  43933. addCamera(newCamera: Camera): void;
  43934. /**
  43935. * Adds the given skeleton to this scene
  43936. * @param newSkeleton The skeleton to add
  43937. */
  43938. addSkeleton(newSkeleton: Skeleton): void;
  43939. /**
  43940. * Adds the given particle system to this scene
  43941. * @param newParticleSystem The particle system to add
  43942. */
  43943. addParticleSystem(newParticleSystem: IParticleSystem): void;
  43944. /**
  43945. * Adds the given animation to this scene
  43946. * @param newAnimation The animation to add
  43947. */
  43948. addAnimation(newAnimation: Animation): void;
  43949. /**
  43950. * Adds the given animation group to this scene.
  43951. * @param newAnimationGroup The animation group to add
  43952. */
  43953. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  43954. /**
  43955. * Adds the given multi-material to this scene
  43956. * @param newMultiMaterial The multi-material to add
  43957. */
  43958. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  43959. /**
  43960. * Adds the given material to this scene
  43961. * @param newMaterial The material to add
  43962. */
  43963. addMaterial(newMaterial: Material): void;
  43964. /**
  43965. * Adds the given morph target to this scene
  43966. * @param newMorphTargetManager The morph target to add
  43967. */
  43968. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  43969. /**
  43970. * Adds the given geometry to this scene
  43971. * @param newGeometry The geometry to add
  43972. */
  43973. addGeometry(newGeometry: Geometry): void;
  43974. /**
  43975. * Adds the given action manager to this scene
  43976. * @param newActionManager The action manager to add
  43977. */
  43978. addActionManager(newActionManager: AbstractActionManager): void;
  43979. /**
  43980. * Adds the given texture to this scene.
  43981. * @param newTexture The texture to add
  43982. */
  43983. addTexture(newTexture: BaseTexture): void;
  43984. /**
  43985. * Switch active camera
  43986. * @param newCamera defines the new active camera
  43987. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  43988. */
  43989. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  43990. /**
  43991. * sets the active camera of the scene using its ID
  43992. * @param id defines the camera's ID
  43993. * @return the new active camera or null if none found.
  43994. */
  43995. setActiveCameraByID(id: string): Nullable<Camera>;
  43996. /**
  43997. * sets the active camera of the scene using its name
  43998. * @param name defines the camera's name
  43999. * @returns the new active camera or null if none found.
  44000. */
  44001. setActiveCameraByName(name: string): Nullable<Camera>;
  44002. /**
  44003. * get an animation group using its name
  44004. * @param name defines the material's name
  44005. * @return the animation group or null if none found.
  44006. */
  44007. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  44008. /**
  44009. * Get a material using its unique id
  44010. * @param uniqueId defines the material's unique id
  44011. * @return the material or null if none found.
  44012. */
  44013. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  44014. /**
  44015. * get a material using its id
  44016. * @param id defines the material's ID
  44017. * @return the material or null if none found.
  44018. */
  44019. getMaterialByID(id: string): Nullable<Material>;
  44020. /**
  44021. * Gets a the last added material using a given id
  44022. * @param id defines the material's ID
  44023. * @return the last material with the given id or null if none found.
  44024. */
  44025. getLastMaterialByID(id: string): Nullable<Material>;
  44026. /**
  44027. * Gets a material using its name
  44028. * @param name defines the material's name
  44029. * @return the material or null if none found.
  44030. */
  44031. getMaterialByName(name: string): Nullable<Material>;
  44032. /**
  44033. * Get a texture using its unique id
  44034. * @param uniqueId defines the texture's unique id
  44035. * @return the texture or null if none found.
  44036. */
  44037. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  44038. /**
  44039. * Gets a camera using its id
  44040. * @param id defines the id to look for
  44041. * @returns the camera or null if not found
  44042. */
  44043. getCameraByID(id: string): Nullable<Camera>;
  44044. /**
  44045. * Gets a camera using its unique id
  44046. * @param uniqueId defines the unique id to look for
  44047. * @returns the camera or null if not found
  44048. */
  44049. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  44050. /**
  44051. * Gets a camera using its name
  44052. * @param name defines the camera's name
  44053. * @return the camera or null if none found.
  44054. */
  44055. getCameraByName(name: string): Nullable<Camera>;
  44056. /**
  44057. * Gets a bone using its id
  44058. * @param id defines the bone's id
  44059. * @return the bone or null if not found
  44060. */
  44061. getBoneByID(id: string): Nullable<Bone>;
  44062. /**
  44063. * Gets a bone using its id
  44064. * @param name defines the bone's name
  44065. * @return the bone or null if not found
  44066. */
  44067. getBoneByName(name: string): Nullable<Bone>;
  44068. /**
  44069. * Gets a light node using its name
  44070. * @param name defines the the light's name
  44071. * @return the light or null if none found.
  44072. */
  44073. getLightByName(name: string): Nullable<Light>;
  44074. /**
  44075. * Gets a light node using its id
  44076. * @param id defines the light's id
  44077. * @return the light or null if none found.
  44078. */
  44079. getLightByID(id: string): Nullable<Light>;
  44080. /**
  44081. * Gets a light node using its scene-generated unique ID
  44082. * @param uniqueId defines the light's unique id
  44083. * @return the light or null if none found.
  44084. */
  44085. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  44086. /**
  44087. * Gets a particle system by id
  44088. * @param id defines the particle system id
  44089. * @return the corresponding system or null if none found
  44090. */
  44091. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  44092. /**
  44093. * Gets a geometry using its ID
  44094. * @param id defines the geometry's id
  44095. * @return the geometry or null if none found.
  44096. */
  44097. getGeometryByID(id: string): Nullable<Geometry>;
  44098. private _getGeometryByUniqueID;
  44099. /**
  44100. * Add a new geometry to this scene
  44101. * @param geometry defines the geometry to be added to the scene.
  44102. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  44103. * @return a boolean defining if the geometry was added or not
  44104. */
  44105. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  44106. /**
  44107. * Removes an existing geometry
  44108. * @param geometry defines the geometry to be removed from the scene
  44109. * @return a boolean defining if the geometry was removed or not
  44110. */
  44111. removeGeometry(geometry: Geometry): boolean;
  44112. /**
  44113. * Gets the list of geometries attached to the scene
  44114. * @returns an array of Geometry
  44115. */
  44116. getGeometries(): Geometry[];
  44117. /**
  44118. * Gets the first added mesh found of a given ID
  44119. * @param id defines the id to search for
  44120. * @return the mesh found or null if not found at all
  44121. */
  44122. getMeshByID(id: string): Nullable<AbstractMesh>;
  44123. /**
  44124. * Gets a list of meshes using their id
  44125. * @param id defines the id to search for
  44126. * @returns a list of meshes
  44127. */
  44128. getMeshesByID(id: string): Array<AbstractMesh>;
  44129. /**
  44130. * Gets the first added transform node found of a given ID
  44131. * @param id defines the id to search for
  44132. * @return the found transform node or null if not found at all.
  44133. */
  44134. getTransformNodeByID(id: string): Nullable<TransformNode>;
  44135. /**
  44136. * Gets a transform node with its auto-generated unique id
  44137. * @param uniqueId efines the unique id to search for
  44138. * @return the found transform node or null if not found at all.
  44139. */
  44140. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  44141. /**
  44142. * Gets a list of transform nodes using their id
  44143. * @param id defines the id to search for
  44144. * @returns a list of transform nodes
  44145. */
  44146. getTransformNodesByID(id: string): Array<TransformNode>;
  44147. /**
  44148. * Gets a mesh with its auto-generated unique id
  44149. * @param uniqueId defines the unique id to search for
  44150. * @return the found mesh or null if not found at all.
  44151. */
  44152. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  44153. /**
  44154. * Gets a the last added mesh using a given id
  44155. * @param id defines the id to search for
  44156. * @return the found mesh or null if not found at all.
  44157. */
  44158. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  44159. /**
  44160. * Gets a the last added node (Mesh, Camera, Light) using a given id
  44161. * @param id defines the id to search for
  44162. * @return the found node or null if not found at all
  44163. */
  44164. getLastEntryByID(id: string): Nullable<Node>;
  44165. /**
  44166. * Gets a node (Mesh, Camera, Light) using a given id
  44167. * @param id defines the id to search for
  44168. * @return the found node or null if not found at all
  44169. */
  44170. getNodeByID(id: string): Nullable<Node>;
  44171. /**
  44172. * Gets a node (Mesh, Camera, Light) using a given name
  44173. * @param name defines the name to search for
  44174. * @return the found node or null if not found at all.
  44175. */
  44176. getNodeByName(name: string): Nullable<Node>;
  44177. /**
  44178. * Gets a mesh using a given name
  44179. * @param name defines the name to search for
  44180. * @return the found mesh or null if not found at all.
  44181. */
  44182. getMeshByName(name: string): Nullable<AbstractMesh>;
  44183. /**
  44184. * Gets a transform node using a given name
  44185. * @param name defines the name to search for
  44186. * @return the found transform node or null if not found at all.
  44187. */
  44188. getTransformNodeByName(name: string): Nullable<TransformNode>;
  44189. /**
  44190. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  44191. * @param id defines the id to search for
  44192. * @return the found skeleton or null if not found at all.
  44193. */
  44194. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  44195. /**
  44196. * Gets a skeleton using a given auto generated unique id
  44197. * @param uniqueId defines the unique id to search for
  44198. * @return the found skeleton or null if not found at all.
  44199. */
  44200. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  44201. /**
  44202. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  44203. * @param id defines the id to search for
  44204. * @return the found skeleton or null if not found at all.
  44205. */
  44206. getSkeletonById(id: string): Nullable<Skeleton>;
  44207. /**
  44208. * Gets a skeleton using a given name
  44209. * @param name defines the name to search for
  44210. * @return the found skeleton or null if not found at all.
  44211. */
  44212. getSkeletonByName(name: string): Nullable<Skeleton>;
  44213. /**
  44214. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  44215. * @param id defines the id to search for
  44216. * @return the found morph target manager or null if not found at all.
  44217. */
  44218. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  44219. /**
  44220. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  44221. * @param id defines the id to search for
  44222. * @return the found morph target or null if not found at all.
  44223. */
  44224. getMorphTargetById(id: string): Nullable<MorphTarget>;
  44225. /**
  44226. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  44227. * @param name defines the name to search for
  44228. * @return the found morph target or null if not found at all.
  44229. */
  44230. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  44231. /**
  44232. * Gets a post process using a given name (if many are found, this function will pick the first one)
  44233. * @param name defines the name to search for
  44234. * @return the found post process or null if not found at all.
  44235. */
  44236. getPostProcessByName(name: string): Nullable<PostProcess>;
  44237. /**
  44238. * Gets a boolean indicating if the given mesh is active
  44239. * @param mesh defines the mesh to look for
  44240. * @returns true if the mesh is in the active list
  44241. */
  44242. isActiveMesh(mesh: AbstractMesh): boolean;
  44243. /**
  44244. * Return a unique id as a string which can serve as an identifier for the scene
  44245. */
  44246. get uid(): string;
  44247. /**
  44248. * Add an externaly attached data from its key.
  44249. * This method call will fail and return false, if such key already exists.
  44250. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  44251. * @param key the unique key that identifies the data
  44252. * @param data the data object to associate to the key for this Engine instance
  44253. * @return true if no such key were already present and the data was added successfully, false otherwise
  44254. */
  44255. addExternalData<T>(key: string, data: T): boolean;
  44256. /**
  44257. * Get an externaly attached data from its key
  44258. * @param key the unique key that identifies the data
  44259. * @return the associated data, if present (can be null), or undefined if not present
  44260. */
  44261. getExternalData<T>(key: string): Nullable<T>;
  44262. /**
  44263. * Get an externaly attached data from its key, create it using a factory if it's not already present
  44264. * @param key the unique key that identifies the data
  44265. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  44266. * @return the associated data, can be null if the factory returned null.
  44267. */
  44268. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44269. /**
  44270. * Remove an externaly attached data from the Engine instance
  44271. * @param key the unique key that identifies the data
  44272. * @return true if the data was successfully removed, false if it doesn't exist
  44273. */
  44274. removeExternalData(key: string): boolean;
  44275. private _evaluateSubMesh;
  44276. /**
  44277. * Clear the processed materials smart array preventing retention point in material dispose.
  44278. */
  44279. freeProcessedMaterials(): void;
  44280. private _preventFreeActiveMeshesAndRenderingGroups;
  44281. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44282. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44283. * when disposing several meshes in a row or a hierarchy of meshes.
  44284. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44285. */
  44286. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44287. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44288. /**
  44289. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44290. */
  44291. freeActiveMeshes(): void;
  44292. /**
  44293. * Clear the info related to rendering groups preventing retention points during dispose.
  44294. */
  44295. freeRenderingGroups(): void;
  44296. /** @hidden */
  44297. _isInIntermediateRendering(): boolean;
  44298. /**
  44299. * Lambda returning the list of potentially active meshes.
  44300. */
  44301. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44302. /**
  44303. * Lambda returning the list of potentially active sub meshes.
  44304. */
  44305. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44306. /**
  44307. * Lambda returning the list of potentially intersecting sub meshes.
  44308. */
  44309. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44310. /**
  44311. * Lambda returning the list of potentially colliding sub meshes.
  44312. */
  44313. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44314. private _activeMeshesFrozen;
  44315. private _skipEvaluateActiveMeshesCompletely;
  44316. /**
  44317. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44318. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44319. * @param onSuccess optional success callback
  44320. * @param onError optional error callback
  44321. * @returns the current scene
  44322. */
  44323. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44324. /**
  44325. * Use this function to restart evaluating active meshes on every frame
  44326. * @returns the current scene
  44327. */
  44328. unfreezeActiveMeshes(): Scene;
  44329. private _evaluateActiveMeshes;
  44330. private _activeMesh;
  44331. /**
  44332. * Update the transform matrix to update from the current active camera
  44333. * @param force defines a boolean used to force the update even if cache is up to date
  44334. */
  44335. updateTransformMatrix(force?: boolean): void;
  44336. private _bindFrameBuffer;
  44337. /** @hidden */
  44338. _allowPostProcessClearColor: boolean;
  44339. /** @hidden */
  44340. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44341. private _processSubCameras;
  44342. private _checkIntersections;
  44343. /** @hidden */
  44344. _advancePhysicsEngineStep(step: number): void;
  44345. /**
  44346. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44347. */
  44348. getDeterministicFrameTime: () => number;
  44349. /** @hidden */
  44350. _animate(): void;
  44351. /** Execute all animations (for a frame) */
  44352. animate(): void;
  44353. /**
  44354. * Render the scene
  44355. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44356. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44357. */
  44358. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44359. /**
  44360. * Freeze all materials
  44361. * A frozen material will not be updatable but should be faster to render
  44362. */
  44363. freezeMaterials(): void;
  44364. /**
  44365. * Unfreeze all materials
  44366. * A frozen material will not be updatable but should be faster to render
  44367. */
  44368. unfreezeMaterials(): void;
  44369. /**
  44370. * Releases all held ressources
  44371. */
  44372. dispose(): void;
  44373. /**
  44374. * Gets if the scene is already disposed
  44375. */
  44376. get isDisposed(): boolean;
  44377. /**
  44378. * Call this function to reduce memory footprint of the scene.
  44379. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44380. */
  44381. clearCachedVertexData(): void;
  44382. /**
  44383. * This function will remove the local cached buffer data from texture.
  44384. * It will save memory but will prevent the texture from being rebuilt
  44385. */
  44386. cleanCachedTextureBuffer(): void;
  44387. /**
  44388. * Get the world extend vectors with an optional filter
  44389. *
  44390. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44391. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44392. */
  44393. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44394. min: Vector3;
  44395. max: Vector3;
  44396. };
  44397. /**
  44398. * Creates a ray that can be used to pick in the scene
  44399. * @param x defines the x coordinate of the origin (on-screen)
  44400. * @param y defines the y coordinate of the origin (on-screen)
  44401. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44402. * @param camera defines the camera to use for the picking
  44403. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44404. * @returns a Ray
  44405. */
  44406. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44407. /**
  44408. * Creates a ray that can be used to pick in the scene
  44409. * @param x defines the x coordinate of the origin (on-screen)
  44410. * @param y defines the y coordinate of the origin (on-screen)
  44411. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44412. * @param result defines the ray where to store the picking ray
  44413. * @param camera defines the camera to use for the picking
  44414. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44415. * @returns the current scene
  44416. */
  44417. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44418. /**
  44419. * Creates a ray that can be used to pick in the scene
  44420. * @param x defines the x coordinate of the origin (on-screen)
  44421. * @param y defines the y coordinate of the origin (on-screen)
  44422. * @param camera defines the camera to use for the picking
  44423. * @returns a Ray
  44424. */
  44425. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44426. /**
  44427. * Creates a ray that can be used to pick in the scene
  44428. * @param x defines the x coordinate of the origin (on-screen)
  44429. * @param y defines the y coordinate of the origin (on-screen)
  44430. * @param result defines the ray where to store the picking ray
  44431. * @param camera defines the camera to use for the picking
  44432. * @returns the current scene
  44433. */
  44434. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44435. /** Launch a ray to try to pick a mesh in the scene
  44436. * @param x position on screen
  44437. * @param y position on screen
  44438. * @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
  44439. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44440. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44441. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44442. * @returns a PickingInfo
  44443. */
  44444. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44445. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44446. * @param x position on screen
  44447. * @param y position on screen
  44448. * @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
  44449. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44450. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44451. * @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)
  44452. */
  44453. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44454. /** Use the given ray to pick a mesh in the scene
  44455. * @param ray The ray to use to pick meshes
  44456. * @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
  44457. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44458. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44459. * @returns a PickingInfo
  44460. */
  44461. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44462. /**
  44463. * Launch a ray to try to pick a mesh in the scene
  44464. * @param x X position on screen
  44465. * @param y Y position on screen
  44466. * @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
  44467. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44469. * @returns an array of PickingInfo
  44470. */
  44471. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44472. /**
  44473. * Launch a ray to try to pick a mesh in the scene
  44474. * @param ray Ray to use
  44475. * @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
  44476. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44477. * @returns an array of PickingInfo
  44478. */
  44479. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44480. /**
  44481. * Force the value of meshUnderPointer
  44482. * @param mesh defines the mesh to use
  44483. * @param pointerId optional pointer id when using more than one pointer
  44484. */
  44485. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44486. /**
  44487. * Gets the mesh under the pointer
  44488. * @returns a Mesh or null if no mesh is under the pointer
  44489. */
  44490. getPointerOverMesh(): Nullable<AbstractMesh>;
  44491. /** @hidden */
  44492. _rebuildGeometries(): void;
  44493. /** @hidden */
  44494. _rebuildTextures(): void;
  44495. private _getByTags;
  44496. /**
  44497. * Get a list of meshes by tags
  44498. * @param tagsQuery defines the tags query to use
  44499. * @param forEach defines a predicate used to filter results
  44500. * @returns an array of Mesh
  44501. */
  44502. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44503. /**
  44504. * Get a list of cameras by tags
  44505. * @param tagsQuery defines the tags query to use
  44506. * @param forEach defines a predicate used to filter results
  44507. * @returns an array of Camera
  44508. */
  44509. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44510. /**
  44511. * Get a list of lights by tags
  44512. * @param tagsQuery defines the tags query to use
  44513. * @param forEach defines a predicate used to filter results
  44514. * @returns an array of Light
  44515. */
  44516. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44517. /**
  44518. * Get a list of materials by tags
  44519. * @param tagsQuery defines the tags query to use
  44520. * @param forEach defines a predicate used to filter results
  44521. * @returns an array of Material
  44522. */
  44523. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44524. /**
  44525. * Get a list of transform nodes by tags
  44526. * @param tagsQuery defines the tags query to use
  44527. * @param forEach defines a predicate used to filter results
  44528. * @returns an array of TransformNode
  44529. */
  44530. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44531. /**
  44532. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44533. * This allowed control for front to back rendering or reversly depending of the special needs.
  44534. *
  44535. * @param renderingGroupId The rendering group id corresponding to its index
  44536. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44537. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44538. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44539. */
  44540. 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;
  44541. /**
  44542. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44543. *
  44544. * @param renderingGroupId The rendering group id corresponding to its index
  44545. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44546. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44547. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44548. */
  44549. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44550. /**
  44551. * Gets the current auto clear configuration for one rendering group of the rendering
  44552. * manager.
  44553. * @param index the rendering group index to get the information for
  44554. * @returns The auto clear setup for the requested rendering group
  44555. */
  44556. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44557. private _blockMaterialDirtyMechanism;
  44558. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44559. get blockMaterialDirtyMechanism(): boolean;
  44560. set blockMaterialDirtyMechanism(value: boolean);
  44561. /**
  44562. * Will flag all materials as dirty to trigger new shader compilation
  44563. * @param flag defines the flag used to specify which material part must be marked as dirty
  44564. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44565. */
  44566. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44567. /** @hidden */
  44568. _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;
  44569. /** @hidden */
  44570. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44571. /** @hidden */
  44572. _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;
  44573. /** @hidden */
  44574. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44575. /** @hidden */
  44576. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44577. /** @hidden */
  44578. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44579. }
  44580. }
  44581. declare module BABYLON {
  44582. /**
  44583. * Set of assets to keep when moving a scene into an asset container.
  44584. */
  44585. export class KeepAssets extends AbstractScene {
  44586. }
  44587. /**
  44588. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44589. */
  44590. export class InstantiatedEntries {
  44591. /**
  44592. * List of new root nodes (eg. nodes with no parent)
  44593. */
  44594. rootNodes: TransformNode[];
  44595. /**
  44596. * List of new skeletons
  44597. */
  44598. skeletons: Skeleton[];
  44599. /**
  44600. * List of new animation groups
  44601. */
  44602. animationGroups: AnimationGroup[];
  44603. }
  44604. /**
  44605. * Container with a set of assets that can be added or removed from a scene.
  44606. */
  44607. export class AssetContainer extends AbstractScene {
  44608. private _wasAddedToScene;
  44609. /**
  44610. * The scene the AssetContainer belongs to.
  44611. */
  44612. scene: Scene;
  44613. /**
  44614. * Instantiates an AssetContainer.
  44615. * @param scene The scene the AssetContainer belongs to.
  44616. */
  44617. constructor(scene: Scene);
  44618. /**
  44619. * Instantiate or clone all meshes and add the new ones to the scene.
  44620. * Skeletons and animation groups will all be cloned
  44621. * @param nameFunction defines an optional function used to get new names for clones
  44622. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44623. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44624. */
  44625. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44626. /**
  44627. * Adds all the assets from the container to the scene.
  44628. */
  44629. addAllToScene(): void;
  44630. /**
  44631. * Removes all the assets in the container from the scene
  44632. */
  44633. removeAllFromScene(): void;
  44634. /**
  44635. * Disposes all the assets in the container
  44636. */
  44637. dispose(): void;
  44638. private _moveAssets;
  44639. /**
  44640. * Removes all the assets contained in the scene and adds them to the container.
  44641. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44642. */
  44643. moveAllFromScene(keepAssets?: KeepAssets): void;
  44644. /**
  44645. * 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.
  44646. * @returns the root mesh
  44647. */
  44648. createRootMesh(): Mesh;
  44649. /**
  44650. * Merge animations (direct and animation groups) from this asset container into a scene
  44651. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44652. * @param animatables set of animatables to retarget to a node from the scene
  44653. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44654. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44655. */
  44656. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44657. }
  44658. }
  44659. declare module BABYLON {
  44660. /**
  44661. * Defines how the parser contract is defined.
  44662. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44663. */
  44664. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44665. /**
  44666. * Defines how the individual parser contract is defined.
  44667. * These parser can parse an individual asset
  44668. */
  44669. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44670. /**
  44671. * Base class of the scene acting as a container for the different elements composing a scene.
  44672. * This class is dynamically extended by the different components of the scene increasing
  44673. * flexibility and reducing coupling
  44674. */
  44675. export abstract class AbstractScene {
  44676. /**
  44677. * Stores the list of available parsers in the application.
  44678. */
  44679. private static _BabylonFileParsers;
  44680. /**
  44681. * Stores the list of available individual parsers in the application.
  44682. */
  44683. private static _IndividualBabylonFileParsers;
  44684. /**
  44685. * Adds a parser in the list of available ones
  44686. * @param name Defines the name of the parser
  44687. * @param parser Defines the parser to add
  44688. */
  44689. static AddParser(name: string, parser: BabylonFileParser): void;
  44690. /**
  44691. * Gets a general parser from the list of avaialble ones
  44692. * @param name Defines the name of the parser
  44693. * @returns the requested parser or null
  44694. */
  44695. static GetParser(name: string): Nullable<BabylonFileParser>;
  44696. /**
  44697. * Adds n individual parser in the list of available ones
  44698. * @param name Defines the name of the parser
  44699. * @param parser Defines the parser to add
  44700. */
  44701. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44702. /**
  44703. * Gets an individual parser from the list of avaialble ones
  44704. * @param name Defines the name of the parser
  44705. * @returns the requested parser or null
  44706. */
  44707. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44708. /**
  44709. * Parser json data and populate both a scene and its associated container object
  44710. * @param jsonData Defines the data to parse
  44711. * @param scene Defines the scene to parse the data for
  44712. * @param container Defines the container attached to the parsing sequence
  44713. * @param rootUrl Defines the root url of the data
  44714. */
  44715. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44716. /**
  44717. * Gets the list of root nodes (ie. nodes with no parent)
  44718. */
  44719. rootNodes: Node[];
  44720. /** All of the cameras added to this scene
  44721. * @see https://doc.babylonjs.com/babylon101/cameras
  44722. */
  44723. cameras: Camera[];
  44724. /**
  44725. * All of the lights added to this scene
  44726. * @see https://doc.babylonjs.com/babylon101/lights
  44727. */
  44728. lights: Light[];
  44729. /**
  44730. * All of the (abstract) meshes added to this scene
  44731. */
  44732. meshes: AbstractMesh[];
  44733. /**
  44734. * The list of skeletons added to the scene
  44735. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44736. */
  44737. skeletons: Skeleton[];
  44738. /**
  44739. * All of the particle systems added to this scene
  44740. * @see https://doc.babylonjs.com/babylon101/particles
  44741. */
  44742. particleSystems: IParticleSystem[];
  44743. /**
  44744. * Gets a list of Animations associated with the scene
  44745. */
  44746. animations: Animation[];
  44747. /**
  44748. * All of the animation groups added to this scene
  44749. * @see https://doc.babylonjs.com/how_to/group
  44750. */
  44751. animationGroups: AnimationGroup[];
  44752. /**
  44753. * All of the multi-materials added to this scene
  44754. * @see https://doc.babylonjs.com/how_to/multi_materials
  44755. */
  44756. multiMaterials: MultiMaterial[];
  44757. /**
  44758. * All of the materials added to this scene
  44759. * In the context of a Scene, it is not supposed to be modified manually.
  44760. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44761. * Note also that the order of the Material within the array is not significant and might change.
  44762. * @see https://doc.babylonjs.com/babylon101/materials
  44763. */
  44764. materials: Material[];
  44765. /**
  44766. * The list of morph target managers added to the scene
  44767. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44768. */
  44769. morphTargetManagers: MorphTargetManager[];
  44770. /**
  44771. * The list of geometries used in the scene.
  44772. */
  44773. geometries: Geometry[];
  44774. /**
  44775. * All of the tranform nodes added to this scene
  44776. * In the context of a Scene, it is not supposed to be modified manually.
  44777. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44778. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44779. * @see https://doc.babylonjs.com/how_to/transformnode
  44780. */
  44781. transformNodes: TransformNode[];
  44782. /**
  44783. * ActionManagers available on the scene.
  44784. */
  44785. actionManagers: AbstractActionManager[];
  44786. /**
  44787. * Textures to keep.
  44788. */
  44789. textures: BaseTexture[];
  44790. /** @hidden */
  44791. protected _environmentTexture: Nullable<BaseTexture>;
  44792. /**
  44793. * Texture used in all pbr material as the reflection texture.
  44794. * As in the majority of the scene they are the same (exception for multi room and so on),
  44795. * this is easier to reference from here than from all the materials.
  44796. */
  44797. get environmentTexture(): Nullable<BaseTexture>;
  44798. set environmentTexture(value: Nullable<BaseTexture>);
  44799. /**
  44800. * The list of postprocesses added to the scene
  44801. */
  44802. postProcesses: PostProcess[];
  44803. /**
  44804. * @returns all meshes, lights, cameras, transformNodes and bones
  44805. */
  44806. getNodes(): Array<Node>;
  44807. }
  44808. }
  44809. declare module BABYLON {
  44810. /**
  44811. * Interface used to define options for Sound class
  44812. */
  44813. export interface ISoundOptions {
  44814. /**
  44815. * Does the sound autoplay once loaded.
  44816. */
  44817. autoplay?: boolean;
  44818. /**
  44819. * Does the sound loop after it finishes playing once.
  44820. */
  44821. loop?: boolean;
  44822. /**
  44823. * Sound's volume
  44824. */
  44825. volume?: number;
  44826. /**
  44827. * Is it a spatial sound?
  44828. */
  44829. spatialSound?: boolean;
  44830. /**
  44831. * Maximum distance to hear that sound
  44832. */
  44833. maxDistance?: number;
  44834. /**
  44835. * Uses user defined attenuation function
  44836. */
  44837. useCustomAttenuation?: boolean;
  44838. /**
  44839. * Define the roll off factor of spatial sounds.
  44840. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44841. */
  44842. rolloffFactor?: number;
  44843. /**
  44844. * Define the reference distance the sound should be heard perfectly.
  44845. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44846. */
  44847. refDistance?: number;
  44848. /**
  44849. * Define the distance attenuation model the sound will follow.
  44850. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44851. */
  44852. distanceModel?: string;
  44853. /**
  44854. * Defines the playback speed (1 by default)
  44855. */
  44856. playbackRate?: number;
  44857. /**
  44858. * Defines if the sound is from a streaming source
  44859. */
  44860. streaming?: boolean;
  44861. /**
  44862. * Defines an optional length (in seconds) inside the sound file
  44863. */
  44864. length?: number;
  44865. /**
  44866. * Defines an optional offset (in seconds) inside the sound file
  44867. */
  44868. offset?: number;
  44869. /**
  44870. * If true, URLs will not be required to state the audio file codec to use.
  44871. */
  44872. skipCodecCheck?: boolean;
  44873. }
  44874. /**
  44875. * Defines a sound that can be played in the application.
  44876. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  44877. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44878. */
  44879. export class Sound {
  44880. /**
  44881. * The name of the sound in the scene.
  44882. */
  44883. name: string;
  44884. /**
  44885. * Does the sound autoplay once loaded.
  44886. */
  44887. autoplay: boolean;
  44888. /**
  44889. * Does the sound loop after it finishes playing once.
  44890. */
  44891. loop: boolean;
  44892. /**
  44893. * Does the sound use a custom attenuation curve to simulate the falloff
  44894. * happening when the source gets further away from the camera.
  44895. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44896. */
  44897. useCustomAttenuation: boolean;
  44898. /**
  44899. * The sound track id this sound belongs to.
  44900. */
  44901. soundTrackId: number;
  44902. /**
  44903. * Is this sound currently played.
  44904. */
  44905. isPlaying: boolean;
  44906. /**
  44907. * Is this sound currently paused.
  44908. */
  44909. isPaused: boolean;
  44910. /**
  44911. * Does this sound enables spatial sound.
  44912. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44913. */
  44914. spatialSound: boolean;
  44915. /**
  44916. * Define the reference distance the sound should be heard perfectly.
  44917. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44918. */
  44919. refDistance: number;
  44920. /**
  44921. * Define the roll off factor of spatial sounds.
  44922. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44923. */
  44924. rolloffFactor: number;
  44925. /**
  44926. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  44927. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44928. */
  44929. maxDistance: number;
  44930. /**
  44931. * Define the distance attenuation model the sound will follow.
  44932. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44933. */
  44934. distanceModel: string;
  44935. /**
  44936. * @hidden
  44937. * Back Compat
  44938. **/
  44939. onended: () => any;
  44940. /**
  44941. * Gets or sets an object used to store user defined information for the sound.
  44942. */
  44943. metadata: any;
  44944. /**
  44945. * Observable event when the current playing sound finishes.
  44946. */
  44947. onEndedObservable: Observable<Sound>;
  44948. private _panningModel;
  44949. private _playbackRate;
  44950. private _streaming;
  44951. private _startTime;
  44952. private _startOffset;
  44953. private _position;
  44954. /** @hidden */
  44955. _positionInEmitterSpace: boolean;
  44956. private _localDirection;
  44957. private _volume;
  44958. private _isReadyToPlay;
  44959. private _isDirectional;
  44960. private _readyToPlayCallback;
  44961. private _audioBuffer;
  44962. private _soundSource;
  44963. private _streamingSource;
  44964. private _soundPanner;
  44965. private _soundGain;
  44966. private _inputAudioNode;
  44967. private _outputAudioNode;
  44968. private _coneInnerAngle;
  44969. private _coneOuterAngle;
  44970. private _coneOuterGain;
  44971. private _scene;
  44972. private _connectedTransformNode;
  44973. private _customAttenuationFunction;
  44974. private _registerFunc;
  44975. private _isOutputConnected;
  44976. private _htmlAudioElement;
  44977. private _urlType;
  44978. private _length?;
  44979. private _offset?;
  44980. /** @hidden */
  44981. static _SceneComponentInitialization: (scene: Scene) => void;
  44982. /**
  44983. * Create a sound and attach it to a scene
  44984. * @param name Name of your sound
  44985. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  44986. * @param scene defines the scene the sound belongs to
  44987. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  44988. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  44989. */
  44990. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  44991. /**
  44992. * Release the sound and its associated resources
  44993. */
  44994. dispose(): void;
  44995. /**
  44996. * Gets if the sounds is ready to be played or not.
  44997. * @returns true if ready, otherwise false
  44998. */
  44999. isReady(): boolean;
  45000. private _soundLoaded;
  45001. /**
  45002. * Sets the data of the sound from an audiobuffer
  45003. * @param audioBuffer The audioBuffer containing the data
  45004. */
  45005. setAudioBuffer(audioBuffer: AudioBuffer): void;
  45006. /**
  45007. * Updates the current sounds options such as maxdistance, loop...
  45008. * @param options A JSON object containing values named as the object properties
  45009. */
  45010. updateOptions(options: ISoundOptions): void;
  45011. private _createSpatialParameters;
  45012. private _updateSpatialParameters;
  45013. /**
  45014. * Switch the panning model to HRTF:
  45015. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45016. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45017. */
  45018. switchPanningModelToHRTF(): void;
  45019. /**
  45020. * Switch the panning model to Equal Power:
  45021. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45022. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45023. */
  45024. switchPanningModelToEqualPower(): void;
  45025. private _switchPanningModel;
  45026. /**
  45027. * Connect this sound to a sound track audio node like gain...
  45028. * @param soundTrackAudioNode the sound track audio node to connect to
  45029. */
  45030. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  45031. /**
  45032. * Transform this sound into a directional source
  45033. * @param coneInnerAngle Size of the inner cone in degree
  45034. * @param coneOuterAngle Size of the outer cone in degree
  45035. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  45036. */
  45037. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  45038. /**
  45039. * Gets or sets the inner angle for the directional cone.
  45040. */
  45041. get directionalConeInnerAngle(): number;
  45042. /**
  45043. * Gets or sets the inner angle for the directional cone.
  45044. */
  45045. set directionalConeInnerAngle(value: number);
  45046. /**
  45047. * Gets or sets the outer angle for the directional cone.
  45048. */
  45049. get directionalConeOuterAngle(): number;
  45050. /**
  45051. * Gets or sets the outer angle for the directional cone.
  45052. */
  45053. set directionalConeOuterAngle(value: number);
  45054. /**
  45055. * Sets the position of the emitter if spatial sound is enabled
  45056. * @param newPosition Defines the new posisiton
  45057. */
  45058. setPosition(newPosition: Vector3): void;
  45059. /**
  45060. * Sets the local direction of the emitter if spatial sound is enabled
  45061. * @param newLocalDirection Defines the new local direction
  45062. */
  45063. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  45064. private _updateDirection;
  45065. /** @hidden */
  45066. updateDistanceFromListener(): void;
  45067. /**
  45068. * Sets a new custom attenuation function for the sound.
  45069. * @param callback Defines the function used for the attenuation
  45070. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45071. */
  45072. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  45073. /**
  45074. * Play the sound
  45075. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  45076. * @param offset (optional) Start the sound at a specific time in seconds
  45077. * @param length (optional) Sound duration (in seconds)
  45078. */
  45079. play(time?: number, offset?: number, length?: number): void;
  45080. private _onended;
  45081. /**
  45082. * Stop the sound
  45083. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  45084. */
  45085. stop(time?: number): void;
  45086. /**
  45087. * Put the sound in pause
  45088. */
  45089. pause(): void;
  45090. /**
  45091. * Sets a dedicated volume for this sounds
  45092. * @param newVolume Define the new volume of the sound
  45093. * @param time Define time for gradual change to new volume
  45094. */
  45095. setVolume(newVolume: number, time?: number): void;
  45096. /**
  45097. * Set the sound play back rate
  45098. * @param newPlaybackRate Define the playback rate the sound should be played at
  45099. */
  45100. setPlaybackRate(newPlaybackRate: number): void;
  45101. /**
  45102. * Gets the volume of the sound.
  45103. * @returns the volume of the sound
  45104. */
  45105. getVolume(): number;
  45106. /**
  45107. * Attach the sound to a dedicated mesh
  45108. * @param transformNode The transform node to connect the sound with
  45109. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45110. */
  45111. attachToMesh(transformNode: TransformNode): void;
  45112. /**
  45113. * Detach the sound from the previously attached mesh
  45114. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45115. */
  45116. detachFromMesh(): void;
  45117. private _onRegisterAfterWorldMatrixUpdate;
  45118. /**
  45119. * Clone the current sound in the scene.
  45120. * @returns the new sound clone
  45121. */
  45122. clone(): Nullable<Sound>;
  45123. /**
  45124. * Gets the current underlying audio buffer containing the data
  45125. * @returns the audio buffer
  45126. */
  45127. getAudioBuffer(): Nullable<AudioBuffer>;
  45128. /**
  45129. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  45130. * @returns the source node
  45131. */
  45132. getSoundSource(): Nullable<AudioBufferSourceNode>;
  45133. /**
  45134. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  45135. * @returns the gain node
  45136. */
  45137. getSoundGain(): Nullable<GainNode>;
  45138. /**
  45139. * Serializes the Sound in a JSON representation
  45140. * @returns the JSON representation of the sound
  45141. */
  45142. serialize(): any;
  45143. /**
  45144. * Parse a JSON representation of a sound to innstantiate in a given scene
  45145. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  45146. * @param scene Define the scene the new parsed sound should be created in
  45147. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  45148. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  45149. * @returns the newly parsed sound
  45150. */
  45151. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  45152. }
  45153. }
  45154. declare module BABYLON {
  45155. /**
  45156. * This defines an action helpful to play a defined sound on a triggered action.
  45157. */
  45158. export class PlaySoundAction extends Action {
  45159. private _sound;
  45160. /**
  45161. * Instantiate the action
  45162. * @param triggerOptions defines the trigger options
  45163. * @param sound defines the sound to play
  45164. * @param condition defines the trigger related conditions
  45165. */
  45166. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45167. /** @hidden */
  45168. _prepare(): void;
  45169. /**
  45170. * Execute the action and play the sound.
  45171. */
  45172. execute(): void;
  45173. /**
  45174. * Serializes the actions and its related information.
  45175. * @param parent defines the object to serialize in
  45176. * @returns the serialized object
  45177. */
  45178. serialize(parent: any): any;
  45179. }
  45180. /**
  45181. * This defines an action helpful to stop a defined sound on a triggered action.
  45182. */
  45183. export class StopSoundAction extends Action {
  45184. private _sound;
  45185. /**
  45186. * Instantiate the action
  45187. * @param triggerOptions defines the trigger options
  45188. * @param sound defines the sound to stop
  45189. * @param condition defines the trigger related conditions
  45190. */
  45191. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45192. /** @hidden */
  45193. _prepare(): void;
  45194. /**
  45195. * Execute the action and stop the sound.
  45196. */
  45197. execute(): void;
  45198. /**
  45199. * Serializes the actions and its related information.
  45200. * @param parent defines the object to serialize in
  45201. * @returns the serialized object
  45202. */
  45203. serialize(parent: any): any;
  45204. }
  45205. }
  45206. declare module BABYLON {
  45207. /**
  45208. * This defines an action responsible to change the value of a property
  45209. * by interpolating between its current value and the newly set one once triggered.
  45210. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45211. */
  45212. export class InterpolateValueAction extends Action {
  45213. /**
  45214. * Defines the path of the property where the value should be interpolated
  45215. */
  45216. propertyPath: string;
  45217. /**
  45218. * Defines the target value at the end of the interpolation.
  45219. */
  45220. value: any;
  45221. /**
  45222. * Defines the time it will take for the property to interpolate to the value.
  45223. */
  45224. duration: number;
  45225. /**
  45226. * Defines if the other scene animations should be stopped when the action has been triggered
  45227. */
  45228. stopOtherAnimations?: boolean;
  45229. /**
  45230. * Defines a callback raised once the interpolation animation has been done.
  45231. */
  45232. onInterpolationDone?: () => void;
  45233. /**
  45234. * Observable triggered once the interpolation animation has been done.
  45235. */
  45236. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  45237. private _target;
  45238. private _effectiveTarget;
  45239. private _property;
  45240. /**
  45241. * Instantiate the action
  45242. * @param triggerOptions defines the trigger options
  45243. * @param target defines the object containing the value to interpolate
  45244. * @param propertyPath defines the path to the property in the target object
  45245. * @param value defines the target value at the end of the interpolation
  45246. * @param duration deines the time it will take for the property to interpolate to the value.
  45247. * @param condition defines the trigger related conditions
  45248. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  45249. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  45250. */
  45251. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  45252. /** @hidden */
  45253. _prepare(): void;
  45254. /**
  45255. * Execute the action starts the value interpolation.
  45256. */
  45257. execute(): void;
  45258. /**
  45259. * Serializes the actions and its related information.
  45260. * @param parent defines the object to serialize in
  45261. * @returns the serialized object
  45262. */
  45263. serialize(parent: any): any;
  45264. }
  45265. }
  45266. declare module BABYLON {
  45267. /**
  45268. * Options allowed during the creation of a sound track.
  45269. */
  45270. export interface ISoundTrackOptions {
  45271. /**
  45272. * The volume the sound track should take during creation
  45273. */
  45274. volume?: number;
  45275. /**
  45276. * Define if the sound track is the main sound track of the scene
  45277. */
  45278. mainTrack?: boolean;
  45279. }
  45280. /**
  45281. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45282. * It will be also used in a future release to apply effects on a specific track.
  45283. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45284. */
  45285. export class SoundTrack {
  45286. /**
  45287. * The unique identifier of the sound track in the scene.
  45288. */
  45289. id: number;
  45290. /**
  45291. * The list of sounds included in the sound track.
  45292. */
  45293. soundCollection: Array<Sound>;
  45294. private _outputAudioNode;
  45295. private _scene;
  45296. private _connectedAnalyser;
  45297. private _options;
  45298. private _isInitialized;
  45299. /**
  45300. * Creates a new sound track.
  45301. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45302. * @param scene Define the scene the sound track belongs to
  45303. * @param options
  45304. */
  45305. constructor(scene: Scene, options?: ISoundTrackOptions);
  45306. private _initializeSoundTrackAudioGraph;
  45307. /**
  45308. * Release the sound track and its associated resources
  45309. */
  45310. dispose(): void;
  45311. /**
  45312. * Adds a sound to this sound track
  45313. * @param sound define the cound to add
  45314. * @ignoreNaming
  45315. */
  45316. AddSound(sound: Sound): void;
  45317. /**
  45318. * Removes a sound to this sound track
  45319. * @param sound define the cound to remove
  45320. * @ignoreNaming
  45321. */
  45322. RemoveSound(sound: Sound): void;
  45323. /**
  45324. * Set a global volume for the full sound track.
  45325. * @param newVolume Define the new volume of the sound track
  45326. */
  45327. setVolume(newVolume: number): void;
  45328. /**
  45329. * Switch the panning model to HRTF:
  45330. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45331. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45332. */
  45333. switchPanningModelToHRTF(): void;
  45334. /**
  45335. * Switch the panning model to Equal Power:
  45336. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45337. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45338. */
  45339. switchPanningModelToEqualPower(): void;
  45340. /**
  45341. * Connect the sound track to an audio analyser allowing some amazing
  45342. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45343. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45344. * @param analyser The analyser to connect to the engine
  45345. */
  45346. connectToAnalyser(analyser: Analyser): void;
  45347. }
  45348. }
  45349. declare module BABYLON {
  45350. interface AbstractScene {
  45351. /**
  45352. * The list of sounds used in the scene.
  45353. */
  45354. sounds: Nullable<Array<Sound>>;
  45355. }
  45356. interface Scene {
  45357. /**
  45358. * @hidden
  45359. * Backing field
  45360. */
  45361. _mainSoundTrack: SoundTrack;
  45362. /**
  45363. * The main sound track played by the scene.
  45364. * It cotains your primary collection of sounds.
  45365. */
  45366. mainSoundTrack: SoundTrack;
  45367. /**
  45368. * The list of sound tracks added to the scene
  45369. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45370. */
  45371. soundTracks: Nullable<Array<SoundTrack>>;
  45372. /**
  45373. * Gets a sound using a given name
  45374. * @param name defines the name to search for
  45375. * @return the found sound or null if not found at all.
  45376. */
  45377. getSoundByName(name: string): Nullable<Sound>;
  45378. /**
  45379. * Gets or sets if audio support is enabled
  45380. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45381. */
  45382. audioEnabled: boolean;
  45383. /**
  45384. * Gets or sets if audio will be output to headphones
  45385. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45386. */
  45387. headphone: boolean;
  45388. /**
  45389. * Gets or sets custom audio listener position provider
  45390. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45391. */
  45392. audioListenerPositionProvider: Nullable<() => Vector3>;
  45393. /**
  45394. * Gets or sets a refresh rate when using 3D audio positioning
  45395. */
  45396. audioPositioningRefreshRate: number;
  45397. }
  45398. /**
  45399. * Defines the sound scene component responsible to manage any sounds
  45400. * in a given scene.
  45401. */
  45402. export class AudioSceneComponent implements ISceneSerializableComponent {
  45403. private static _CameraDirectionLH;
  45404. private static _CameraDirectionRH;
  45405. /**
  45406. * The component name helpfull to identify the component in the list of scene components.
  45407. */
  45408. readonly name: string;
  45409. /**
  45410. * The scene the component belongs to.
  45411. */
  45412. scene: Scene;
  45413. private _audioEnabled;
  45414. /**
  45415. * Gets whether audio is enabled or not.
  45416. * Please use related enable/disable method to switch state.
  45417. */
  45418. get audioEnabled(): boolean;
  45419. private _headphone;
  45420. /**
  45421. * Gets whether audio is outputing to headphone or not.
  45422. * Please use the according Switch methods to change output.
  45423. */
  45424. get headphone(): boolean;
  45425. /**
  45426. * Gets or sets a refresh rate when using 3D audio positioning
  45427. */
  45428. audioPositioningRefreshRate: number;
  45429. private _audioListenerPositionProvider;
  45430. /**
  45431. * Gets the current audio listener position provider
  45432. */
  45433. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45434. /**
  45435. * Sets a custom listener position for all sounds in the scene
  45436. * By default, this is the position of the first active camera
  45437. */
  45438. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45439. /**
  45440. * Creates a new instance of the component for the given scene
  45441. * @param scene Defines the scene to register the component in
  45442. */
  45443. constructor(scene: Scene);
  45444. /**
  45445. * Registers the component in a given scene
  45446. */
  45447. register(): void;
  45448. /**
  45449. * Rebuilds the elements related to this component in case of
  45450. * context lost for instance.
  45451. */
  45452. rebuild(): void;
  45453. /**
  45454. * Serializes the component data to the specified json object
  45455. * @param serializationObject The object to serialize to
  45456. */
  45457. serialize(serializationObject: any): void;
  45458. /**
  45459. * Adds all the elements from the container to the scene
  45460. * @param container the container holding the elements
  45461. */
  45462. addFromContainer(container: AbstractScene): void;
  45463. /**
  45464. * Removes all the elements in the container from the scene
  45465. * @param container contains the elements to remove
  45466. * @param dispose if the removed element should be disposed (default: false)
  45467. */
  45468. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45469. /**
  45470. * Disposes the component and the associated ressources.
  45471. */
  45472. dispose(): void;
  45473. /**
  45474. * Disables audio in the associated scene.
  45475. */
  45476. disableAudio(): void;
  45477. /**
  45478. * Enables audio in the associated scene.
  45479. */
  45480. enableAudio(): void;
  45481. /**
  45482. * Switch audio to headphone output.
  45483. */
  45484. switchAudioModeForHeadphones(): void;
  45485. /**
  45486. * Switch audio to normal speakers.
  45487. */
  45488. switchAudioModeForNormalSpeakers(): void;
  45489. private _cachedCameraDirection;
  45490. private _cachedCameraPosition;
  45491. private _lastCheck;
  45492. private _afterRender;
  45493. }
  45494. }
  45495. declare module BABYLON {
  45496. /**
  45497. * Wraps one or more Sound objects and selects one with random weight for playback.
  45498. */
  45499. export class WeightedSound {
  45500. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45501. loop: boolean;
  45502. private _coneInnerAngle;
  45503. private _coneOuterAngle;
  45504. private _volume;
  45505. /** A Sound is currently playing. */
  45506. isPlaying: boolean;
  45507. /** A Sound is currently paused. */
  45508. isPaused: boolean;
  45509. private _sounds;
  45510. private _weights;
  45511. private _currentIndex?;
  45512. /**
  45513. * Creates a new WeightedSound from the list of sounds given.
  45514. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45515. * @param sounds Array of Sounds that will be selected from.
  45516. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45517. */
  45518. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45519. /**
  45520. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45521. */
  45522. get directionalConeInnerAngle(): number;
  45523. /**
  45524. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45525. */
  45526. set directionalConeInnerAngle(value: number);
  45527. /**
  45528. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45529. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45530. */
  45531. get directionalConeOuterAngle(): number;
  45532. /**
  45533. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45534. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45535. */
  45536. set directionalConeOuterAngle(value: number);
  45537. /**
  45538. * Playback volume.
  45539. */
  45540. get volume(): number;
  45541. /**
  45542. * Playback volume.
  45543. */
  45544. set volume(value: number);
  45545. private _onended;
  45546. /**
  45547. * Suspend playback
  45548. */
  45549. pause(): void;
  45550. /**
  45551. * Stop playback
  45552. */
  45553. stop(): void;
  45554. /**
  45555. * Start playback.
  45556. * @param startOffset Position the clip head at a specific time in seconds.
  45557. */
  45558. play(startOffset?: number): void;
  45559. }
  45560. }
  45561. declare module BABYLON {
  45562. /**
  45563. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45564. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45565. */
  45566. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45567. /**
  45568. * Gets the name of the behavior.
  45569. */
  45570. get name(): string;
  45571. /**
  45572. * The easing function used by animations
  45573. */
  45574. static EasingFunction: BackEase;
  45575. /**
  45576. * The easing mode used by animations
  45577. */
  45578. static EasingMode: number;
  45579. /**
  45580. * The duration of the animation, in milliseconds
  45581. */
  45582. transitionDuration: number;
  45583. /**
  45584. * Length of the distance animated by the transition when lower radius is reached
  45585. */
  45586. lowerRadiusTransitionRange: number;
  45587. /**
  45588. * Length of the distance animated by the transition when upper radius is reached
  45589. */
  45590. upperRadiusTransitionRange: number;
  45591. private _autoTransitionRange;
  45592. /**
  45593. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45594. */
  45595. get autoTransitionRange(): boolean;
  45596. /**
  45597. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45598. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45599. */
  45600. set autoTransitionRange(value: boolean);
  45601. private _attachedCamera;
  45602. private _onAfterCheckInputsObserver;
  45603. private _onMeshTargetChangedObserver;
  45604. /**
  45605. * Initializes the behavior.
  45606. */
  45607. init(): void;
  45608. /**
  45609. * Attaches the behavior to its arc rotate camera.
  45610. * @param camera Defines the camera to attach the behavior to
  45611. */
  45612. attach(camera: ArcRotateCamera): void;
  45613. /**
  45614. * Detaches the behavior from its current arc rotate camera.
  45615. */
  45616. detach(): void;
  45617. private _radiusIsAnimating;
  45618. private _radiusBounceTransition;
  45619. private _animatables;
  45620. private _cachedWheelPrecision;
  45621. /**
  45622. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45623. * @param radiusLimit The limit to check against.
  45624. * @return Bool to indicate if at limit.
  45625. */
  45626. private _isRadiusAtLimit;
  45627. /**
  45628. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45629. * @param radiusDelta The delta by which to animate to. Can be negative.
  45630. */
  45631. private _applyBoundRadiusAnimation;
  45632. /**
  45633. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45634. */
  45635. protected _clearAnimationLocks(): void;
  45636. /**
  45637. * Stops and removes all animations that have been applied to the camera
  45638. */
  45639. stopAllAnimations(): void;
  45640. }
  45641. }
  45642. declare module BABYLON {
  45643. /**
  45644. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  45645. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45646. */
  45647. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45648. /**
  45649. * Gets the name of the behavior.
  45650. */
  45651. get name(): string;
  45652. private _mode;
  45653. private _radiusScale;
  45654. private _positionScale;
  45655. private _defaultElevation;
  45656. private _elevationReturnTime;
  45657. private _elevationReturnWaitTime;
  45658. private _zoomStopsAnimation;
  45659. private _framingTime;
  45660. /**
  45661. * The easing function used by animations
  45662. */
  45663. static EasingFunction: ExponentialEase;
  45664. /**
  45665. * The easing mode used by animations
  45666. */
  45667. static EasingMode: number;
  45668. /**
  45669. * Sets the current mode used by the behavior
  45670. */
  45671. set mode(mode: number);
  45672. /**
  45673. * Gets current mode used by the behavior.
  45674. */
  45675. get mode(): number;
  45676. /**
  45677. * Sets the scale applied to the radius (1 by default)
  45678. */
  45679. set radiusScale(radius: number);
  45680. /**
  45681. * Gets the scale applied to the radius
  45682. */
  45683. get radiusScale(): number;
  45684. /**
  45685. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45686. */
  45687. set positionScale(scale: number);
  45688. /**
  45689. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45690. */
  45691. get positionScale(): number;
  45692. /**
  45693. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45694. * behaviour is triggered, in radians.
  45695. */
  45696. set defaultElevation(elevation: number);
  45697. /**
  45698. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45699. * behaviour is triggered, in radians.
  45700. */
  45701. get defaultElevation(): number;
  45702. /**
  45703. * Sets the time (in milliseconds) taken to return to the default beta position.
  45704. * Negative value indicates camera should not return to default.
  45705. */
  45706. set elevationReturnTime(speed: number);
  45707. /**
  45708. * Gets the time (in milliseconds) taken to return to the default beta position.
  45709. * Negative value indicates camera should not return to default.
  45710. */
  45711. get elevationReturnTime(): number;
  45712. /**
  45713. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45714. */
  45715. set elevationReturnWaitTime(time: number);
  45716. /**
  45717. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45718. */
  45719. get elevationReturnWaitTime(): number;
  45720. /**
  45721. * Sets the flag that indicates if user zooming should stop animation.
  45722. */
  45723. set zoomStopsAnimation(flag: boolean);
  45724. /**
  45725. * Gets the flag that indicates if user zooming should stop animation.
  45726. */
  45727. get zoomStopsAnimation(): boolean;
  45728. /**
  45729. * Sets the transition time when framing the mesh, in milliseconds
  45730. */
  45731. set framingTime(time: number);
  45732. /**
  45733. * Gets the transition time when framing the mesh, in milliseconds
  45734. */
  45735. get framingTime(): number;
  45736. /**
  45737. * Define if the behavior should automatically change the configured
  45738. * camera limits and sensibilities.
  45739. */
  45740. autoCorrectCameraLimitsAndSensibility: boolean;
  45741. private _onPrePointerObservableObserver;
  45742. private _onAfterCheckInputsObserver;
  45743. private _onMeshTargetChangedObserver;
  45744. private _attachedCamera;
  45745. private _isPointerDown;
  45746. private _lastInteractionTime;
  45747. /**
  45748. * Initializes the behavior.
  45749. */
  45750. init(): void;
  45751. /**
  45752. * Attaches the behavior to its arc rotate camera.
  45753. * @param camera Defines the camera to attach the behavior to
  45754. */
  45755. attach(camera: ArcRotateCamera): void;
  45756. /**
  45757. * Detaches the behavior from its current arc rotate camera.
  45758. */
  45759. detach(): void;
  45760. private _animatables;
  45761. private _betaIsAnimating;
  45762. private _betaTransition;
  45763. private _radiusTransition;
  45764. private _vectorTransition;
  45765. /**
  45766. * Targets the given mesh and updates zoom level accordingly.
  45767. * @param mesh The mesh to target.
  45768. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45769. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45770. */
  45771. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45772. /**
  45773. * Targets the given mesh with its children and updates zoom level accordingly.
  45774. * @param mesh The mesh to target.
  45775. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45776. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45777. */
  45778. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45779. /**
  45780. * Targets the given meshes with their children and updates zoom level accordingly.
  45781. * @param meshes The mesh to target.
  45782. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45783. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45784. */
  45785. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45786. /**
  45787. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  45788. * @param minimumWorld Determines the smaller position of the bounding box extend
  45789. * @param maximumWorld Determines the bigger position of the bounding box extend
  45790. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45791. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45792. */
  45793. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45794. /**
  45795. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  45796. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  45797. * frustum width.
  45798. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  45799. * to fully enclose the mesh in the viewing frustum.
  45800. */
  45801. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  45802. /**
  45803. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  45804. * is automatically returned to its default position (expected to be above ground plane).
  45805. */
  45806. private _maintainCameraAboveGround;
  45807. /**
  45808. * Returns the frustum slope based on the canvas ratio and camera FOV
  45809. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  45810. */
  45811. private _getFrustumSlope;
  45812. /**
  45813. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  45814. */
  45815. private _clearAnimationLocks;
  45816. /**
  45817. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  45818. */
  45819. private _applyUserInteraction;
  45820. /**
  45821. * Stops and removes all animations that have been applied to the camera
  45822. */
  45823. stopAllAnimations(): void;
  45824. /**
  45825. * Gets a value indicating if the user is moving the camera
  45826. */
  45827. get isUserIsMoving(): boolean;
  45828. /**
  45829. * The camera can move all the way towards the mesh.
  45830. */
  45831. static IgnoreBoundsSizeMode: number;
  45832. /**
  45833. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  45834. */
  45835. static FitFrustumSidesMode: number;
  45836. }
  45837. }
  45838. declare module BABYLON {
  45839. /**
  45840. * Base class for Camera Pointer Inputs.
  45841. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  45842. * for example usage.
  45843. */
  45844. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  45845. /**
  45846. * Defines the camera the input is attached to.
  45847. */
  45848. abstract camera: Camera;
  45849. /**
  45850. * Whether keyboard modifier keys are pressed at time of last mouse event.
  45851. */
  45852. protected _altKey: boolean;
  45853. protected _ctrlKey: boolean;
  45854. protected _metaKey: boolean;
  45855. protected _shiftKey: boolean;
  45856. /**
  45857. * Which mouse buttons were pressed at time of last mouse event.
  45858. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  45859. */
  45860. protected _buttonsPressed: number;
  45861. /**
  45862. * Defines the buttons associated with the input to handle camera move.
  45863. */
  45864. buttons: number[];
  45865. /**
  45866. * Attach the input controls to a specific dom element to get the input from.
  45867. * @param element Defines the element the controls should be listened from
  45868. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45869. */
  45870. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45871. /**
  45872. * Detach the current controls from the specified dom element.
  45873. * @param element Defines the element to stop listening the inputs from
  45874. */
  45875. detachControl(element: Nullable<HTMLElement>): void;
  45876. /**
  45877. * Gets the class name of the current input.
  45878. * @returns the class name
  45879. */
  45880. getClassName(): string;
  45881. /**
  45882. * Get the friendly name associated with the input class.
  45883. * @returns the input friendly name
  45884. */
  45885. getSimpleName(): string;
  45886. /**
  45887. * Called on pointer POINTERDOUBLETAP event.
  45888. * Override this method to provide functionality on POINTERDOUBLETAP event.
  45889. */
  45890. protected onDoubleTap(type: string): void;
  45891. /**
  45892. * Called on pointer POINTERMOVE event if only a single touch is active.
  45893. * Override this method to provide functionality.
  45894. */
  45895. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45896. /**
  45897. * Called on pointer POINTERMOVE event if multiple touches are active.
  45898. * Override this method to provide functionality.
  45899. */
  45900. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45901. /**
  45902. * Called on JS contextmenu event.
  45903. * Override this method to provide functionality.
  45904. */
  45905. protected onContextMenu(evt: PointerEvent): void;
  45906. /**
  45907. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45908. * press.
  45909. * Override this method to provide functionality.
  45910. */
  45911. protected onButtonDown(evt: PointerEvent): void;
  45912. /**
  45913. * Called each time a new POINTERUP event occurs. Ie, for each button
  45914. * release.
  45915. * Override this method to provide functionality.
  45916. */
  45917. protected onButtonUp(evt: PointerEvent): void;
  45918. /**
  45919. * Called when window becomes inactive.
  45920. * Override this method to provide functionality.
  45921. */
  45922. protected onLostFocus(): void;
  45923. private _pointerInput;
  45924. private _observer;
  45925. private _onLostFocus;
  45926. private pointA;
  45927. private pointB;
  45928. }
  45929. }
  45930. declare module BABYLON {
  45931. /**
  45932. * Manage the pointers inputs to control an arc rotate camera.
  45933. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45934. */
  45935. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  45936. /**
  45937. * Defines the camera the input is attached to.
  45938. */
  45939. camera: ArcRotateCamera;
  45940. /**
  45941. * Gets the class name of the current input.
  45942. * @returns the class name
  45943. */
  45944. getClassName(): string;
  45945. /**
  45946. * Defines the buttons associated with the input to handle camera move.
  45947. */
  45948. buttons: number[];
  45949. /**
  45950. * Defines the pointer angular sensibility along the X axis or how fast is
  45951. * the camera rotating.
  45952. */
  45953. angularSensibilityX: number;
  45954. /**
  45955. * Defines the pointer angular sensibility along the Y axis or how fast is
  45956. * the camera rotating.
  45957. */
  45958. angularSensibilityY: number;
  45959. /**
  45960. * Defines the pointer pinch precision or how fast is the camera zooming.
  45961. */
  45962. pinchPrecision: number;
  45963. /**
  45964. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45965. * from 0.
  45966. * It defines the percentage of current camera.radius to use as delta when
  45967. * pinch zoom is used.
  45968. */
  45969. pinchDeltaPercentage: number;
  45970. /**
  45971. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  45972. * that any object in the plane at the camera's target point will scale
  45973. * perfectly with finger motion.
  45974. * Overrides pinchDeltaPercentage and pinchPrecision.
  45975. */
  45976. useNaturalPinchZoom: boolean;
  45977. /**
  45978. * Defines the pointer panning sensibility or how fast is the camera moving.
  45979. */
  45980. panningSensibility: number;
  45981. /**
  45982. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  45983. */
  45984. multiTouchPanning: boolean;
  45985. /**
  45986. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  45987. * zoom (pinch) through multitouch.
  45988. */
  45989. multiTouchPanAndZoom: boolean;
  45990. /**
  45991. * Revers pinch action direction.
  45992. */
  45993. pinchInwards: boolean;
  45994. private _isPanClick;
  45995. private _twoFingerActivityCount;
  45996. private _isPinching;
  45997. /**
  45998. * Called on pointer POINTERMOVE event if only a single touch is active.
  45999. */
  46000. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46001. /**
  46002. * Called on pointer POINTERDOUBLETAP event.
  46003. */
  46004. protected onDoubleTap(type: string): void;
  46005. /**
  46006. * Called on pointer POINTERMOVE event if multiple touches are active.
  46007. */
  46008. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46009. /**
  46010. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46011. * press.
  46012. */
  46013. protected onButtonDown(evt: PointerEvent): void;
  46014. /**
  46015. * Called each time a new POINTERUP event occurs. Ie, for each button
  46016. * release.
  46017. */
  46018. protected onButtonUp(evt: PointerEvent): void;
  46019. /**
  46020. * Called when window becomes inactive.
  46021. */
  46022. protected onLostFocus(): void;
  46023. }
  46024. }
  46025. declare module BABYLON {
  46026. /**
  46027. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  46028. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46029. */
  46030. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  46031. /**
  46032. * Defines the camera the input is attached to.
  46033. */
  46034. camera: ArcRotateCamera;
  46035. /**
  46036. * Defines the list of key codes associated with the up action (increase alpha)
  46037. */
  46038. keysUp: number[];
  46039. /**
  46040. * Defines the list of key codes associated with the down action (decrease alpha)
  46041. */
  46042. keysDown: number[];
  46043. /**
  46044. * Defines the list of key codes associated with the left action (increase beta)
  46045. */
  46046. keysLeft: number[];
  46047. /**
  46048. * Defines the list of key codes associated with the right action (decrease beta)
  46049. */
  46050. keysRight: number[];
  46051. /**
  46052. * Defines the list of key codes associated with the reset action.
  46053. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  46054. */
  46055. keysReset: number[];
  46056. /**
  46057. * Defines the panning sensibility of the inputs.
  46058. * (How fast is the camera panning)
  46059. */
  46060. panningSensibility: number;
  46061. /**
  46062. * Defines the zooming sensibility of the inputs.
  46063. * (How fast is the camera zooming)
  46064. */
  46065. zoomingSensibility: number;
  46066. /**
  46067. * Defines whether maintaining the alt key down switch the movement mode from
  46068. * orientation to zoom.
  46069. */
  46070. useAltToZoom: boolean;
  46071. /**
  46072. * Rotation speed of the camera
  46073. */
  46074. angularSpeed: number;
  46075. private _keys;
  46076. private _ctrlPressed;
  46077. private _altPressed;
  46078. private _onCanvasBlurObserver;
  46079. private _onKeyboardObserver;
  46080. private _engine;
  46081. private _scene;
  46082. /**
  46083. * Attach the input controls to a specific dom element to get the input from.
  46084. * @param element Defines the element the controls should be listened from
  46085. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46086. */
  46087. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46088. /**
  46089. * Detach the current controls from the specified dom element.
  46090. * @param element Defines the element to stop listening the inputs from
  46091. */
  46092. detachControl(element: Nullable<HTMLElement>): void;
  46093. /**
  46094. * Update the current camera state depending on the inputs that have been used this frame.
  46095. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46096. */
  46097. checkInputs(): void;
  46098. /**
  46099. * Gets the class name of the current intput.
  46100. * @returns the class name
  46101. */
  46102. getClassName(): string;
  46103. /**
  46104. * Get the friendly name associated with the input class.
  46105. * @returns the input friendly name
  46106. */
  46107. getSimpleName(): string;
  46108. }
  46109. }
  46110. declare module BABYLON {
  46111. /**
  46112. * Manage the mouse wheel inputs to control an arc rotate camera.
  46113. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46114. */
  46115. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  46116. /**
  46117. * Defines the camera the input is attached to.
  46118. */
  46119. camera: ArcRotateCamera;
  46120. /**
  46121. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46122. */
  46123. wheelPrecision: number;
  46124. /**
  46125. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46126. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46127. */
  46128. wheelDeltaPercentage: number;
  46129. private _wheel;
  46130. private _observer;
  46131. private computeDeltaFromMouseWheelLegacyEvent;
  46132. /**
  46133. * Attach the input controls to a specific dom element to get the input from.
  46134. * @param element Defines the element the controls should be listened from
  46135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46136. */
  46137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46138. /**
  46139. * Detach the current controls from the specified dom element.
  46140. * @param element Defines the element to stop listening the inputs from
  46141. */
  46142. detachControl(element: Nullable<HTMLElement>): void;
  46143. /**
  46144. * Gets the class name of the current intput.
  46145. * @returns the class name
  46146. */
  46147. getClassName(): string;
  46148. /**
  46149. * Get the friendly name associated with the input class.
  46150. * @returns the input friendly name
  46151. */
  46152. getSimpleName(): string;
  46153. }
  46154. }
  46155. declare module BABYLON {
  46156. /**
  46157. * Default Inputs manager for the ArcRotateCamera.
  46158. * It groups all the default supported inputs for ease of use.
  46159. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46160. */
  46161. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  46162. /**
  46163. * Instantiates a new ArcRotateCameraInputsManager.
  46164. * @param camera Defines the camera the inputs belong to
  46165. */
  46166. constructor(camera: ArcRotateCamera);
  46167. /**
  46168. * Add mouse wheel input support to the input manager.
  46169. * @returns the current input manager
  46170. */
  46171. addMouseWheel(): ArcRotateCameraInputsManager;
  46172. /**
  46173. * Add pointers input support to the input manager.
  46174. * @returns the current input manager
  46175. */
  46176. addPointers(): ArcRotateCameraInputsManager;
  46177. /**
  46178. * Add keyboard input support to the input manager.
  46179. * @returns the current input manager
  46180. */
  46181. addKeyboard(): ArcRotateCameraInputsManager;
  46182. }
  46183. }
  46184. declare module BABYLON {
  46185. /**
  46186. * This represents an orbital type of camera.
  46187. *
  46188. * 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.
  46189. * 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.
  46190. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  46191. */
  46192. export class ArcRotateCamera extends TargetCamera {
  46193. /**
  46194. * Defines the rotation angle of the camera along the longitudinal axis.
  46195. */
  46196. alpha: number;
  46197. /**
  46198. * Defines the rotation angle of the camera along the latitudinal axis.
  46199. */
  46200. beta: number;
  46201. /**
  46202. * Defines the radius of the camera from it s target point.
  46203. */
  46204. radius: number;
  46205. protected _target: Vector3;
  46206. protected _targetHost: Nullable<AbstractMesh>;
  46207. /**
  46208. * Defines the target point of the camera.
  46209. * The camera looks towards it form the radius distance.
  46210. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  46211. */
  46212. get target(): Vector3;
  46213. set target(value: Vector3);
  46214. /**
  46215. * Define the current local position of the camera in the scene
  46216. */
  46217. get position(): Vector3;
  46218. set position(newPosition: Vector3);
  46219. protected _upToYMatrix: Matrix;
  46220. protected _YToUpMatrix: Matrix;
  46221. /**
  46222. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  46223. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  46224. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  46225. */
  46226. set upVector(vec: Vector3);
  46227. get upVector(): Vector3;
  46228. /**
  46229. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  46230. */
  46231. setMatUp(): void;
  46232. /**
  46233. * Current inertia value on the longitudinal axis.
  46234. * The bigger this number the longer it will take for the camera to stop.
  46235. */
  46236. inertialAlphaOffset: number;
  46237. /**
  46238. * Current inertia value on the latitudinal axis.
  46239. * The bigger this number the longer it will take for the camera to stop.
  46240. */
  46241. inertialBetaOffset: number;
  46242. /**
  46243. * Current inertia value on the radius axis.
  46244. * The bigger this number the longer it will take for the camera to stop.
  46245. */
  46246. inertialRadiusOffset: number;
  46247. /**
  46248. * Minimum allowed angle on the longitudinal axis.
  46249. * This can help limiting how the Camera is able to move in the scene.
  46250. */
  46251. lowerAlphaLimit: Nullable<number>;
  46252. /**
  46253. * Maximum allowed angle on the longitudinal axis.
  46254. * This can help limiting how the Camera is able to move in the scene.
  46255. */
  46256. upperAlphaLimit: Nullable<number>;
  46257. /**
  46258. * Minimum allowed angle on the latitudinal axis.
  46259. * This can help limiting how the Camera is able to move in the scene.
  46260. */
  46261. lowerBetaLimit: number;
  46262. /**
  46263. * Maximum allowed angle on the latitudinal axis.
  46264. * This can help limiting how the Camera is able to move in the scene.
  46265. */
  46266. upperBetaLimit: number;
  46267. /**
  46268. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46269. * This can help limiting how the Camera is able to move in the scene.
  46270. */
  46271. lowerRadiusLimit: Nullable<number>;
  46272. /**
  46273. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46274. * This can help limiting how the Camera is able to move in the scene.
  46275. */
  46276. upperRadiusLimit: Nullable<number>;
  46277. /**
  46278. * Defines the current inertia value used during panning of the camera along the X axis.
  46279. */
  46280. inertialPanningX: number;
  46281. /**
  46282. * Defines the current inertia value used during panning of the camera along the Y axis.
  46283. */
  46284. inertialPanningY: number;
  46285. /**
  46286. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46287. * Basically if your fingers moves away from more than this distance you will be considered
  46288. * in pinch mode.
  46289. */
  46290. pinchToPanMaxDistance: number;
  46291. /**
  46292. * Defines the maximum distance the camera can pan.
  46293. * This could help keeping the cammera always in your scene.
  46294. */
  46295. panningDistanceLimit: Nullable<number>;
  46296. /**
  46297. * Defines the target of the camera before paning.
  46298. */
  46299. panningOriginTarget: Vector3;
  46300. /**
  46301. * Defines the value of the inertia used during panning.
  46302. * 0 would mean stop inertia and one would mean no decelleration at all.
  46303. */
  46304. panningInertia: number;
  46305. /**
  46306. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46307. */
  46308. get angularSensibilityX(): number;
  46309. set angularSensibilityX(value: number);
  46310. /**
  46311. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46312. */
  46313. get angularSensibilityY(): number;
  46314. set angularSensibilityY(value: number);
  46315. /**
  46316. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46317. */
  46318. get pinchPrecision(): number;
  46319. set pinchPrecision(value: number);
  46320. /**
  46321. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46322. * It will be used instead of pinchDeltaPrecision if different from 0.
  46323. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46324. */
  46325. get pinchDeltaPercentage(): number;
  46326. set pinchDeltaPercentage(value: number);
  46327. /**
  46328. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46329. * and pinch delta percentage.
  46330. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46331. * that any object in the plane at the camera's target point will scale
  46332. * perfectly with finger motion.
  46333. */
  46334. get useNaturalPinchZoom(): boolean;
  46335. set useNaturalPinchZoom(value: boolean);
  46336. /**
  46337. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46338. */
  46339. get panningSensibility(): number;
  46340. set panningSensibility(value: number);
  46341. /**
  46342. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46343. */
  46344. get keysUp(): number[];
  46345. set keysUp(value: number[]);
  46346. /**
  46347. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46348. */
  46349. get keysDown(): number[];
  46350. set keysDown(value: number[]);
  46351. /**
  46352. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46353. */
  46354. get keysLeft(): number[];
  46355. set keysLeft(value: number[]);
  46356. /**
  46357. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46358. */
  46359. get keysRight(): number[];
  46360. set keysRight(value: number[]);
  46361. /**
  46362. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46363. */
  46364. get wheelPrecision(): number;
  46365. set wheelPrecision(value: number);
  46366. /**
  46367. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46368. * It will be used instead of pinchDeltaPrecision if different from 0.
  46369. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46370. */
  46371. get wheelDeltaPercentage(): number;
  46372. set wheelDeltaPercentage(value: number);
  46373. /**
  46374. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46375. */
  46376. zoomOnFactor: number;
  46377. /**
  46378. * Defines a screen offset for the camera position.
  46379. */
  46380. targetScreenOffset: Vector2;
  46381. /**
  46382. * Allows the camera to be completely reversed.
  46383. * If false the camera can not arrive upside down.
  46384. */
  46385. allowUpsideDown: boolean;
  46386. /**
  46387. * Define if double tap/click is used to restore the previously saved state of the camera.
  46388. */
  46389. useInputToRestoreState: boolean;
  46390. /** @hidden */
  46391. _viewMatrix: Matrix;
  46392. /** @hidden */
  46393. _useCtrlForPanning: boolean;
  46394. /** @hidden */
  46395. _panningMouseButton: number;
  46396. /**
  46397. * Defines the input associated to the camera.
  46398. */
  46399. inputs: ArcRotateCameraInputsManager;
  46400. /** @hidden */
  46401. _reset: () => void;
  46402. /**
  46403. * Defines the allowed panning axis.
  46404. */
  46405. panningAxis: Vector3;
  46406. protected _localDirection: Vector3;
  46407. protected _transformedDirection: Vector3;
  46408. private _bouncingBehavior;
  46409. /**
  46410. * Gets the bouncing behavior of the camera if it has been enabled.
  46411. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46412. */
  46413. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46414. /**
  46415. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46416. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46417. */
  46418. get useBouncingBehavior(): boolean;
  46419. set useBouncingBehavior(value: boolean);
  46420. private _framingBehavior;
  46421. /**
  46422. * Gets the framing behavior of the camera if it has been enabled.
  46423. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46424. */
  46425. get framingBehavior(): Nullable<FramingBehavior>;
  46426. /**
  46427. * Defines if the framing behavior of the camera is enabled on the camera.
  46428. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46429. */
  46430. get useFramingBehavior(): boolean;
  46431. set useFramingBehavior(value: boolean);
  46432. private _autoRotationBehavior;
  46433. /**
  46434. * Gets the auto rotation behavior of the camera if it has been enabled.
  46435. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46436. */
  46437. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46438. /**
  46439. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46440. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46441. */
  46442. get useAutoRotationBehavior(): boolean;
  46443. set useAutoRotationBehavior(value: boolean);
  46444. /**
  46445. * Observable triggered when the mesh target has been changed on the camera.
  46446. */
  46447. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46448. /**
  46449. * Event raised when the camera is colliding with a mesh.
  46450. */
  46451. onCollide: (collidedMesh: AbstractMesh) => void;
  46452. /**
  46453. * Defines whether the camera should check collision with the objects oh the scene.
  46454. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46455. */
  46456. checkCollisions: boolean;
  46457. /**
  46458. * Defines the collision radius of the camera.
  46459. * This simulates a sphere around the camera.
  46460. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46461. */
  46462. collisionRadius: Vector3;
  46463. protected _collider: Collider;
  46464. protected _previousPosition: Vector3;
  46465. protected _collisionVelocity: Vector3;
  46466. protected _newPosition: Vector3;
  46467. protected _previousAlpha: number;
  46468. protected _previousBeta: number;
  46469. protected _previousRadius: number;
  46470. protected _collisionTriggered: boolean;
  46471. protected _targetBoundingCenter: Nullable<Vector3>;
  46472. private _computationVector;
  46473. /**
  46474. * Instantiates a new ArcRotateCamera in a given scene
  46475. * @param name Defines the name of the camera
  46476. * @param alpha Defines the camera rotation along the logitudinal axis
  46477. * @param beta Defines the camera rotation along the latitudinal axis
  46478. * @param radius Defines the camera distance from its target
  46479. * @param target Defines the camera target
  46480. * @param scene Defines the scene the camera belongs to
  46481. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46482. */
  46483. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46484. /** @hidden */
  46485. _initCache(): void;
  46486. /** @hidden */
  46487. _updateCache(ignoreParentClass?: boolean): void;
  46488. protected _getTargetPosition(): Vector3;
  46489. private _storedAlpha;
  46490. private _storedBeta;
  46491. private _storedRadius;
  46492. private _storedTarget;
  46493. private _storedTargetScreenOffset;
  46494. /**
  46495. * Stores the current state of the camera (alpha, beta, radius and target)
  46496. * @returns the camera itself
  46497. */
  46498. storeState(): Camera;
  46499. /**
  46500. * @hidden
  46501. * Restored camera state. You must call storeState() first
  46502. */
  46503. _restoreStateValues(): boolean;
  46504. /** @hidden */
  46505. _isSynchronizedViewMatrix(): boolean;
  46506. /**
  46507. * Attached controls to the current camera.
  46508. * @param element Defines the element the controls should be listened from
  46509. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46510. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46511. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46512. */
  46513. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  46514. /**
  46515. * Detach the current controls from the camera.
  46516. * The camera will stop reacting to inputs.
  46517. * @param element Defines the element to stop listening the inputs from
  46518. */
  46519. detachControl(element: HTMLElement): void;
  46520. /** @hidden */
  46521. _checkInputs(): void;
  46522. protected _checkLimits(): void;
  46523. /**
  46524. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46525. */
  46526. rebuildAnglesAndRadius(): void;
  46527. /**
  46528. * Use a position to define the current camera related information like alpha, beta and radius
  46529. * @param position Defines the position to set the camera at
  46530. */
  46531. setPosition(position: Vector3): void;
  46532. /**
  46533. * Defines the target the camera should look at.
  46534. * This will automatically adapt alpha beta and radius to fit within the new target.
  46535. * @param target Defines the new target as a Vector or a mesh
  46536. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46537. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46538. */
  46539. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46540. /** @hidden */
  46541. _getViewMatrix(): Matrix;
  46542. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46543. /**
  46544. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46545. * @param meshes Defines the mesh to zoom on
  46546. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  46547. */
  46548. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46549. /**
  46550. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46551. * The target will be changed but the radius
  46552. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46553. * @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)
  46554. */
  46555. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46556. min: Vector3;
  46557. max: Vector3;
  46558. distance: number;
  46559. }, doNotUpdateMaxZ?: boolean): void;
  46560. /**
  46561. * @override
  46562. * Override Camera.createRigCamera
  46563. */
  46564. createRigCamera(name: string, cameraIndex: number): Camera;
  46565. /**
  46566. * @hidden
  46567. * @override
  46568. * Override Camera._updateRigCameras
  46569. */
  46570. _updateRigCameras(): void;
  46571. /**
  46572. * Destroy the camera and release the current resources hold by it.
  46573. */
  46574. dispose(): void;
  46575. /**
  46576. * Gets the current object class name.
  46577. * @return the class name
  46578. */
  46579. getClassName(): string;
  46580. }
  46581. }
  46582. declare module BABYLON {
  46583. /**
  46584. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46585. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46586. */
  46587. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46588. /**
  46589. * Gets the name of the behavior.
  46590. */
  46591. get name(): string;
  46592. private _zoomStopsAnimation;
  46593. private _idleRotationSpeed;
  46594. private _idleRotationWaitTime;
  46595. private _idleRotationSpinupTime;
  46596. /**
  46597. * Sets the flag that indicates if user zooming should stop animation.
  46598. */
  46599. set zoomStopsAnimation(flag: boolean);
  46600. /**
  46601. * Gets the flag that indicates if user zooming should stop animation.
  46602. */
  46603. get zoomStopsAnimation(): boolean;
  46604. /**
  46605. * Sets the default speed at which the camera rotates around the model.
  46606. */
  46607. set idleRotationSpeed(speed: number);
  46608. /**
  46609. * Gets the default speed at which the camera rotates around the model.
  46610. */
  46611. get idleRotationSpeed(): number;
  46612. /**
  46613. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46614. */
  46615. set idleRotationWaitTime(time: number);
  46616. /**
  46617. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46618. */
  46619. get idleRotationWaitTime(): number;
  46620. /**
  46621. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46622. */
  46623. set idleRotationSpinupTime(time: number);
  46624. /**
  46625. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46626. */
  46627. get idleRotationSpinupTime(): number;
  46628. /**
  46629. * Gets a value indicating if the camera is currently rotating because of this behavior
  46630. */
  46631. get rotationInProgress(): boolean;
  46632. private _onPrePointerObservableObserver;
  46633. private _onAfterCheckInputsObserver;
  46634. private _attachedCamera;
  46635. private _isPointerDown;
  46636. private _lastFrameTime;
  46637. private _lastInteractionTime;
  46638. private _cameraRotationSpeed;
  46639. /**
  46640. * Initializes the behavior.
  46641. */
  46642. init(): void;
  46643. /**
  46644. * Attaches the behavior to its arc rotate camera.
  46645. * @param camera Defines the camera to attach the behavior to
  46646. */
  46647. attach(camera: ArcRotateCamera): void;
  46648. /**
  46649. * Detaches the behavior from its current arc rotate camera.
  46650. */
  46651. detach(): void;
  46652. /**
  46653. * Returns true if user is scrolling.
  46654. * @return true if user is scrolling.
  46655. */
  46656. private _userIsZooming;
  46657. private _lastFrameRadius;
  46658. private _shouldAnimationStopForInteraction;
  46659. /**
  46660. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46661. */
  46662. private _applyUserInteraction;
  46663. private _userIsMoving;
  46664. }
  46665. }
  46666. declare module BABYLON {
  46667. /**
  46668. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46669. */
  46670. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46671. private ui;
  46672. /**
  46673. * The name of the behavior
  46674. */
  46675. name: string;
  46676. /**
  46677. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  46678. */
  46679. distanceAwayFromFace: number;
  46680. /**
  46681. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  46682. */
  46683. distanceAwayFromBottomOfFace: number;
  46684. private _faceVectors;
  46685. private _target;
  46686. private _scene;
  46687. private _onRenderObserver;
  46688. private _tmpMatrix;
  46689. private _tmpVector;
  46690. /**
  46691. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  46692. * @param ui The transform node that should be attched to the mesh
  46693. */
  46694. constructor(ui: TransformNode);
  46695. /**
  46696. * Initializes the behavior
  46697. */
  46698. init(): void;
  46699. private _closestFace;
  46700. private _zeroVector;
  46701. private _lookAtTmpMatrix;
  46702. private _lookAtToRef;
  46703. /**
  46704. * Attaches the AttachToBoxBehavior to the passed in mesh
  46705. * @param target The mesh that the specified node will be attached to
  46706. */
  46707. attach(target: Mesh): void;
  46708. /**
  46709. * Detaches the behavior from the mesh
  46710. */
  46711. detach(): void;
  46712. }
  46713. }
  46714. declare module BABYLON {
  46715. /**
  46716. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  46717. */
  46718. export class FadeInOutBehavior implements Behavior<Mesh> {
  46719. /**
  46720. * Time in milliseconds to delay before fading in (Default: 0)
  46721. */
  46722. delay: number;
  46723. /**
  46724. * Time in milliseconds for the mesh to fade in (Default: 300)
  46725. */
  46726. fadeInTime: number;
  46727. private _millisecondsPerFrame;
  46728. private _hovered;
  46729. private _hoverValue;
  46730. private _ownerNode;
  46731. /**
  46732. * Instatiates the FadeInOutBehavior
  46733. */
  46734. constructor();
  46735. /**
  46736. * The name of the behavior
  46737. */
  46738. get name(): string;
  46739. /**
  46740. * Initializes the behavior
  46741. */
  46742. init(): void;
  46743. /**
  46744. * Attaches the fade behavior on the passed in mesh
  46745. * @param ownerNode The mesh that will be faded in/out once attached
  46746. */
  46747. attach(ownerNode: Mesh): void;
  46748. /**
  46749. * Detaches the behavior from the mesh
  46750. */
  46751. detach(): void;
  46752. /**
  46753. * Triggers the mesh to begin fading in or out
  46754. * @param value if the object should fade in or out (true to fade in)
  46755. */
  46756. fadeIn(value: boolean): void;
  46757. private _update;
  46758. private _setAllVisibility;
  46759. }
  46760. }
  46761. declare module BABYLON {
  46762. /**
  46763. * Class containing a set of static utilities functions for managing Pivots
  46764. * @hidden
  46765. */
  46766. export class PivotTools {
  46767. private static _PivotCached;
  46768. private static _OldPivotPoint;
  46769. private static _PivotTranslation;
  46770. private static _PivotTmpVector;
  46771. private static _PivotPostMultiplyPivotMatrix;
  46772. /** @hidden */
  46773. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  46774. /** @hidden */
  46775. static _RestorePivotPoint(mesh: AbstractMesh): void;
  46776. }
  46777. }
  46778. declare module BABYLON {
  46779. /**
  46780. * Class containing static functions to help procedurally build meshes
  46781. */
  46782. export class PlaneBuilder {
  46783. /**
  46784. * Creates a plane mesh
  46785. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  46786. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  46787. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  46788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46789. * * 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
  46790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46791. * @param name defines the name of the mesh
  46792. * @param options defines the options used to create the mesh
  46793. * @param scene defines the hosting scene
  46794. * @returns the plane mesh
  46795. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  46796. */
  46797. static CreatePlane(name: string, options: {
  46798. size?: number;
  46799. width?: number;
  46800. height?: number;
  46801. sideOrientation?: number;
  46802. frontUVs?: Vector4;
  46803. backUVs?: Vector4;
  46804. updatable?: boolean;
  46805. sourcePlane?: Plane;
  46806. }, scene?: Nullable<Scene>): Mesh;
  46807. }
  46808. }
  46809. declare module BABYLON {
  46810. /**
  46811. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  46812. */
  46813. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  46814. private static _AnyMouseID;
  46815. /**
  46816. * Abstract mesh the behavior is set on
  46817. */
  46818. attachedNode: AbstractMesh;
  46819. private _dragPlane;
  46820. private _scene;
  46821. private _pointerObserver;
  46822. private _beforeRenderObserver;
  46823. private static _planeScene;
  46824. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  46825. /**
  46826. * 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)
  46827. */
  46828. maxDragAngle: number;
  46829. /**
  46830. * @hidden
  46831. */
  46832. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  46833. /**
  46834. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46835. */
  46836. currentDraggingPointerID: number;
  46837. /**
  46838. * The last position where the pointer hit the drag plane in world space
  46839. */
  46840. lastDragPosition: Vector3;
  46841. /**
  46842. * If the behavior is currently in a dragging state
  46843. */
  46844. dragging: boolean;
  46845. /**
  46846. * 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)
  46847. */
  46848. dragDeltaRatio: number;
  46849. /**
  46850. * If the drag plane orientation should be updated during the dragging (Default: true)
  46851. */
  46852. updateDragPlane: boolean;
  46853. private _debugMode;
  46854. private _moving;
  46855. /**
  46856. * Fires each time the attached mesh is dragged with the pointer
  46857. * * delta between last drag position and current drag position in world space
  46858. * * dragDistance along the drag axis
  46859. * * dragPlaneNormal normal of the current drag plane used during the drag
  46860. * * dragPlanePoint in world space where the drag intersects the drag plane
  46861. */
  46862. onDragObservable: Observable<{
  46863. delta: Vector3;
  46864. dragPlanePoint: Vector3;
  46865. dragPlaneNormal: Vector3;
  46866. dragDistance: number;
  46867. pointerId: number;
  46868. }>;
  46869. /**
  46870. * Fires each time a drag begins (eg. mouse down on mesh)
  46871. */
  46872. onDragStartObservable: Observable<{
  46873. dragPlanePoint: Vector3;
  46874. pointerId: number;
  46875. }>;
  46876. /**
  46877. * Fires each time a drag ends (eg. mouse release after drag)
  46878. */
  46879. onDragEndObservable: Observable<{
  46880. dragPlanePoint: Vector3;
  46881. pointerId: number;
  46882. }>;
  46883. /**
  46884. * If the attached mesh should be moved when dragged
  46885. */
  46886. moveAttached: boolean;
  46887. /**
  46888. * If the drag behavior will react to drag events (Default: true)
  46889. */
  46890. enabled: boolean;
  46891. /**
  46892. * If pointer events should start and release the drag (Default: true)
  46893. */
  46894. startAndReleaseDragOnPointerEvents: boolean;
  46895. /**
  46896. * If camera controls should be detached during the drag
  46897. */
  46898. detachCameraControls: boolean;
  46899. /**
  46900. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  46901. */
  46902. useObjectOrientationForDragging: boolean;
  46903. private _options;
  46904. /**
  46905. * Gets the options used by the behavior
  46906. */
  46907. get options(): {
  46908. dragAxis?: Vector3;
  46909. dragPlaneNormal?: Vector3;
  46910. };
  46911. /**
  46912. * Sets the options used by the behavior
  46913. */
  46914. set options(options: {
  46915. dragAxis?: Vector3;
  46916. dragPlaneNormal?: Vector3;
  46917. });
  46918. /**
  46919. * Creates a pointer drag behavior that can be attached to a mesh
  46920. * @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)
  46921. */
  46922. constructor(options?: {
  46923. dragAxis?: Vector3;
  46924. dragPlaneNormal?: Vector3;
  46925. });
  46926. /**
  46927. * Predicate to determine if it is valid to move the object to a new position when it is moved
  46928. */
  46929. validateDrag: (targetPosition: Vector3) => boolean;
  46930. /**
  46931. * The name of the behavior
  46932. */
  46933. get name(): string;
  46934. /**
  46935. * Initializes the behavior
  46936. */
  46937. init(): void;
  46938. private _tmpVector;
  46939. private _alternatePickedPoint;
  46940. private _worldDragAxis;
  46941. private _targetPosition;
  46942. private _attachedElement;
  46943. /**
  46944. * Attaches the drag behavior the passed in mesh
  46945. * @param ownerNode The mesh that will be dragged around once attached
  46946. * @param predicate Predicate to use for pick filtering
  46947. */
  46948. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  46949. /**
  46950. * Force relase the drag action by code.
  46951. */
  46952. releaseDrag(): void;
  46953. private _startDragRay;
  46954. private _lastPointerRay;
  46955. /**
  46956. * Simulates the start of a pointer drag event on the behavior
  46957. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  46958. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  46959. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  46960. */
  46961. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46962. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46963. private _dragDelta;
  46964. protected _moveDrag(ray: Ray): void;
  46965. private _pickWithRayOnDragPlane;
  46966. private _pointA;
  46967. private _pointC;
  46968. private _localAxis;
  46969. private _lookAt;
  46970. private _updateDragPlanePosition;
  46971. /**
  46972. * Detaches the behavior from the mesh
  46973. */
  46974. detach(): void;
  46975. }
  46976. }
  46977. declare module BABYLON {
  46978. /**
  46979. * A behavior that when attached to a mesh will allow the mesh to be scaled
  46980. */
  46981. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  46982. private _dragBehaviorA;
  46983. private _dragBehaviorB;
  46984. private _startDistance;
  46985. private _initialScale;
  46986. private _targetScale;
  46987. private _ownerNode;
  46988. private _sceneRenderObserver;
  46989. /**
  46990. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  46991. */
  46992. constructor();
  46993. /**
  46994. * The name of the behavior
  46995. */
  46996. get name(): string;
  46997. /**
  46998. * Initializes the behavior
  46999. */
  47000. init(): void;
  47001. private _getCurrentDistance;
  47002. /**
  47003. * Attaches the scale behavior the passed in mesh
  47004. * @param ownerNode The mesh that will be scaled around once attached
  47005. */
  47006. attach(ownerNode: Mesh): void;
  47007. /**
  47008. * Detaches the behavior from the mesh
  47009. */
  47010. detach(): void;
  47011. }
  47012. }
  47013. declare module BABYLON {
  47014. /**
  47015. * 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
  47016. */
  47017. export class SixDofDragBehavior implements Behavior<Mesh> {
  47018. private static _virtualScene;
  47019. private _ownerNode;
  47020. private _sceneRenderObserver;
  47021. private _scene;
  47022. private _targetPosition;
  47023. private _virtualOriginMesh;
  47024. private _virtualDragMesh;
  47025. private _pointerObserver;
  47026. private _moving;
  47027. private _startingOrientation;
  47028. private _attachedElement;
  47029. /**
  47030. * 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)
  47031. */
  47032. private zDragFactor;
  47033. /**
  47034. * If the object should rotate to face the drag origin
  47035. */
  47036. rotateDraggedObject: boolean;
  47037. /**
  47038. * If the behavior is currently in a dragging state
  47039. */
  47040. dragging: boolean;
  47041. /**
  47042. * 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)
  47043. */
  47044. dragDeltaRatio: number;
  47045. /**
  47046. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47047. */
  47048. currentDraggingPointerID: number;
  47049. /**
  47050. * If camera controls should be detached during the drag
  47051. */
  47052. detachCameraControls: boolean;
  47053. /**
  47054. * Fires each time a drag starts
  47055. */
  47056. onDragStartObservable: Observable<{}>;
  47057. /**
  47058. * Fires each time a drag ends (eg. mouse release after drag)
  47059. */
  47060. onDragEndObservable: Observable<{}>;
  47061. /**
  47062. * 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
  47063. */
  47064. constructor();
  47065. /**
  47066. * The name of the behavior
  47067. */
  47068. get name(): string;
  47069. /**
  47070. * Initializes the behavior
  47071. */
  47072. init(): void;
  47073. /**
  47074. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  47075. */
  47076. private get _pointerCamera();
  47077. /**
  47078. * Attaches the scale behavior the passed in mesh
  47079. * @param ownerNode The mesh that will be scaled around once attached
  47080. */
  47081. attach(ownerNode: Mesh): void;
  47082. /**
  47083. * Detaches the behavior from the mesh
  47084. */
  47085. detach(): void;
  47086. }
  47087. }
  47088. declare module BABYLON {
  47089. /**
  47090. * Class used to apply inverse kinematics to bones
  47091. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  47092. */
  47093. export class BoneIKController {
  47094. private static _tmpVecs;
  47095. private static _tmpQuat;
  47096. private static _tmpMats;
  47097. /**
  47098. * Gets or sets the target mesh
  47099. */
  47100. targetMesh: AbstractMesh;
  47101. /** Gets or sets the mesh used as pole */
  47102. poleTargetMesh: AbstractMesh;
  47103. /**
  47104. * Gets or sets the bone used as pole
  47105. */
  47106. poleTargetBone: Nullable<Bone>;
  47107. /**
  47108. * Gets or sets the target position
  47109. */
  47110. targetPosition: Vector3;
  47111. /**
  47112. * Gets or sets the pole target position
  47113. */
  47114. poleTargetPosition: Vector3;
  47115. /**
  47116. * Gets or sets the pole target local offset
  47117. */
  47118. poleTargetLocalOffset: Vector3;
  47119. /**
  47120. * Gets or sets the pole angle
  47121. */
  47122. poleAngle: number;
  47123. /**
  47124. * Gets or sets the mesh associated with the controller
  47125. */
  47126. mesh: AbstractMesh;
  47127. /**
  47128. * 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)
  47129. */
  47130. slerpAmount: number;
  47131. private _bone1Quat;
  47132. private _bone1Mat;
  47133. private _bone2Ang;
  47134. private _bone1;
  47135. private _bone2;
  47136. private _bone1Length;
  47137. private _bone2Length;
  47138. private _maxAngle;
  47139. private _maxReach;
  47140. private _rightHandedSystem;
  47141. private _bendAxis;
  47142. private _slerping;
  47143. private _adjustRoll;
  47144. /**
  47145. * Gets or sets maximum allowed angle
  47146. */
  47147. get maxAngle(): number;
  47148. set maxAngle(value: number);
  47149. /**
  47150. * Creates a new BoneIKController
  47151. * @param mesh defines the mesh to control
  47152. * @param bone defines the bone to control
  47153. * @param options defines options to set up the controller
  47154. */
  47155. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  47156. targetMesh?: AbstractMesh;
  47157. poleTargetMesh?: AbstractMesh;
  47158. poleTargetBone?: Bone;
  47159. poleTargetLocalOffset?: Vector3;
  47160. poleAngle?: number;
  47161. bendAxis?: Vector3;
  47162. maxAngle?: number;
  47163. slerpAmount?: number;
  47164. });
  47165. private _setMaxAngle;
  47166. /**
  47167. * Force the controller to update the bones
  47168. */
  47169. update(): void;
  47170. }
  47171. }
  47172. declare module BABYLON {
  47173. /**
  47174. * Class used to make a bone look toward a point in space
  47175. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  47176. */
  47177. export class BoneLookController {
  47178. private static _tmpVecs;
  47179. private static _tmpQuat;
  47180. private static _tmpMats;
  47181. /**
  47182. * The target Vector3 that the bone will look at
  47183. */
  47184. target: Vector3;
  47185. /**
  47186. * The mesh that the bone is attached to
  47187. */
  47188. mesh: AbstractMesh;
  47189. /**
  47190. * The bone that will be looking to the target
  47191. */
  47192. bone: Bone;
  47193. /**
  47194. * The up axis of the coordinate system that is used when the bone is rotated
  47195. */
  47196. upAxis: Vector3;
  47197. /**
  47198. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  47199. */
  47200. upAxisSpace: Space;
  47201. /**
  47202. * Used to make an adjustment to the yaw of the bone
  47203. */
  47204. adjustYaw: number;
  47205. /**
  47206. * Used to make an adjustment to the pitch of the bone
  47207. */
  47208. adjustPitch: number;
  47209. /**
  47210. * Used to make an adjustment to the roll of the bone
  47211. */
  47212. adjustRoll: number;
  47213. /**
  47214. * 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)
  47215. */
  47216. slerpAmount: number;
  47217. private _minYaw;
  47218. private _maxYaw;
  47219. private _minPitch;
  47220. private _maxPitch;
  47221. private _minYawSin;
  47222. private _minYawCos;
  47223. private _maxYawSin;
  47224. private _maxYawCos;
  47225. private _midYawConstraint;
  47226. private _minPitchTan;
  47227. private _maxPitchTan;
  47228. private _boneQuat;
  47229. private _slerping;
  47230. private _transformYawPitch;
  47231. private _transformYawPitchInv;
  47232. private _firstFrameSkipped;
  47233. private _yawRange;
  47234. private _fowardAxis;
  47235. /**
  47236. * Gets or sets the minimum yaw angle that the bone can look to
  47237. */
  47238. get minYaw(): number;
  47239. set minYaw(value: number);
  47240. /**
  47241. * Gets or sets the maximum yaw angle that the bone can look to
  47242. */
  47243. get maxYaw(): number;
  47244. set maxYaw(value: number);
  47245. /**
  47246. * Gets or sets the minimum pitch angle that the bone can look to
  47247. */
  47248. get minPitch(): number;
  47249. set minPitch(value: number);
  47250. /**
  47251. * Gets or sets the maximum pitch angle that the bone can look to
  47252. */
  47253. get maxPitch(): number;
  47254. set maxPitch(value: number);
  47255. /**
  47256. * Create a BoneLookController
  47257. * @param mesh the mesh that the bone belongs to
  47258. * @param bone the bone that will be looking to the target
  47259. * @param target the target Vector3 to look at
  47260. * @param options optional settings:
  47261. * * maxYaw: the maximum angle the bone will yaw to
  47262. * * minYaw: the minimum angle the bone will yaw to
  47263. * * maxPitch: the maximum angle the bone will pitch to
  47264. * * minPitch: the minimum angle the bone will yaw to
  47265. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  47266. * * upAxis: the up axis of the coordinate system
  47267. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  47268. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47269. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47270. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47271. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47272. * * adjustRoll: used to make an adjustment to the roll of the bone
  47273. **/
  47274. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47275. maxYaw?: number;
  47276. minYaw?: number;
  47277. maxPitch?: number;
  47278. minPitch?: number;
  47279. slerpAmount?: number;
  47280. upAxis?: Vector3;
  47281. upAxisSpace?: Space;
  47282. yawAxis?: Vector3;
  47283. pitchAxis?: Vector3;
  47284. adjustYaw?: number;
  47285. adjustPitch?: number;
  47286. adjustRoll?: number;
  47287. });
  47288. /**
  47289. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47290. */
  47291. update(): void;
  47292. private _getAngleDiff;
  47293. private _getAngleBetween;
  47294. private _isAngleBetween;
  47295. }
  47296. }
  47297. declare module BABYLON {
  47298. /**
  47299. * Manage the gamepad inputs to control an arc rotate camera.
  47300. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47301. */
  47302. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47303. /**
  47304. * Defines the camera the input is attached to.
  47305. */
  47306. camera: ArcRotateCamera;
  47307. /**
  47308. * Defines the gamepad the input is gathering event from.
  47309. */
  47310. gamepad: Nullable<Gamepad>;
  47311. /**
  47312. * Defines the gamepad rotation sensiblity.
  47313. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47314. */
  47315. gamepadRotationSensibility: number;
  47316. /**
  47317. * Defines the gamepad move sensiblity.
  47318. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47319. */
  47320. gamepadMoveSensibility: number;
  47321. private _yAxisScale;
  47322. /**
  47323. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47324. */
  47325. get invertYAxis(): boolean;
  47326. set invertYAxis(value: boolean);
  47327. private _onGamepadConnectedObserver;
  47328. private _onGamepadDisconnectedObserver;
  47329. /**
  47330. * Attach the input controls to a specific dom element to get the input from.
  47331. * @param element Defines the element the controls should be listened from
  47332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47333. */
  47334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47335. /**
  47336. * Detach the current controls from the specified dom element.
  47337. * @param element Defines the element to stop listening the inputs from
  47338. */
  47339. detachControl(element: Nullable<HTMLElement>): void;
  47340. /**
  47341. * Update the current camera state depending on the inputs that have been used this frame.
  47342. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47343. */
  47344. checkInputs(): void;
  47345. /**
  47346. * Gets the class name of the current intput.
  47347. * @returns the class name
  47348. */
  47349. getClassName(): string;
  47350. /**
  47351. * Get the friendly name associated with the input class.
  47352. * @returns the input friendly name
  47353. */
  47354. getSimpleName(): string;
  47355. }
  47356. }
  47357. declare module BABYLON {
  47358. interface ArcRotateCameraInputsManager {
  47359. /**
  47360. * Add orientation input support to the input manager.
  47361. * @returns the current input manager
  47362. */
  47363. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47364. }
  47365. /**
  47366. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47367. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47368. */
  47369. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47370. /**
  47371. * Defines the camera the input is attached to.
  47372. */
  47373. camera: ArcRotateCamera;
  47374. /**
  47375. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47376. */
  47377. alphaCorrection: number;
  47378. /**
  47379. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47380. */
  47381. gammaCorrection: number;
  47382. private _alpha;
  47383. private _gamma;
  47384. private _dirty;
  47385. private _deviceOrientationHandler;
  47386. /**
  47387. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47388. */
  47389. constructor();
  47390. /**
  47391. * Attach the input controls to a specific dom element to get the input from.
  47392. * @param element Defines the element the controls should be listened from
  47393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47394. */
  47395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47396. /** @hidden */
  47397. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47398. /**
  47399. * Update the current camera state depending on the inputs that have been used this frame.
  47400. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47401. */
  47402. checkInputs(): void;
  47403. /**
  47404. * Detach the current controls from the specified dom element.
  47405. * @param element Defines the element to stop listening the inputs from
  47406. */
  47407. detachControl(element: Nullable<HTMLElement>): void;
  47408. /**
  47409. * Gets the class name of the current intput.
  47410. * @returns the class name
  47411. */
  47412. getClassName(): string;
  47413. /**
  47414. * Get the friendly name associated with the input class.
  47415. * @returns the input friendly name
  47416. */
  47417. getSimpleName(): string;
  47418. }
  47419. }
  47420. declare module BABYLON {
  47421. /**
  47422. * Listen to mouse events to control the camera.
  47423. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47424. */
  47425. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47426. /**
  47427. * Defines the camera the input is attached to.
  47428. */
  47429. camera: FlyCamera;
  47430. /**
  47431. * Defines if touch is enabled. (Default is true.)
  47432. */
  47433. touchEnabled: boolean;
  47434. /**
  47435. * Defines the buttons associated with the input to handle camera rotation.
  47436. */
  47437. buttons: number[];
  47438. /**
  47439. * Assign buttons for Yaw control.
  47440. */
  47441. buttonsYaw: number[];
  47442. /**
  47443. * Assign buttons for Pitch control.
  47444. */
  47445. buttonsPitch: number[];
  47446. /**
  47447. * Assign buttons for Roll control.
  47448. */
  47449. buttonsRoll: number[];
  47450. /**
  47451. * Detect if any button is being pressed while mouse is moved.
  47452. * -1 = Mouse locked.
  47453. * 0 = Left button.
  47454. * 1 = Middle Button.
  47455. * 2 = Right Button.
  47456. */
  47457. activeButton: number;
  47458. /**
  47459. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47460. * Higher values reduce its sensitivity.
  47461. */
  47462. angularSensibility: number;
  47463. private _observer;
  47464. private _rollObserver;
  47465. private previousPosition;
  47466. private noPreventDefault;
  47467. private element;
  47468. /**
  47469. * Listen to mouse events to control the camera.
  47470. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47471. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47472. */
  47473. constructor(touchEnabled?: boolean);
  47474. /**
  47475. * Attach the mouse control to the HTML DOM element.
  47476. * @param element Defines the element that listens to the input events.
  47477. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47478. */
  47479. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47480. /**
  47481. * Detach the current controls from the specified dom element.
  47482. * @param element Defines the element to stop listening the inputs from
  47483. */
  47484. detachControl(element: Nullable<HTMLElement>): void;
  47485. /**
  47486. * Gets the class name of the current input.
  47487. * @returns the class name.
  47488. */
  47489. getClassName(): string;
  47490. /**
  47491. * Get the friendly name associated with the input class.
  47492. * @returns the input's friendly name.
  47493. */
  47494. getSimpleName(): string;
  47495. private _pointerInput;
  47496. private _onMouseMove;
  47497. /**
  47498. * Rotate camera by mouse offset.
  47499. */
  47500. private rotateCamera;
  47501. }
  47502. }
  47503. declare module BABYLON {
  47504. /**
  47505. * Default Inputs manager for the FlyCamera.
  47506. * It groups all the default supported inputs for ease of use.
  47507. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47508. */
  47509. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47510. /**
  47511. * Instantiates a new FlyCameraInputsManager.
  47512. * @param camera Defines the camera the inputs belong to.
  47513. */
  47514. constructor(camera: FlyCamera);
  47515. /**
  47516. * Add keyboard input support to the input manager.
  47517. * @returns the new FlyCameraKeyboardMoveInput().
  47518. */
  47519. addKeyboard(): FlyCameraInputsManager;
  47520. /**
  47521. * Add mouse input support to the input manager.
  47522. * @param touchEnabled Enable touch screen support.
  47523. * @returns the new FlyCameraMouseInput().
  47524. */
  47525. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47526. }
  47527. }
  47528. declare module BABYLON {
  47529. /**
  47530. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47531. * such as in a 3D Space Shooter or a Flight Simulator.
  47532. */
  47533. export class FlyCamera extends TargetCamera {
  47534. /**
  47535. * Define the collision ellipsoid of the camera.
  47536. * This is helpful for simulating a camera body, like a player's body.
  47537. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47538. */
  47539. ellipsoid: Vector3;
  47540. /**
  47541. * Define an offset for the position of the ellipsoid around the camera.
  47542. * This can be helpful if the camera is attached away from the player's body center,
  47543. * such as at its head.
  47544. */
  47545. ellipsoidOffset: Vector3;
  47546. /**
  47547. * Enable or disable collisions of the camera with the rest of the scene objects.
  47548. */
  47549. checkCollisions: boolean;
  47550. /**
  47551. * Enable or disable gravity on the camera.
  47552. */
  47553. applyGravity: boolean;
  47554. /**
  47555. * Define the current direction the camera is moving to.
  47556. */
  47557. cameraDirection: Vector3;
  47558. /**
  47559. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47560. * This overrides and empties cameraRotation.
  47561. */
  47562. rotationQuaternion: Quaternion;
  47563. /**
  47564. * Track Roll to maintain the wanted Rolling when looking around.
  47565. */
  47566. _trackRoll: number;
  47567. /**
  47568. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47569. */
  47570. rollCorrect: number;
  47571. /**
  47572. * Mimic a banked turn, Rolling the camera when Yawing.
  47573. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47574. */
  47575. bankedTurn: boolean;
  47576. /**
  47577. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47578. */
  47579. bankedTurnLimit: number;
  47580. /**
  47581. * Value of 0 disables the banked Roll.
  47582. * Value of 1 is equal to the Yaw angle in radians.
  47583. */
  47584. bankedTurnMultiplier: number;
  47585. /**
  47586. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47587. */
  47588. inputs: FlyCameraInputsManager;
  47589. /**
  47590. * Gets the input sensibility for mouse input.
  47591. * Higher values reduce sensitivity.
  47592. */
  47593. get angularSensibility(): number;
  47594. /**
  47595. * Sets the input sensibility for a mouse input.
  47596. * Higher values reduce sensitivity.
  47597. */
  47598. set angularSensibility(value: number);
  47599. /**
  47600. * Get the keys for camera movement forward.
  47601. */
  47602. get keysForward(): number[];
  47603. /**
  47604. * Set the keys for camera movement forward.
  47605. */
  47606. set keysForward(value: number[]);
  47607. /**
  47608. * Get the keys for camera movement backward.
  47609. */
  47610. get keysBackward(): number[];
  47611. set keysBackward(value: number[]);
  47612. /**
  47613. * Get the keys for camera movement up.
  47614. */
  47615. get keysUp(): number[];
  47616. /**
  47617. * Set the keys for camera movement up.
  47618. */
  47619. set keysUp(value: number[]);
  47620. /**
  47621. * Get the keys for camera movement down.
  47622. */
  47623. get keysDown(): number[];
  47624. /**
  47625. * Set the keys for camera movement down.
  47626. */
  47627. set keysDown(value: number[]);
  47628. /**
  47629. * Get the keys for camera movement left.
  47630. */
  47631. get keysLeft(): number[];
  47632. /**
  47633. * Set the keys for camera movement left.
  47634. */
  47635. set keysLeft(value: number[]);
  47636. /**
  47637. * Set the keys for camera movement right.
  47638. */
  47639. get keysRight(): number[];
  47640. /**
  47641. * Set the keys for camera movement right.
  47642. */
  47643. set keysRight(value: number[]);
  47644. /**
  47645. * Event raised when the camera collides with a mesh in the scene.
  47646. */
  47647. onCollide: (collidedMesh: AbstractMesh) => void;
  47648. private _collider;
  47649. private _needMoveForGravity;
  47650. private _oldPosition;
  47651. private _diffPosition;
  47652. private _newPosition;
  47653. /** @hidden */
  47654. _localDirection: Vector3;
  47655. /** @hidden */
  47656. _transformedDirection: Vector3;
  47657. /**
  47658. * Instantiates a FlyCamera.
  47659. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47660. * such as in a 3D Space Shooter or a Flight Simulator.
  47661. * @param name Define the name of the camera in the scene.
  47662. * @param position Define the starting position of the camera in the scene.
  47663. * @param scene Define the scene the camera belongs to.
  47664. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47665. */
  47666. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47667. /**
  47668. * Attach a control to the HTML DOM element.
  47669. * @param element Defines the element that listens to the input events.
  47670. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  47671. */
  47672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47673. /**
  47674. * Detach a control from the HTML DOM element.
  47675. * The camera will stop reacting to that input.
  47676. * @param element Defines the element that listens to the input events.
  47677. */
  47678. detachControl(element: HTMLElement): void;
  47679. private _collisionMask;
  47680. /**
  47681. * Get the mask that the camera ignores in collision events.
  47682. */
  47683. get collisionMask(): number;
  47684. /**
  47685. * Set the mask that the camera ignores in collision events.
  47686. */
  47687. set collisionMask(mask: number);
  47688. /** @hidden */
  47689. _collideWithWorld(displacement: Vector3): void;
  47690. /** @hidden */
  47691. private _onCollisionPositionChange;
  47692. /** @hidden */
  47693. _checkInputs(): void;
  47694. /** @hidden */
  47695. _decideIfNeedsToMove(): boolean;
  47696. /** @hidden */
  47697. _updatePosition(): void;
  47698. /**
  47699. * Restore the Roll to its target value at the rate specified.
  47700. * @param rate - Higher means slower restoring.
  47701. * @hidden
  47702. */
  47703. restoreRoll(rate: number): void;
  47704. /**
  47705. * Destroy the camera and release the current resources held by it.
  47706. */
  47707. dispose(): void;
  47708. /**
  47709. * Get the current object class name.
  47710. * @returns the class name.
  47711. */
  47712. getClassName(): string;
  47713. }
  47714. }
  47715. declare module BABYLON {
  47716. /**
  47717. * Listen to keyboard events to control the camera.
  47718. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47719. */
  47720. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  47721. /**
  47722. * Defines the camera the input is attached to.
  47723. */
  47724. camera: FlyCamera;
  47725. /**
  47726. * The list of keyboard keys used to control the forward move of the camera.
  47727. */
  47728. keysForward: number[];
  47729. /**
  47730. * The list of keyboard keys used to control the backward move of the camera.
  47731. */
  47732. keysBackward: number[];
  47733. /**
  47734. * The list of keyboard keys used to control the forward move of the camera.
  47735. */
  47736. keysUp: number[];
  47737. /**
  47738. * The list of keyboard keys used to control the backward move of the camera.
  47739. */
  47740. keysDown: number[];
  47741. /**
  47742. * The list of keyboard keys used to control the right strafe move of the camera.
  47743. */
  47744. keysRight: number[];
  47745. /**
  47746. * The list of keyboard keys used to control the left strafe move of the camera.
  47747. */
  47748. keysLeft: number[];
  47749. private _keys;
  47750. private _onCanvasBlurObserver;
  47751. private _onKeyboardObserver;
  47752. private _engine;
  47753. private _scene;
  47754. /**
  47755. * Attach the input controls to a specific dom element to get the input from.
  47756. * @param element Defines the element the controls should be listened from
  47757. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47758. */
  47759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47760. /**
  47761. * Detach the current controls from the specified dom element.
  47762. * @param element Defines the element to stop listening the inputs from
  47763. */
  47764. detachControl(element: Nullable<HTMLElement>): void;
  47765. /**
  47766. * Gets the class name of the current intput.
  47767. * @returns the class name
  47768. */
  47769. getClassName(): string;
  47770. /** @hidden */
  47771. _onLostFocus(e: FocusEvent): void;
  47772. /**
  47773. * Get the friendly name associated with the input class.
  47774. * @returns the input friendly name
  47775. */
  47776. getSimpleName(): string;
  47777. /**
  47778. * Update the current camera state depending on the inputs that have been used this frame.
  47779. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47780. */
  47781. checkInputs(): void;
  47782. }
  47783. }
  47784. declare module BABYLON {
  47785. /**
  47786. * Manage the mouse wheel inputs to control a follow camera.
  47787. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47788. */
  47789. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  47790. /**
  47791. * Defines the camera the input is attached to.
  47792. */
  47793. camera: FollowCamera;
  47794. /**
  47795. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  47796. */
  47797. axisControlRadius: boolean;
  47798. /**
  47799. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  47800. */
  47801. axisControlHeight: boolean;
  47802. /**
  47803. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  47804. */
  47805. axisControlRotation: boolean;
  47806. /**
  47807. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  47808. * relation to mouseWheel events.
  47809. */
  47810. wheelPrecision: number;
  47811. /**
  47812. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47813. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47814. */
  47815. wheelDeltaPercentage: number;
  47816. private _wheel;
  47817. private _observer;
  47818. /**
  47819. * Attach the input controls to a specific dom element to get the input from.
  47820. * @param element Defines the element the controls should be listened from
  47821. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47822. */
  47823. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47824. /**
  47825. * Detach the current controls from the specified dom element.
  47826. * @param element Defines the element to stop listening the inputs from
  47827. */
  47828. detachControl(element: Nullable<HTMLElement>): void;
  47829. /**
  47830. * Gets the class name of the current intput.
  47831. * @returns the class name
  47832. */
  47833. getClassName(): string;
  47834. /**
  47835. * Get the friendly name associated with the input class.
  47836. * @returns the input friendly name
  47837. */
  47838. getSimpleName(): string;
  47839. }
  47840. }
  47841. declare module BABYLON {
  47842. /**
  47843. * Manage the pointers inputs to control an follow camera.
  47844. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47845. */
  47846. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  47847. /**
  47848. * Defines the camera the input is attached to.
  47849. */
  47850. camera: FollowCamera;
  47851. /**
  47852. * Gets the class name of the current input.
  47853. * @returns the class name
  47854. */
  47855. getClassName(): string;
  47856. /**
  47857. * Defines the pointer angular sensibility along the X axis or how fast is
  47858. * the camera rotating.
  47859. * A negative number will reverse the axis direction.
  47860. */
  47861. angularSensibilityX: number;
  47862. /**
  47863. * Defines the pointer angular sensibility along the Y axis or how fast is
  47864. * the camera rotating.
  47865. * A negative number will reverse the axis direction.
  47866. */
  47867. angularSensibilityY: number;
  47868. /**
  47869. * Defines the pointer pinch precision or how fast is the camera zooming.
  47870. * A negative number will reverse the axis direction.
  47871. */
  47872. pinchPrecision: number;
  47873. /**
  47874. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47875. * from 0.
  47876. * It defines the percentage of current camera.radius to use as delta when
  47877. * pinch zoom is used.
  47878. */
  47879. pinchDeltaPercentage: number;
  47880. /**
  47881. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  47882. */
  47883. axisXControlRadius: boolean;
  47884. /**
  47885. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  47886. */
  47887. axisXControlHeight: boolean;
  47888. /**
  47889. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  47890. */
  47891. axisXControlRotation: boolean;
  47892. /**
  47893. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  47894. */
  47895. axisYControlRadius: boolean;
  47896. /**
  47897. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  47898. */
  47899. axisYControlHeight: boolean;
  47900. /**
  47901. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  47902. */
  47903. axisYControlRotation: boolean;
  47904. /**
  47905. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  47906. */
  47907. axisPinchControlRadius: boolean;
  47908. /**
  47909. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  47910. */
  47911. axisPinchControlHeight: boolean;
  47912. /**
  47913. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  47914. */
  47915. axisPinchControlRotation: boolean;
  47916. /**
  47917. * Log error messages if basic misconfiguration has occurred.
  47918. */
  47919. warningEnable: boolean;
  47920. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47921. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47922. private _warningCounter;
  47923. private _warning;
  47924. }
  47925. }
  47926. declare module BABYLON {
  47927. /**
  47928. * Default Inputs manager for the FollowCamera.
  47929. * It groups all the default supported inputs for ease of use.
  47930. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47931. */
  47932. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  47933. /**
  47934. * Instantiates a new FollowCameraInputsManager.
  47935. * @param camera Defines the camera the inputs belong to
  47936. */
  47937. constructor(camera: FollowCamera);
  47938. /**
  47939. * Add keyboard input support to the input manager.
  47940. * @returns the current input manager
  47941. */
  47942. addKeyboard(): FollowCameraInputsManager;
  47943. /**
  47944. * Add mouse wheel input support to the input manager.
  47945. * @returns the current input manager
  47946. */
  47947. addMouseWheel(): FollowCameraInputsManager;
  47948. /**
  47949. * Add pointers input support to the input manager.
  47950. * @returns the current input manager
  47951. */
  47952. addPointers(): FollowCameraInputsManager;
  47953. /**
  47954. * Add orientation input support to the input manager.
  47955. * @returns the current input manager
  47956. */
  47957. addVRDeviceOrientation(): FollowCameraInputsManager;
  47958. }
  47959. }
  47960. declare module BABYLON {
  47961. /**
  47962. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  47963. * an arc rotate version arcFollowCamera are available.
  47964. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47965. */
  47966. export class FollowCamera extends TargetCamera {
  47967. /**
  47968. * Distance the follow camera should follow an object at
  47969. */
  47970. radius: number;
  47971. /**
  47972. * Minimum allowed distance of the camera to the axis of rotation
  47973. * (The camera can not get closer).
  47974. * This can help limiting how the Camera is able to move in the scene.
  47975. */
  47976. lowerRadiusLimit: Nullable<number>;
  47977. /**
  47978. * Maximum allowed distance of the camera to the axis of rotation
  47979. * (The camera can not get further).
  47980. * This can help limiting how the Camera is able to move in the scene.
  47981. */
  47982. upperRadiusLimit: Nullable<number>;
  47983. /**
  47984. * Define a rotation offset between the camera and the object it follows
  47985. */
  47986. rotationOffset: number;
  47987. /**
  47988. * Minimum allowed angle to camera position relative to target object.
  47989. * This can help limiting how the Camera is able to move in the scene.
  47990. */
  47991. lowerRotationOffsetLimit: Nullable<number>;
  47992. /**
  47993. * Maximum allowed angle to camera position relative to target object.
  47994. * This can help limiting how the Camera is able to move in the scene.
  47995. */
  47996. upperRotationOffsetLimit: Nullable<number>;
  47997. /**
  47998. * Define a height offset between the camera and the object it follows.
  47999. * It can help following an object from the top (like a car chaing a plane)
  48000. */
  48001. heightOffset: number;
  48002. /**
  48003. * Minimum allowed height of camera position relative to target object.
  48004. * This can help limiting how the Camera is able to move in the scene.
  48005. */
  48006. lowerHeightOffsetLimit: Nullable<number>;
  48007. /**
  48008. * Maximum allowed height of camera position relative to target object.
  48009. * This can help limiting how the Camera is able to move in the scene.
  48010. */
  48011. upperHeightOffsetLimit: Nullable<number>;
  48012. /**
  48013. * Define how fast the camera can accelerate to follow it s target.
  48014. */
  48015. cameraAcceleration: number;
  48016. /**
  48017. * Define the speed limit of the camera following an object.
  48018. */
  48019. maxCameraSpeed: number;
  48020. /**
  48021. * Define the target of the camera.
  48022. */
  48023. lockedTarget: Nullable<AbstractMesh>;
  48024. /**
  48025. * Defines the input associated with the camera.
  48026. */
  48027. inputs: FollowCameraInputsManager;
  48028. /**
  48029. * Instantiates the follow camera.
  48030. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48031. * @param name Define the name of the camera in the scene
  48032. * @param position Define the position of the camera
  48033. * @param scene Define the scene the camera belong to
  48034. * @param lockedTarget Define the target of the camera
  48035. */
  48036. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  48037. private _follow;
  48038. /**
  48039. * Attached controls to the current camera.
  48040. * @param element Defines the element the controls should be listened from
  48041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48042. */
  48043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48044. /**
  48045. * Detach the current controls from the camera.
  48046. * The camera will stop reacting to inputs.
  48047. * @param element Defines the element to stop listening the inputs from
  48048. */
  48049. detachControl(element: HTMLElement): void;
  48050. /** @hidden */
  48051. _checkInputs(): void;
  48052. private _checkLimits;
  48053. /**
  48054. * Gets the camera class name.
  48055. * @returns the class name
  48056. */
  48057. getClassName(): string;
  48058. }
  48059. /**
  48060. * Arc Rotate version of the follow camera.
  48061. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  48062. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48063. */
  48064. export class ArcFollowCamera extends TargetCamera {
  48065. /** The longitudinal angle of the camera */
  48066. alpha: number;
  48067. /** The latitudinal angle of the camera */
  48068. beta: number;
  48069. /** The radius of the camera from its target */
  48070. radius: number;
  48071. private _cartesianCoordinates;
  48072. /** Define the camera target (the mesh it should follow) */
  48073. private _meshTarget;
  48074. /**
  48075. * Instantiates a new ArcFollowCamera
  48076. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48077. * @param name Define the name of the camera
  48078. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  48079. * @param beta Define the rotation angle of the camera around the elevation axis
  48080. * @param radius Define the radius of the camera from its target point
  48081. * @param target Define the target of the camera
  48082. * @param scene Define the scene the camera belongs to
  48083. */
  48084. constructor(name: string,
  48085. /** The longitudinal angle of the camera */
  48086. alpha: number,
  48087. /** The latitudinal angle of the camera */
  48088. beta: number,
  48089. /** The radius of the camera from its target */
  48090. radius: number,
  48091. /** Define the camera target (the mesh it should follow) */
  48092. target: Nullable<AbstractMesh>, scene: Scene);
  48093. private _follow;
  48094. /** @hidden */
  48095. _checkInputs(): void;
  48096. /**
  48097. * Returns the class name of the object.
  48098. * It is mostly used internally for serialization purposes.
  48099. */
  48100. getClassName(): string;
  48101. }
  48102. }
  48103. declare module BABYLON {
  48104. /**
  48105. * Manage the keyboard inputs to control the movement of a follow camera.
  48106. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48107. */
  48108. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  48109. /**
  48110. * Defines the camera the input is attached to.
  48111. */
  48112. camera: FollowCamera;
  48113. /**
  48114. * Defines the list of key codes associated with the up action (increase heightOffset)
  48115. */
  48116. keysHeightOffsetIncr: number[];
  48117. /**
  48118. * Defines the list of key codes associated with the down action (decrease heightOffset)
  48119. */
  48120. keysHeightOffsetDecr: number[];
  48121. /**
  48122. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  48123. */
  48124. keysHeightOffsetModifierAlt: boolean;
  48125. /**
  48126. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  48127. */
  48128. keysHeightOffsetModifierCtrl: boolean;
  48129. /**
  48130. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  48131. */
  48132. keysHeightOffsetModifierShift: boolean;
  48133. /**
  48134. * Defines the list of key codes associated with the left action (increase rotationOffset)
  48135. */
  48136. keysRotationOffsetIncr: number[];
  48137. /**
  48138. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  48139. */
  48140. keysRotationOffsetDecr: number[];
  48141. /**
  48142. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  48143. */
  48144. keysRotationOffsetModifierAlt: boolean;
  48145. /**
  48146. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  48147. */
  48148. keysRotationOffsetModifierCtrl: boolean;
  48149. /**
  48150. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  48151. */
  48152. keysRotationOffsetModifierShift: boolean;
  48153. /**
  48154. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  48155. */
  48156. keysRadiusIncr: number[];
  48157. /**
  48158. * Defines the list of key codes associated with the zoom-out action (increase radius)
  48159. */
  48160. keysRadiusDecr: number[];
  48161. /**
  48162. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  48163. */
  48164. keysRadiusModifierAlt: boolean;
  48165. /**
  48166. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  48167. */
  48168. keysRadiusModifierCtrl: boolean;
  48169. /**
  48170. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  48171. */
  48172. keysRadiusModifierShift: boolean;
  48173. /**
  48174. * Defines the rate of change of heightOffset.
  48175. */
  48176. heightSensibility: number;
  48177. /**
  48178. * Defines the rate of change of rotationOffset.
  48179. */
  48180. rotationSensibility: number;
  48181. /**
  48182. * Defines the rate of change of radius.
  48183. */
  48184. radiusSensibility: number;
  48185. private _keys;
  48186. private _ctrlPressed;
  48187. private _altPressed;
  48188. private _shiftPressed;
  48189. private _onCanvasBlurObserver;
  48190. private _onKeyboardObserver;
  48191. private _engine;
  48192. private _scene;
  48193. /**
  48194. * Attach the input controls to a specific dom element to get the input from.
  48195. * @param element Defines the element the controls should be listened from
  48196. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48197. */
  48198. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48199. /**
  48200. * Detach the current controls from the specified dom element.
  48201. * @param element Defines the element to stop listening the inputs from
  48202. */
  48203. detachControl(element: Nullable<HTMLElement>): void;
  48204. /**
  48205. * Update the current camera state depending on the inputs that have been used this frame.
  48206. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48207. */
  48208. checkInputs(): void;
  48209. /**
  48210. * Gets the class name of the current input.
  48211. * @returns the class name
  48212. */
  48213. getClassName(): string;
  48214. /**
  48215. * Get the friendly name associated with the input class.
  48216. * @returns the input friendly name
  48217. */
  48218. getSimpleName(): string;
  48219. /**
  48220. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48221. * allow modification of the heightOffset value.
  48222. */
  48223. private _modifierHeightOffset;
  48224. /**
  48225. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48226. * allow modification of the rotationOffset value.
  48227. */
  48228. private _modifierRotationOffset;
  48229. /**
  48230. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48231. * allow modification of the radius value.
  48232. */
  48233. private _modifierRadius;
  48234. }
  48235. }
  48236. declare module BABYLON {
  48237. interface FreeCameraInputsManager {
  48238. /**
  48239. * @hidden
  48240. */
  48241. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  48242. /**
  48243. * Add orientation input support to the input manager.
  48244. * @returns the current input manager
  48245. */
  48246. addDeviceOrientation(): FreeCameraInputsManager;
  48247. }
  48248. /**
  48249. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  48250. * Screen rotation is taken into account.
  48251. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48252. */
  48253. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  48254. private _camera;
  48255. private _screenOrientationAngle;
  48256. private _constantTranform;
  48257. private _screenQuaternion;
  48258. private _alpha;
  48259. private _beta;
  48260. private _gamma;
  48261. /**
  48262. * Can be used to detect if a device orientation sensor is available on a device
  48263. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  48264. * @returns a promise that will resolve on orientation change
  48265. */
  48266. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  48267. /**
  48268. * @hidden
  48269. */
  48270. _onDeviceOrientationChangedObservable: Observable<void>;
  48271. /**
  48272. * Instantiates a new input
  48273. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48274. */
  48275. constructor();
  48276. /**
  48277. * Define the camera controlled by the input.
  48278. */
  48279. get camera(): FreeCamera;
  48280. set camera(camera: FreeCamera);
  48281. /**
  48282. * Attach the input controls to a specific dom element to get the input from.
  48283. * @param element Defines the element the controls should be listened from
  48284. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48285. */
  48286. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48287. private _orientationChanged;
  48288. private _deviceOrientation;
  48289. /**
  48290. * Detach the current controls from the specified dom element.
  48291. * @param element Defines the element to stop listening the inputs from
  48292. */
  48293. detachControl(element: Nullable<HTMLElement>): void;
  48294. /**
  48295. * Update the current camera state depending on the inputs that have been used this frame.
  48296. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48297. */
  48298. checkInputs(): void;
  48299. /**
  48300. * Gets the class name of the current intput.
  48301. * @returns the class name
  48302. */
  48303. getClassName(): string;
  48304. /**
  48305. * Get the friendly name associated with the input class.
  48306. * @returns the input friendly name
  48307. */
  48308. getSimpleName(): string;
  48309. }
  48310. }
  48311. declare module BABYLON {
  48312. /**
  48313. * Manage the gamepad inputs to control a free camera.
  48314. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48315. */
  48316. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48317. /**
  48318. * Define the camera the input is attached to.
  48319. */
  48320. camera: FreeCamera;
  48321. /**
  48322. * Define the Gamepad controlling the input
  48323. */
  48324. gamepad: Nullable<Gamepad>;
  48325. /**
  48326. * Defines the gamepad rotation sensiblity.
  48327. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48328. */
  48329. gamepadAngularSensibility: number;
  48330. /**
  48331. * Defines the gamepad move sensiblity.
  48332. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48333. */
  48334. gamepadMoveSensibility: number;
  48335. private _yAxisScale;
  48336. /**
  48337. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48338. */
  48339. get invertYAxis(): boolean;
  48340. set invertYAxis(value: boolean);
  48341. private _onGamepadConnectedObserver;
  48342. private _onGamepadDisconnectedObserver;
  48343. private _cameraTransform;
  48344. private _deltaTransform;
  48345. private _vector3;
  48346. private _vector2;
  48347. /**
  48348. * Attach the input controls to a specific dom element to get the input from.
  48349. * @param element Defines the element the controls should be listened from
  48350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48351. */
  48352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48353. /**
  48354. * Detach the current controls from the specified dom element.
  48355. * @param element Defines the element to stop listening the inputs from
  48356. */
  48357. detachControl(element: Nullable<HTMLElement>): void;
  48358. /**
  48359. * Update the current camera state depending on the inputs that have been used this frame.
  48360. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48361. */
  48362. checkInputs(): void;
  48363. /**
  48364. * Gets the class name of the current intput.
  48365. * @returns the class name
  48366. */
  48367. getClassName(): string;
  48368. /**
  48369. * Get the friendly name associated with the input class.
  48370. * @returns the input friendly name
  48371. */
  48372. getSimpleName(): string;
  48373. }
  48374. }
  48375. declare module BABYLON {
  48376. /**
  48377. * Defines the potential axis of a Joystick
  48378. */
  48379. export enum JoystickAxis {
  48380. /** X axis */
  48381. X = 0,
  48382. /** Y axis */
  48383. Y = 1,
  48384. /** Z axis */
  48385. Z = 2
  48386. }
  48387. /**
  48388. * Represents the different customization options available
  48389. * for VirtualJoystick
  48390. */
  48391. interface VirtualJoystickCustomizations {
  48392. /**
  48393. * Size of the joystick's puck
  48394. */
  48395. puckSize: number;
  48396. /**
  48397. * Size of the joystick's container
  48398. */
  48399. containerSize: number;
  48400. /**
  48401. * Color of the joystick && puck
  48402. */
  48403. color: string;
  48404. /**
  48405. * Image URL for the joystick's puck
  48406. */
  48407. puckImage?: string;
  48408. /**
  48409. * Image URL for the joystick's container
  48410. */
  48411. containerImage?: string;
  48412. /**
  48413. * Defines the unmoving position of the joystick container
  48414. */
  48415. position?: {
  48416. x: number;
  48417. y: number;
  48418. };
  48419. /**
  48420. * Defines whether or not the joystick container is always visible
  48421. */
  48422. alwaysVisible: boolean;
  48423. /**
  48424. * Defines whether or not to limit the movement of the puck to the joystick's container
  48425. */
  48426. limitToContainer: boolean;
  48427. }
  48428. /**
  48429. * Class used to define virtual joystick (used in touch mode)
  48430. */
  48431. export class VirtualJoystick {
  48432. /**
  48433. * Gets or sets a boolean indicating that left and right values must be inverted
  48434. */
  48435. reverseLeftRight: boolean;
  48436. /**
  48437. * Gets or sets a boolean indicating that up and down values must be inverted
  48438. */
  48439. reverseUpDown: boolean;
  48440. /**
  48441. * Gets the offset value for the position (ie. the change of the position value)
  48442. */
  48443. deltaPosition: Vector3;
  48444. /**
  48445. * Gets a boolean indicating if the virtual joystick was pressed
  48446. */
  48447. pressed: boolean;
  48448. /**
  48449. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48450. */
  48451. static Canvas: Nullable<HTMLCanvasElement>;
  48452. /**
  48453. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48454. */
  48455. limitToContainer: boolean;
  48456. private static _globalJoystickIndex;
  48457. private static _alwaysVisibleSticks;
  48458. private static vjCanvasContext;
  48459. private static vjCanvasWidth;
  48460. private static vjCanvasHeight;
  48461. private static halfWidth;
  48462. private static _GetDefaultOptions;
  48463. private _action;
  48464. private _axisTargetedByLeftAndRight;
  48465. private _axisTargetedByUpAndDown;
  48466. private _joystickSensibility;
  48467. private _inversedSensibility;
  48468. private _joystickPointerID;
  48469. private _joystickColor;
  48470. private _joystickPointerPos;
  48471. private _joystickPreviousPointerPos;
  48472. private _joystickPointerStartPos;
  48473. private _deltaJoystickVector;
  48474. private _leftJoystick;
  48475. private _touches;
  48476. private _joystickPosition;
  48477. private _alwaysVisible;
  48478. private _puckImage;
  48479. private _containerImage;
  48480. private _joystickPuckSize;
  48481. private _joystickContainerSize;
  48482. private _clearPuckSize;
  48483. private _clearContainerSize;
  48484. private _clearPuckSizeOffset;
  48485. private _clearContainerSizeOffset;
  48486. private _onPointerDownHandlerRef;
  48487. private _onPointerMoveHandlerRef;
  48488. private _onPointerUpHandlerRef;
  48489. private _onResize;
  48490. /**
  48491. * Creates a new virtual joystick
  48492. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48493. * @param customizations Defines the options we want to customize the VirtualJoystick
  48494. */
  48495. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48496. /**
  48497. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48498. * @param newJoystickSensibility defines the new sensibility
  48499. */
  48500. setJoystickSensibility(newJoystickSensibility: number): void;
  48501. private _onPointerDown;
  48502. private _onPointerMove;
  48503. private _onPointerUp;
  48504. /**
  48505. * Change the color of the virtual joystick
  48506. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48507. */
  48508. setJoystickColor(newColor: string): void;
  48509. /**
  48510. * Size of the joystick's container
  48511. */
  48512. set containerSize(newSize: number);
  48513. get containerSize(): number;
  48514. /**
  48515. * Size of the joystick's puck
  48516. */
  48517. set puckSize(newSize: number);
  48518. get puckSize(): number;
  48519. /**
  48520. * Clears the set position of the joystick
  48521. */
  48522. clearPosition(): void;
  48523. /**
  48524. * Defines whether or not the joystick container is always visible
  48525. */
  48526. set alwaysVisible(value: boolean);
  48527. get alwaysVisible(): boolean;
  48528. /**
  48529. * Sets the constant position of the Joystick container
  48530. * @param x X axis coordinate
  48531. * @param y Y axis coordinate
  48532. */
  48533. setPosition(x: number, y: number): void;
  48534. /**
  48535. * Defines a callback to call when the joystick is touched
  48536. * @param action defines the callback
  48537. */
  48538. setActionOnTouch(action: () => any): void;
  48539. /**
  48540. * Defines which axis you'd like to control for left & right
  48541. * @param axis defines the axis to use
  48542. */
  48543. setAxisForLeftRight(axis: JoystickAxis): void;
  48544. /**
  48545. * Defines which axis you'd like to control for up & down
  48546. * @param axis defines the axis to use
  48547. */
  48548. setAxisForUpDown(axis: JoystickAxis): void;
  48549. /**
  48550. * Clears the canvas from the previous puck / container draw
  48551. */
  48552. private _clearPreviousDraw;
  48553. /**
  48554. * Loads `urlPath` to be used for the container's image
  48555. * @param urlPath defines the urlPath of an image to use
  48556. */
  48557. setContainerImage(urlPath: string): void;
  48558. /**
  48559. * Loads `urlPath` to be used for the puck's image
  48560. * @param urlPath defines the urlPath of an image to use
  48561. */
  48562. setPuckImage(urlPath: string): void;
  48563. /**
  48564. * Draws the Virtual Joystick's container
  48565. */
  48566. private _drawContainer;
  48567. /**
  48568. * Draws the Virtual Joystick's puck
  48569. */
  48570. private _drawPuck;
  48571. private _drawVirtualJoystick;
  48572. /**
  48573. * Release internal HTML canvas
  48574. */
  48575. releaseCanvas(): void;
  48576. }
  48577. }
  48578. declare module BABYLON {
  48579. interface FreeCameraInputsManager {
  48580. /**
  48581. * Add virtual joystick input support to the input manager.
  48582. * @returns the current input manager
  48583. */
  48584. addVirtualJoystick(): FreeCameraInputsManager;
  48585. }
  48586. /**
  48587. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48588. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48589. */
  48590. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48591. /**
  48592. * Defines the camera the input is attached to.
  48593. */
  48594. camera: FreeCamera;
  48595. private _leftjoystick;
  48596. private _rightjoystick;
  48597. /**
  48598. * Gets the left stick of the virtual joystick.
  48599. * @returns The virtual Joystick
  48600. */
  48601. getLeftJoystick(): VirtualJoystick;
  48602. /**
  48603. * Gets the right stick of the virtual joystick.
  48604. * @returns The virtual Joystick
  48605. */
  48606. getRightJoystick(): VirtualJoystick;
  48607. /**
  48608. * Update the current camera state depending on the inputs that have been used this frame.
  48609. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48610. */
  48611. checkInputs(): void;
  48612. /**
  48613. * Attach the input controls to a specific dom element to get the input from.
  48614. * @param element Defines the element the controls should be listened from
  48615. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48616. */
  48617. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48618. /**
  48619. * Detach the current controls from the specified dom element.
  48620. * @param element Defines the element to stop listening the inputs from
  48621. */
  48622. detachControl(element: Nullable<HTMLElement>): void;
  48623. /**
  48624. * Gets the class name of the current intput.
  48625. * @returns the class name
  48626. */
  48627. getClassName(): string;
  48628. /**
  48629. * Get the friendly name associated with the input class.
  48630. * @returns the input friendly name
  48631. */
  48632. getSimpleName(): string;
  48633. }
  48634. }
  48635. declare module BABYLON {
  48636. /**
  48637. * This represents a FPS type of camera controlled by touch.
  48638. * This is like a universal camera minus the Gamepad controls.
  48639. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48640. */
  48641. export class TouchCamera extends FreeCamera {
  48642. /**
  48643. * Defines the touch sensibility for rotation.
  48644. * The higher the faster.
  48645. */
  48646. get touchAngularSensibility(): number;
  48647. set touchAngularSensibility(value: number);
  48648. /**
  48649. * Defines the touch sensibility for move.
  48650. * The higher the faster.
  48651. */
  48652. get touchMoveSensibility(): number;
  48653. set touchMoveSensibility(value: number);
  48654. /**
  48655. * Instantiates a new touch camera.
  48656. * This represents a FPS type of camera controlled by touch.
  48657. * This is like a universal camera minus the Gamepad controls.
  48658. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48659. * @param name Define the name of the camera in the scene
  48660. * @param position Define the start position of the camera in the scene
  48661. * @param scene Define the scene the camera belongs to
  48662. */
  48663. constructor(name: string, position: Vector3, scene: Scene);
  48664. /**
  48665. * Gets the current object class name.
  48666. * @return the class name
  48667. */
  48668. getClassName(): string;
  48669. /** @hidden */
  48670. _setupInputs(): void;
  48671. }
  48672. }
  48673. declare module BABYLON {
  48674. /**
  48675. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48676. * being tilted forward or back and left or right.
  48677. */
  48678. export class DeviceOrientationCamera extends FreeCamera {
  48679. private _initialQuaternion;
  48680. private _quaternionCache;
  48681. private _tmpDragQuaternion;
  48682. private _disablePointerInputWhenUsingDeviceOrientation;
  48683. /**
  48684. * Creates a new device orientation camera
  48685. * @param name The name of the camera
  48686. * @param position The start position camera
  48687. * @param scene The scene the camera belongs to
  48688. */
  48689. constructor(name: string, position: Vector3, scene: Scene);
  48690. /**
  48691. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48692. */
  48693. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48694. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48695. private _dragFactor;
  48696. /**
  48697. * Enabled turning on the y axis when the orientation sensor is active
  48698. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  48699. */
  48700. enableHorizontalDragging(dragFactor?: number): void;
  48701. /**
  48702. * Gets the current instance class name ("DeviceOrientationCamera").
  48703. * This helps avoiding instanceof at run time.
  48704. * @returns the class name
  48705. */
  48706. getClassName(): string;
  48707. /**
  48708. * @hidden
  48709. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  48710. */
  48711. _checkInputs(): void;
  48712. /**
  48713. * Reset the camera to its default orientation on the specified axis only.
  48714. * @param axis The axis to reset
  48715. */
  48716. resetToCurrentRotation(axis?: Axis): void;
  48717. }
  48718. }
  48719. declare module BABYLON {
  48720. /**
  48721. * Defines supported buttons for XBox360 compatible gamepads
  48722. */
  48723. export enum Xbox360Button {
  48724. /** A */
  48725. A = 0,
  48726. /** B */
  48727. B = 1,
  48728. /** X */
  48729. X = 2,
  48730. /** Y */
  48731. Y = 3,
  48732. /** Left button */
  48733. LB = 4,
  48734. /** Right button */
  48735. RB = 5,
  48736. /** Back */
  48737. Back = 8,
  48738. /** Start */
  48739. Start = 9,
  48740. /** Left stick */
  48741. LeftStick = 10,
  48742. /** Right stick */
  48743. RightStick = 11
  48744. }
  48745. /** Defines values for XBox360 DPad */
  48746. export enum Xbox360Dpad {
  48747. /** Up */
  48748. Up = 12,
  48749. /** Down */
  48750. Down = 13,
  48751. /** Left */
  48752. Left = 14,
  48753. /** Right */
  48754. Right = 15
  48755. }
  48756. /**
  48757. * Defines a XBox360 gamepad
  48758. */
  48759. export class Xbox360Pad extends Gamepad {
  48760. private _leftTrigger;
  48761. private _rightTrigger;
  48762. private _onlefttriggerchanged;
  48763. private _onrighttriggerchanged;
  48764. private _onbuttondown;
  48765. private _onbuttonup;
  48766. private _ondpaddown;
  48767. private _ondpadup;
  48768. /** Observable raised when a button is pressed */
  48769. onButtonDownObservable: Observable<Xbox360Button>;
  48770. /** Observable raised when a button is released */
  48771. onButtonUpObservable: Observable<Xbox360Button>;
  48772. /** Observable raised when a pad is pressed */
  48773. onPadDownObservable: Observable<Xbox360Dpad>;
  48774. /** Observable raised when a pad is released */
  48775. onPadUpObservable: Observable<Xbox360Dpad>;
  48776. private _buttonA;
  48777. private _buttonB;
  48778. private _buttonX;
  48779. private _buttonY;
  48780. private _buttonBack;
  48781. private _buttonStart;
  48782. private _buttonLB;
  48783. private _buttonRB;
  48784. private _buttonLeftStick;
  48785. private _buttonRightStick;
  48786. private _dPadUp;
  48787. private _dPadDown;
  48788. private _dPadLeft;
  48789. private _dPadRight;
  48790. private _isXboxOnePad;
  48791. /**
  48792. * Creates a new XBox360 gamepad object
  48793. * @param id defines the id of this gamepad
  48794. * @param index defines its index
  48795. * @param gamepad defines the internal HTML gamepad object
  48796. * @param xboxOne defines if it is a XBox One gamepad
  48797. */
  48798. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  48799. /**
  48800. * Defines the callback to call when left trigger is pressed
  48801. * @param callback defines the callback to use
  48802. */
  48803. onlefttriggerchanged(callback: (value: number) => void): void;
  48804. /**
  48805. * Defines the callback to call when right trigger is pressed
  48806. * @param callback defines the callback to use
  48807. */
  48808. onrighttriggerchanged(callback: (value: number) => void): void;
  48809. /**
  48810. * Gets the left trigger value
  48811. */
  48812. get leftTrigger(): number;
  48813. /**
  48814. * Sets the left trigger value
  48815. */
  48816. set leftTrigger(newValue: number);
  48817. /**
  48818. * Gets the right trigger value
  48819. */
  48820. get rightTrigger(): number;
  48821. /**
  48822. * Sets the right trigger value
  48823. */
  48824. set rightTrigger(newValue: number);
  48825. /**
  48826. * Defines the callback to call when a button is pressed
  48827. * @param callback defines the callback to use
  48828. */
  48829. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  48830. /**
  48831. * Defines the callback to call when a button is released
  48832. * @param callback defines the callback to use
  48833. */
  48834. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  48835. /**
  48836. * Defines the callback to call when a pad is pressed
  48837. * @param callback defines the callback to use
  48838. */
  48839. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  48840. /**
  48841. * Defines the callback to call when a pad is released
  48842. * @param callback defines the callback to use
  48843. */
  48844. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  48845. private _setButtonValue;
  48846. private _setDPadValue;
  48847. /**
  48848. * Gets the value of the `A` button
  48849. */
  48850. get buttonA(): number;
  48851. /**
  48852. * Sets the value of the `A` button
  48853. */
  48854. set buttonA(value: number);
  48855. /**
  48856. * Gets the value of the `B` button
  48857. */
  48858. get buttonB(): number;
  48859. /**
  48860. * Sets the value of the `B` button
  48861. */
  48862. set buttonB(value: number);
  48863. /**
  48864. * Gets the value of the `X` button
  48865. */
  48866. get buttonX(): number;
  48867. /**
  48868. * Sets the value of the `X` button
  48869. */
  48870. set buttonX(value: number);
  48871. /**
  48872. * Gets the value of the `Y` button
  48873. */
  48874. get buttonY(): number;
  48875. /**
  48876. * Sets the value of the `Y` button
  48877. */
  48878. set buttonY(value: number);
  48879. /**
  48880. * Gets the value of the `Start` button
  48881. */
  48882. get buttonStart(): number;
  48883. /**
  48884. * Sets the value of the `Start` button
  48885. */
  48886. set buttonStart(value: number);
  48887. /**
  48888. * Gets the value of the `Back` button
  48889. */
  48890. get buttonBack(): number;
  48891. /**
  48892. * Sets the value of the `Back` button
  48893. */
  48894. set buttonBack(value: number);
  48895. /**
  48896. * Gets the value of the `Left` button
  48897. */
  48898. get buttonLB(): number;
  48899. /**
  48900. * Sets the value of the `Left` button
  48901. */
  48902. set buttonLB(value: number);
  48903. /**
  48904. * Gets the value of the `Right` button
  48905. */
  48906. get buttonRB(): number;
  48907. /**
  48908. * Sets the value of the `Right` button
  48909. */
  48910. set buttonRB(value: number);
  48911. /**
  48912. * Gets the value of the Left joystick
  48913. */
  48914. get buttonLeftStick(): number;
  48915. /**
  48916. * Sets the value of the Left joystick
  48917. */
  48918. set buttonLeftStick(value: number);
  48919. /**
  48920. * Gets the value of the Right joystick
  48921. */
  48922. get buttonRightStick(): number;
  48923. /**
  48924. * Sets the value of the Right joystick
  48925. */
  48926. set buttonRightStick(value: number);
  48927. /**
  48928. * Gets the value of D-pad up
  48929. */
  48930. get dPadUp(): number;
  48931. /**
  48932. * Sets the value of D-pad up
  48933. */
  48934. set dPadUp(value: number);
  48935. /**
  48936. * Gets the value of D-pad down
  48937. */
  48938. get dPadDown(): number;
  48939. /**
  48940. * Sets the value of D-pad down
  48941. */
  48942. set dPadDown(value: number);
  48943. /**
  48944. * Gets the value of D-pad left
  48945. */
  48946. get dPadLeft(): number;
  48947. /**
  48948. * Sets the value of D-pad left
  48949. */
  48950. set dPadLeft(value: number);
  48951. /**
  48952. * Gets the value of D-pad right
  48953. */
  48954. get dPadRight(): number;
  48955. /**
  48956. * Sets the value of D-pad right
  48957. */
  48958. set dPadRight(value: number);
  48959. /**
  48960. * Force the gamepad to synchronize with device values
  48961. */
  48962. update(): void;
  48963. /**
  48964. * Disposes the gamepad
  48965. */
  48966. dispose(): void;
  48967. }
  48968. }
  48969. declare module BABYLON {
  48970. /**
  48971. * Defines supported buttons for DualShock compatible gamepads
  48972. */
  48973. export enum DualShockButton {
  48974. /** Cross */
  48975. Cross = 0,
  48976. /** Circle */
  48977. Circle = 1,
  48978. /** Square */
  48979. Square = 2,
  48980. /** Triangle */
  48981. Triangle = 3,
  48982. /** L1 */
  48983. L1 = 4,
  48984. /** R1 */
  48985. R1 = 5,
  48986. /** Share */
  48987. Share = 8,
  48988. /** Options */
  48989. Options = 9,
  48990. /** Left stick */
  48991. LeftStick = 10,
  48992. /** Right stick */
  48993. RightStick = 11
  48994. }
  48995. /** Defines values for DualShock DPad */
  48996. export enum DualShockDpad {
  48997. /** Up */
  48998. Up = 12,
  48999. /** Down */
  49000. Down = 13,
  49001. /** Left */
  49002. Left = 14,
  49003. /** Right */
  49004. Right = 15
  49005. }
  49006. /**
  49007. * Defines a DualShock gamepad
  49008. */
  49009. export class DualShockPad extends Gamepad {
  49010. private _leftTrigger;
  49011. private _rightTrigger;
  49012. private _onlefttriggerchanged;
  49013. private _onrighttriggerchanged;
  49014. private _onbuttondown;
  49015. private _onbuttonup;
  49016. private _ondpaddown;
  49017. private _ondpadup;
  49018. /** Observable raised when a button is pressed */
  49019. onButtonDownObservable: Observable<DualShockButton>;
  49020. /** Observable raised when a button is released */
  49021. onButtonUpObservable: Observable<DualShockButton>;
  49022. /** Observable raised when a pad is pressed */
  49023. onPadDownObservable: Observable<DualShockDpad>;
  49024. /** Observable raised when a pad is released */
  49025. onPadUpObservable: Observable<DualShockDpad>;
  49026. private _buttonCross;
  49027. private _buttonCircle;
  49028. private _buttonSquare;
  49029. private _buttonTriangle;
  49030. private _buttonShare;
  49031. private _buttonOptions;
  49032. private _buttonL1;
  49033. private _buttonR1;
  49034. private _buttonLeftStick;
  49035. private _buttonRightStick;
  49036. private _dPadUp;
  49037. private _dPadDown;
  49038. private _dPadLeft;
  49039. private _dPadRight;
  49040. /**
  49041. * Creates a new DualShock gamepad object
  49042. * @param id defines the id of this gamepad
  49043. * @param index defines its index
  49044. * @param gamepad defines the internal HTML gamepad object
  49045. */
  49046. constructor(id: string, index: number, gamepad: any);
  49047. /**
  49048. * Defines the callback to call when left trigger is pressed
  49049. * @param callback defines the callback to use
  49050. */
  49051. onlefttriggerchanged(callback: (value: number) => void): void;
  49052. /**
  49053. * Defines the callback to call when right trigger is pressed
  49054. * @param callback defines the callback to use
  49055. */
  49056. onrighttriggerchanged(callback: (value: number) => void): void;
  49057. /**
  49058. * Gets the left trigger value
  49059. */
  49060. get leftTrigger(): number;
  49061. /**
  49062. * Sets the left trigger value
  49063. */
  49064. set leftTrigger(newValue: number);
  49065. /**
  49066. * Gets the right trigger value
  49067. */
  49068. get rightTrigger(): number;
  49069. /**
  49070. * Sets the right trigger value
  49071. */
  49072. set rightTrigger(newValue: number);
  49073. /**
  49074. * Defines the callback to call when a button is pressed
  49075. * @param callback defines the callback to use
  49076. */
  49077. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  49078. /**
  49079. * Defines the callback to call when a button is released
  49080. * @param callback defines the callback to use
  49081. */
  49082. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  49083. /**
  49084. * Defines the callback to call when a pad is pressed
  49085. * @param callback defines the callback to use
  49086. */
  49087. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  49088. /**
  49089. * Defines the callback to call when a pad is released
  49090. * @param callback defines the callback to use
  49091. */
  49092. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  49093. private _setButtonValue;
  49094. private _setDPadValue;
  49095. /**
  49096. * Gets the value of the `Cross` button
  49097. */
  49098. get buttonCross(): number;
  49099. /**
  49100. * Sets the value of the `Cross` button
  49101. */
  49102. set buttonCross(value: number);
  49103. /**
  49104. * Gets the value of the `Circle` button
  49105. */
  49106. get buttonCircle(): number;
  49107. /**
  49108. * Sets the value of the `Circle` button
  49109. */
  49110. set buttonCircle(value: number);
  49111. /**
  49112. * Gets the value of the `Square` button
  49113. */
  49114. get buttonSquare(): number;
  49115. /**
  49116. * Sets the value of the `Square` button
  49117. */
  49118. set buttonSquare(value: number);
  49119. /**
  49120. * Gets the value of the `Triangle` button
  49121. */
  49122. get buttonTriangle(): number;
  49123. /**
  49124. * Sets the value of the `Triangle` button
  49125. */
  49126. set buttonTriangle(value: number);
  49127. /**
  49128. * Gets the value of the `Options` button
  49129. */
  49130. get buttonOptions(): number;
  49131. /**
  49132. * Sets the value of the `Options` button
  49133. */
  49134. set buttonOptions(value: number);
  49135. /**
  49136. * Gets the value of the `Share` button
  49137. */
  49138. get buttonShare(): number;
  49139. /**
  49140. * Sets the value of the `Share` button
  49141. */
  49142. set buttonShare(value: number);
  49143. /**
  49144. * Gets the value of the `L1` button
  49145. */
  49146. get buttonL1(): number;
  49147. /**
  49148. * Sets the value of the `L1` button
  49149. */
  49150. set buttonL1(value: number);
  49151. /**
  49152. * Gets the value of the `R1` button
  49153. */
  49154. get buttonR1(): number;
  49155. /**
  49156. * Sets the value of the `R1` button
  49157. */
  49158. set buttonR1(value: number);
  49159. /**
  49160. * Gets the value of the Left joystick
  49161. */
  49162. get buttonLeftStick(): number;
  49163. /**
  49164. * Sets the value of the Left joystick
  49165. */
  49166. set buttonLeftStick(value: number);
  49167. /**
  49168. * Gets the value of the Right joystick
  49169. */
  49170. get buttonRightStick(): number;
  49171. /**
  49172. * Sets the value of the Right joystick
  49173. */
  49174. set buttonRightStick(value: number);
  49175. /**
  49176. * Gets the value of D-pad up
  49177. */
  49178. get dPadUp(): number;
  49179. /**
  49180. * Sets the value of D-pad up
  49181. */
  49182. set dPadUp(value: number);
  49183. /**
  49184. * Gets the value of D-pad down
  49185. */
  49186. get dPadDown(): number;
  49187. /**
  49188. * Sets the value of D-pad down
  49189. */
  49190. set dPadDown(value: number);
  49191. /**
  49192. * Gets the value of D-pad left
  49193. */
  49194. get dPadLeft(): number;
  49195. /**
  49196. * Sets the value of D-pad left
  49197. */
  49198. set dPadLeft(value: number);
  49199. /**
  49200. * Gets the value of D-pad right
  49201. */
  49202. get dPadRight(): number;
  49203. /**
  49204. * Sets the value of D-pad right
  49205. */
  49206. set dPadRight(value: number);
  49207. /**
  49208. * Force the gamepad to synchronize with device values
  49209. */
  49210. update(): void;
  49211. /**
  49212. * Disposes the gamepad
  49213. */
  49214. dispose(): void;
  49215. }
  49216. }
  49217. declare module BABYLON {
  49218. /**
  49219. * Manager for handling gamepads
  49220. */
  49221. export class GamepadManager {
  49222. private _scene?;
  49223. private _babylonGamepads;
  49224. private _oneGamepadConnected;
  49225. /** @hidden */
  49226. _isMonitoring: boolean;
  49227. private _gamepadEventSupported;
  49228. private _gamepadSupport?;
  49229. /**
  49230. * observable to be triggered when the gamepad controller has been connected
  49231. */
  49232. onGamepadConnectedObservable: Observable<Gamepad>;
  49233. /**
  49234. * observable to be triggered when the gamepad controller has been disconnected
  49235. */
  49236. onGamepadDisconnectedObservable: Observable<Gamepad>;
  49237. private _onGamepadConnectedEvent;
  49238. private _onGamepadDisconnectedEvent;
  49239. /**
  49240. * Initializes the gamepad manager
  49241. * @param _scene BabylonJS scene
  49242. */
  49243. constructor(_scene?: Scene | undefined);
  49244. /**
  49245. * The gamepads in the game pad manager
  49246. */
  49247. get gamepads(): Gamepad[];
  49248. /**
  49249. * Get the gamepad controllers based on type
  49250. * @param type The type of gamepad controller
  49251. * @returns Nullable gamepad
  49252. */
  49253. getGamepadByType(type?: number): Nullable<Gamepad>;
  49254. /**
  49255. * Disposes the gamepad manager
  49256. */
  49257. dispose(): void;
  49258. private _addNewGamepad;
  49259. private _startMonitoringGamepads;
  49260. private _stopMonitoringGamepads;
  49261. /** @hidden */
  49262. _checkGamepadsStatus(): void;
  49263. private _updateGamepadObjects;
  49264. }
  49265. }
  49266. declare module BABYLON {
  49267. interface Scene {
  49268. /** @hidden */
  49269. _gamepadManager: Nullable<GamepadManager>;
  49270. /**
  49271. * Gets the gamepad manager associated with the scene
  49272. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49273. */
  49274. gamepadManager: GamepadManager;
  49275. }
  49276. /**
  49277. * Interface representing a free camera inputs manager
  49278. */
  49279. interface FreeCameraInputsManager {
  49280. /**
  49281. * Adds gamepad input support to the FreeCameraInputsManager.
  49282. * @returns the FreeCameraInputsManager
  49283. */
  49284. addGamepad(): FreeCameraInputsManager;
  49285. }
  49286. /**
  49287. * Interface representing an arc rotate camera inputs manager
  49288. */
  49289. interface ArcRotateCameraInputsManager {
  49290. /**
  49291. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49292. * @returns the camera inputs manager
  49293. */
  49294. addGamepad(): ArcRotateCameraInputsManager;
  49295. }
  49296. /**
  49297. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49298. */
  49299. export class GamepadSystemSceneComponent implements ISceneComponent {
  49300. /**
  49301. * The component name helpfull to identify the component in the list of scene components.
  49302. */
  49303. readonly name: string;
  49304. /**
  49305. * The scene the component belongs to.
  49306. */
  49307. scene: Scene;
  49308. /**
  49309. * Creates a new instance of the component for the given scene
  49310. * @param scene Defines the scene to register the component in
  49311. */
  49312. constructor(scene: Scene);
  49313. /**
  49314. * Registers the component in a given scene
  49315. */
  49316. register(): void;
  49317. /**
  49318. * Rebuilds the elements related to this component in case of
  49319. * context lost for instance.
  49320. */
  49321. rebuild(): void;
  49322. /**
  49323. * Disposes the component and the associated ressources
  49324. */
  49325. dispose(): void;
  49326. private _beforeCameraUpdate;
  49327. }
  49328. }
  49329. declare module BABYLON {
  49330. /**
  49331. * 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,
  49332. * which still works and will still be found in many Playgrounds.
  49333. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49334. */
  49335. export class UniversalCamera extends TouchCamera {
  49336. /**
  49337. * Defines the gamepad rotation sensiblity.
  49338. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49339. */
  49340. get gamepadAngularSensibility(): number;
  49341. set gamepadAngularSensibility(value: number);
  49342. /**
  49343. * Defines the gamepad move sensiblity.
  49344. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49345. */
  49346. get gamepadMoveSensibility(): number;
  49347. set gamepadMoveSensibility(value: number);
  49348. /**
  49349. * 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,
  49350. * which still works and will still be found in many Playgrounds.
  49351. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49352. * @param name Define the name of the camera in the scene
  49353. * @param position Define the start position of the camera in the scene
  49354. * @param scene Define the scene the camera belongs to
  49355. */
  49356. constructor(name: string, position: Vector3, scene: Scene);
  49357. /**
  49358. * Gets the current object class name.
  49359. * @return the class name
  49360. */
  49361. getClassName(): string;
  49362. }
  49363. }
  49364. declare module BABYLON {
  49365. /**
  49366. * This represents a FPS type of camera. This is only here for back compat purpose.
  49367. * Please use the UniversalCamera instead as both are identical.
  49368. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49369. */
  49370. export class GamepadCamera extends UniversalCamera {
  49371. /**
  49372. * Instantiates a new Gamepad Camera
  49373. * This represents a FPS type of camera. This is only here for back compat purpose.
  49374. * Please use the UniversalCamera instead as both are identical.
  49375. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49376. * @param name Define the name of the camera in the scene
  49377. * @param position Define the start position of the camera in the scene
  49378. * @param scene Define the scene the camera belongs to
  49379. */
  49380. constructor(name: string, position: Vector3, scene: Scene);
  49381. /**
  49382. * Gets the current object class name.
  49383. * @return the class name
  49384. */
  49385. getClassName(): string;
  49386. }
  49387. }
  49388. declare module BABYLON {
  49389. /** @hidden */
  49390. export var passPixelShader: {
  49391. name: string;
  49392. shader: string;
  49393. };
  49394. }
  49395. declare module BABYLON {
  49396. /** @hidden */
  49397. export var passCubePixelShader: {
  49398. name: string;
  49399. shader: string;
  49400. };
  49401. }
  49402. declare module BABYLON {
  49403. /**
  49404. * PassPostProcess which produces an output the same as it's input
  49405. */
  49406. export class PassPostProcess extends PostProcess {
  49407. /**
  49408. * Gets a string identifying the name of the class
  49409. * @returns "PassPostProcess" string
  49410. */
  49411. getClassName(): string;
  49412. /**
  49413. * Creates the PassPostProcess
  49414. * @param name The name of the effect.
  49415. * @param options The required width/height ratio to downsize to before computing the render pass.
  49416. * @param camera The camera to apply the render pass to.
  49417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49418. * @param engine The engine which the post process will be applied. (default: current engine)
  49419. * @param reusable If the post process can be reused on the same frame. (default: false)
  49420. * @param textureType The type of texture to be used when performing the post processing.
  49421. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  49422. */
  49423. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49424. /** @hidden */
  49425. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49426. }
  49427. /**
  49428. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49429. */
  49430. export class PassCubePostProcess extends PostProcess {
  49431. private _face;
  49432. /**
  49433. * Gets or sets the cube face to display.
  49434. * * 0 is +X
  49435. * * 1 is -X
  49436. * * 2 is +Y
  49437. * * 3 is -Y
  49438. * * 4 is +Z
  49439. * * 5 is -Z
  49440. */
  49441. get face(): number;
  49442. set face(value: number);
  49443. /**
  49444. * Gets a string identifying the name of the class
  49445. * @returns "PassCubePostProcess" string
  49446. */
  49447. getClassName(): string;
  49448. /**
  49449. * Creates the PassCubePostProcess
  49450. * @param name The name of the effect.
  49451. * @param options The required width/height ratio to downsize to before computing the render pass.
  49452. * @param camera The camera to apply the render pass to.
  49453. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49454. * @param engine The engine which the post process will be applied. (default: current engine)
  49455. * @param reusable If the post process can be reused on the same frame. (default: false)
  49456. * @param textureType The type of texture to be used when performing the post processing.
  49457. * @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)
  49458. */
  49459. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49460. /** @hidden */
  49461. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49462. }
  49463. }
  49464. declare module BABYLON {
  49465. /** @hidden */
  49466. export var anaglyphPixelShader: {
  49467. name: string;
  49468. shader: string;
  49469. };
  49470. }
  49471. declare module BABYLON {
  49472. /**
  49473. * Postprocess used to generate anaglyphic rendering
  49474. */
  49475. export class AnaglyphPostProcess extends PostProcess {
  49476. private _passedProcess;
  49477. /**
  49478. * Gets a string identifying the name of the class
  49479. * @returns "AnaglyphPostProcess" string
  49480. */
  49481. getClassName(): string;
  49482. /**
  49483. * Creates a new AnaglyphPostProcess
  49484. * @param name defines postprocess name
  49485. * @param options defines creation options or target ratio scale
  49486. * @param rigCameras defines cameras using this postprocess
  49487. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49488. * @param engine defines hosting engine
  49489. * @param reusable defines if the postprocess will be reused multiple times per frame
  49490. */
  49491. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49492. }
  49493. }
  49494. declare module BABYLON {
  49495. /**
  49496. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49497. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49498. */
  49499. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49500. /**
  49501. * Creates a new AnaglyphArcRotateCamera
  49502. * @param name defines camera name
  49503. * @param alpha defines alpha angle (in radians)
  49504. * @param beta defines beta angle (in radians)
  49505. * @param radius defines radius
  49506. * @param target defines camera target
  49507. * @param interaxialDistance defines distance between each color axis
  49508. * @param scene defines the hosting scene
  49509. */
  49510. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49511. /**
  49512. * Gets camera class name
  49513. * @returns AnaglyphArcRotateCamera
  49514. */
  49515. getClassName(): string;
  49516. }
  49517. }
  49518. declare module BABYLON {
  49519. /**
  49520. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49521. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49522. */
  49523. export class AnaglyphFreeCamera extends FreeCamera {
  49524. /**
  49525. * Creates a new AnaglyphFreeCamera
  49526. * @param name defines camera name
  49527. * @param position defines initial position
  49528. * @param interaxialDistance defines distance between each color axis
  49529. * @param scene defines the hosting scene
  49530. */
  49531. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49532. /**
  49533. * Gets camera class name
  49534. * @returns AnaglyphFreeCamera
  49535. */
  49536. getClassName(): string;
  49537. }
  49538. }
  49539. declare module BABYLON {
  49540. /**
  49541. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49542. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49543. */
  49544. export class AnaglyphGamepadCamera extends GamepadCamera {
  49545. /**
  49546. * Creates a new AnaglyphGamepadCamera
  49547. * @param name defines camera name
  49548. * @param position defines initial position
  49549. * @param interaxialDistance defines distance between each color axis
  49550. * @param scene defines the hosting scene
  49551. */
  49552. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49553. /**
  49554. * Gets camera class name
  49555. * @returns AnaglyphGamepadCamera
  49556. */
  49557. getClassName(): string;
  49558. }
  49559. }
  49560. declare module BABYLON {
  49561. /**
  49562. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49563. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49564. */
  49565. export class AnaglyphUniversalCamera extends UniversalCamera {
  49566. /**
  49567. * Creates a new AnaglyphUniversalCamera
  49568. * @param name defines camera name
  49569. * @param position defines initial position
  49570. * @param interaxialDistance defines distance between each color axis
  49571. * @param scene defines the hosting scene
  49572. */
  49573. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49574. /**
  49575. * Gets camera class name
  49576. * @returns AnaglyphUniversalCamera
  49577. */
  49578. getClassName(): string;
  49579. }
  49580. }
  49581. declare module BABYLON {
  49582. /**
  49583. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49584. * @see https://doc.babylonjs.com/features/cameras
  49585. */
  49586. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49587. /**
  49588. * Creates a new StereoscopicArcRotateCamera
  49589. * @param name defines camera name
  49590. * @param alpha defines alpha angle (in radians)
  49591. * @param beta defines beta angle (in radians)
  49592. * @param radius defines radius
  49593. * @param target defines camera target
  49594. * @param interaxialDistance defines distance between each color axis
  49595. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49596. * @param scene defines the hosting scene
  49597. */
  49598. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49599. /**
  49600. * Gets camera class name
  49601. * @returns StereoscopicArcRotateCamera
  49602. */
  49603. getClassName(): string;
  49604. }
  49605. }
  49606. declare module BABYLON {
  49607. /**
  49608. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49609. * @see https://doc.babylonjs.com/features/cameras
  49610. */
  49611. export class StereoscopicFreeCamera extends FreeCamera {
  49612. /**
  49613. * Creates a new StereoscopicFreeCamera
  49614. * @param name defines camera name
  49615. * @param position defines initial position
  49616. * @param interaxialDistance defines distance between each color axis
  49617. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49618. * @param scene defines the hosting scene
  49619. */
  49620. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49621. /**
  49622. * Gets camera class name
  49623. * @returns StereoscopicFreeCamera
  49624. */
  49625. getClassName(): string;
  49626. }
  49627. }
  49628. declare module BABYLON {
  49629. /**
  49630. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49631. * @see https://doc.babylonjs.com/features/cameras
  49632. */
  49633. export class StereoscopicGamepadCamera extends GamepadCamera {
  49634. /**
  49635. * Creates a new StereoscopicGamepadCamera
  49636. * @param name defines camera name
  49637. * @param position defines initial position
  49638. * @param interaxialDistance defines distance between each color axis
  49639. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49640. * @param scene defines the hosting scene
  49641. */
  49642. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49643. /**
  49644. * Gets camera class name
  49645. * @returns StereoscopicGamepadCamera
  49646. */
  49647. getClassName(): string;
  49648. }
  49649. }
  49650. declare module BABYLON {
  49651. /**
  49652. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49653. * @see https://doc.babylonjs.com/features/cameras
  49654. */
  49655. export class StereoscopicUniversalCamera extends UniversalCamera {
  49656. /**
  49657. * Creates a new StereoscopicUniversalCamera
  49658. * @param name defines camera name
  49659. * @param position defines initial position
  49660. * @param interaxialDistance defines distance between each color axis
  49661. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49662. * @param scene defines the hosting scene
  49663. */
  49664. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49665. /**
  49666. * Gets camera class name
  49667. * @returns StereoscopicUniversalCamera
  49668. */
  49669. getClassName(): string;
  49670. }
  49671. }
  49672. declare module BABYLON {
  49673. /**
  49674. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49675. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49676. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49677. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49678. */
  49679. export class VirtualJoysticksCamera extends FreeCamera {
  49680. /**
  49681. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49682. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49683. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49684. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49685. * @param name Define the name of the camera in the scene
  49686. * @param position Define the start position of the camera in the scene
  49687. * @param scene Define the scene the camera belongs to
  49688. */
  49689. constructor(name: string, position: Vector3, scene: Scene);
  49690. /**
  49691. * Gets the current object class name.
  49692. * @return the class name
  49693. */
  49694. getClassName(): string;
  49695. }
  49696. }
  49697. declare module BABYLON {
  49698. /**
  49699. * This represents all the required metrics to create a VR camera.
  49700. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  49701. */
  49702. export class VRCameraMetrics {
  49703. /**
  49704. * Define the horizontal resolution off the screen.
  49705. */
  49706. hResolution: number;
  49707. /**
  49708. * Define the vertical resolution off the screen.
  49709. */
  49710. vResolution: number;
  49711. /**
  49712. * Define the horizontal screen size.
  49713. */
  49714. hScreenSize: number;
  49715. /**
  49716. * Define the vertical screen size.
  49717. */
  49718. vScreenSize: number;
  49719. /**
  49720. * Define the vertical screen center position.
  49721. */
  49722. vScreenCenter: number;
  49723. /**
  49724. * Define the distance of the eyes to the screen.
  49725. */
  49726. eyeToScreenDistance: number;
  49727. /**
  49728. * Define the distance between both lenses
  49729. */
  49730. lensSeparationDistance: number;
  49731. /**
  49732. * Define the distance between both viewer's eyes.
  49733. */
  49734. interpupillaryDistance: number;
  49735. /**
  49736. * Define the distortion factor of the VR postprocess.
  49737. * Please, touch with care.
  49738. */
  49739. distortionK: number[];
  49740. /**
  49741. * Define the chromatic aberration correction factors for the VR post process.
  49742. */
  49743. chromaAbCorrection: number[];
  49744. /**
  49745. * Define the scale factor of the post process.
  49746. * The smaller the better but the slower.
  49747. */
  49748. postProcessScaleFactor: number;
  49749. /**
  49750. * Define an offset for the lens center.
  49751. */
  49752. lensCenterOffset: number;
  49753. /**
  49754. * Define if the current vr camera should compensate the distortion of the lense or not.
  49755. */
  49756. compensateDistortion: boolean;
  49757. /**
  49758. * Defines if multiview should be enabled when rendering (Default: false)
  49759. */
  49760. multiviewEnabled: boolean;
  49761. /**
  49762. * Gets the rendering aspect ratio based on the provided resolutions.
  49763. */
  49764. get aspectRatio(): number;
  49765. /**
  49766. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  49767. */
  49768. get aspectRatioFov(): number;
  49769. /**
  49770. * @hidden
  49771. */
  49772. get leftHMatrix(): Matrix;
  49773. /**
  49774. * @hidden
  49775. */
  49776. get rightHMatrix(): Matrix;
  49777. /**
  49778. * @hidden
  49779. */
  49780. get leftPreViewMatrix(): Matrix;
  49781. /**
  49782. * @hidden
  49783. */
  49784. get rightPreViewMatrix(): Matrix;
  49785. /**
  49786. * Get the default VRMetrics based on the most generic setup.
  49787. * @returns the default vr metrics
  49788. */
  49789. static GetDefault(): VRCameraMetrics;
  49790. }
  49791. }
  49792. declare module BABYLON {
  49793. /** @hidden */
  49794. export var vrDistortionCorrectionPixelShader: {
  49795. name: string;
  49796. shader: string;
  49797. };
  49798. }
  49799. declare module BABYLON {
  49800. /**
  49801. * VRDistortionCorrectionPostProcess used for mobile VR
  49802. */
  49803. export class VRDistortionCorrectionPostProcess extends PostProcess {
  49804. private _isRightEye;
  49805. private _distortionFactors;
  49806. private _postProcessScaleFactor;
  49807. private _lensCenterOffset;
  49808. private _scaleIn;
  49809. private _scaleFactor;
  49810. private _lensCenter;
  49811. /**
  49812. * Gets a string identifying the name of the class
  49813. * @returns "VRDistortionCorrectionPostProcess" string
  49814. */
  49815. getClassName(): string;
  49816. /**
  49817. * Initializes the VRDistortionCorrectionPostProcess
  49818. * @param name The name of the effect.
  49819. * @param camera The camera to apply the render pass to.
  49820. * @param isRightEye If this is for the right eye distortion
  49821. * @param vrMetrics All the required metrics for the VR camera
  49822. */
  49823. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  49824. }
  49825. }
  49826. declare module BABYLON {
  49827. /**
  49828. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  49829. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49830. */
  49831. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  49832. /**
  49833. * Creates a new VRDeviceOrientationArcRotateCamera
  49834. * @param name defines camera name
  49835. * @param alpha defines the camera rotation along the logitudinal axis
  49836. * @param beta defines the camera rotation along the latitudinal axis
  49837. * @param radius defines the camera distance from its target
  49838. * @param target defines the camera target
  49839. * @param scene defines the scene the camera belongs to
  49840. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49841. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49842. */
  49843. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49844. /**
  49845. * Gets camera class name
  49846. * @returns VRDeviceOrientationArcRotateCamera
  49847. */
  49848. getClassName(): string;
  49849. }
  49850. }
  49851. declare module BABYLON {
  49852. /**
  49853. * Camera used to simulate VR rendering (based on FreeCamera)
  49854. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49855. */
  49856. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  49857. /**
  49858. * Creates a new VRDeviceOrientationFreeCamera
  49859. * @param name defines camera name
  49860. * @param position defines the start position of the camera
  49861. * @param scene defines the scene the camera belongs to
  49862. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49863. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49864. */
  49865. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49866. /**
  49867. * Gets camera class name
  49868. * @returns VRDeviceOrientationFreeCamera
  49869. */
  49870. getClassName(): string;
  49871. }
  49872. }
  49873. declare module BABYLON {
  49874. /**
  49875. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  49876. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49877. */
  49878. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  49879. /**
  49880. * Creates a new VRDeviceOrientationGamepadCamera
  49881. * @param name defines camera name
  49882. * @param position defines the start position of the camera
  49883. * @param scene defines the scene the camera belongs to
  49884. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49885. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49886. */
  49887. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49888. /**
  49889. * Gets camera class name
  49890. * @returns VRDeviceOrientationGamepadCamera
  49891. */
  49892. getClassName(): string;
  49893. }
  49894. }
  49895. declare module BABYLON {
  49896. /**
  49897. * A class extending Texture allowing drawing on a texture
  49898. * @see https://doc.babylonjs.com/how_to/dynamictexture
  49899. */
  49900. export class DynamicTexture extends Texture {
  49901. private _generateMipMaps;
  49902. private _canvas;
  49903. private _context;
  49904. /**
  49905. * Creates a DynamicTexture
  49906. * @param name defines the name of the texture
  49907. * @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
  49908. * @param scene defines the scene where you want the texture
  49909. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  49910. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  49911. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  49912. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  49913. */
  49914. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  49915. /**
  49916. * Get the current class name of the texture useful for serialization or dynamic coding.
  49917. * @returns "DynamicTexture"
  49918. */
  49919. getClassName(): string;
  49920. /**
  49921. * Gets the current state of canRescale
  49922. */
  49923. get canRescale(): boolean;
  49924. private _recreate;
  49925. /**
  49926. * Scales the texture
  49927. * @param ratio the scale factor to apply to both width and height
  49928. */
  49929. scale(ratio: number): void;
  49930. /**
  49931. * Resizes the texture
  49932. * @param width the new width
  49933. * @param height the new height
  49934. */
  49935. scaleTo(width: number, height: number): void;
  49936. /**
  49937. * Gets the context of the canvas used by the texture
  49938. * @returns the canvas context of the dynamic texture
  49939. */
  49940. getContext(): CanvasRenderingContext2D;
  49941. /**
  49942. * Clears the texture
  49943. */
  49944. clear(): void;
  49945. /**
  49946. * Updates the texture
  49947. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49948. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  49949. */
  49950. update(invertY?: boolean, premulAlpha?: boolean): void;
  49951. /**
  49952. * Draws text onto the texture
  49953. * @param text defines the text to be drawn
  49954. * @param x defines the placement of the text from the left
  49955. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  49956. * @param font defines the font to be used with font-style, font-size, font-name
  49957. * @param color defines the color used for the text
  49958. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  49959. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49960. * @param update defines whether texture is immediately update (default is true)
  49961. */
  49962. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  49963. /**
  49964. * Clones the texture
  49965. * @returns the clone of the texture.
  49966. */
  49967. clone(): DynamicTexture;
  49968. /**
  49969. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  49970. * @returns a serialized dynamic texture object
  49971. */
  49972. serialize(): any;
  49973. private _IsCanvasElement;
  49974. /** @hidden */
  49975. _rebuild(): void;
  49976. }
  49977. }
  49978. declare module BABYLON {
  49979. /**
  49980. * Class containing static functions to help procedurally build meshes
  49981. */
  49982. export class GroundBuilder {
  49983. /**
  49984. * Creates a ground mesh
  49985. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49986. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49988. * @param name defines the name of the mesh
  49989. * @param options defines the options used to create the mesh
  49990. * @param scene defines the hosting scene
  49991. * @returns the ground mesh
  49992. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49993. */
  49994. static CreateGround(name: string, options: {
  49995. width?: number;
  49996. height?: number;
  49997. subdivisions?: number;
  49998. subdivisionsX?: number;
  49999. subdivisionsY?: number;
  50000. updatable?: boolean;
  50001. }, scene: any): Mesh;
  50002. /**
  50003. * Creates a tiled ground mesh
  50004. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50005. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50006. * * 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
  50007. * * 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
  50008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50009. * @param name defines the name of the mesh
  50010. * @param options defines the options used to create the mesh
  50011. * @param scene defines the hosting scene
  50012. * @returns the tiled ground mesh
  50013. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50014. */
  50015. static CreateTiledGround(name: string, options: {
  50016. xmin: number;
  50017. zmin: number;
  50018. xmax: number;
  50019. zmax: number;
  50020. subdivisions?: {
  50021. w: number;
  50022. h: number;
  50023. };
  50024. precision?: {
  50025. w: number;
  50026. h: number;
  50027. };
  50028. updatable?: boolean;
  50029. }, scene?: Nullable<Scene>): Mesh;
  50030. /**
  50031. * Creates a ground mesh from a height map
  50032. * * The parameter `url` sets the URL of the height map image resource.
  50033. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50034. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50035. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50036. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50037. * * 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.
  50038. * * 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).
  50039. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50041. * @param name defines the name of the mesh
  50042. * @param url defines the url to the height map
  50043. * @param options defines the options used to create the mesh
  50044. * @param scene defines the hosting scene
  50045. * @returns the ground mesh
  50046. * @see https://doc.babylonjs.com/babylon101/height_map
  50047. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50048. */
  50049. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50050. width?: number;
  50051. height?: number;
  50052. subdivisions?: number;
  50053. minHeight?: number;
  50054. maxHeight?: number;
  50055. colorFilter?: Color3;
  50056. alphaFilter?: number;
  50057. updatable?: boolean;
  50058. onReady?: (mesh: GroundMesh) => void;
  50059. }, scene?: Nullable<Scene>): GroundMesh;
  50060. }
  50061. }
  50062. declare module BABYLON {
  50063. /**
  50064. * Class containing static functions to help procedurally build meshes
  50065. */
  50066. export class TorusBuilder {
  50067. /**
  50068. * Creates a torus mesh
  50069. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50070. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50071. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50073. * * 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
  50074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50075. * @param name defines the name of the mesh
  50076. * @param options defines the options used to create the mesh
  50077. * @param scene defines the hosting scene
  50078. * @returns the torus mesh
  50079. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50080. */
  50081. static CreateTorus(name: string, options: {
  50082. diameter?: number;
  50083. thickness?: number;
  50084. tessellation?: number;
  50085. updatable?: boolean;
  50086. sideOrientation?: number;
  50087. frontUVs?: Vector4;
  50088. backUVs?: Vector4;
  50089. }, scene: any): Mesh;
  50090. }
  50091. }
  50092. declare module BABYLON {
  50093. /**
  50094. * Class containing static functions to help procedurally build meshes
  50095. */
  50096. export class CylinderBuilder {
  50097. /**
  50098. * Creates a cylinder or a cone mesh
  50099. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50100. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50101. * * 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.
  50102. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50103. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50104. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50105. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50106. * * 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).
  50107. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50108. * * 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).
  50109. * * 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
  50110. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50111. * * 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
  50112. * * 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.
  50113. * * If `enclose` is false, a ring surface is one element.
  50114. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50115. * * 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
  50116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50117. * * 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
  50118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50119. * @param name defines the name of the mesh
  50120. * @param options defines the options used to create the mesh
  50121. * @param scene defines the hosting scene
  50122. * @returns the cylinder mesh
  50123. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50124. */
  50125. static CreateCylinder(name: string, options: {
  50126. height?: number;
  50127. diameterTop?: number;
  50128. diameterBottom?: number;
  50129. diameter?: number;
  50130. tessellation?: number;
  50131. subdivisions?: number;
  50132. arc?: number;
  50133. faceColors?: Color4[];
  50134. faceUV?: Vector4[];
  50135. updatable?: boolean;
  50136. hasRings?: boolean;
  50137. enclose?: boolean;
  50138. cap?: number;
  50139. sideOrientation?: number;
  50140. frontUVs?: Vector4;
  50141. backUVs?: Vector4;
  50142. }, scene: any): Mesh;
  50143. }
  50144. }
  50145. declare module BABYLON {
  50146. /**
  50147. * States of the webXR experience
  50148. */
  50149. export enum WebXRState {
  50150. /**
  50151. * Transitioning to being in XR mode
  50152. */
  50153. ENTERING_XR = 0,
  50154. /**
  50155. * Transitioning to non XR mode
  50156. */
  50157. EXITING_XR = 1,
  50158. /**
  50159. * In XR mode and presenting
  50160. */
  50161. IN_XR = 2,
  50162. /**
  50163. * Not entered XR mode
  50164. */
  50165. NOT_IN_XR = 3
  50166. }
  50167. /**
  50168. * The state of the XR camera's tracking
  50169. */
  50170. export enum WebXRTrackingState {
  50171. /**
  50172. * No transformation received, device is not being tracked
  50173. */
  50174. NOT_TRACKING = 0,
  50175. /**
  50176. * Tracking lost - using emulated position
  50177. */
  50178. TRACKING_LOST = 1,
  50179. /**
  50180. * Transformation tracking works normally
  50181. */
  50182. TRACKING = 2
  50183. }
  50184. /**
  50185. * Abstraction of the XR render target
  50186. */
  50187. export interface WebXRRenderTarget extends IDisposable {
  50188. /**
  50189. * xrpresent context of the canvas which can be used to display/mirror xr content
  50190. */
  50191. canvasContext: WebGLRenderingContext;
  50192. /**
  50193. * xr layer for the canvas
  50194. */
  50195. xrLayer: Nullable<XRWebGLLayer>;
  50196. /**
  50197. * Initializes the xr layer for the session
  50198. * @param xrSession xr session
  50199. * @returns a promise that will resolve once the XR Layer has been created
  50200. */
  50201. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50202. }
  50203. }
  50204. declare module BABYLON {
  50205. /**
  50206. * COnfiguration object for WebXR output canvas
  50207. */
  50208. export class WebXRManagedOutputCanvasOptions {
  50209. /**
  50210. * An optional canvas in case you wish to create it yourself and provide it here.
  50211. * If not provided, a new canvas will be created
  50212. */
  50213. canvasElement?: HTMLCanvasElement;
  50214. /**
  50215. * Options for this XR Layer output
  50216. */
  50217. canvasOptions?: XRWebGLLayerOptions;
  50218. /**
  50219. * CSS styling for a newly created canvas (if not provided)
  50220. */
  50221. newCanvasCssStyle?: string;
  50222. /**
  50223. * Get the default values of the configuration object
  50224. * @param engine defines the engine to use (can be null)
  50225. * @returns default values of this configuration object
  50226. */
  50227. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  50228. }
  50229. /**
  50230. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  50231. */
  50232. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  50233. private _options;
  50234. private _canvas;
  50235. private _engine;
  50236. private _originalCanvasSize;
  50237. /**
  50238. * Rendering context of the canvas which can be used to display/mirror xr content
  50239. */
  50240. canvasContext: WebGLRenderingContext;
  50241. /**
  50242. * xr layer for the canvas
  50243. */
  50244. xrLayer: Nullable<XRWebGLLayer>;
  50245. /**
  50246. * Obseervers registered here will be triggered when the xr layer was initialized
  50247. */
  50248. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  50249. /**
  50250. * Initializes the canvas to be added/removed upon entering/exiting xr
  50251. * @param _xrSessionManager The XR Session manager
  50252. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  50253. */
  50254. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  50255. /**
  50256. * Disposes of the object
  50257. */
  50258. dispose(): void;
  50259. /**
  50260. * Initializes the xr layer for the session
  50261. * @param xrSession xr session
  50262. * @returns a promise that will resolve once the XR Layer has been created
  50263. */
  50264. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50265. private _addCanvas;
  50266. private _removeCanvas;
  50267. private _setCanvasSize;
  50268. private _setManagedOutputCanvas;
  50269. }
  50270. }
  50271. declare module BABYLON {
  50272. /**
  50273. * Manages an XRSession to work with Babylon's engine
  50274. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50275. */
  50276. export class WebXRSessionManager implements IDisposable {
  50277. /** The scene which the session should be created for */
  50278. scene: Scene;
  50279. private _referenceSpace;
  50280. private _rttProvider;
  50281. private _sessionEnded;
  50282. private _xrNavigator;
  50283. private baseLayer;
  50284. /**
  50285. * The base reference space from which the session started. good if you want to reset your
  50286. * reference space
  50287. */
  50288. baseReferenceSpace: XRReferenceSpace;
  50289. /**
  50290. * Current XR frame
  50291. */
  50292. currentFrame: Nullable<XRFrame>;
  50293. /** WebXR timestamp updated every frame */
  50294. currentTimestamp: number;
  50295. /**
  50296. * Used just in case of a failure to initialize an immersive session.
  50297. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50298. */
  50299. defaultHeightCompensation: number;
  50300. /**
  50301. * Fires every time a new xrFrame arrives which can be used to update the camera
  50302. */
  50303. onXRFrameObservable: Observable<XRFrame>;
  50304. /**
  50305. * Fires when the reference space changed
  50306. */
  50307. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50308. /**
  50309. * Fires when the xr session is ended either by the device or manually done
  50310. */
  50311. onXRSessionEnded: Observable<any>;
  50312. /**
  50313. * Fires when the xr session is ended either by the device or manually done
  50314. */
  50315. onXRSessionInit: Observable<XRSession>;
  50316. /**
  50317. * Underlying xr session
  50318. */
  50319. session: XRSession;
  50320. /**
  50321. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50322. * or get the offset the player is currently at.
  50323. */
  50324. viewerReferenceSpace: XRReferenceSpace;
  50325. /**
  50326. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50327. * @param scene The scene which the session should be created for
  50328. */
  50329. constructor(
  50330. /** The scene which the session should be created for */
  50331. scene: Scene);
  50332. /**
  50333. * The current reference space used in this session. This reference space can constantly change!
  50334. * It is mainly used to offset the camera's position.
  50335. */
  50336. get referenceSpace(): XRReferenceSpace;
  50337. /**
  50338. * Set a new reference space and triggers the observable
  50339. */
  50340. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50341. /**
  50342. * Disposes of the session manager
  50343. */
  50344. dispose(): void;
  50345. /**
  50346. * Stops the xrSession and restores the render loop
  50347. * @returns Promise which resolves after it exits XR
  50348. */
  50349. exitXRAsync(): Promise<void>;
  50350. /**
  50351. * Gets the correct render target texture to be rendered this frame for this eye
  50352. * @param eye the eye for which to get the render target
  50353. * @returns the render target for the specified eye
  50354. */
  50355. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50356. /**
  50357. * Creates a WebXRRenderTarget object for the XR session
  50358. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50359. * @param options optional options to provide when creating a new render target
  50360. * @returns a WebXR render target to which the session can render
  50361. */
  50362. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50363. /**
  50364. * Initializes the manager
  50365. * After initialization enterXR can be called to start an XR session
  50366. * @returns Promise which resolves after it is initialized
  50367. */
  50368. initializeAsync(): Promise<void>;
  50369. /**
  50370. * Initializes an xr session
  50371. * @param xrSessionMode mode to initialize
  50372. * @param xrSessionInit defines optional and required values to pass to the session builder
  50373. * @returns a promise which will resolve once the session has been initialized
  50374. */
  50375. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50376. /**
  50377. * Checks if a session would be supported for the creation options specified
  50378. * @param sessionMode session mode to check if supported eg. immersive-vr
  50379. * @returns A Promise that resolves to true if supported and false if not
  50380. */
  50381. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50382. /**
  50383. * Resets the reference space to the one started the session
  50384. */
  50385. resetReferenceSpace(): void;
  50386. /**
  50387. * Starts rendering to the xr layer
  50388. */
  50389. runXRRenderLoop(): void;
  50390. /**
  50391. * Sets the reference space on the xr session
  50392. * @param referenceSpaceType space to set
  50393. * @returns a promise that will resolve once the reference space has been set
  50394. */
  50395. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50396. /**
  50397. * Updates the render state of the session
  50398. * @param state state to set
  50399. * @returns a promise that resolves once the render state has been updated
  50400. */
  50401. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50402. /**
  50403. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50404. * @param sessionMode defines the session to test
  50405. * @returns a promise with boolean as final value
  50406. */
  50407. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50408. private _createRenderTargetTexture;
  50409. }
  50410. }
  50411. declare module BABYLON {
  50412. /**
  50413. * WebXR Camera which holds the views for the xrSession
  50414. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50415. */
  50416. export class WebXRCamera extends FreeCamera {
  50417. private _xrSessionManager;
  50418. private _firstFrame;
  50419. private _referenceQuaternion;
  50420. private _referencedPosition;
  50421. private _xrInvPositionCache;
  50422. private _xrInvQuaternionCache;
  50423. private _trackingState;
  50424. /**
  50425. * Observable raised before camera teleportation
  50426. */
  50427. onBeforeCameraTeleport: Observable<Vector3>;
  50428. /**
  50429. * Observable raised after camera teleportation
  50430. */
  50431. onAfterCameraTeleport: Observable<Vector3>;
  50432. /**
  50433. * Notifies when the camera's tracking state has changed.
  50434. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50435. */
  50436. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50437. /**
  50438. * Should position compensation execute on first frame.
  50439. * This is used when copying the position from a native (non XR) camera
  50440. */
  50441. compensateOnFirstFrame: boolean;
  50442. /**
  50443. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50444. * @param name the name of the camera
  50445. * @param scene the scene to add the camera to
  50446. * @param _xrSessionManager a constructed xr session manager
  50447. */
  50448. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50449. /**
  50450. * Get the current XR tracking state of the camera
  50451. */
  50452. get trackingState(): WebXRTrackingState;
  50453. private _setTrackingState;
  50454. /**
  50455. * Return the user's height, unrelated to the current ground.
  50456. * This will be the y position of this camera, when ground level is 0.
  50457. */
  50458. get realWorldHeight(): number;
  50459. /** @hidden */
  50460. _updateForDualEyeDebugging(): void;
  50461. /**
  50462. * Sets this camera's transformation based on a non-vr camera
  50463. * @param otherCamera the non-vr camera to copy the transformation from
  50464. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50465. */
  50466. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50467. /**
  50468. * Gets the current instance class name ("WebXRCamera").
  50469. * @returns the class name
  50470. */
  50471. getClassName(): string;
  50472. private _rotate180;
  50473. private _updateFromXRSession;
  50474. private _updateNumberOfRigCameras;
  50475. private _updateReferenceSpace;
  50476. private _updateReferenceSpaceOffset;
  50477. }
  50478. }
  50479. declare module BABYLON {
  50480. /**
  50481. * Defining the interface required for a (webxr) feature
  50482. */
  50483. export interface IWebXRFeature extends IDisposable {
  50484. /**
  50485. * Is this feature attached
  50486. */
  50487. attached: boolean;
  50488. /**
  50489. * Should auto-attach be disabled?
  50490. */
  50491. disableAutoAttach: boolean;
  50492. /**
  50493. * Attach the feature to the session
  50494. * Will usually be called by the features manager
  50495. *
  50496. * @param force should attachment be forced (even when already attached)
  50497. * @returns true if successful.
  50498. */
  50499. attach(force?: boolean): boolean;
  50500. /**
  50501. * Detach the feature from the session
  50502. * Will usually be called by the features manager
  50503. *
  50504. * @returns true if successful.
  50505. */
  50506. detach(): boolean;
  50507. /**
  50508. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50509. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50510. *
  50511. * @returns whether or not the feature is compatible in this environment
  50512. */
  50513. isCompatible(): boolean;
  50514. /**
  50515. * Was this feature disposed;
  50516. */
  50517. isDisposed: boolean;
  50518. /**
  50519. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50520. */
  50521. xrNativeFeatureName?: string;
  50522. /**
  50523. * A list of (Babylon WebXR) features this feature depends on
  50524. */
  50525. dependsOn?: string[];
  50526. }
  50527. /**
  50528. * A list of the currently available features without referencing them
  50529. */
  50530. export class WebXRFeatureName {
  50531. /**
  50532. * The name of the anchor system feature
  50533. */
  50534. static readonly ANCHOR_SYSTEM: string;
  50535. /**
  50536. * The name of the background remover feature
  50537. */
  50538. static readonly BACKGROUND_REMOVER: string;
  50539. /**
  50540. * The name of the hit test feature
  50541. */
  50542. static readonly HIT_TEST: string;
  50543. /**
  50544. * physics impostors for xr controllers feature
  50545. */
  50546. static readonly PHYSICS_CONTROLLERS: string;
  50547. /**
  50548. * The name of the plane detection feature
  50549. */
  50550. static readonly PLANE_DETECTION: string;
  50551. /**
  50552. * The name of the pointer selection feature
  50553. */
  50554. static readonly POINTER_SELECTION: string;
  50555. /**
  50556. * The name of the teleportation feature
  50557. */
  50558. static readonly TELEPORTATION: string;
  50559. /**
  50560. * The name of the feature points feature.
  50561. */
  50562. static readonly FEATURE_POINTS: string;
  50563. /**
  50564. * The name of the hand tracking feature.
  50565. */
  50566. static readonly HAND_TRACKING: string;
  50567. }
  50568. /**
  50569. * Defining the constructor of a feature. Used to register the modules.
  50570. */
  50571. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50572. /**
  50573. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50574. * It is mainly used in AR sessions.
  50575. *
  50576. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50577. */
  50578. export class WebXRFeaturesManager implements IDisposable {
  50579. private _xrSessionManager;
  50580. private static readonly _AvailableFeatures;
  50581. private _features;
  50582. /**
  50583. * constructs a new features manages.
  50584. *
  50585. * @param _xrSessionManager an instance of WebXRSessionManager
  50586. */
  50587. constructor(_xrSessionManager: WebXRSessionManager);
  50588. /**
  50589. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50590. * Mainly used internally.
  50591. *
  50592. * @param featureName the name of the feature to register
  50593. * @param constructorFunction the function used to construct the module
  50594. * @param version the (babylon) version of the module
  50595. * @param stable is that a stable version of this module
  50596. */
  50597. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50598. /**
  50599. * Returns a constructor of a specific feature.
  50600. *
  50601. * @param featureName the name of the feature to construct
  50602. * @param version the version of the feature to load
  50603. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50604. * @param options optional options provided to the module.
  50605. * @returns a function that, when called, will return a new instance of this feature
  50606. */
  50607. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50608. /**
  50609. * Can be used to return the list of features currently registered
  50610. *
  50611. * @returns an Array of available features
  50612. */
  50613. static GetAvailableFeatures(): string[];
  50614. /**
  50615. * Gets the versions available for a specific feature
  50616. * @param featureName the name of the feature
  50617. * @returns an array with the available versions
  50618. */
  50619. static GetAvailableVersions(featureName: string): string[];
  50620. /**
  50621. * Return the latest unstable version of this feature
  50622. * @param featureName the name of the feature to search
  50623. * @returns the version number. if not found will return -1
  50624. */
  50625. static GetLatestVersionOfFeature(featureName: string): number;
  50626. /**
  50627. * Return the latest stable version of this feature
  50628. * @param featureName the name of the feature to search
  50629. * @returns the version number. if not found will return -1
  50630. */
  50631. static GetStableVersionOfFeature(featureName: string): number;
  50632. /**
  50633. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50634. * Can be used during a session to start a feature
  50635. * @param featureName the name of feature to attach
  50636. */
  50637. attachFeature(featureName: string): void;
  50638. /**
  50639. * Can be used inside a session or when the session ends to detach a specific feature
  50640. * @param featureName the name of the feature to detach
  50641. */
  50642. detachFeature(featureName: string): void;
  50643. /**
  50644. * Used to disable an already-enabled feature
  50645. * The feature will be disposed and will be recreated once enabled.
  50646. * @param featureName the feature to disable
  50647. * @returns true if disable was successful
  50648. */
  50649. disableFeature(featureName: string | {
  50650. Name: string;
  50651. }): boolean;
  50652. /**
  50653. * dispose this features manager
  50654. */
  50655. dispose(): void;
  50656. /**
  50657. * 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.
  50658. * 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.
  50659. *
  50660. * @param featureName the name of the feature to load or the class of the feature
  50661. * @param version optional version to load. if not provided the latest version will be enabled
  50662. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50663. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50664. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50665. * @returns a new constructed feature or throws an error if feature not found.
  50666. */
  50667. enableFeature(featureName: string | {
  50668. Name: string;
  50669. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50670. /**
  50671. * get the implementation of an enabled feature.
  50672. * @param featureName the name of the feature to load
  50673. * @returns the feature class, if found
  50674. */
  50675. getEnabledFeature(featureName: string): IWebXRFeature;
  50676. /**
  50677. * Get the list of enabled features
  50678. * @returns an array of enabled features
  50679. */
  50680. getEnabledFeatures(): string[];
  50681. /**
  50682. * This function will exten the session creation configuration object with enabled features.
  50683. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50684. * according to the defined "required" variable, provided during enableFeature call
  50685. * @param xrSessionInit the xr Session init object to extend
  50686. *
  50687. * @returns an extended XRSessionInit object
  50688. */
  50689. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50690. }
  50691. }
  50692. declare module BABYLON {
  50693. /**
  50694. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50695. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50696. */
  50697. export class WebXRExperienceHelper implements IDisposable {
  50698. private scene;
  50699. private _nonVRCamera;
  50700. private _originalSceneAutoClear;
  50701. private _supported;
  50702. /**
  50703. * Camera used to render xr content
  50704. */
  50705. camera: WebXRCamera;
  50706. /** A features manager for this xr session */
  50707. featuresManager: WebXRFeaturesManager;
  50708. /**
  50709. * Observers registered here will be triggered after the camera's initial transformation is set
  50710. * This can be used to set a different ground level or an extra rotation.
  50711. *
  50712. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  50713. * to the position set after this observable is done executing.
  50714. */
  50715. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  50716. /**
  50717. * Fires when the state of the experience helper has changed
  50718. */
  50719. onStateChangedObservable: Observable<WebXRState>;
  50720. /** Session manager used to keep track of xr session */
  50721. sessionManager: WebXRSessionManager;
  50722. /**
  50723. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  50724. */
  50725. state: WebXRState;
  50726. /**
  50727. * Creates a WebXRExperienceHelper
  50728. * @param scene The scene the helper should be created in
  50729. */
  50730. private constructor();
  50731. /**
  50732. * Creates the experience helper
  50733. * @param scene the scene to attach the experience helper to
  50734. * @returns a promise for the experience helper
  50735. */
  50736. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  50737. /**
  50738. * Disposes of the experience helper
  50739. */
  50740. dispose(): void;
  50741. /**
  50742. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  50743. * @param sessionMode options for the XR session
  50744. * @param referenceSpaceType frame of reference of the XR session
  50745. * @param renderTarget the output canvas that will be used to enter XR mode
  50746. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  50747. * @returns promise that resolves after xr mode has entered
  50748. */
  50749. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  50750. /**
  50751. * Exits XR mode and returns the scene to its original state
  50752. * @returns promise that resolves after xr mode has exited
  50753. */
  50754. exitXRAsync(): Promise<void>;
  50755. private _nonXRToXRCamera;
  50756. private _setState;
  50757. }
  50758. }
  50759. declare module BABYLON {
  50760. /**
  50761. * X-Y values for axes in WebXR
  50762. */
  50763. export interface IWebXRMotionControllerAxesValue {
  50764. /**
  50765. * The value of the x axis
  50766. */
  50767. x: number;
  50768. /**
  50769. * The value of the y-axis
  50770. */
  50771. y: number;
  50772. }
  50773. /**
  50774. * changed / previous values for the values of this component
  50775. */
  50776. export interface IWebXRMotionControllerComponentChangesValues<T> {
  50777. /**
  50778. * current (this frame) value
  50779. */
  50780. current: T;
  50781. /**
  50782. * previous (last change) value
  50783. */
  50784. previous: T;
  50785. }
  50786. /**
  50787. * Represents changes in the component between current frame and last values recorded
  50788. */
  50789. export interface IWebXRMotionControllerComponentChanges {
  50790. /**
  50791. * will be populated with previous and current values if axes changed
  50792. */
  50793. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  50794. /**
  50795. * will be populated with previous and current values if pressed changed
  50796. */
  50797. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50798. /**
  50799. * will be populated with previous and current values if touched changed
  50800. */
  50801. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50802. /**
  50803. * will be populated with previous and current values if value changed
  50804. */
  50805. value?: IWebXRMotionControllerComponentChangesValues<number>;
  50806. }
  50807. /**
  50808. * This class represents a single component (for example button or thumbstick) of a motion controller
  50809. */
  50810. export class WebXRControllerComponent implements IDisposable {
  50811. /**
  50812. * the id of this component
  50813. */
  50814. id: string;
  50815. /**
  50816. * the type of the component
  50817. */
  50818. type: MotionControllerComponentType;
  50819. private _buttonIndex;
  50820. private _axesIndices;
  50821. private _axes;
  50822. private _changes;
  50823. private _currentValue;
  50824. private _hasChanges;
  50825. private _pressed;
  50826. private _touched;
  50827. /**
  50828. * button component type
  50829. */
  50830. static BUTTON_TYPE: MotionControllerComponentType;
  50831. /**
  50832. * squeeze component type
  50833. */
  50834. static SQUEEZE_TYPE: MotionControllerComponentType;
  50835. /**
  50836. * Thumbstick component type
  50837. */
  50838. static THUMBSTICK_TYPE: MotionControllerComponentType;
  50839. /**
  50840. * Touchpad component type
  50841. */
  50842. static TOUCHPAD_TYPE: MotionControllerComponentType;
  50843. /**
  50844. * trigger component type
  50845. */
  50846. static TRIGGER_TYPE: MotionControllerComponentType;
  50847. /**
  50848. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  50849. * the axes data changes
  50850. */
  50851. onAxisValueChangedObservable: Observable<{
  50852. x: number;
  50853. y: number;
  50854. }>;
  50855. /**
  50856. * Observers registered here will be triggered when the state of a button changes
  50857. * State change is either pressed / touched / value
  50858. */
  50859. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  50860. /**
  50861. * Creates a new component for a motion controller.
  50862. * It is created by the motion controller itself
  50863. *
  50864. * @param id the id of this component
  50865. * @param type the type of the component
  50866. * @param _buttonIndex index in the buttons array of the gamepad
  50867. * @param _axesIndices indices of the values in the axes array of the gamepad
  50868. */
  50869. constructor(
  50870. /**
  50871. * the id of this component
  50872. */
  50873. id: string,
  50874. /**
  50875. * the type of the component
  50876. */
  50877. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  50878. /**
  50879. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  50880. */
  50881. get axes(): IWebXRMotionControllerAxesValue;
  50882. /**
  50883. * Get the changes. Elements will be populated only if they changed with their previous and current value
  50884. */
  50885. get changes(): IWebXRMotionControllerComponentChanges;
  50886. /**
  50887. * Return whether or not the component changed the last frame
  50888. */
  50889. get hasChanges(): boolean;
  50890. /**
  50891. * is the button currently pressed
  50892. */
  50893. get pressed(): boolean;
  50894. /**
  50895. * is the button currently touched
  50896. */
  50897. get touched(): boolean;
  50898. /**
  50899. * Get the current value of this component
  50900. */
  50901. get value(): number;
  50902. /**
  50903. * Dispose this component
  50904. */
  50905. dispose(): void;
  50906. /**
  50907. * Are there axes correlating to this component
  50908. * @return true is axes data is available
  50909. */
  50910. isAxes(): boolean;
  50911. /**
  50912. * Is this component a button (hence - pressable)
  50913. * @returns true if can be pressed
  50914. */
  50915. isButton(): boolean;
  50916. /**
  50917. * update this component using the gamepad object it is in. Called on every frame
  50918. * @param nativeController the native gamepad controller object
  50919. */
  50920. update(nativeController: IMinimalMotionControllerObject): void;
  50921. }
  50922. }
  50923. declare module BABYLON {
  50924. /**
  50925. * Interface used to represent data loading progression
  50926. */
  50927. export interface ISceneLoaderProgressEvent {
  50928. /**
  50929. * Defines if data length to load can be evaluated
  50930. */
  50931. readonly lengthComputable: boolean;
  50932. /**
  50933. * Defines the loaded data length
  50934. */
  50935. readonly loaded: number;
  50936. /**
  50937. * Defines the data length to load
  50938. */
  50939. readonly total: number;
  50940. }
  50941. /**
  50942. * Interface used by SceneLoader plugins to define supported file extensions
  50943. */
  50944. export interface ISceneLoaderPluginExtensions {
  50945. /**
  50946. * Defines the list of supported extensions
  50947. */
  50948. [extension: string]: {
  50949. isBinary: boolean;
  50950. };
  50951. }
  50952. /**
  50953. * Interface used by SceneLoader plugin factory
  50954. */
  50955. export interface ISceneLoaderPluginFactory {
  50956. /**
  50957. * Defines the name of the factory
  50958. */
  50959. name: string;
  50960. /**
  50961. * Function called to create a new plugin
  50962. * @return the new plugin
  50963. */
  50964. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  50965. /**
  50966. * The callback that returns true if the data can be directly loaded.
  50967. * @param data string containing the file data
  50968. * @returns if the data can be loaded directly
  50969. */
  50970. canDirectLoad?(data: string): boolean;
  50971. }
  50972. /**
  50973. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  50974. */
  50975. export interface ISceneLoaderPluginBase {
  50976. /**
  50977. * The friendly name of this plugin.
  50978. */
  50979. name: string;
  50980. /**
  50981. * The file extensions supported by this plugin.
  50982. */
  50983. extensions: string | ISceneLoaderPluginExtensions;
  50984. /**
  50985. * The callback called when loading from a url.
  50986. * @param scene scene loading this url
  50987. * @param url url to load
  50988. * @param onSuccess callback called when the file successfully loads
  50989. * @param onProgress callback called while file is loading (if the server supports this mode)
  50990. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  50991. * @param onError callback called when the file fails to load
  50992. * @returns a file request object
  50993. */
  50994. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50995. /**
  50996. * The callback called when loading from a file object.
  50997. * @param scene scene loading this file
  50998. * @param file defines the file to load
  50999. * @param onSuccess defines the callback to call when data is loaded
  51000. * @param onProgress defines the callback to call during loading process
  51001. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  51002. * @param onError defines the callback to call when an error occurs
  51003. * @returns a file request object
  51004. */
  51005. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51006. /**
  51007. * The callback that returns true if the data can be directly loaded.
  51008. * @param data string containing the file data
  51009. * @returns if the data can be loaded directly
  51010. */
  51011. canDirectLoad?(data: string): boolean;
  51012. /**
  51013. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  51014. * @param scene scene loading this data
  51015. * @param data string containing the data
  51016. * @returns data to pass to the plugin
  51017. */
  51018. directLoad?(scene: Scene, data: string): any;
  51019. /**
  51020. * The callback that allows custom handling of the root url based on the response url.
  51021. * @param rootUrl the original root url
  51022. * @param responseURL the response url if available
  51023. * @returns the new root url
  51024. */
  51025. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  51026. }
  51027. /**
  51028. * Interface used to define a SceneLoader plugin
  51029. */
  51030. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  51031. /**
  51032. * Import meshes into a scene.
  51033. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51034. * @param scene The scene to import into
  51035. * @param data The data to import
  51036. * @param rootUrl The root url for scene and resources
  51037. * @param meshes The meshes array to import into
  51038. * @param particleSystems The particle systems array to import into
  51039. * @param skeletons The skeletons array to import into
  51040. * @param onError The callback when import fails
  51041. * @returns True if successful or false otherwise
  51042. */
  51043. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  51044. /**
  51045. * Load into a scene.
  51046. * @param scene The scene to load into
  51047. * @param data The data to import
  51048. * @param rootUrl The root url for scene and resources
  51049. * @param onError The callback when import fails
  51050. * @returns True if successful or false otherwise
  51051. */
  51052. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  51053. /**
  51054. * Load into an asset container.
  51055. * @param scene The scene to load into
  51056. * @param data The data to import
  51057. * @param rootUrl The root url for scene and resources
  51058. * @param onError The callback when import fails
  51059. * @returns The loaded asset container
  51060. */
  51061. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  51062. }
  51063. /**
  51064. * Interface used to define an async SceneLoader plugin
  51065. */
  51066. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  51067. /**
  51068. * Import meshes into a scene.
  51069. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51070. * @param scene The scene to import into
  51071. * @param data The data to import
  51072. * @param rootUrl The root url for scene and resources
  51073. * @param onProgress The callback when the load progresses
  51074. * @param fileName Defines the name of the file to load
  51075. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  51076. */
  51077. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  51078. meshes: AbstractMesh[];
  51079. particleSystems: IParticleSystem[];
  51080. skeletons: Skeleton[];
  51081. animationGroups: AnimationGroup[];
  51082. }>;
  51083. /**
  51084. * Load into a scene.
  51085. * @param scene The scene to load into
  51086. * @param data The data to import
  51087. * @param rootUrl The root url for scene and resources
  51088. * @param onProgress The callback when the load progresses
  51089. * @param fileName Defines the name of the file to load
  51090. * @returns Nothing
  51091. */
  51092. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51093. /**
  51094. * Load into an asset container.
  51095. * @param scene The scene to load into
  51096. * @param data The data to import
  51097. * @param rootUrl The root url for scene and resources
  51098. * @param onProgress The callback when the load progresses
  51099. * @param fileName Defines the name of the file to load
  51100. * @returns The loaded asset container
  51101. */
  51102. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51103. }
  51104. /**
  51105. * Mode that determines how to handle old animation groups before loading new ones.
  51106. */
  51107. export enum SceneLoaderAnimationGroupLoadingMode {
  51108. /**
  51109. * Reset all old animations to initial state then dispose them.
  51110. */
  51111. Clean = 0,
  51112. /**
  51113. * Stop all old animations.
  51114. */
  51115. Stop = 1,
  51116. /**
  51117. * Restart old animations from first frame.
  51118. */
  51119. Sync = 2,
  51120. /**
  51121. * Old animations remains untouched.
  51122. */
  51123. NoSync = 3
  51124. }
  51125. /**
  51126. * Defines a plugin registered by the SceneLoader
  51127. */
  51128. interface IRegisteredPlugin {
  51129. /**
  51130. * Defines the plugin to use
  51131. */
  51132. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51133. /**
  51134. * Defines if the plugin supports binary data
  51135. */
  51136. isBinary: boolean;
  51137. }
  51138. /**
  51139. * Class used to load scene from various file formats using registered plugins
  51140. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  51141. */
  51142. export class SceneLoader {
  51143. /**
  51144. * No logging while loading
  51145. */
  51146. static readonly NO_LOGGING: number;
  51147. /**
  51148. * Minimal logging while loading
  51149. */
  51150. static readonly MINIMAL_LOGGING: number;
  51151. /**
  51152. * Summary logging while loading
  51153. */
  51154. static readonly SUMMARY_LOGGING: number;
  51155. /**
  51156. * Detailled logging while loading
  51157. */
  51158. static readonly DETAILED_LOGGING: number;
  51159. /**
  51160. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51161. */
  51162. static get ForceFullSceneLoadingForIncremental(): boolean;
  51163. static set ForceFullSceneLoadingForIncremental(value: boolean);
  51164. /**
  51165. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51166. */
  51167. static get ShowLoadingScreen(): boolean;
  51168. static set ShowLoadingScreen(value: boolean);
  51169. /**
  51170. * Defines the current logging level (while loading the scene)
  51171. * @ignorenaming
  51172. */
  51173. static get loggingLevel(): number;
  51174. static set loggingLevel(value: number);
  51175. /**
  51176. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51177. */
  51178. static get CleanBoneMatrixWeights(): boolean;
  51179. static set CleanBoneMatrixWeights(value: boolean);
  51180. /**
  51181. * Event raised when a plugin is used to load a scene
  51182. */
  51183. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51184. private static _registeredPlugins;
  51185. private static _showingLoadingScreen;
  51186. /**
  51187. * Gets the default plugin (used to load Babylon files)
  51188. * @returns the .babylon plugin
  51189. */
  51190. static GetDefaultPlugin(): IRegisteredPlugin;
  51191. private static _GetPluginForExtension;
  51192. private static _GetPluginForDirectLoad;
  51193. private static _GetPluginForFilename;
  51194. private static _GetDirectLoad;
  51195. private static _LoadData;
  51196. private static _GetFileInfo;
  51197. /**
  51198. * Gets a plugin that can load the given extension
  51199. * @param extension defines the extension to load
  51200. * @returns a plugin or null if none works
  51201. */
  51202. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51203. /**
  51204. * Gets a boolean indicating that the given extension can be loaded
  51205. * @param extension defines the extension to load
  51206. * @returns true if the extension is supported
  51207. */
  51208. static IsPluginForExtensionAvailable(extension: string): boolean;
  51209. /**
  51210. * Adds a new plugin to the list of registered plugins
  51211. * @param plugin defines the plugin to add
  51212. */
  51213. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  51214. /**
  51215. * Import meshes into a scene
  51216. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51217. * @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)
  51218. * @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)
  51219. * @param scene the instance of BABYLON.Scene to append to
  51220. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  51221. * @param onProgress a callback with a progress event for each file being loaded
  51222. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51223. * @param pluginExtension the extension used to determine the plugin
  51224. * @returns The loaded plugin
  51225. */
  51226. 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>;
  51227. /**
  51228. * Import meshes into a scene
  51229. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51230. * @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)
  51231. * @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)
  51232. * @param scene the instance of BABYLON.Scene to append to
  51233. * @param onProgress a callback with a progress event for each file being loaded
  51234. * @param pluginExtension the extension used to determine the plugin
  51235. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51236. */
  51237. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  51238. meshes: AbstractMesh[];
  51239. particleSystems: IParticleSystem[];
  51240. skeletons: Skeleton[];
  51241. animationGroups: AnimationGroup[];
  51242. }>;
  51243. /**
  51244. * Load a scene
  51245. * @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)
  51246. * @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)
  51247. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51248. * @param onSuccess a callback with the scene when import succeeds
  51249. * @param onProgress a callback with a progress event for each file being loaded
  51250. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51251. * @param pluginExtension the extension used to determine the plugin
  51252. * @returns The loaded plugin
  51253. */
  51254. 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>;
  51255. /**
  51256. * Load a scene
  51257. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  51258. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  51259. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51260. * @param onProgress a callback with a progress event for each file being loaded
  51261. * @param pluginExtension the extension used to determine the plugin
  51262. * @returns The loaded scene
  51263. */
  51264. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51265. /**
  51266. * Append a scene
  51267. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  51268. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  51269. * @param scene is the instance of BABYLON.Scene to append to
  51270. * @param onSuccess a callback with the scene when import succeeds
  51271. * @param onProgress a callback with a progress event for each file being loaded
  51272. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51273. * @param pluginExtension the extension used to determine the plugin
  51274. * @returns The loaded plugin
  51275. */
  51276. static 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>;
  51277. /**
  51278. * Append a scene
  51279. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  51280. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  51281. * @param scene is the instance of BABYLON.Scene to append to
  51282. * @param onProgress a callback with a progress event for each file being loaded
  51283. * @param pluginExtension the extension used to determine the plugin
  51284. * @returns The given scene
  51285. */
  51286. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51287. /**
  51288. * Load a scene into an asset container
  51289. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  51290. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  51291. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51292. * @param onSuccess a callback with the scene when import succeeds
  51293. * @param onProgress a callback with a progress event for each file being loaded
  51294. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51295. * @param pluginExtension the extension used to determine the plugin
  51296. * @returns The loaded plugin
  51297. */
  51298. static 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>;
  51299. /**
  51300. * Load a scene into an asset container
  51301. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  51302. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  51303. * @param scene is the instance of Scene to append to
  51304. * @param onProgress a callback with a progress event for each file being loaded
  51305. * @param pluginExtension the extension used to determine the plugin
  51306. * @returns The loaded asset container
  51307. */
  51308. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51309. /**
  51310. * Import animations from a file into a scene
  51311. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  51312. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  51313. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51314. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51315. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51316. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51317. * @param onSuccess a callback with the scene when import succeeds
  51318. * @param onProgress a callback with a progress event for each file being loaded
  51319. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51320. * @param pluginExtension the extension used to determine the plugin
  51321. */
  51322. 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;
  51323. /**
  51324. * Import animations from a file into a scene
  51325. * @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)
  51326. * @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)
  51327. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51328. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51329. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51330. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51331. * @param onSuccess a callback with the scene when import succeeds
  51332. * @param onProgress a callback with a progress event for each file being loaded
  51333. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51334. * @param pluginExtension the extension used to determine the plugin
  51335. * @returns the updated scene with imported animations
  51336. */
  51337. 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>;
  51338. }
  51339. }
  51340. declare module BABYLON {
  51341. /**
  51342. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51343. */
  51344. export type MotionControllerHandedness = "none" | "left" | "right";
  51345. /**
  51346. * The type of components available in motion controllers.
  51347. * This is not the name of the component.
  51348. */
  51349. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51350. /**
  51351. * The state of a controller component
  51352. */
  51353. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51354. /**
  51355. * The schema of motion controller layout.
  51356. * No object will be initialized using this interface
  51357. * This is used just to define the profile.
  51358. */
  51359. export interface IMotionControllerLayout {
  51360. /**
  51361. * Path to load the assets. Usually relative to the base path
  51362. */
  51363. assetPath: string;
  51364. /**
  51365. * Available components (unsorted)
  51366. */
  51367. components: {
  51368. /**
  51369. * A map of component Ids
  51370. */
  51371. [componentId: string]: {
  51372. /**
  51373. * The type of input the component outputs
  51374. */
  51375. type: MotionControllerComponentType;
  51376. /**
  51377. * The indices of this component in the gamepad object
  51378. */
  51379. gamepadIndices: {
  51380. /**
  51381. * Index of button
  51382. */
  51383. button?: number;
  51384. /**
  51385. * If available, index of x-axis
  51386. */
  51387. xAxis?: number;
  51388. /**
  51389. * If available, index of y-axis
  51390. */
  51391. yAxis?: number;
  51392. };
  51393. /**
  51394. * The mesh's root node name
  51395. */
  51396. rootNodeName: string;
  51397. /**
  51398. * Animation definitions for this model
  51399. */
  51400. visualResponses: {
  51401. [stateKey: string]: {
  51402. /**
  51403. * What property will be animated
  51404. */
  51405. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51406. /**
  51407. * What states influence this visual response
  51408. */
  51409. states: MotionControllerComponentStateType[];
  51410. /**
  51411. * Type of animation - movement or visibility
  51412. */
  51413. valueNodeProperty: "transform" | "visibility";
  51414. /**
  51415. * Base node name to move. Its position will be calculated according to the min and max nodes
  51416. */
  51417. valueNodeName?: string;
  51418. /**
  51419. * Minimum movement node
  51420. */
  51421. minNodeName?: string;
  51422. /**
  51423. * Max movement node
  51424. */
  51425. maxNodeName?: string;
  51426. };
  51427. };
  51428. /**
  51429. * If touch enabled, what is the name of node to display user feedback
  51430. */
  51431. touchPointNodeName?: string;
  51432. };
  51433. };
  51434. /**
  51435. * Is it xr standard mapping or not
  51436. */
  51437. gamepadMapping: "" | "xr-standard";
  51438. /**
  51439. * Base root node of this entire model
  51440. */
  51441. rootNodeName: string;
  51442. /**
  51443. * Defines the main button component id
  51444. */
  51445. selectComponentId: string;
  51446. }
  51447. /**
  51448. * A definition for the layout map in the input profile
  51449. */
  51450. export interface IMotionControllerLayoutMap {
  51451. /**
  51452. * Layouts with handedness type as a key
  51453. */
  51454. [handedness: string]: IMotionControllerLayout;
  51455. }
  51456. /**
  51457. * The XR Input profile schema
  51458. * Profiles can be found here:
  51459. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51460. */
  51461. export interface IMotionControllerProfile {
  51462. /**
  51463. * fallback profiles for this profileId
  51464. */
  51465. fallbackProfileIds: string[];
  51466. /**
  51467. * The layout map, with handedness as key
  51468. */
  51469. layouts: IMotionControllerLayoutMap;
  51470. /**
  51471. * The id of this profile
  51472. * correlates to the profile(s) in the xrInput.profiles array
  51473. */
  51474. profileId: string;
  51475. }
  51476. /**
  51477. * A helper-interface for the 3 meshes needed for controller button animation
  51478. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51479. */
  51480. export interface IMotionControllerButtonMeshMap {
  51481. /**
  51482. * the mesh that defines the pressed value mesh position.
  51483. * This is used to find the max-position of this button
  51484. */
  51485. pressedMesh: AbstractMesh;
  51486. /**
  51487. * the mesh that defines the unpressed value mesh position.
  51488. * This is used to find the min (or initial) position of this button
  51489. */
  51490. unpressedMesh: AbstractMesh;
  51491. /**
  51492. * The mesh that will be changed when value changes
  51493. */
  51494. valueMesh: AbstractMesh;
  51495. }
  51496. /**
  51497. * A helper-interface for the 3 meshes needed for controller axis animation.
  51498. * This will be expanded when touchpad animations are fully supported
  51499. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51500. */
  51501. export interface IMotionControllerMeshMap {
  51502. /**
  51503. * the mesh that defines the maximum value mesh position.
  51504. */
  51505. maxMesh?: AbstractMesh;
  51506. /**
  51507. * the mesh that defines the minimum value mesh position.
  51508. */
  51509. minMesh?: AbstractMesh;
  51510. /**
  51511. * The mesh that will be changed when axis value changes
  51512. */
  51513. valueMesh?: AbstractMesh;
  51514. }
  51515. /**
  51516. * The elements needed for change-detection of the gamepad objects in motion controllers
  51517. */
  51518. export interface IMinimalMotionControllerObject {
  51519. /**
  51520. * Available axes of this controller
  51521. */
  51522. axes: number[];
  51523. /**
  51524. * An array of available buttons
  51525. */
  51526. buttons: Array<{
  51527. /**
  51528. * Value of the button/trigger
  51529. */
  51530. value: number;
  51531. /**
  51532. * If the button/trigger is currently touched
  51533. */
  51534. touched: boolean;
  51535. /**
  51536. * If the button/trigger is currently pressed
  51537. */
  51538. pressed: boolean;
  51539. }>;
  51540. /**
  51541. * EXPERIMENTAL haptic support.
  51542. */
  51543. hapticActuators?: Array<{
  51544. pulse: (value: number, duration: number) => Promise<boolean>;
  51545. }>;
  51546. }
  51547. /**
  51548. * An Abstract Motion controller
  51549. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51550. * Each component has an observable to check for changes in value and state
  51551. */
  51552. export abstract class WebXRAbstractMotionController implements IDisposable {
  51553. protected scene: Scene;
  51554. protected layout: IMotionControllerLayout;
  51555. /**
  51556. * The gamepad object correlating to this controller
  51557. */
  51558. gamepadObject: IMinimalMotionControllerObject;
  51559. /**
  51560. * handedness (left/right/none) of this controller
  51561. */
  51562. handedness: MotionControllerHandedness;
  51563. private _initComponent;
  51564. private _modelReady;
  51565. /**
  51566. * A map of components (WebXRControllerComponent) in this motion controller
  51567. * Components have a ComponentType and can also have both button and axis definitions
  51568. */
  51569. readonly components: {
  51570. [id: string]: WebXRControllerComponent;
  51571. };
  51572. /**
  51573. * Disable the model's animation. Can be set at any time.
  51574. */
  51575. disableAnimation: boolean;
  51576. /**
  51577. * Observers registered here will be triggered when the model of this controller is done loading
  51578. */
  51579. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51580. /**
  51581. * The profile id of this motion controller
  51582. */
  51583. abstract profileId: string;
  51584. /**
  51585. * The root mesh of the model. It is null if the model was not yet initialized
  51586. */
  51587. rootMesh: Nullable<AbstractMesh>;
  51588. /**
  51589. * constructs a new abstract motion controller
  51590. * @param scene the scene to which the model of the controller will be added
  51591. * @param layout The profile layout to load
  51592. * @param gamepadObject The gamepad object correlating to this controller
  51593. * @param handedness handedness (left/right/none) of this controller
  51594. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51595. */
  51596. constructor(scene: Scene, layout: IMotionControllerLayout,
  51597. /**
  51598. * The gamepad object correlating to this controller
  51599. */
  51600. gamepadObject: IMinimalMotionControllerObject,
  51601. /**
  51602. * handedness (left/right/none) of this controller
  51603. */
  51604. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51605. /**
  51606. * Dispose this controller, the model mesh and all its components
  51607. */
  51608. dispose(): void;
  51609. /**
  51610. * Returns all components of specific type
  51611. * @param type the type to search for
  51612. * @return an array of components with this type
  51613. */
  51614. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51615. /**
  51616. * get a component based an its component id as defined in layout.components
  51617. * @param id the id of the component
  51618. * @returns the component correlates to the id or undefined if not found
  51619. */
  51620. getComponent(id: string): WebXRControllerComponent;
  51621. /**
  51622. * Get the list of components available in this motion controller
  51623. * @returns an array of strings correlating to available components
  51624. */
  51625. getComponentIds(): string[];
  51626. /**
  51627. * Get the first component of specific type
  51628. * @param type type of component to find
  51629. * @return a controller component or null if not found
  51630. */
  51631. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51632. /**
  51633. * Get the main (Select) component of this controller as defined in the layout
  51634. * @returns the main component of this controller
  51635. */
  51636. getMainComponent(): WebXRControllerComponent;
  51637. /**
  51638. * Loads the model correlating to this controller
  51639. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51640. * @returns A promise fulfilled with the result of the model loading
  51641. */
  51642. loadModel(): Promise<boolean>;
  51643. /**
  51644. * Update this model using the current XRFrame
  51645. * @param xrFrame the current xr frame to use and update the model
  51646. */
  51647. updateFromXRFrame(xrFrame: XRFrame): void;
  51648. /**
  51649. * Backwards compatibility due to a deeply-integrated typo
  51650. */
  51651. get handness(): XREye;
  51652. /**
  51653. * Pulse (vibrate) this controller
  51654. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51655. * Consecutive calls to this function will cancel the last pulse call
  51656. *
  51657. * @param value the strength of the pulse in 0.0...1.0 range
  51658. * @param duration Duration of the pulse in milliseconds
  51659. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51660. * @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
  51661. */
  51662. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51663. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51664. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51665. /**
  51666. * Moves the axis on the controller mesh based on its current state
  51667. * @param axis the index of the axis
  51668. * @param axisValue the value of the axis which determines the meshes new position
  51669. * @hidden
  51670. */
  51671. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  51672. /**
  51673. * Update the model itself with the current frame data
  51674. * @param xrFrame the frame to use for updating the model mesh
  51675. */
  51676. protected updateModel(xrFrame: XRFrame): void;
  51677. /**
  51678. * Get the filename and path for this controller's model
  51679. * @returns a map of filename and path
  51680. */
  51681. protected abstract _getFilenameAndPath(): {
  51682. filename: string;
  51683. path: string;
  51684. };
  51685. /**
  51686. * This function is called before the mesh is loaded. It checks for loading constraints.
  51687. * For example, this function can check if the GLB loader is available
  51688. * If this function returns false, the generic controller will be loaded instead
  51689. * @returns Is the client ready to load the mesh
  51690. */
  51691. protected abstract _getModelLoadingConstraints(): boolean;
  51692. /**
  51693. * This function will be called after the model was successfully loaded and can be used
  51694. * for mesh transformations before it is available for the user
  51695. * @param meshes the loaded meshes
  51696. */
  51697. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  51698. /**
  51699. * Set the root mesh for this controller. Important for the WebXR controller class
  51700. * @param meshes the loaded meshes
  51701. */
  51702. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  51703. /**
  51704. * A function executed each frame that updates the mesh (if needed)
  51705. * @param xrFrame the current xrFrame
  51706. */
  51707. protected abstract _updateModel(xrFrame: XRFrame): void;
  51708. private _getGenericFilenameAndPath;
  51709. private _getGenericParentMesh;
  51710. }
  51711. }
  51712. declare module BABYLON {
  51713. /**
  51714. * A generic trigger-only motion controller for WebXR
  51715. */
  51716. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  51717. /**
  51718. * Static version of the profile id of this controller
  51719. */
  51720. static ProfileId: string;
  51721. profileId: string;
  51722. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  51723. protected _getFilenameAndPath(): {
  51724. filename: string;
  51725. path: string;
  51726. };
  51727. protected _getModelLoadingConstraints(): boolean;
  51728. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  51729. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51730. protected _updateModel(): void;
  51731. }
  51732. }
  51733. declare module BABYLON {
  51734. /**
  51735. * Class containing static functions to help procedurally build meshes
  51736. */
  51737. export class SphereBuilder {
  51738. /**
  51739. * Creates a sphere mesh
  51740. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51741. * * 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`)
  51742. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51743. * * 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
  51744. * * 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)
  51745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51746. * * 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
  51747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51748. * @param name defines the name of the mesh
  51749. * @param options defines the options used to create the mesh
  51750. * @param scene defines the hosting scene
  51751. * @returns the sphere mesh
  51752. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51753. */
  51754. static CreateSphere(name: string, options: {
  51755. segments?: number;
  51756. diameter?: number;
  51757. diameterX?: number;
  51758. diameterY?: number;
  51759. diameterZ?: number;
  51760. arc?: number;
  51761. slice?: number;
  51762. sideOrientation?: number;
  51763. frontUVs?: Vector4;
  51764. backUVs?: Vector4;
  51765. updatable?: boolean;
  51766. }, scene?: Nullable<Scene>): Mesh;
  51767. }
  51768. }
  51769. declare module BABYLON {
  51770. /**
  51771. * A profiled motion controller has its profile loaded from an online repository.
  51772. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  51773. */
  51774. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  51775. private _repositoryUrl;
  51776. private _buttonMeshMapping;
  51777. private _touchDots;
  51778. /**
  51779. * The profile ID of this controller. Will be populated when the controller initializes.
  51780. */
  51781. profileId: string;
  51782. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  51783. dispose(): void;
  51784. protected _getFilenameAndPath(): {
  51785. filename: string;
  51786. path: string;
  51787. };
  51788. protected _getModelLoadingConstraints(): boolean;
  51789. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  51790. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51791. protected _updateModel(_xrFrame: XRFrame): void;
  51792. }
  51793. }
  51794. declare module BABYLON {
  51795. /**
  51796. * A construction function type to create a new controller based on an xrInput object
  51797. */
  51798. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  51799. /**
  51800. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  51801. *
  51802. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  51803. * it should be replaced with auto-loaded controllers.
  51804. *
  51805. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  51806. */
  51807. export class WebXRMotionControllerManager {
  51808. private static _AvailableControllers;
  51809. private static _Fallbacks;
  51810. private static _ProfileLoadingPromises;
  51811. private static _ProfilesList;
  51812. /**
  51813. * The base URL of the online controller repository. Can be changed at any time.
  51814. */
  51815. static BaseRepositoryUrl: string;
  51816. /**
  51817. * Which repository gets priority - local or online
  51818. */
  51819. static PrioritizeOnlineRepository: boolean;
  51820. /**
  51821. * Use the online repository, or use only locally-defined controllers
  51822. */
  51823. static UseOnlineRepository: boolean;
  51824. /**
  51825. * Clear the cache used for profile loading and reload when requested again
  51826. */
  51827. static ClearProfilesCache(): void;
  51828. /**
  51829. * Register the default fallbacks.
  51830. * This function is called automatically when this file is imported.
  51831. */
  51832. static DefaultFallbacks(): void;
  51833. /**
  51834. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  51835. * @param profileId the profile to which a fallback needs to be found
  51836. * @return an array with corresponding fallback profiles
  51837. */
  51838. static FindFallbackWithProfileId(profileId: string): string[];
  51839. /**
  51840. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  51841. * The order of search:
  51842. *
  51843. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  51844. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  51845. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  51846. * 4) return the generic trigger controller if none were found
  51847. *
  51848. * @param xrInput the xrInput to which a new controller is initialized
  51849. * @param scene the scene to which the model will be added
  51850. * @param forceProfile force a certain profile for this controller
  51851. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  51852. */
  51853. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  51854. /**
  51855. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  51856. *
  51857. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  51858. *
  51859. * @param type the profile type to register
  51860. * @param constructFunction the function to be called when loading this profile
  51861. */
  51862. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  51863. /**
  51864. * Register a fallback to a specific profile.
  51865. * @param profileId the profileId that will receive the fallbacks
  51866. * @param fallbacks A list of fallback profiles
  51867. */
  51868. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  51869. /**
  51870. * Will update the list of profiles available in the repository
  51871. * @return a promise that resolves to a map of profiles available online
  51872. */
  51873. static UpdateProfilesList(): Promise<{
  51874. [profile: string]: string;
  51875. }>;
  51876. private static _LoadProfileFromRepository;
  51877. private static _LoadProfilesFromAvailableControllers;
  51878. }
  51879. }
  51880. declare module BABYLON {
  51881. /**
  51882. * Configuration options for the WebXR controller creation
  51883. */
  51884. export interface IWebXRControllerOptions {
  51885. /**
  51886. * Should the controller mesh be animated when a user interacts with it
  51887. * The pressed buttons / thumbstick and touchpad animations will be disabled
  51888. */
  51889. disableMotionControllerAnimation?: boolean;
  51890. /**
  51891. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  51892. */
  51893. doNotLoadControllerMesh?: boolean;
  51894. /**
  51895. * Force a specific controller type for this controller.
  51896. * This can be used when creating your own profile or when testing different controllers
  51897. */
  51898. forceControllerProfile?: string;
  51899. /**
  51900. * Defines a rendering group ID for meshes that will be loaded.
  51901. * This is for the default controllers only.
  51902. */
  51903. renderingGroupId?: number;
  51904. }
  51905. /**
  51906. * Represents an XR controller
  51907. */
  51908. export class WebXRInputSource {
  51909. private _scene;
  51910. /** The underlying input source for the controller */
  51911. inputSource: XRInputSource;
  51912. private _options;
  51913. private _tmpVector;
  51914. private _uniqueId;
  51915. private _disposed;
  51916. /**
  51917. * 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
  51918. */
  51919. grip?: AbstractMesh;
  51920. /**
  51921. * If available, this is the gamepad object related to this controller.
  51922. * Using this object it is possible to get click events and trackpad changes of the
  51923. * webxr controller that is currently being used.
  51924. */
  51925. motionController?: WebXRAbstractMotionController;
  51926. /**
  51927. * Event that fires when the controller is removed/disposed.
  51928. * The object provided as event data is this controller, after associated assets were disposed.
  51929. * uniqueId is still available.
  51930. */
  51931. onDisposeObservable: Observable<WebXRInputSource>;
  51932. /**
  51933. * Will be triggered when the mesh associated with the motion controller is done loading.
  51934. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  51935. * A shortened version of controller -> motion controller -> on mesh loaded.
  51936. */
  51937. onMeshLoadedObservable: Observable<AbstractMesh>;
  51938. /**
  51939. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  51940. */
  51941. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  51942. /**
  51943. * Pointer which can be used to select objects or attach a visible laser to
  51944. */
  51945. pointer: AbstractMesh;
  51946. /**
  51947. * Creates the input source object
  51948. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  51949. * @param _scene the scene which the controller should be associated to
  51950. * @param inputSource the underlying input source for the controller
  51951. * @param _options options for this controller creation
  51952. */
  51953. constructor(_scene: Scene,
  51954. /** The underlying input source for the controller */
  51955. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  51956. /**
  51957. * Get this controllers unique id
  51958. */
  51959. get uniqueId(): string;
  51960. /**
  51961. * Disposes of the object
  51962. */
  51963. dispose(): void;
  51964. /**
  51965. * Gets a world space ray coming from the pointer or grip
  51966. * @param result the resulting ray
  51967. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  51968. */
  51969. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  51970. /**
  51971. * Updates the controller pose based on the given XRFrame
  51972. * @param xrFrame xr frame to update the pose with
  51973. * @param referenceSpace reference space to use
  51974. */
  51975. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  51976. }
  51977. }
  51978. declare module BABYLON {
  51979. /**
  51980. * The schema for initialization options of the XR Input class
  51981. */
  51982. export interface IWebXRInputOptions {
  51983. /**
  51984. * If set to true no model will be automatically loaded
  51985. */
  51986. doNotLoadControllerMeshes?: boolean;
  51987. /**
  51988. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  51989. * If not found, the xr input profile data will be used.
  51990. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  51991. */
  51992. forceInputProfile?: string;
  51993. /**
  51994. * Do not send a request to the controller repository to load the profile.
  51995. *
  51996. * Instead, use the controllers available in babylon itself.
  51997. */
  51998. disableOnlineControllerRepository?: boolean;
  51999. /**
  52000. * A custom URL for the controllers repository
  52001. */
  52002. customControllersRepositoryURL?: string;
  52003. /**
  52004. * Should the controller model's components not move according to the user input
  52005. */
  52006. disableControllerAnimation?: boolean;
  52007. /**
  52008. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  52009. */
  52010. controllerOptions?: IWebXRControllerOptions;
  52011. }
  52012. /**
  52013. * XR input used to track XR inputs such as controllers/rays
  52014. */
  52015. export class WebXRInput implements IDisposable {
  52016. /**
  52017. * the xr session manager for this session
  52018. */
  52019. xrSessionManager: WebXRSessionManager;
  52020. /**
  52021. * the WebXR camera for this session. Mainly used for teleportation
  52022. */
  52023. xrCamera: WebXRCamera;
  52024. private readonly options;
  52025. /**
  52026. * XR controllers being tracked
  52027. */
  52028. controllers: Array<WebXRInputSource>;
  52029. private _frameObserver;
  52030. private _sessionEndedObserver;
  52031. private _sessionInitObserver;
  52032. /**
  52033. * Event when a controller has been connected/added
  52034. */
  52035. onControllerAddedObservable: Observable<WebXRInputSource>;
  52036. /**
  52037. * Event when a controller has been removed/disconnected
  52038. */
  52039. onControllerRemovedObservable: Observable<WebXRInputSource>;
  52040. /**
  52041. * Initializes the WebXRInput
  52042. * @param xrSessionManager the xr session manager for this session
  52043. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  52044. * @param options = initialization options for this xr input
  52045. */
  52046. constructor(
  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, options?: IWebXRInputOptions);
  52055. private _onInputSourcesChange;
  52056. private _addAndRemoveControllers;
  52057. /**
  52058. * Disposes of the object
  52059. */
  52060. dispose(): void;
  52061. }
  52062. }
  52063. declare module BABYLON {
  52064. /**
  52065. * This is the base class for all WebXR features.
  52066. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  52067. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  52068. */
  52069. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  52070. protected _xrSessionManager: WebXRSessionManager;
  52071. private _attached;
  52072. private _removeOnDetach;
  52073. /**
  52074. * Is this feature disposed?
  52075. */
  52076. isDisposed: boolean;
  52077. /**
  52078. * Should auto-attach be disabled?
  52079. */
  52080. disableAutoAttach: boolean;
  52081. /**
  52082. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  52083. */
  52084. xrNativeFeatureName: string;
  52085. /**
  52086. * Construct a new (abstract) WebXR feature
  52087. * @param _xrSessionManager the xr session manager for this feature
  52088. */
  52089. constructor(_xrSessionManager: WebXRSessionManager);
  52090. /**
  52091. * Is this feature attached
  52092. */
  52093. get attached(): boolean;
  52094. /**
  52095. * attach this feature
  52096. *
  52097. * @param force should attachment be forced (even when already attached)
  52098. * @returns true if successful, false is failed or already attached
  52099. */
  52100. attach(force?: boolean): boolean;
  52101. /**
  52102. * detach this feature.
  52103. *
  52104. * @returns true if successful, false if failed or already detached
  52105. */
  52106. detach(): boolean;
  52107. /**
  52108. * Dispose this feature and all of the resources attached
  52109. */
  52110. dispose(): void;
  52111. /**
  52112. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52113. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52114. *
  52115. * @returns whether or not the feature is compatible in this environment
  52116. */
  52117. isCompatible(): boolean;
  52118. /**
  52119. * This is used to register callbacks that will automatically be removed when detach is called.
  52120. * @param observable the observable to which the observer will be attached
  52121. * @param callback the callback to register
  52122. */
  52123. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  52124. /**
  52125. * Code in this function will be executed on each xrFrame received from the browser.
  52126. * This function will not execute after the feature is detached.
  52127. * @param _xrFrame the current frame
  52128. */
  52129. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  52130. }
  52131. }
  52132. declare module BABYLON {
  52133. /**
  52134. * Renders a layer on top of an existing scene
  52135. */
  52136. export class UtilityLayerRenderer implements IDisposable {
  52137. /** the original scene that will be rendered on top of */
  52138. originalScene: Scene;
  52139. private _pointerCaptures;
  52140. private _lastPointerEvents;
  52141. private static _DefaultUtilityLayer;
  52142. private static _DefaultKeepDepthUtilityLayer;
  52143. private _sharedGizmoLight;
  52144. private _renderCamera;
  52145. /**
  52146. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  52147. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  52148. * @returns the camera that is used when rendering the utility layer
  52149. */
  52150. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  52151. /**
  52152. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  52153. * @param cam the camera that should be used when rendering the utility layer
  52154. */
  52155. setRenderCamera(cam: Nullable<Camera>): void;
  52156. /**
  52157. * @hidden
  52158. * Light which used by gizmos to get light shading
  52159. */
  52160. _getSharedGizmoLight(): HemisphericLight;
  52161. /**
  52162. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  52163. */
  52164. pickUtilitySceneFirst: boolean;
  52165. /**
  52166. * 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)
  52167. */
  52168. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  52169. /**
  52170. * 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)
  52171. */
  52172. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  52173. /**
  52174. * The scene that is rendered on top of the original scene
  52175. */
  52176. utilityLayerScene: Scene;
  52177. /**
  52178. * If the utility layer should automatically be rendered on top of existing scene
  52179. */
  52180. shouldRender: boolean;
  52181. /**
  52182. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  52183. */
  52184. onlyCheckPointerDownEvents: boolean;
  52185. /**
  52186. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  52187. */
  52188. processAllEvents: boolean;
  52189. /**
  52190. * Observable raised when the pointer move from the utility layer scene to the main scene
  52191. */
  52192. onPointerOutObservable: Observable<number>;
  52193. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  52194. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  52195. private _afterRenderObserver;
  52196. private _sceneDisposeObserver;
  52197. private _originalPointerObserver;
  52198. /**
  52199. * Instantiates a UtilityLayerRenderer
  52200. * @param originalScene the original scene that will be rendered on top of
  52201. * @param handleEvents boolean indicating if the utility layer should handle events
  52202. */
  52203. constructor(
  52204. /** the original scene that will be rendered on top of */
  52205. originalScene: Scene, handleEvents?: boolean);
  52206. private _notifyObservers;
  52207. /**
  52208. * Renders the utility layers scene on top of the original scene
  52209. */
  52210. render(): void;
  52211. /**
  52212. * Disposes of the renderer
  52213. */
  52214. dispose(): void;
  52215. private _updateCamera;
  52216. }
  52217. }
  52218. declare module BABYLON {
  52219. /**
  52220. * Options interface for the pointer selection module
  52221. */
  52222. export interface IWebXRControllerPointerSelectionOptions {
  52223. /**
  52224. * if provided, this scene will be used to render meshes.
  52225. */
  52226. customUtilityLayerScene?: Scene;
  52227. /**
  52228. * 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)
  52229. * If not disabled, the last picked point will be used to execute a pointer up event
  52230. * If disabled, pointer up event will be triggered right after the pointer down event.
  52231. * Used in screen and gaze target ray mode only
  52232. */
  52233. disablePointerUpOnTouchOut: boolean;
  52234. /**
  52235. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  52236. */
  52237. forceGazeMode: boolean;
  52238. /**
  52239. * 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
  52240. * to start a new countdown to the pointer down event.
  52241. * Defaults to 1.
  52242. */
  52243. gazeModePointerMovedFactor?: number;
  52244. /**
  52245. * Different button type to use instead of the main component
  52246. */
  52247. overrideButtonId?: string;
  52248. /**
  52249. * use this rendering group id for the meshes (optional)
  52250. */
  52251. renderingGroupId?: number;
  52252. /**
  52253. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  52254. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  52255. * 3000 means 3 seconds between pointing at something and selecting it
  52256. */
  52257. timeToSelect?: number;
  52258. /**
  52259. * Should meshes created here be added to a utility layer or the main scene
  52260. */
  52261. useUtilityLayer?: boolean;
  52262. /**
  52263. * Optional WebXR camera to be used for gaze selection
  52264. */
  52265. gazeCamera?: WebXRCamera;
  52266. /**
  52267. * the xr input to use with this pointer selection
  52268. */
  52269. xrInput: WebXRInput;
  52270. /**
  52271. * Should the scene pointerX and pointerY update be disabled
  52272. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52273. * Disable in VR, if not needed.
  52274. * The first rig camera (left eye) will be used to calculate the projection
  52275. */
  52276. disableScenePointerVectorUpdate: boolean;
  52277. /**
  52278. * Enable pointer selection on all controllers instead of switching between them
  52279. */
  52280. enablePointerSelectionOnAllControllers?: boolean;
  52281. /**
  52282. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52283. * If switch is enabled, it will still allow the user to switch between the different controllers
  52284. */
  52285. preferredHandedness?: XRHandedness;
  52286. /**
  52287. * Disable switching the pointer selection from one controller to the other.
  52288. * 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
  52289. */
  52290. disableSwitchOnClick?: boolean;
  52291. /**
  52292. * The maximum distance of the pointer selection feature. Defaults to 100.
  52293. */
  52294. maxPointerDistance?: number;
  52295. }
  52296. /**
  52297. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52298. */
  52299. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52300. private readonly _options;
  52301. private static _idCounter;
  52302. private _attachController;
  52303. private _controllers;
  52304. private _scene;
  52305. private _tmpVectorForPickCompare;
  52306. private _attachedController;
  52307. /**
  52308. * The module's name
  52309. */
  52310. static readonly Name: string;
  52311. /**
  52312. * The (Babylon) version of this module.
  52313. * This is an integer representing the implementation version.
  52314. * This number does not correspond to the WebXR specs version
  52315. */
  52316. static readonly Version: number;
  52317. /**
  52318. * Disable lighting on the laser pointer (so it will always be visible)
  52319. */
  52320. disablePointerLighting: boolean;
  52321. /**
  52322. * Disable lighting on the selection mesh (so it will always be visible)
  52323. */
  52324. disableSelectionMeshLighting: boolean;
  52325. /**
  52326. * Should the laser pointer be displayed
  52327. */
  52328. displayLaserPointer: boolean;
  52329. /**
  52330. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52331. */
  52332. displaySelectionMesh: boolean;
  52333. /**
  52334. * This color will be set to the laser pointer when selection is triggered
  52335. */
  52336. laserPointerPickedColor: Color3;
  52337. /**
  52338. * Default color of the laser pointer
  52339. */
  52340. laserPointerDefaultColor: Color3;
  52341. /**
  52342. * default color of the selection ring
  52343. */
  52344. selectionMeshDefaultColor: Color3;
  52345. /**
  52346. * This color will be applied to the selection ring when selection is triggered
  52347. */
  52348. selectionMeshPickedColor: Color3;
  52349. /**
  52350. * Optional filter to be used for ray selection. This predicate shares behavior with
  52351. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52352. */
  52353. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52354. /**
  52355. * constructs a new background remover module
  52356. * @param _xrSessionManager the session manager for this module
  52357. * @param _options read-only options to be used in this module
  52358. */
  52359. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52360. /**
  52361. * attach this feature
  52362. * Will usually be called by the features manager
  52363. *
  52364. * @returns true if successful.
  52365. */
  52366. attach(): boolean;
  52367. /**
  52368. * detach this feature.
  52369. * Will usually be called by the features manager
  52370. *
  52371. * @returns true if successful.
  52372. */
  52373. detach(): boolean;
  52374. /**
  52375. * Will get the mesh under a specific pointer.
  52376. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52377. * @param controllerId the controllerId to check
  52378. * @returns The mesh under pointer or null if no mesh is under the pointer
  52379. */
  52380. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52381. /**
  52382. * Get the xr controller that correlates to the pointer id in the pointer event
  52383. *
  52384. * @param id the pointer id to search for
  52385. * @returns the controller that correlates to this id or null if not found
  52386. */
  52387. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52388. private _identityMatrix;
  52389. private _screenCoordinatesRef;
  52390. private _viewportRef;
  52391. protected _onXRFrame(_xrFrame: XRFrame): void;
  52392. private _attachGazeMode;
  52393. private _attachScreenRayMode;
  52394. private _attachTrackedPointerRayMode;
  52395. private _convertNormalToDirectionOfRay;
  52396. private _detachController;
  52397. private _generateNewMeshPair;
  52398. private _pickingMoved;
  52399. private _updatePointerDistance;
  52400. /** @hidden */
  52401. get lasterPointerDefaultColor(): Color3;
  52402. }
  52403. }
  52404. declare module BABYLON {
  52405. /**
  52406. * Button which can be used to enter a different mode of XR
  52407. */
  52408. export class WebXREnterExitUIButton {
  52409. /** button element */
  52410. element: HTMLElement;
  52411. /** XR initialization options for the button */
  52412. sessionMode: XRSessionMode;
  52413. /** Reference space type */
  52414. referenceSpaceType: XRReferenceSpaceType;
  52415. /**
  52416. * Creates a WebXREnterExitUIButton
  52417. * @param element button element
  52418. * @param sessionMode XR initialization session mode
  52419. * @param referenceSpaceType the type of reference space to be used
  52420. */
  52421. constructor(
  52422. /** button element */
  52423. element: HTMLElement,
  52424. /** XR initialization options for the button */
  52425. sessionMode: XRSessionMode,
  52426. /** Reference space type */
  52427. referenceSpaceType: XRReferenceSpaceType);
  52428. /**
  52429. * Extendable function which can be used to update the button's visuals when the state changes
  52430. * @param activeButton the current active button in the UI
  52431. */
  52432. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52433. }
  52434. /**
  52435. * Options to create the webXR UI
  52436. */
  52437. export class WebXREnterExitUIOptions {
  52438. /**
  52439. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52440. */
  52441. customButtons?: Array<WebXREnterExitUIButton>;
  52442. /**
  52443. * A reference space type to use when creating the default button.
  52444. * Default is local-floor
  52445. */
  52446. referenceSpaceType?: XRReferenceSpaceType;
  52447. /**
  52448. * Context to enter xr with
  52449. */
  52450. renderTarget?: Nullable<WebXRRenderTarget>;
  52451. /**
  52452. * A session mode to use when creating the default button.
  52453. * Default is immersive-vr
  52454. */
  52455. sessionMode?: XRSessionMode;
  52456. /**
  52457. * A list of optional features to init the session with
  52458. */
  52459. optionalFeatures?: string[];
  52460. /**
  52461. * A list of optional features to init the session with
  52462. */
  52463. requiredFeatures?: string[];
  52464. }
  52465. /**
  52466. * UI to allow the user to enter/exit XR mode
  52467. */
  52468. export class WebXREnterExitUI implements IDisposable {
  52469. private scene;
  52470. /** version of the options passed to this UI */
  52471. options: WebXREnterExitUIOptions;
  52472. private _activeButton;
  52473. private _buttons;
  52474. /**
  52475. * The HTML Div Element to which buttons are added.
  52476. */
  52477. readonly overlay: HTMLDivElement;
  52478. /**
  52479. * Fired every time the active button is changed.
  52480. *
  52481. * When xr is entered via a button that launches xr that button will be the callback parameter
  52482. *
  52483. * When exiting xr the callback parameter will be null)
  52484. */
  52485. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52486. /**
  52487. *
  52488. * @param scene babylon scene object to use
  52489. * @param options (read-only) version of the options passed to this UI
  52490. */
  52491. private constructor();
  52492. /**
  52493. * Creates UI to allow the user to enter/exit XR mode
  52494. * @param scene the scene to add the ui to
  52495. * @param helper the xr experience helper to enter/exit xr with
  52496. * @param options options to configure the UI
  52497. * @returns the created ui
  52498. */
  52499. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52500. /**
  52501. * Disposes of the XR UI component
  52502. */
  52503. dispose(): void;
  52504. private _updateButtons;
  52505. }
  52506. }
  52507. declare module BABYLON {
  52508. /**
  52509. * Class containing static functions to help procedurally build meshes
  52510. */
  52511. export class LinesBuilder {
  52512. /**
  52513. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52514. * * 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
  52515. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52516. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52517. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52518. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52519. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52520. * * 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
  52521. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52523. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52524. * @param name defines the name of the new line system
  52525. * @param options defines the options used to create the line system
  52526. * @param scene defines the hosting scene
  52527. * @returns a new line system mesh
  52528. */
  52529. static CreateLineSystem(name: string, options: {
  52530. lines: Vector3[][];
  52531. updatable?: boolean;
  52532. instance?: Nullable<LinesMesh>;
  52533. colors?: Nullable<Color4[][]>;
  52534. useVertexAlpha?: boolean;
  52535. }, scene: Nullable<Scene>): LinesMesh;
  52536. /**
  52537. * Creates a line mesh
  52538. * 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
  52539. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52540. * * The parameter `points` is an array successive Vector3
  52541. * * 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
  52542. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52543. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52544. * * When updating an instance, remember that only point positions can change, not the number of points
  52545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52546. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52547. * @param name defines the name of the new line system
  52548. * @param options defines the options used to create the line system
  52549. * @param scene defines the hosting scene
  52550. * @returns a new line mesh
  52551. */
  52552. static CreateLines(name: string, options: {
  52553. points: Vector3[];
  52554. updatable?: boolean;
  52555. instance?: Nullable<LinesMesh>;
  52556. colors?: Color4[];
  52557. useVertexAlpha?: boolean;
  52558. }, scene?: Nullable<Scene>): LinesMesh;
  52559. /**
  52560. * Creates a dashed line mesh
  52561. * * 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
  52562. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52563. * * The parameter `points` is an array successive Vector3
  52564. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52565. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52566. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52567. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  52568. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52569. * * When updating an instance, remember that only point positions can change, not the number of points
  52570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52571. * @param name defines the name of the mesh
  52572. * @param options defines the options used to create the mesh
  52573. * @param scene defines the hosting scene
  52574. * @returns the dashed line mesh
  52575. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52576. */
  52577. static CreateDashedLines(name: string, options: {
  52578. points: Vector3[];
  52579. dashSize?: number;
  52580. gapSize?: number;
  52581. dashNb?: number;
  52582. updatable?: boolean;
  52583. instance?: LinesMesh;
  52584. useVertexAlpha?: boolean;
  52585. }, scene?: Nullable<Scene>): LinesMesh;
  52586. }
  52587. }
  52588. declare module BABYLON {
  52589. /**
  52590. * Construction options for a timer
  52591. */
  52592. export interface ITimerOptions<T> {
  52593. /**
  52594. * Time-to-end
  52595. */
  52596. timeout: number;
  52597. /**
  52598. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52599. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52600. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52601. */
  52602. contextObservable: Observable<T>;
  52603. /**
  52604. * Optional parameters when adding an observer to the observable
  52605. */
  52606. observableParameters?: {
  52607. mask?: number;
  52608. insertFirst?: boolean;
  52609. scope?: any;
  52610. };
  52611. /**
  52612. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52613. */
  52614. breakCondition?: (data?: ITimerData<T>) => boolean;
  52615. /**
  52616. * Will be triggered when the time condition has met
  52617. */
  52618. onEnded?: (data: ITimerData<any>) => void;
  52619. /**
  52620. * Will be triggered when the break condition has met (prematurely ended)
  52621. */
  52622. onAborted?: (data: ITimerData<any>) => void;
  52623. /**
  52624. * Optional function to execute on each tick (or count)
  52625. */
  52626. onTick?: (data: ITimerData<any>) => void;
  52627. }
  52628. /**
  52629. * An interface defining the data sent by the timer
  52630. */
  52631. export interface ITimerData<T> {
  52632. /**
  52633. * When did it start
  52634. */
  52635. startTime: number;
  52636. /**
  52637. * Time now
  52638. */
  52639. currentTime: number;
  52640. /**
  52641. * Time passed since started
  52642. */
  52643. deltaTime: number;
  52644. /**
  52645. * How much is completed, in [0.0...1.0].
  52646. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52647. */
  52648. completeRate: number;
  52649. /**
  52650. * What the registered observable sent in the last count
  52651. */
  52652. payload: T;
  52653. }
  52654. /**
  52655. * The current state of the timer
  52656. */
  52657. export enum TimerState {
  52658. /**
  52659. * Timer initialized, not yet started
  52660. */
  52661. INIT = 0,
  52662. /**
  52663. * Timer started and counting
  52664. */
  52665. STARTED = 1,
  52666. /**
  52667. * Timer ended (whether aborted or time reached)
  52668. */
  52669. ENDED = 2
  52670. }
  52671. /**
  52672. * A simple version of the timer. Will take options and start the timer immediately after calling it
  52673. *
  52674. * @param options options with which to initialize this timer
  52675. */
  52676. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  52677. /**
  52678. * An advanced implementation of a timer class
  52679. */
  52680. export class AdvancedTimer<T = any> implements IDisposable {
  52681. /**
  52682. * Will notify each time the timer calculates the remaining time
  52683. */
  52684. onEachCountObservable: Observable<ITimerData<T>>;
  52685. /**
  52686. * Will trigger when the timer was aborted due to the break condition
  52687. */
  52688. onTimerAbortedObservable: Observable<ITimerData<T>>;
  52689. /**
  52690. * Will trigger when the timer ended successfully
  52691. */
  52692. onTimerEndedObservable: Observable<ITimerData<T>>;
  52693. /**
  52694. * Will trigger when the timer state has changed
  52695. */
  52696. onStateChangedObservable: Observable<TimerState>;
  52697. private _observer;
  52698. private _contextObservable;
  52699. private _observableParameters;
  52700. private _startTime;
  52701. private _timer;
  52702. private _state;
  52703. private _breakCondition;
  52704. private _timeToEnd;
  52705. private _breakOnNextTick;
  52706. /**
  52707. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  52708. * @param options construction options for this advanced timer
  52709. */
  52710. constructor(options: ITimerOptions<T>);
  52711. /**
  52712. * set a breaking condition for this timer. Default is to never break during count
  52713. * @param predicate the new break condition. Returns true to break, false otherwise
  52714. */
  52715. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  52716. /**
  52717. * Reset ALL associated observables in this advanced timer
  52718. */
  52719. clearObservables(): void;
  52720. /**
  52721. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  52722. *
  52723. * @param timeToEnd how much time to measure until timer ended
  52724. */
  52725. start(timeToEnd?: number): void;
  52726. /**
  52727. * Will force a stop on the next tick.
  52728. */
  52729. stop(): void;
  52730. /**
  52731. * Dispose this timer, clearing all resources
  52732. */
  52733. dispose(): void;
  52734. private _setState;
  52735. private _tick;
  52736. private _stop;
  52737. }
  52738. }
  52739. declare module BABYLON {
  52740. /**
  52741. * The options container for the teleportation module
  52742. */
  52743. export interface IWebXRTeleportationOptions {
  52744. /**
  52745. * if provided, this scene will be used to render meshes.
  52746. */
  52747. customUtilityLayerScene?: Scene;
  52748. /**
  52749. * Values to configure the default target mesh
  52750. */
  52751. defaultTargetMeshOptions?: {
  52752. /**
  52753. * Fill color of the teleportation area
  52754. */
  52755. teleportationFillColor?: string;
  52756. /**
  52757. * Border color for the teleportation area
  52758. */
  52759. teleportationBorderColor?: string;
  52760. /**
  52761. * Disable the mesh's animation sequence
  52762. */
  52763. disableAnimation?: boolean;
  52764. /**
  52765. * Disable lighting on the material or the ring and arrow
  52766. */
  52767. disableLighting?: boolean;
  52768. /**
  52769. * Override the default material of the torus and arrow
  52770. */
  52771. torusArrowMaterial?: Material;
  52772. };
  52773. /**
  52774. * A list of meshes to use as floor meshes.
  52775. * Meshes can be added and removed after initializing the feature using the
  52776. * addFloorMesh and removeFloorMesh functions
  52777. * If empty, rotation will still work
  52778. */
  52779. floorMeshes?: AbstractMesh[];
  52780. /**
  52781. * use this rendering group id for the meshes (optional)
  52782. */
  52783. renderingGroupId?: number;
  52784. /**
  52785. * Should teleportation move only to snap points
  52786. */
  52787. snapPointsOnly?: boolean;
  52788. /**
  52789. * An array of points to which the teleportation will snap to.
  52790. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  52791. */
  52792. snapPositions?: Vector3[];
  52793. /**
  52794. * How close should the teleportation ray be in order to snap to position.
  52795. * Default to 0.8 units (meters)
  52796. */
  52797. snapToPositionRadius?: number;
  52798. /**
  52799. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  52800. * If you want to support rotation, make sure your mesh has a direction indicator.
  52801. *
  52802. * When left untouched, the default mesh will be initialized.
  52803. */
  52804. teleportationTargetMesh?: AbstractMesh;
  52805. /**
  52806. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  52807. */
  52808. timeToTeleport?: number;
  52809. /**
  52810. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  52811. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  52812. */
  52813. useMainComponentOnly?: boolean;
  52814. /**
  52815. * Should meshes created here be added to a utility layer or the main scene
  52816. */
  52817. useUtilityLayer?: boolean;
  52818. /**
  52819. * Babylon XR Input class for controller
  52820. */
  52821. xrInput: WebXRInput;
  52822. /**
  52823. * Meshes that the teleportation ray cannot go through
  52824. */
  52825. pickBlockerMeshes?: AbstractMesh[];
  52826. }
  52827. /**
  52828. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  52829. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  52830. * the input of the attached controllers.
  52831. */
  52832. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  52833. private _options;
  52834. private _controllers;
  52835. private _currentTeleportationControllerId;
  52836. private _floorMeshes;
  52837. private _quadraticBezierCurve;
  52838. private _selectionFeature;
  52839. private _snapToPositions;
  52840. private _snappedToPoint;
  52841. private _teleportationRingMaterial?;
  52842. private _tmpRay;
  52843. private _tmpVector;
  52844. private _tmpQuaternion;
  52845. /**
  52846. * The module's name
  52847. */
  52848. static readonly Name: string;
  52849. /**
  52850. * The (Babylon) version of this module.
  52851. * This is an integer representing the implementation version.
  52852. * This number does not correspond to the webxr specs version
  52853. */
  52854. static readonly Version: number;
  52855. /**
  52856. * Is movement backwards enabled
  52857. */
  52858. backwardsMovementEnabled: boolean;
  52859. /**
  52860. * Distance to travel when moving backwards
  52861. */
  52862. backwardsTeleportationDistance: number;
  52863. /**
  52864. * The distance from the user to the inspection point in the direction of the controller
  52865. * A higher number will allow the user to move further
  52866. * defaults to 5 (meters, in xr units)
  52867. */
  52868. parabolicCheckRadius: number;
  52869. /**
  52870. * Should the module support parabolic ray on top of direct ray
  52871. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  52872. * Very helpful when moving between floors / different heights
  52873. */
  52874. parabolicRayEnabled: boolean;
  52875. /**
  52876. * How much rotation should be applied when rotating right and left
  52877. */
  52878. rotationAngle: number;
  52879. /**
  52880. * Is rotation enabled when moving forward?
  52881. * Disabling this feature will prevent the user from deciding the direction when teleporting
  52882. */
  52883. rotationEnabled: boolean;
  52884. /**
  52885. * constructs a new anchor system
  52886. * @param _xrSessionManager an instance of WebXRSessionManager
  52887. * @param _options configuration object for this feature
  52888. */
  52889. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  52890. /**
  52891. * Get the snapPointsOnly flag
  52892. */
  52893. get snapPointsOnly(): boolean;
  52894. /**
  52895. * Sets the snapPointsOnly flag
  52896. * @param snapToPoints should teleportation be exclusively to snap points
  52897. */
  52898. set snapPointsOnly(snapToPoints: boolean);
  52899. /**
  52900. * Add a new mesh to the floor meshes array
  52901. * @param mesh the mesh to use as floor mesh
  52902. */
  52903. addFloorMesh(mesh: AbstractMesh): void;
  52904. /**
  52905. * Add a new snap-to point to fix teleportation to this position
  52906. * @param newSnapPoint The new Snap-To point
  52907. */
  52908. addSnapPoint(newSnapPoint: Vector3): void;
  52909. attach(): boolean;
  52910. detach(): boolean;
  52911. dispose(): void;
  52912. /**
  52913. * Remove a mesh from the floor meshes array
  52914. * @param mesh the mesh to remove
  52915. */
  52916. removeFloorMesh(mesh: AbstractMesh): void;
  52917. /**
  52918. * Remove a mesh from the floor meshes array using its name
  52919. * @param name the mesh name to remove
  52920. */
  52921. removeFloorMeshByName(name: string): void;
  52922. /**
  52923. * 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
  52924. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  52925. * @returns was the point found and removed or not
  52926. */
  52927. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  52928. /**
  52929. * This function sets a selection feature that will be disabled when
  52930. * the forward ray is shown and will be reattached when hidden.
  52931. * This is used to remove the selection rays when moving.
  52932. * @param selectionFeature the feature to disable when forward movement is enabled
  52933. */
  52934. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  52935. protected _onXRFrame(_xrFrame: XRFrame): void;
  52936. private _attachController;
  52937. private _createDefaultTargetMesh;
  52938. private _detachController;
  52939. private _findClosestSnapPointWithRadius;
  52940. private _setTargetMeshPosition;
  52941. private _setTargetMeshVisibility;
  52942. private _showParabolicPath;
  52943. private _teleportForward;
  52944. }
  52945. }
  52946. declare module BABYLON {
  52947. /**
  52948. * Options for the default xr helper
  52949. */
  52950. export class WebXRDefaultExperienceOptions {
  52951. /**
  52952. * Enable or disable default UI to enter XR
  52953. */
  52954. disableDefaultUI?: boolean;
  52955. /**
  52956. * Should teleportation not initialize. defaults to false.
  52957. */
  52958. disableTeleportation?: boolean;
  52959. /**
  52960. * Floor meshes that will be used for teleport
  52961. */
  52962. floorMeshes?: Array<AbstractMesh>;
  52963. /**
  52964. * If set to true, the first frame will not be used to reset position
  52965. * The first frame is mainly used when copying transformation from the old camera
  52966. * Mainly used in AR
  52967. */
  52968. ignoreNativeCameraTransformation?: boolean;
  52969. /**
  52970. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  52971. */
  52972. inputOptions?: IWebXRInputOptions;
  52973. /**
  52974. * optional configuration for the output canvas
  52975. */
  52976. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  52977. /**
  52978. * optional UI options. This can be used among other to change session mode and reference space type
  52979. */
  52980. uiOptions?: WebXREnterExitUIOptions;
  52981. /**
  52982. * When loading teleportation and pointer select, use stable versions instead of latest.
  52983. */
  52984. useStablePlugins?: boolean;
  52985. /**
  52986. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  52987. */
  52988. renderingGroupId?: number;
  52989. /**
  52990. * A list of optional features to init the session with
  52991. * If set to true, all features we support will be added
  52992. */
  52993. optionalFeatures?: boolean | string[];
  52994. }
  52995. /**
  52996. * Default experience which provides a similar setup to the previous webVRExperience
  52997. */
  52998. export class WebXRDefaultExperience {
  52999. /**
  53000. * Base experience
  53001. */
  53002. baseExperience: WebXRExperienceHelper;
  53003. /**
  53004. * Enables ui for entering/exiting xr
  53005. */
  53006. enterExitUI: WebXREnterExitUI;
  53007. /**
  53008. * Input experience extension
  53009. */
  53010. input: WebXRInput;
  53011. /**
  53012. * Enables laser pointer and selection
  53013. */
  53014. pointerSelection: WebXRControllerPointerSelection;
  53015. /**
  53016. * Default target xr should render to
  53017. */
  53018. renderTarget: WebXRRenderTarget;
  53019. /**
  53020. * Enables teleportation
  53021. */
  53022. teleportation: WebXRMotionControllerTeleportation;
  53023. private constructor();
  53024. /**
  53025. * Creates the default xr experience
  53026. * @param scene scene
  53027. * @param options options for basic configuration
  53028. * @returns resulting WebXRDefaultExperience
  53029. */
  53030. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53031. /**
  53032. * DIsposes of the experience helper
  53033. */
  53034. dispose(): void;
  53035. }
  53036. }
  53037. declare module BABYLON {
  53038. /**
  53039. * Options to modify the vr teleportation behavior.
  53040. */
  53041. export interface VRTeleportationOptions {
  53042. /**
  53043. * The name of the mesh which should be used as the teleportation floor. (default: null)
  53044. */
  53045. floorMeshName?: string;
  53046. /**
  53047. * A list of meshes to be used as the teleportation floor. (default: empty)
  53048. */
  53049. floorMeshes?: Mesh[];
  53050. /**
  53051. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  53052. */
  53053. teleportationMode?: number;
  53054. /**
  53055. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  53056. */
  53057. teleportationTime?: number;
  53058. /**
  53059. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  53060. */
  53061. teleportationSpeed?: number;
  53062. /**
  53063. * The easing function used in the animation or null for Linear. (default CircleEase)
  53064. */
  53065. easingFunction?: EasingFunction;
  53066. }
  53067. /**
  53068. * Options to modify the vr experience helper's behavior.
  53069. */
  53070. export interface VRExperienceHelperOptions extends WebVROptions {
  53071. /**
  53072. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  53073. */
  53074. createDeviceOrientationCamera?: boolean;
  53075. /**
  53076. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  53077. */
  53078. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  53079. /**
  53080. * Uses the main button on the controller to toggle the laser casted. (default: true)
  53081. */
  53082. laserToggle?: boolean;
  53083. /**
  53084. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  53085. */
  53086. floorMeshes?: Mesh[];
  53087. /**
  53088. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  53089. */
  53090. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  53091. /**
  53092. * Defines if WebXR should be used instead of WebVR (if available)
  53093. */
  53094. useXR?: boolean;
  53095. }
  53096. /**
  53097. * Event containing information after VR has been entered
  53098. */
  53099. export class OnAfterEnteringVRObservableEvent {
  53100. /**
  53101. * If entering vr was successful
  53102. */
  53103. success: boolean;
  53104. }
  53105. /**
  53106. * Helps to quickly add VR support to an existing scene.
  53107. * See https://doc.babylonjs.com/how_to/webvr_helper
  53108. */
  53109. export class VRExperienceHelper {
  53110. /** Options to modify the vr experience helper's behavior. */
  53111. webVROptions: VRExperienceHelperOptions;
  53112. private _scene;
  53113. private _position;
  53114. private _btnVR;
  53115. private _btnVRDisplayed;
  53116. private _webVRsupported;
  53117. private _webVRready;
  53118. private _webVRrequesting;
  53119. private _webVRpresenting;
  53120. private _hasEnteredVR;
  53121. private _fullscreenVRpresenting;
  53122. private _inputElement;
  53123. private _webVRCamera;
  53124. private _vrDeviceOrientationCamera;
  53125. private _deviceOrientationCamera;
  53126. private _existingCamera;
  53127. private _onKeyDown;
  53128. private _onVrDisplayPresentChange;
  53129. private _onVRDisplayChanged;
  53130. private _onVRRequestPresentStart;
  53131. private _onVRRequestPresentComplete;
  53132. /**
  53133. * 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)
  53134. */
  53135. enableGazeEvenWhenNoPointerLock: boolean;
  53136. /**
  53137. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  53138. */
  53139. exitVROnDoubleTap: boolean;
  53140. /**
  53141. * Observable raised right before entering VR.
  53142. */
  53143. onEnteringVRObservable: Observable<VRExperienceHelper>;
  53144. /**
  53145. * Observable raised when entering VR has completed.
  53146. */
  53147. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  53148. /**
  53149. * Observable raised when exiting VR.
  53150. */
  53151. onExitingVRObservable: Observable<VRExperienceHelper>;
  53152. /**
  53153. * Observable raised when controller mesh is loaded.
  53154. */
  53155. onControllerMeshLoadedObservable: Observable<WebVRController>;
  53156. /** Return this.onEnteringVRObservable
  53157. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  53158. */
  53159. get onEnteringVR(): Observable<VRExperienceHelper>;
  53160. /** Return this.onExitingVRObservable
  53161. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  53162. */
  53163. get onExitingVR(): Observable<VRExperienceHelper>;
  53164. /** Return this.onControllerMeshLoadedObservable
  53165. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  53166. */
  53167. get onControllerMeshLoaded(): Observable<WebVRController>;
  53168. private _rayLength;
  53169. private _useCustomVRButton;
  53170. private _teleportationRequested;
  53171. private _teleportActive;
  53172. private _floorMeshName;
  53173. private _floorMeshesCollection;
  53174. private _teleportationMode;
  53175. private _teleportationTime;
  53176. private _teleportationSpeed;
  53177. private _teleportationEasing;
  53178. private _rotationAllowed;
  53179. private _teleportBackwardsVector;
  53180. private _teleportationTarget;
  53181. private _isDefaultTeleportationTarget;
  53182. private _postProcessMove;
  53183. private _teleportationFillColor;
  53184. private _teleportationBorderColor;
  53185. private _rotationAngle;
  53186. private _haloCenter;
  53187. private _cameraGazer;
  53188. private _padSensibilityUp;
  53189. private _padSensibilityDown;
  53190. private _leftController;
  53191. private _rightController;
  53192. private _gazeColor;
  53193. private _laserColor;
  53194. private _pickedLaserColor;
  53195. private _pickedGazeColor;
  53196. /**
  53197. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  53198. */
  53199. onNewMeshSelected: Observable<AbstractMesh>;
  53200. /**
  53201. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  53202. * This observable will provide the mesh and the controller used to select the mesh
  53203. */
  53204. onMeshSelectedWithController: Observable<{
  53205. mesh: AbstractMesh;
  53206. controller: WebVRController;
  53207. }>;
  53208. /**
  53209. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  53210. */
  53211. onNewMeshPicked: Observable<PickingInfo>;
  53212. private _circleEase;
  53213. /**
  53214. * Observable raised before camera teleportation
  53215. */
  53216. onBeforeCameraTeleport: Observable<Vector3>;
  53217. /**
  53218. * Observable raised after camera teleportation
  53219. */
  53220. onAfterCameraTeleport: Observable<Vector3>;
  53221. /**
  53222. * Observable raised when current selected mesh gets unselected
  53223. */
  53224. onSelectedMeshUnselected: Observable<AbstractMesh>;
  53225. private _raySelectionPredicate;
  53226. /**
  53227. * To be optionaly changed by user to define custom ray selection
  53228. */
  53229. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53230. /**
  53231. * To be optionaly changed by user to define custom selection logic (after ray selection)
  53232. */
  53233. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53234. /**
  53235. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  53236. */
  53237. teleportationEnabled: boolean;
  53238. private _defaultHeight;
  53239. private _teleportationInitialized;
  53240. private _interactionsEnabled;
  53241. private _interactionsRequested;
  53242. private _displayGaze;
  53243. private _displayLaserPointer;
  53244. /**
  53245. * The mesh used to display where the user is going to teleport.
  53246. */
  53247. get teleportationTarget(): Mesh;
  53248. /**
  53249. * Sets the mesh to be used to display where the user is going to teleport.
  53250. */
  53251. set teleportationTarget(value: Mesh);
  53252. /**
  53253. * 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
  53254. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  53255. * See https://doc.babylonjs.com/resources/baking_transformations
  53256. */
  53257. get gazeTrackerMesh(): Mesh;
  53258. set gazeTrackerMesh(value: Mesh);
  53259. /**
  53260. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  53261. */
  53262. updateGazeTrackerScale: boolean;
  53263. /**
  53264. * If the gaze trackers color should be updated when selecting meshes
  53265. */
  53266. updateGazeTrackerColor: boolean;
  53267. /**
  53268. * If the controller laser color should be updated when selecting meshes
  53269. */
  53270. updateControllerLaserColor: boolean;
  53271. /**
  53272. * The gaze tracking mesh corresponding to the left controller
  53273. */
  53274. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53275. /**
  53276. * The gaze tracking mesh corresponding to the right controller
  53277. */
  53278. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53279. /**
  53280. * If the ray of the gaze should be displayed.
  53281. */
  53282. get displayGaze(): boolean;
  53283. /**
  53284. * Sets if the ray of the gaze should be displayed.
  53285. */
  53286. set displayGaze(value: boolean);
  53287. /**
  53288. * If the ray of the LaserPointer should be displayed.
  53289. */
  53290. get displayLaserPointer(): boolean;
  53291. /**
  53292. * Sets if the ray of the LaserPointer should be displayed.
  53293. */
  53294. set displayLaserPointer(value: boolean);
  53295. /**
  53296. * The deviceOrientationCamera used as the camera when not in VR.
  53297. */
  53298. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53299. /**
  53300. * Based on the current WebVR support, returns the current VR camera used.
  53301. */
  53302. get currentVRCamera(): Nullable<Camera>;
  53303. /**
  53304. * The webVRCamera which is used when in VR.
  53305. */
  53306. get webVRCamera(): WebVRFreeCamera;
  53307. /**
  53308. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53309. */
  53310. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53311. /**
  53312. * The html button that is used to trigger entering into VR.
  53313. */
  53314. get vrButton(): Nullable<HTMLButtonElement>;
  53315. private get _teleportationRequestInitiated();
  53316. /**
  53317. * Defines whether or not Pointer lock should be requested when switching to
  53318. * full screen.
  53319. */
  53320. requestPointerLockOnFullScreen: boolean;
  53321. /**
  53322. * If asking to force XR, this will be populated with the default xr experience
  53323. */
  53324. xr: WebXRDefaultExperience;
  53325. /**
  53326. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53327. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53328. */
  53329. xrTestDone: boolean;
  53330. /**
  53331. * Instantiates a VRExperienceHelper.
  53332. * Helps to quickly add VR support to an existing scene.
  53333. * @param scene The scene the VRExperienceHelper belongs to.
  53334. * @param webVROptions Options to modify the vr experience helper's behavior.
  53335. */
  53336. constructor(scene: Scene,
  53337. /** Options to modify the vr experience helper's behavior. */
  53338. webVROptions?: VRExperienceHelperOptions);
  53339. private completeVRInit;
  53340. private _onDefaultMeshLoaded;
  53341. private _onResize;
  53342. private _onFullscreenChange;
  53343. /**
  53344. * Gets a value indicating if we are currently in VR mode.
  53345. */
  53346. get isInVRMode(): boolean;
  53347. private onVrDisplayPresentChange;
  53348. private onVRDisplayChanged;
  53349. private moveButtonToBottomRight;
  53350. private displayVRButton;
  53351. private updateButtonVisibility;
  53352. private _cachedAngularSensibility;
  53353. /**
  53354. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53355. * Otherwise, will use the fullscreen API.
  53356. */
  53357. enterVR(): void;
  53358. /**
  53359. * Attempt to exit VR, or fullscreen.
  53360. */
  53361. exitVR(): void;
  53362. /**
  53363. * The position of the vr experience helper.
  53364. */
  53365. get position(): Vector3;
  53366. /**
  53367. * Sets the position of the vr experience helper.
  53368. */
  53369. set position(value: Vector3);
  53370. /**
  53371. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53372. */
  53373. enableInteractions(): void;
  53374. private get _noControllerIsActive();
  53375. private beforeRender;
  53376. private _isTeleportationFloor;
  53377. /**
  53378. * Adds a floor mesh to be used for teleportation.
  53379. * @param floorMesh the mesh to be used for teleportation.
  53380. */
  53381. addFloorMesh(floorMesh: Mesh): void;
  53382. /**
  53383. * Removes a floor mesh from being used for teleportation.
  53384. * @param floorMesh the mesh to be removed.
  53385. */
  53386. removeFloorMesh(floorMesh: Mesh): void;
  53387. /**
  53388. * Enables interactions and teleportation using the VR controllers and gaze.
  53389. * @param vrTeleportationOptions options to modify teleportation behavior.
  53390. */
  53391. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53392. private _onNewGamepadConnected;
  53393. private _tryEnableInteractionOnController;
  53394. private _onNewGamepadDisconnected;
  53395. private _enableInteractionOnController;
  53396. private _checkTeleportWithRay;
  53397. private _checkRotate;
  53398. private _checkTeleportBackwards;
  53399. private _enableTeleportationOnController;
  53400. private _createTeleportationCircles;
  53401. private _displayTeleportationTarget;
  53402. private _hideTeleportationTarget;
  53403. private _rotateCamera;
  53404. private _moveTeleportationSelectorTo;
  53405. private _workingVector;
  53406. private _workingQuaternion;
  53407. private _workingMatrix;
  53408. /**
  53409. * Time Constant Teleportation Mode
  53410. */
  53411. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53412. /**
  53413. * Speed Constant Teleportation Mode
  53414. */
  53415. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53416. /**
  53417. * Teleports the users feet to the desired location
  53418. * @param location The location where the user's feet should be placed
  53419. */
  53420. teleportCamera(location: Vector3): void;
  53421. private _convertNormalToDirectionOfRay;
  53422. private _castRayAndSelectObject;
  53423. private _notifySelectedMeshUnselected;
  53424. /**
  53425. * Permanently set new colors for the laser pointer
  53426. * @param color the new laser color
  53427. * @param pickedColor the new laser color when picked mesh detected
  53428. */
  53429. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53430. /**
  53431. * Set lighting enabled / disabled on the laser pointer of both controllers
  53432. * @param enabled should the lighting be enabled on the laser pointer
  53433. */
  53434. setLaserLightingState(enabled?: boolean): void;
  53435. /**
  53436. * Permanently set new colors for the gaze pointer
  53437. * @param color the new gaze color
  53438. * @param pickedColor the new gaze color when picked mesh detected
  53439. */
  53440. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53441. /**
  53442. * Sets the color of the laser ray from the vr controllers.
  53443. * @param color new color for the ray.
  53444. */
  53445. changeLaserColor(color: Color3): void;
  53446. /**
  53447. * Sets the color of the ray from the vr headsets gaze.
  53448. * @param color new color for the ray.
  53449. */
  53450. changeGazeColor(color: Color3): void;
  53451. /**
  53452. * Exits VR and disposes of the vr experience helper
  53453. */
  53454. dispose(): void;
  53455. /**
  53456. * Gets the name of the VRExperienceHelper class
  53457. * @returns "VRExperienceHelper"
  53458. */
  53459. getClassName(): string;
  53460. }
  53461. }
  53462. declare module BABYLON {
  53463. /**
  53464. * Contains an array of blocks representing the octree
  53465. */
  53466. export interface IOctreeContainer<T> {
  53467. /**
  53468. * Blocks within the octree
  53469. */
  53470. blocks: Array<OctreeBlock<T>>;
  53471. }
  53472. /**
  53473. * Class used to store a cell in an octree
  53474. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53475. */
  53476. export class OctreeBlock<T> {
  53477. /**
  53478. * Gets the content of the current block
  53479. */
  53480. entries: T[];
  53481. /**
  53482. * Gets the list of block children
  53483. */
  53484. blocks: Array<OctreeBlock<T>>;
  53485. private _depth;
  53486. private _maxDepth;
  53487. private _capacity;
  53488. private _minPoint;
  53489. private _maxPoint;
  53490. private _boundingVectors;
  53491. private _creationFunc;
  53492. /**
  53493. * Creates a new block
  53494. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53495. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53496. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53497. * @param depth defines the current depth of this block in the octree
  53498. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53499. * @param creationFunc defines a callback to call when an element is added to the block
  53500. */
  53501. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53502. /**
  53503. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53504. */
  53505. get capacity(): number;
  53506. /**
  53507. * Gets the minimum vector (in world space) of the block's bounding box
  53508. */
  53509. get minPoint(): Vector3;
  53510. /**
  53511. * Gets the maximum vector (in world space) of the block's bounding box
  53512. */
  53513. get maxPoint(): Vector3;
  53514. /**
  53515. * Add a new element to this block
  53516. * @param entry defines the element to add
  53517. */
  53518. addEntry(entry: T): void;
  53519. /**
  53520. * Remove an element from this block
  53521. * @param entry defines the element to remove
  53522. */
  53523. removeEntry(entry: T): void;
  53524. /**
  53525. * Add an array of elements to this block
  53526. * @param entries defines the array of elements to add
  53527. */
  53528. addEntries(entries: T[]): void;
  53529. /**
  53530. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53531. * @param frustumPlanes defines the frustum planes to test
  53532. * @param selection defines the array to store current content if selection is positive
  53533. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53534. */
  53535. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53536. /**
  53537. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53538. * @param sphereCenter defines the bounding sphere center
  53539. * @param sphereRadius defines the bounding sphere radius
  53540. * @param selection defines the array to store current content if selection is positive
  53541. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53542. */
  53543. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53544. /**
  53545. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53546. * @param ray defines the ray to test with
  53547. * @param selection defines the array to store current content if selection is positive
  53548. */
  53549. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53550. /**
  53551. * Subdivide the content into child blocks (this block will then be empty)
  53552. */
  53553. createInnerBlocks(): void;
  53554. /**
  53555. * @hidden
  53556. */
  53557. 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;
  53558. }
  53559. }
  53560. declare module BABYLON {
  53561. /**
  53562. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53563. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53564. */
  53565. export class Octree<T> {
  53566. /** 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.) */
  53567. maxDepth: number;
  53568. /**
  53569. * Blocks within the octree containing objects
  53570. */
  53571. blocks: Array<OctreeBlock<T>>;
  53572. /**
  53573. * Content stored in the octree
  53574. */
  53575. dynamicContent: T[];
  53576. private _maxBlockCapacity;
  53577. private _selectionContent;
  53578. private _creationFunc;
  53579. /**
  53580. * Creates a octree
  53581. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53582. * @param creationFunc function to be used to instatiate the octree
  53583. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53584. * @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.)
  53585. */
  53586. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53587. /** 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.) */
  53588. maxDepth?: number);
  53589. /**
  53590. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53591. * @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);
  53592. * @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);
  53593. * @param entries meshes to be added to the octree blocks
  53594. */
  53595. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53596. /**
  53597. * Adds a mesh to the octree
  53598. * @param entry Mesh to add to the octree
  53599. */
  53600. addMesh(entry: T): void;
  53601. /**
  53602. * Remove an element from the octree
  53603. * @param entry defines the element to remove
  53604. */
  53605. removeMesh(entry: T): void;
  53606. /**
  53607. * Selects an array of meshes within the frustum
  53608. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53609. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53610. * @returns array of meshes within the frustum
  53611. */
  53612. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53613. /**
  53614. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53615. * @param sphereCenter defines the bounding sphere center
  53616. * @param sphereRadius defines the bounding sphere radius
  53617. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53618. * @returns an array of objects that intersect the sphere
  53619. */
  53620. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53621. /**
  53622. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53623. * @param ray defines the ray to test with
  53624. * @returns array of intersected objects
  53625. */
  53626. intersectsRay(ray: Ray): SmartArray<T>;
  53627. /**
  53628. * Adds a mesh into the octree block if it intersects the block
  53629. */
  53630. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53631. /**
  53632. * Adds a submesh into the octree block if it intersects the block
  53633. */
  53634. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53635. }
  53636. }
  53637. declare module BABYLON {
  53638. interface Scene {
  53639. /**
  53640. * @hidden
  53641. * Backing Filed
  53642. */
  53643. _selectionOctree: Octree<AbstractMesh>;
  53644. /**
  53645. * Gets the octree used to boost mesh selection (picking)
  53646. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53647. */
  53648. selectionOctree: Octree<AbstractMesh>;
  53649. /**
  53650. * Creates or updates the octree used to boost selection (picking)
  53651. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53652. * @param maxCapacity defines the maximum capacity per leaf
  53653. * @param maxDepth defines the maximum depth of the octree
  53654. * @returns an octree of AbstractMesh
  53655. */
  53656. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  53657. }
  53658. interface AbstractMesh {
  53659. /**
  53660. * @hidden
  53661. * Backing Field
  53662. */
  53663. _submeshesOctree: Octree<SubMesh>;
  53664. /**
  53665. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  53666. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  53667. * @param maxCapacity defines the maximum size of each block (64 by default)
  53668. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  53669. * @returns the new octree
  53670. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  53671. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53672. */
  53673. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  53674. }
  53675. /**
  53676. * Defines the octree scene component responsible to manage any octrees
  53677. * in a given scene.
  53678. */
  53679. export class OctreeSceneComponent {
  53680. /**
  53681. * The component name help to identify the component in the list of scene components.
  53682. */
  53683. readonly name: string;
  53684. /**
  53685. * The scene the component belongs to.
  53686. */
  53687. scene: Scene;
  53688. /**
  53689. * Indicates if the meshes have been checked to make sure they are isEnabled()
  53690. */
  53691. readonly checksIsEnabled: boolean;
  53692. /**
  53693. * Creates a new instance of the component for the given scene
  53694. * @param scene Defines the scene to register the component in
  53695. */
  53696. constructor(scene: Scene);
  53697. /**
  53698. * Registers the component in a given scene
  53699. */
  53700. register(): void;
  53701. /**
  53702. * Return the list of active meshes
  53703. * @returns the list of active meshes
  53704. */
  53705. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  53706. /**
  53707. * Return the list of active sub meshes
  53708. * @param mesh The mesh to get the candidates sub meshes from
  53709. * @returns the list of active sub meshes
  53710. */
  53711. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  53712. private _tempRay;
  53713. /**
  53714. * Return the list of sub meshes intersecting with a given local ray
  53715. * @param mesh defines the mesh to find the submesh for
  53716. * @param localRay defines the ray in local space
  53717. * @returns the list of intersecting sub meshes
  53718. */
  53719. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  53720. /**
  53721. * Return the list of sub meshes colliding with a collider
  53722. * @param mesh defines the mesh to find the submesh for
  53723. * @param collider defines the collider to evaluate the collision against
  53724. * @returns the list of colliding sub meshes
  53725. */
  53726. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  53727. /**
  53728. * Rebuilds the elements related to this component in case of
  53729. * context lost for instance.
  53730. */
  53731. rebuild(): void;
  53732. /**
  53733. * Disposes the component and the associated ressources.
  53734. */
  53735. dispose(): void;
  53736. }
  53737. }
  53738. declare module BABYLON {
  53739. /**
  53740. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  53741. */
  53742. export class Gizmo implements IDisposable {
  53743. /** The utility layer the gizmo will be added to */
  53744. gizmoLayer: UtilityLayerRenderer;
  53745. /**
  53746. * The root mesh of the gizmo
  53747. */
  53748. _rootMesh: Mesh;
  53749. private _attachedMesh;
  53750. private _attachedNode;
  53751. /**
  53752. * Ratio for the scale of the gizmo (Default: 1)
  53753. */
  53754. protected _scaleRatio: number;
  53755. /**
  53756. * boolean updated by pointermove when a gizmo mesh is hovered
  53757. */
  53758. protected _isHovered: boolean;
  53759. /**
  53760. * Ratio for the scale of the gizmo (Default: 1)
  53761. */
  53762. set scaleRatio(value: number);
  53763. get scaleRatio(): number;
  53764. /**
  53765. * True when the mouse pointer is hovered a gizmo mesh
  53766. */
  53767. get isHovered(): boolean;
  53768. /**
  53769. * If a custom mesh has been set (Default: false)
  53770. */
  53771. protected _customMeshSet: boolean;
  53772. /**
  53773. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  53774. * * When set, interactions will be enabled
  53775. */
  53776. get attachedMesh(): Nullable<AbstractMesh>;
  53777. set attachedMesh(value: Nullable<AbstractMesh>);
  53778. /**
  53779. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  53780. * * When set, interactions will be enabled
  53781. */
  53782. get attachedNode(): Nullable<Node>;
  53783. set attachedNode(value: Nullable<Node>);
  53784. /**
  53785. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53786. * @param mesh The mesh to replace the default mesh of the gizmo
  53787. */
  53788. setCustomMesh(mesh: Mesh): void;
  53789. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  53790. /**
  53791. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  53792. */
  53793. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53794. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53795. /**
  53796. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  53797. */
  53798. updateGizmoPositionToMatchAttachedMesh: boolean;
  53799. /**
  53800. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  53801. */
  53802. updateScale: boolean;
  53803. protected _interactionsEnabled: boolean;
  53804. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53805. private _beforeRenderObserver;
  53806. private _tempQuaternion;
  53807. private _tempVector;
  53808. private _tempVector2;
  53809. private _tempMatrix1;
  53810. private _tempMatrix2;
  53811. private _rightHandtoLeftHandMatrix;
  53812. /**
  53813. * Creates a gizmo
  53814. * @param gizmoLayer The utility layer the gizmo will be added to
  53815. */
  53816. constructor(
  53817. /** The utility layer the gizmo will be added to */
  53818. gizmoLayer?: UtilityLayerRenderer);
  53819. /**
  53820. * Updates the gizmo to match the attached mesh's position/rotation
  53821. */
  53822. protected _update(): void;
  53823. /**
  53824. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  53825. * @param value Node, TransformNode or mesh
  53826. */
  53827. protected _matrixChanged(): void;
  53828. /**
  53829. * Disposes of the gizmo
  53830. */
  53831. dispose(): void;
  53832. }
  53833. }
  53834. declare module BABYLON {
  53835. /**
  53836. * Single plane drag gizmo
  53837. */
  53838. export class PlaneDragGizmo extends Gizmo {
  53839. /**
  53840. * Drag behavior responsible for the gizmos dragging interactions
  53841. */
  53842. dragBehavior: PointerDragBehavior;
  53843. private _pointerObserver;
  53844. /**
  53845. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53846. */
  53847. snapDistance: number;
  53848. /**
  53849. * Event that fires each time the gizmo snaps to a new location.
  53850. * * snapDistance is the the change in distance
  53851. */
  53852. onSnapObservable: Observable<{
  53853. snapDistance: number;
  53854. }>;
  53855. private _plane;
  53856. private _coloredMaterial;
  53857. private _hoverMaterial;
  53858. private _isEnabled;
  53859. private _parent;
  53860. /** @hidden */
  53861. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  53862. /** @hidden */
  53863. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53864. /**
  53865. * Creates a PlaneDragGizmo
  53866. * @param gizmoLayer The utility layer the gizmo will be added to
  53867. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  53868. * @param color The color of the gizmo
  53869. */
  53870. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  53871. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53872. /**
  53873. * If the gizmo is enabled
  53874. */
  53875. set isEnabled(value: boolean);
  53876. get isEnabled(): boolean;
  53877. /**
  53878. * Disposes of the gizmo
  53879. */
  53880. dispose(): void;
  53881. }
  53882. }
  53883. declare module BABYLON {
  53884. /**
  53885. * Gizmo that enables dragging a mesh along 3 axis
  53886. */
  53887. export class PositionGizmo extends Gizmo {
  53888. /**
  53889. * Internal gizmo used for interactions on the x axis
  53890. */
  53891. xGizmo: AxisDragGizmo;
  53892. /**
  53893. * Internal gizmo used for interactions on the y axis
  53894. */
  53895. yGizmo: AxisDragGizmo;
  53896. /**
  53897. * Internal gizmo used for interactions on the z axis
  53898. */
  53899. zGizmo: AxisDragGizmo;
  53900. /**
  53901. * Internal gizmo used for interactions on the yz plane
  53902. */
  53903. xPlaneGizmo: PlaneDragGizmo;
  53904. /**
  53905. * Internal gizmo used for interactions on the xz plane
  53906. */
  53907. yPlaneGizmo: PlaneDragGizmo;
  53908. /**
  53909. * Internal gizmo used for interactions on the xy plane
  53910. */
  53911. zPlaneGizmo: PlaneDragGizmo;
  53912. /**
  53913. * private variables
  53914. */
  53915. private _meshAttached;
  53916. private _nodeAttached;
  53917. private _snapDistance;
  53918. /** Fires an event when any of it's sub gizmos are dragged */
  53919. onDragStartObservable: Observable<unknown>;
  53920. /** Fires an event when any of it's sub gizmos are released from dragging */
  53921. onDragEndObservable: Observable<unknown>;
  53922. /**
  53923. * If set to true, planar drag is enabled
  53924. */
  53925. private _planarGizmoEnabled;
  53926. get attachedMesh(): Nullable<AbstractMesh>;
  53927. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53928. get attachedNode(): Nullable<Node>;
  53929. set attachedNode(node: Nullable<Node>);
  53930. /**
  53931. * True when the mouse pointer is hovering a gizmo mesh
  53932. */
  53933. get isHovered(): boolean;
  53934. /**
  53935. * Creates a PositionGizmo
  53936. * @param gizmoLayer The utility layer the gizmo will be added to
  53937. @param thickness display gizmo axis thickness
  53938. */
  53939. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53940. /**
  53941. * If the planar drag gizmo is enabled
  53942. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  53943. */
  53944. set planarGizmoEnabled(value: boolean);
  53945. get planarGizmoEnabled(): boolean;
  53946. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53947. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53948. /**
  53949. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53950. */
  53951. set snapDistance(value: number);
  53952. get snapDistance(): number;
  53953. /**
  53954. * Ratio for the scale of the gizmo (Default: 1)
  53955. */
  53956. set scaleRatio(value: number);
  53957. get scaleRatio(): number;
  53958. /**
  53959. * Disposes of the gizmo
  53960. */
  53961. dispose(): void;
  53962. /**
  53963. * CustomMeshes are not supported by this gizmo
  53964. * @param mesh The mesh to replace the default mesh of the gizmo
  53965. */
  53966. setCustomMesh(mesh: Mesh): void;
  53967. }
  53968. }
  53969. declare module BABYLON {
  53970. /**
  53971. * Single axis drag gizmo
  53972. */
  53973. export class AxisDragGizmo extends Gizmo {
  53974. /**
  53975. * Drag behavior responsible for the gizmos dragging interactions
  53976. */
  53977. dragBehavior: PointerDragBehavior;
  53978. private _pointerObserver;
  53979. /**
  53980. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53981. */
  53982. snapDistance: number;
  53983. /**
  53984. * Event that fires each time the gizmo snaps to a new location.
  53985. * * snapDistance is the the change in distance
  53986. */
  53987. onSnapObservable: Observable<{
  53988. snapDistance: number;
  53989. }>;
  53990. private _isEnabled;
  53991. private _parent;
  53992. private _arrow;
  53993. private _coloredMaterial;
  53994. private _hoverMaterial;
  53995. /** @hidden */
  53996. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  53997. /** @hidden */
  53998. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53999. /**
  54000. * Creates an AxisDragGizmo
  54001. * @param gizmoLayer The utility layer the gizmo will be added to
  54002. * @param dragAxis The axis which the gizmo will be able to drag on
  54003. * @param color The color of the gizmo
  54004. * @param thickness display gizmo axis thickness
  54005. */
  54006. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  54007. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54008. /**
  54009. * If the gizmo is enabled
  54010. */
  54011. set isEnabled(value: boolean);
  54012. get isEnabled(): boolean;
  54013. /**
  54014. * Disposes of the gizmo
  54015. */
  54016. dispose(): void;
  54017. }
  54018. }
  54019. declare module BABYLON.Debug {
  54020. /**
  54021. * The Axes viewer will show 3 axes in a specific point in space
  54022. */
  54023. export class AxesViewer {
  54024. private _xAxis;
  54025. private _yAxis;
  54026. private _zAxis;
  54027. private _scaleLinesFactor;
  54028. private _instanced;
  54029. /**
  54030. * Gets the hosting scene
  54031. */
  54032. scene: Nullable<Scene>;
  54033. /**
  54034. * Gets or sets a number used to scale line length
  54035. */
  54036. scaleLines: number;
  54037. /** Gets the node hierarchy used to render x-axis */
  54038. get xAxis(): TransformNode;
  54039. /** Gets the node hierarchy used to render y-axis */
  54040. get yAxis(): TransformNode;
  54041. /** Gets the node hierarchy used to render z-axis */
  54042. get zAxis(): TransformNode;
  54043. /**
  54044. * Creates a new AxesViewer
  54045. * @param scene defines the hosting scene
  54046. * @param scaleLines defines a number used to scale line length (1 by default)
  54047. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  54048. * @param xAxis defines the node hierarchy used to render the x-axis
  54049. * @param yAxis defines the node hierarchy used to render the y-axis
  54050. * @param zAxis defines the node hierarchy used to render the z-axis
  54051. */
  54052. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  54053. /**
  54054. * Force the viewer to update
  54055. * @param position defines the position of the viewer
  54056. * @param xaxis defines the x axis of the viewer
  54057. * @param yaxis defines the y axis of the viewer
  54058. * @param zaxis defines the z axis of the viewer
  54059. */
  54060. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  54061. /**
  54062. * Creates an instance of this axes viewer.
  54063. * @returns a new axes viewer with instanced meshes
  54064. */
  54065. createInstance(): AxesViewer;
  54066. /** Releases resources */
  54067. dispose(): void;
  54068. private static _SetRenderingGroupId;
  54069. }
  54070. }
  54071. declare module BABYLON.Debug {
  54072. /**
  54073. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  54074. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  54075. */
  54076. export class BoneAxesViewer extends AxesViewer {
  54077. /**
  54078. * Gets or sets the target mesh where to display the axes viewer
  54079. */
  54080. mesh: Nullable<Mesh>;
  54081. /**
  54082. * Gets or sets the target bone where to display the axes viewer
  54083. */
  54084. bone: Nullable<Bone>;
  54085. /** Gets current position */
  54086. pos: Vector3;
  54087. /** Gets direction of X axis */
  54088. xaxis: Vector3;
  54089. /** Gets direction of Y axis */
  54090. yaxis: Vector3;
  54091. /** Gets direction of Z axis */
  54092. zaxis: Vector3;
  54093. /**
  54094. * Creates a new BoneAxesViewer
  54095. * @param scene defines the hosting scene
  54096. * @param bone defines the target bone
  54097. * @param mesh defines the target mesh
  54098. * @param scaleLines defines a scaling factor for line length (1 by default)
  54099. */
  54100. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  54101. /**
  54102. * Force the viewer to update
  54103. */
  54104. update(): void;
  54105. /** Releases resources */
  54106. dispose(): void;
  54107. }
  54108. }
  54109. declare module BABYLON {
  54110. /**
  54111. * Interface used to define scene explorer extensibility option
  54112. */
  54113. export interface IExplorerExtensibilityOption {
  54114. /**
  54115. * Define the option label
  54116. */
  54117. label: string;
  54118. /**
  54119. * Defines the action to execute on click
  54120. */
  54121. action: (entity: any) => void;
  54122. }
  54123. /**
  54124. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  54125. */
  54126. export interface IExplorerExtensibilityGroup {
  54127. /**
  54128. * Defines a predicate to test if a given type mut be extended
  54129. */
  54130. predicate: (entity: any) => boolean;
  54131. /**
  54132. * Gets the list of options added to a type
  54133. */
  54134. entries: IExplorerExtensibilityOption[];
  54135. }
  54136. /**
  54137. * Interface used to define the options to use to create the Inspector
  54138. */
  54139. export interface IInspectorOptions {
  54140. /**
  54141. * Display in overlay mode (default: false)
  54142. */
  54143. overlay?: boolean;
  54144. /**
  54145. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  54146. */
  54147. globalRoot?: HTMLElement;
  54148. /**
  54149. * Display the Scene explorer
  54150. */
  54151. showExplorer?: boolean;
  54152. /**
  54153. * Display the property inspector
  54154. */
  54155. showInspector?: boolean;
  54156. /**
  54157. * Display in embed mode (both panes on the right)
  54158. */
  54159. embedMode?: boolean;
  54160. /**
  54161. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  54162. */
  54163. handleResize?: boolean;
  54164. /**
  54165. * Allow the panes to popup (default: true)
  54166. */
  54167. enablePopup?: boolean;
  54168. /**
  54169. * Allow the panes to be closed by users (default: true)
  54170. */
  54171. enableClose?: boolean;
  54172. /**
  54173. * Optional list of extensibility entries
  54174. */
  54175. explorerExtensibility?: IExplorerExtensibilityGroup[];
  54176. /**
  54177. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  54178. */
  54179. inspectorURL?: string;
  54180. /**
  54181. * Optional initial tab (default to DebugLayerTab.Properties)
  54182. */
  54183. initialTab?: DebugLayerTab;
  54184. }
  54185. interface Scene {
  54186. /**
  54187. * @hidden
  54188. * Backing field
  54189. */
  54190. _debugLayer: DebugLayer;
  54191. /**
  54192. * Gets the debug layer (aka Inspector) associated with the scene
  54193. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54194. */
  54195. debugLayer: DebugLayer;
  54196. }
  54197. /**
  54198. * Enum of inspector action tab
  54199. */
  54200. export enum DebugLayerTab {
  54201. /**
  54202. * Properties tag (default)
  54203. */
  54204. Properties = 0,
  54205. /**
  54206. * Debug tab
  54207. */
  54208. Debug = 1,
  54209. /**
  54210. * Statistics tab
  54211. */
  54212. Statistics = 2,
  54213. /**
  54214. * Tools tab
  54215. */
  54216. Tools = 3,
  54217. /**
  54218. * Settings tab
  54219. */
  54220. Settings = 4
  54221. }
  54222. /**
  54223. * The debug layer (aka Inspector) is the go to tool in order to better understand
  54224. * what is happening in your scene
  54225. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54226. */
  54227. export class DebugLayer {
  54228. /**
  54229. * Define the url to get the inspector script from.
  54230. * By default it uses the babylonjs CDN.
  54231. * @ignoreNaming
  54232. */
  54233. static InspectorURL: string;
  54234. private _scene;
  54235. private BJSINSPECTOR;
  54236. private _onPropertyChangedObservable?;
  54237. /**
  54238. * Observable triggered when a property is changed through the inspector.
  54239. */
  54240. get onPropertyChangedObservable(): any;
  54241. /**
  54242. * Instantiates a new debug layer.
  54243. * The debug layer (aka Inspector) is the go to tool in order to better understand
  54244. * what is happening in your scene
  54245. * @see https://doc.babylonjs.com/features/playground_debuglayer
  54246. * @param scene Defines the scene to inspect
  54247. */
  54248. constructor(scene: Scene);
  54249. /** Creates the inspector window. */
  54250. private _createInspector;
  54251. /**
  54252. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  54253. * @param entity defines the entity to select
  54254. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  54255. */
  54256. select(entity: any, lineContainerTitles?: string | string[]): void;
  54257. /** Get the inspector from bundle or global */
  54258. private _getGlobalInspector;
  54259. /**
  54260. * Get if the inspector is visible or not.
  54261. * @returns true if visible otherwise, false
  54262. */
  54263. isVisible(): boolean;
  54264. /**
  54265. * Hide the inspector and close its window.
  54266. */
  54267. hide(): void;
  54268. /**
  54269. * Update the scene in the inspector
  54270. */
  54271. setAsActiveScene(): void;
  54272. /**
  54273. * Launch the debugLayer.
  54274. * @param config Define the configuration of the inspector
  54275. * @return a promise fulfilled when the debug layer is visible
  54276. */
  54277. show(config?: IInspectorOptions): Promise<DebugLayer>;
  54278. }
  54279. }
  54280. declare module BABYLON {
  54281. /**
  54282. * Class containing static functions to help procedurally build meshes
  54283. */
  54284. export class BoxBuilder {
  54285. /**
  54286. * Creates a box mesh
  54287. * * The parameter `size` sets the size (float) of each box side (default 1)
  54288. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54289. * * 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)
  54290. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54292. * * 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
  54293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54294. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54295. * @param name defines the name of the mesh
  54296. * @param options defines the options used to create the mesh
  54297. * @param scene defines the hosting scene
  54298. * @returns the box mesh
  54299. */
  54300. static CreateBox(name: string, options: {
  54301. size?: number;
  54302. width?: number;
  54303. height?: number;
  54304. depth?: number;
  54305. faceUV?: Vector4[];
  54306. faceColors?: Color4[];
  54307. sideOrientation?: number;
  54308. frontUVs?: Vector4;
  54309. backUVs?: Vector4;
  54310. wrap?: boolean;
  54311. topBaseAt?: number;
  54312. bottomBaseAt?: number;
  54313. updatable?: boolean;
  54314. }, scene?: Nullable<Scene>): Mesh;
  54315. }
  54316. }
  54317. declare module BABYLON.Debug {
  54318. /**
  54319. * Used to show the physics impostor around the specific mesh
  54320. */
  54321. export class PhysicsViewer {
  54322. /** @hidden */
  54323. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  54324. /** @hidden */
  54325. protected _meshes: Array<Nullable<AbstractMesh>>;
  54326. /** @hidden */
  54327. protected _scene: Nullable<Scene>;
  54328. /** @hidden */
  54329. protected _numMeshes: number;
  54330. /** @hidden */
  54331. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  54332. private _renderFunction;
  54333. private _utilityLayer;
  54334. private _debugBoxMesh;
  54335. private _debugSphereMesh;
  54336. private _debugCylinderMesh;
  54337. private _debugMaterial;
  54338. private _debugMeshMeshes;
  54339. /**
  54340. * Creates a new PhysicsViewer
  54341. * @param scene defines the hosting scene
  54342. */
  54343. constructor(scene: Scene);
  54344. /** @hidden */
  54345. protected _updateDebugMeshes(): void;
  54346. /**
  54347. * Renders a specified physic impostor
  54348. * @param impostor defines the impostor to render
  54349. * @param targetMesh defines the mesh represented by the impostor
  54350. * @returns the new debug mesh used to render the impostor
  54351. */
  54352. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  54353. /**
  54354. * Hides a specified physic impostor
  54355. * @param impostor defines the impostor to hide
  54356. */
  54357. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  54358. private _getDebugMaterial;
  54359. private _getDebugBoxMesh;
  54360. private _getDebugSphereMesh;
  54361. private _getDebugCylinderMesh;
  54362. private _getDebugMeshMesh;
  54363. private _getDebugMesh;
  54364. /** Releases all resources */
  54365. dispose(): void;
  54366. }
  54367. }
  54368. declare module BABYLON {
  54369. /**
  54370. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54371. * in order to better appreciate the issue one might have.
  54372. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54373. */
  54374. export class RayHelper {
  54375. /**
  54376. * Defines the ray we are currently tryin to visualize.
  54377. */
  54378. ray: Nullable<Ray>;
  54379. private _renderPoints;
  54380. private _renderLine;
  54381. private _renderFunction;
  54382. private _scene;
  54383. private _onAfterRenderObserver;
  54384. private _onAfterStepObserver;
  54385. private _attachedToMesh;
  54386. private _meshSpaceDirection;
  54387. private _meshSpaceOrigin;
  54388. /**
  54389. * Helper function to create a colored helper in a scene in one line.
  54390. * @param ray Defines the ray we are currently tryin to visualize
  54391. * @param scene Defines the scene the ray is used in
  54392. * @param color Defines the color we want to see the ray in
  54393. * @returns The newly created ray helper.
  54394. */
  54395. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  54396. /**
  54397. * Instantiate a new ray helper.
  54398. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  54399. * in order to better appreciate the issue one might have.
  54400. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  54401. * @param ray Defines the ray we are currently tryin to visualize
  54402. */
  54403. constructor(ray: Ray);
  54404. /**
  54405. * Shows the ray we are willing to debug.
  54406. * @param scene Defines the scene the ray needs to be rendered in
  54407. * @param color Defines the color the ray needs to be rendered in
  54408. */
  54409. show(scene: Scene, color?: Color3): void;
  54410. /**
  54411. * Hides the ray we are debugging.
  54412. */
  54413. hide(): void;
  54414. private _render;
  54415. /**
  54416. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  54417. * @param mesh Defines the mesh we want the helper attached to
  54418. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  54419. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  54420. * @param length Defines the length of the ray
  54421. */
  54422. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  54423. /**
  54424. * Detach the ray helper from the mesh it has previously been attached to.
  54425. */
  54426. detachFromMesh(): void;
  54427. private _updateToMesh;
  54428. /**
  54429. * Dispose the helper and release its associated resources.
  54430. */
  54431. dispose(): void;
  54432. }
  54433. }
  54434. declare module BABYLON {
  54435. /**
  54436. * Defines the options associated with the creation of a SkeletonViewer.
  54437. */
  54438. export interface ISkeletonViewerOptions {
  54439. /** Should the system pause animations before building the Viewer? */
  54440. pauseAnimations: boolean;
  54441. /** Should the system return the skeleton to rest before building? */
  54442. returnToRest: boolean;
  54443. /** public Display Mode of the Viewer */
  54444. displayMode: number;
  54445. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54446. displayOptions: ISkeletonViewerDisplayOptions;
  54447. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54448. computeBonesUsingShaders: boolean;
  54449. /** Flag ignore non weighted bones */
  54450. useAllBones: boolean;
  54451. }
  54452. /**
  54453. * Defines how to display the various bone meshes for the viewer.
  54454. */
  54455. export interface ISkeletonViewerDisplayOptions {
  54456. /** How far down to start tapering the bone spurs */
  54457. midStep?: number;
  54458. /** How big is the midStep? */
  54459. midStepFactor?: number;
  54460. /** Base for the Sphere Size */
  54461. sphereBaseSize?: number;
  54462. /** The ratio of the sphere to the longest bone in units */
  54463. sphereScaleUnit?: number;
  54464. /** Ratio for the Sphere Size */
  54465. sphereFactor?: number;
  54466. /** Whether a spur should attach its far end to the child bone position */
  54467. spurFollowsChild?: boolean;
  54468. /** Whether to show local axes or not */
  54469. showLocalAxes?: boolean;
  54470. /** Length of each local axis */
  54471. localAxesSize?: number;
  54472. }
  54473. /**
  54474. * Defines the constructor options for the BoneWeight Shader.
  54475. */
  54476. export interface IBoneWeightShaderOptions {
  54477. /** Skeleton to Map */
  54478. skeleton: Skeleton;
  54479. /** Colors for Uninfluenced bones */
  54480. colorBase?: Color3;
  54481. /** Colors for 0.0-0.25 Weight bones */
  54482. colorZero?: Color3;
  54483. /** Color for 0.25-0.5 Weight Influence */
  54484. colorQuarter?: Color3;
  54485. /** Color for 0.5-0.75 Weight Influence */
  54486. colorHalf?: Color3;
  54487. /** Color for 0.75-1 Weight Influence */
  54488. colorFull?: Color3;
  54489. /** Color for Zero Weight Influence */
  54490. targetBoneIndex?: number;
  54491. }
  54492. /**
  54493. * Simple structure of the gradient steps for the Color Map.
  54494. */
  54495. export interface ISkeletonMapShaderColorMapKnot {
  54496. /** Color of the Knot */
  54497. color: Color3;
  54498. /** Location of the Knot */
  54499. location: number;
  54500. }
  54501. /**
  54502. * Defines the constructor options for the SkeletonMap Shader.
  54503. */
  54504. export interface ISkeletonMapShaderOptions {
  54505. /** Skeleton to Map */
  54506. skeleton: Skeleton;
  54507. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  54508. colorMap?: ISkeletonMapShaderColorMapKnot[];
  54509. }
  54510. }
  54511. declare module BABYLON {
  54512. /**
  54513. * Class containing static functions to help procedurally build meshes
  54514. */
  54515. export class RibbonBuilder {
  54516. /**
  54517. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54518. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54519. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54520. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54521. * * 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
  54522. * * 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
  54523. * * 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
  54524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54525. * * 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
  54526. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54527. * * 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
  54528. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54529. * * 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
  54530. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54532. * @param name defines the name of the mesh
  54533. * @param options defines the options used to create the mesh
  54534. * @param scene defines the hosting scene
  54535. * @returns the ribbon mesh
  54536. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54537. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54538. */
  54539. static CreateRibbon(name: string, options: {
  54540. pathArray: Vector3[][];
  54541. closeArray?: boolean;
  54542. closePath?: boolean;
  54543. offset?: number;
  54544. updatable?: boolean;
  54545. sideOrientation?: number;
  54546. frontUVs?: Vector4;
  54547. backUVs?: Vector4;
  54548. instance?: Mesh;
  54549. invertUV?: boolean;
  54550. uvs?: Vector2[];
  54551. colors?: Color4[];
  54552. }, scene?: Nullable<Scene>): Mesh;
  54553. }
  54554. }
  54555. declare module BABYLON {
  54556. /**
  54557. * Class containing static functions to help procedurally build meshes
  54558. */
  54559. export class ShapeBuilder {
  54560. /**
  54561. * 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.
  54562. * * 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.
  54563. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54564. * * 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.
  54565. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54566. * * 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
  54567. * * 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
  54568. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54570. * * 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
  54571. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54573. * @param name defines the name of the mesh
  54574. * @param options defines the options used to create the mesh
  54575. * @param scene defines the hosting scene
  54576. * @returns the extruded shape mesh
  54577. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54578. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54579. */
  54580. static ExtrudeShape(name: string, options: {
  54581. shape: Vector3[];
  54582. path: Vector3[];
  54583. scale?: number;
  54584. rotation?: number;
  54585. cap?: number;
  54586. updatable?: boolean;
  54587. sideOrientation?: number;
  54588. frontUVs?: Vector4;
  54589. backUVs?: Vector4;
  54590. instance?: Mesh;
  54591. invertUV?: boolean;
  54592. }, scene?: Nullable<Scene>): Mesh;
  54593. /**
  54594. * Creates an custom extruded shape mesh.
  54595. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54596. * * 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.
  54597. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54598. * * 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
  54599. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54600. * * 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
  54601. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54602. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54603. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54604. * * 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
  54605. * * 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
  54606. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54608. * * 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
  54609. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54611. * @param name defines the name of the mesh
  54612. * @param options defines the options used to create the mesh
  54613. * @param scene defines the hosting scene
  54614. * @returns the custom extruded shape mesh
  54615. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54616. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54617. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54618. */
  54619. static ExtrudeShapeCustom(name: string, options: {
  54620. shape: Vector3[];
  54621. path: Vector3[];
  54622. scaleFunction?: any;
  54623. rotationFunction?: any;
  54624. ribbonCloseArray?: boolean;
  54625. ribbonClosePath?: boolean;
  54626. cap?: number;
  54627. updatable?: boolean;
  54628. sideOrientation?: number;
  54629. frontUVs?: Vector4;
  54630. backUVs?: Vector4;
  54631. instance?: Mesh;
  54632. invertUV?: boolean;
  54633. }, scene?: Nullable<Scene>): Mesh;
  54634. private static _ExtrudeShapeGeneric;
  54635. }
  54636. }
  54637. declare module BABYLON.Debug {
  54638. /**
  54639. * Class used to render a debug view of a given skeleton
  54640. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  54641. */
  54642. export class SkeletonViewer {
  54643. /** defines the skeleton to render */
  54644. skeleton: Skeleton;
  54645. /** defines the mesh attached to the skeleton */
  54646. mesh: AbstractMesh;
  54647. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54648. autoUpdateBonesMatrices: boolean;
  54649. /** defines the rendering group id to use with the viewer */
  54650. renderingGroupId: number;
  54651. /** is the options for the viewer */
  54652. options: Partial<ISkeletonViewerOptions>;
  54653. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  54654. static readonly DISPLAY_LINES: number;
  54655. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  54656. static readonly DISPLAY_SPHERES: number;
  54657. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  54658. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  54659. /** public static method to create a BoneWeight Shader
  54660. * @param options The constructor options
  54661. * @param scene The scene that the shader is scoped to
  54662. * @returns The created ShaderMaterial
  54663. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  54664. */
  54665. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  54666. /** public static method to create a BoneWeight Shader
  54667. * @param options The constructor options
  54668. * @param scene The scene that the shader is scoped to
  54669. * @returns The created ShaderMaterial
  54670. */
  54671. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  54672. /** private static method to create a BoneWeight Shader
  54673. * @param size The size of the buffer to create (usually the bone count)
  54674. * @param colorMap The gradient data to generate
  54675. * @param scene The scene that the shader is scoped to
  54676. * @returns an Array of floats from the color gradient values
  54677. */
  54678. private static _CreateBoneMapColorBuffer;
  54679. /** If SkeletonViewer scene scope. */
  54680. private _scene;
  54681. /** Gets or sets the color used to render the skeleton */
  54682. color: Color3;
  54683. /** Array of the points of the skeleton fo the line view. */
  54684. private _debugLines;
  54685. /** The SkeletonViewers Mesh. */
  54686. private _debugMesh;
  54687. /** The local axes Meshes. */
  54688. private _localAxes;
  54689. /** If SkeletonViewer is enabled. */
  54690. private _isEnabled;
  54691. /** If SkeletonViewer is ready. */
  54692. private _ready;
  54693. /** SkeletonViewer render observable. */
  54694. private _obs;
  54695. /** The Utility Layer to render the gizmos in. */
  54696. private _utilityLayer;
  54697. private _boneIndices;
  54698. /** Gets the Scene. */
  54699. get scene(): Scene;
  54700. /** Gets the utilityLayer. */
  54701. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  54702. /** Checks Ready Status. */
  54703. get isReady(): Boolean;
  54704. /** Sets Ready Status. */
  54705. set ready(value: boolean);
  54706. /** Gets the debugMesh */
  54707. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  54708. /** Sets the debugMesh */
  54709. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  54710. /** Gets the displayMode */
  54711. get displayMode(): number;
  54712. /** Sets the displayMode */
  54713. set displayMode(value: number);
  54714. /**
  54715. * Creates a new SkeletonViewer
  54716. * @param skeleton defines the skeleton to render
  54717. * @param mesh defines the mesh attached to the skeleton
  54718. * @param scene defines the hosting scene
  54719. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  54720. * @param renderingGroupId defines the rendering group id to use with the viewer
  54721. * @param options All of the extra constructor options for the SkeletonViewer
  54722. */
  54723. constructor(
  54724. /** defines the skeleton to render */
  54725. skeleton: Skeleton,
  54726. /** defines the mesh attached to the skeleton */
  54727. mesh: AbstractMesh,
  54728. /** The Scene scope*/
  54729. scene: Scene,
  54730. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54731. autoUpdateBonesMatrices?: boolean,
  54732. /** defines the rendering group id to use with the viewer */
  54733. renderingGroupId?: number,
  54734. /** is the options for the viewer */
  54735. options?: Partial<ISkeletonViewerOptions>);
  54736. /** The Dynamic bindings for the update functions */
  54737. private _bindObs;
  54738. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  54739. update(): void;
  54740. /** Gets or sets a boolean indicating if the viewer is enabled */
  54741. set isEnabled(value: boolean);
  54742. get isEnabled(): boolean;
  54743. private _getBonePosition;
  54744. private _getLinesForBonesWithLength;
  54745. private _getLinesForBonesNoLength;
  54746. /** function to revert the mesh and scene back to the initial state. */
  54747. private _revert;
  54748. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  54749. private _getAbsoluteBindPoseToRef;
  54750. /** function to build and bind sphere joint points and spur bone representations. */
  54751. private _buildSpheresAndSpurs;
  54752. private _buildLocalAxes;
  54753. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  54754. private _displayLinesUpdate;
  54755. /** Changes the displayMode of the skeleton viewer
  54756. * @param mode The displayMode numerical value
  54757. */
  54758. changeDisplayMode(mode: number): void;
  54759. /** Sets a display option of the skeleton viewer
  54760. *
  54761. * | Option | Type | Default | Description |
  54762. * | ---------------- | ------- | ------- | ----------- |
  54763. * | 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`. |
  54764. * | 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`. |
  54765. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54766. * | 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`. |
  54767. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  54768. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  54769. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  54770. *
  54771. * @param option String of the option name
  54772. * @param value The numerical option value
  54773. */
  54774. changeDisplayOptions(option: string, value: number): void;
  54775. /** Release associated resources */
  54776. dispose(): void;
  54777. }
  54778. }
  54779. declare module BABYLON {
  54780. /**
  54781. * Enum for Device Types
  54782. */
  54783. export enum DeviceType {
  54784. /** Generic */
  54785. Generic = 0,
  54786. /** Keyboard */
  54787. Keyboard = 1,
  54788. /** Mouse */
  54789. Mouse = 2,
  54790. /** Touch Pointers */
  54791. Touch = 3,
  54792. /** PS4 Dual Shock */
  54793. DualShock = 4,
  54794. /** Xbox */
  54795. Xbox = 5,
  54796. /** Switch Controller */
  54797. Switch = 6
  54798. }
  54799. /**
  54800. * Enum for All Pointers (Touch/Mouse)
  54801. */
  54802. export enum PointerInput {
  54803. /** Horizontal Axis */
  54804. Horizontal = 0,
  54805. /** Vertical Axis */
  54806. Vertical = 1,
  54807. /** Left Click or Touch */
  54808. LeftClick = 2,
  54809. /** Middle Click */
  54810. MiddleClick = 3,
  54811. /** Right Click */
  54812. RightClick = 4,
  54813. /** Browser Back */
  54814. BrowserBack = 5,
  54815. /** Browser Forward */
  54816. BrowserForward = 6
  54817. }
  54818. /**
  54819. * Enum for Dual Shock Gamepad
  54820. */
  54821. export enum DualShockInput {
  54822. /** Cross */
  54823. Cross = 0,
  54824. /** Circle */
  54825. Circle = 1,
  54826. /** Square */
  54827. Square = 2,
  54828. /** Triangle */
  54829. Triangle = 3,
  54830. /** L1 */
  54831. L1 = 4,
  54832. /** R1 */
  54833. R1 = 5,
  54834. /** L2 */
  54835. L2 = 6,
  54836. /** R2 */
  54837. R2 = 7,
  54838. /** Share */
  54839. Share = 8,
  54840. /** Options */
  54841. Options = 9,
  54842. /** L3 */
  54843. L3 = 10,
  54844. /** R3 */
  54845. R3 = 11,
  54846. /** DPadUp */
  54847. DPadUp = 12,
  54848. /** DPadDown */
  54849. DPadDown = 13,
  54850. /** DPadLeft */
  54851. DPadLeft = 14,
  54852. /** DRight */
  54853. DPadRight = 15,
  54854. /** Home */
  54855. Home = 16,
  54856. /** TouchPad */
  54857. TouchPad = 17,
  54858. /** LStickXAxis */
  54859. LStickXAxis = 18,
  54860. /** LStickYAxis */
  54861. LStickYAxis = 19,
  54862. /** RStickXAxis */
  54863. RStickXAxis = 20,
  54864. /** RStickYAxis */
  54865. RStickYAxis = 21
  54866. }
  54867. /**
  54868. * Enum for Xbox Gamepad
  54869. */
  54870. export enum XboxInput {
  54871. /** A */
  54872. A = 0,
  54873. /** B */
  54874. B = 1,
  54875. /** X */
  54876. X = 2,
  54877. /** Y */
  54878. Y = 3,
  54879. /** LB */
  54880. LB = 4,
  54881. /** RB */
  54882. RB = 5,
  54883. /** LT */
  54884. LT = 6,
  54885. /** RT */
  54886. RT = 7,
  54887. /** Back */
  54888. Back = 8,
  54889. /** Start */
  54890. Start = 9,
  54891. /** LS */
  54892. LS = 10,
  54893. /** RS */
  54894. RS = 11,
  54895. /** DPadUp */
  54896. DPadUp = 12,
  54897. /** DPadDown */
  54898. DPadDown = 13,
  54899. /** DPadLeft */
  54900. DPadLeft = 14,
  54901. /** DRight */
  54902. DPadRight = 15,
  54903. /** Home */
  54904. Home = 16,
  54905. /** LStickXAxis */
  54906. LStickXAxis = 17,
  54907. /** LStickYAxis */
  54908. LStickYAxis = 18,
  54909. /** RStickXAxis */
  54910. RStickXAxis = 19,
  54911. /** RStickYAxis */
  54912. RStickYAxis = 20
  54913. }
  54914. /**
  54915. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  54916. */
  54917. export enum SwitchInput {
  54918. /** B */
  54919. B = 0,
  54920. /** A */
  54921. A = 1,
  54922. /** Y */
  54923. Y = 2,
  54924. /** X */
  54925. X = 3,
  54926. /** L */
  54927. L = 4,
  54928. /** R */
  54929. R = 5,
  54930. /** ZL */
  54931. ZL = 6,
  54932. /** ZR */
  54933. ZR = 7,
  54934. /** Minus */
  54935. Minus = 8,
  54936. /** Plus */
  54937. Plus = 9,
  54938. /** LS */
  54939. LS = 10,
  54940. /** RS */
  54941. RS = 11,
  54942. /** DPadUp */
  54943. DPadUp = 12,
  54944. /** DPadDown */
  54945. DPadDown = 13,
  54946. /** DPadLeft */
  54947. DPadLeft = 14,
  54948. /** DRight */
  54949. DPadRight = 15,
  54950. /** Home */
  54951. Home = 16,
  54952. /** Capture */
  54953. Capture = 17,
  54954. /** LStickXAxis */
  54955. LStickXAxis = 18,
  54956. /** LStickYAxis */
  54957. LStickYAxis = 19,
  54958. /** RStickXAxis */
  54959. RStickXAxis = 20,
  54960. /** RStickYAxis */
  54961. RStickYAxis = 21
  54962. }
  54963. }
  54964. declare module BABYLON {
  54965. /**
  54966. * This class will take all inputs from Keyboard, Pointer, and
  54967. * any Gamepads and provide a polling system that all devices
  54968. * will use. This class assumes that there will only be one
  54969. * pointer device and one keyboard.
  54970. */
  54971. export class DeviceInputSystem implements IDisposable {
  54972. /**
  54973. * Callback to be triggered when a device is connected
  54974. */
  54975. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54976. /**
  54977. * Callback to be triggered when a device is disconnected
  54978. */
  54979. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54980. /**
  54981. * Callback to be triggered when event driven input is updated
  54982. */
  54983. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  54984. private _inputs;
  54985. private _gamepads;
  54986. private _keyboardActive;
  54987. private _pointerActive;
  54988. private _elementToAttachTo;
  54989. private _keyboardDownEvent;
  54990. private _keyboardUpEvent;
  54991. private _pointerMoveEvent;
  54992. private _pointerDownEvent;
  54993. private _pointerUpEvent;
  54994. private _gamepadConnectedEvent;
  54995. private _gamepadDisconnectedEvent;
  54996. private static _MAX_KEYCODES;
  54997. private static _MAX_POINTER_INPUTS;
  54998. private constructor();
  54999. /**
  55000. * Creates a new DeviceInputSystem instance
  55001. * @param engine Engine to pull input element from
  55002. * @returns The new instance
  55003. */
  55004. static Create(engine: Engine): DeviceInputSystem;
  55005. /**
  55006. * Checks for current device input value, given an id and input index
  55007. * @param deviceName Id of connected device
  55008. * @param inputIndex Index of device input
  55009. * @returns Current value of input
  55010. */
  55011. /**
  55012. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  55013. * @param deviceType Enum specifiying device type
  55014. * @param deviceSlot "Slot" or index that device is referenced in
  55015. * @param inputIndex Id of input to be checked
  55016. * @returns Current value of input
  55017. */
  55018. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  55019. /**
  55020. * Dispose of all the eventlisteners
  55021. */
  55022. dispose(): void;
  55023. /**
  55024. * Add device and inputs to device array
  55025. * @param deviceType Enum specifiying device type
  55026. * @param deviceSlot "Slot" or index that device is referenced in
  55027. * @param numberOfInputs Number of input entries to create for given device
  55028. */
  55029. private _registerDevice;
  55030. /**
  55031. * Given a specific device name, remove that device from the device map
  55032. * @param deviceType Enum specifiying device type
  55033. * @param deviceSlot "Slot" or index that device is referenced in
  55034. */
  55035. private _unregisterDevice;
  55036. /**
  55037. * Handle all actions that come from keyboard interaction
  55038. */
  55039. private _handleKeyActions;
  55040. /**
  55041. * Handle all actions that come from pointer interaction
  55042. */
  55043. private _handlePointerActions;
  55044. /**
  55045. * Handle all actions that come from gamepad interaction
  55046. */
  55047. private _handleGamepadActions;
  55048. /**
  55049. * Update all non-event based devices with each frame
  55050. * @param deviceType Enum specifiying device type
  55051. * @param deviceSlot "Slot" or index that device is referenced in
  55052. * @param inputIndex Id of input to be checked
  55053. */
  55054. private _updateDevice;
  55055. /**
  55056. * Gets DeviceType from the device name
  55057. * @param deviceName Name of Device from DeviceInputSystem
  55058. * @returns DeviceType enum value
  55059. */
  55060. private _getGamepadDeviceType;
  55061. }
  55062. }
  55063. declare module BABYLON {
  55064. /**
  55065. * Type to handle enforcement of inputs
  55066. */
  55067. 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;
  55068. }
  55069. declare module BABYLON {
  55070. /**
  55071. * Class that handles all input for a specific device
  55072. */
  55073. export class DeviceSource<T extends DeviceType> {
  55074. /** Type of device */
  55075. readonly deviceType: DeviceType;
  55076. /** "Slot" or index that device is referenced in */
  55077. readonly deviceSlot: number;
  55078. /**
  55079. * Observable to handle device input changes per device
  55080. */
  55081. readonly onInputChangedObservable: Observable<{
  55082. inputIndex: DeviceInput<T>;
  55083. previousState: Nullable<number>;
  55084. currentState: Nullable<number>;
  55085. }>;
  55086. private readonly _deviceInputSystem;
  55087. /**
  55088. * Default Constructor
  55089. * @param deviceInputSystem Reference to DeviceInputSystem
  55090. * @param deviceType Type of device
  55091. * @param deviceSlot "Slot" or index that device is referenced in
  55092. */
  55093. constructor(deviceInputSystem: DeviceInputSystem,
  55094. /** Type of device */
  55095. deviceType: DeviceType,
  55096. /** "Slot" or index that device is referenced in */
  55097. deviceSlot?: number);
  55098. /**
  55099. * Get input for specific input
  55100. * @param inputIndex index of specific input on device
  55101. * @returns Input value from DeviceInputSystem
  55102. */
  55103. getInput(inputIndex: DeviceInput<T>): number;
  55104. }
  55105. /**
  55106. * Class to keep track of devices
  55107. */
  55108. export class DeviceSourceManager implements IDisposable {
  55109. /**
  55110. * Observable to be triggered when before a device is connected
  55111. */
  55112. readonly onBeforeDeviceConnectedObservable: Observable<{
  55113. deviceType: DeviceType;
  55114. deviceSlot: number;
  55115. }>;
  55116. /**
  55117. * Observable to be triggered when before a device is disconnected
  55118. */
  55119. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  55120. deviceType: DeviceType;
  55121. deviceSlot: number;
  55122. }>;
  55123. /**
  55124. * Observable to be triggered when after a device is connected
  55125. */
  55126. readonly onAfterDeviceConnectedObservable: Observable<{
  55127. deviceType: DeviceType;
  55128. deviceSlot: number;
  55129. }>;
  55130. /**
  55131. * Observable to be triggered when after a device is disconnected
  55132. */
  55133. readonly onAfterDeviceDisconnectedObservable: Observable<{
  55134. deviceType: DeviceType;
  55135. deviceSlot: number;
  55136. }>;
  55137. private readonly _devices;
  55138. private readonly _firstDevice;
  55139. private readonly _deviceInputSystem;
  55140. /**
  55141. * Default Constructor
  55142. * @param engine engine to pull input element from
  55143. */
  55144. constructor(engine: Engine);
  55145. /**
  55146. * Gets a DeviceSource, given a type and slot
  55147. * @param deviceType Enum specifying device type
  55148. * @param deviceSlot "Slot" or index that device is referenced in
  55149. * @returns DeviceSource object
  55150. */
  55151. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  55152. /**
  55153. * Gets an array of DeviceSource objects for a given device type
  55154. * @param deviceType Enum specifying device type
  55155. * @returns Array of DeviceSource objects
  55156. */
  55157. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  55158. /**
  55159. * Dispose of DeviceInputSystem and other parts
  55160. */
  55161. dispose(): void;
  55162. /**
  55163. * Function to add device name to device list
  55164. * @param deviceType Enum specifying device type
  55165. * @param deviceSlot "Slot" or index that device is referenced in
  55166. */
  55167. private _addDevice;
  55168. /**
  55169. * Function to remove device name to device list
  55170. * @param deviceType Enum specifying device type
  55171. * @param deviceSlot "Slot" or index that device is referenced in
  55172. */
  55173. private _removeDevice;
  55174. /**
  55175. * Updates array storing first connected device of each type
  55176. * @param type Type of Device
  55177. */
  55178. private _updateFirstDevices;
  55179. }
  55180. }
  55181. declare module BABYLON {
  55182. /**
  55183. * Options to create the null engine
  55184. */
  55185. export class NullEngineOptions {
  55186. /**
  55187. * Render width (Default: 512)
  55188. */
  55189. renderWidth: number;
  55190. /**
  55191. * Render height (Default: 256)
  55192. */
  55193. renderHeight: number;
  55194. /**
  55195. * Texture size (Default: 512)
  55196. */
  55197. textureSize: number;
  55198. /**
  55199. * If delta time between frames should be constant
  55200. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55201. */
  55202. deterministicLockstep: boolean;
  55203. /**
  55204. * Maximum about of steps between frames (Default: 4)
  55205. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55206. */
  55207. lockstepMaxSteps: number;
  55208. /**
  55209. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  55210. */
  55211. useHighPrecisionMatrix?: boolean;
  55212. }
  55213. /**
  55214. * The null engine class provides support for headless version of babylon.js.
  55215. * This can be used in server side scenario or for testing purposes
  55216. */
  55217. export class NullEngine extends Engine {
  55218. private _options;
  55219. /**
  55220. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  55221. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55222. * @returns true if engine is in deterministic lock step mode
  55223. */
  55224. isDeterministicLockStep(): boolean;
  55225. /**
  55226. * Gets the max steps when engine is running in deterministic lock step
  55227. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  55228. * @returns the max steps
  55229. */
  55230. getLockstepMaxSteps(): number;
  55231. /**
  55232. * Gets the current hardware scaling level.
  55233. * By default the hardware scaling level is computed from the window device ratio.
  55234. * 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.
  55235. * @returns a number indicating the current hardware scaling level
  55236. */
  55237. getHardwareScalingLevel(): number;
  55238. constructor(options?: NullEngineOptions);
  55239. /**
  55240. * Creates a vertex buffer
  55241. * @param vertices the data for the vertex buffer
  55242. * @returns the new WebGL static buffer
  55243. */
  55244. createVertexBuffer(vertices: FloatArray): DataBuffer;
  55245. /**
  55246. * Creates a new index buffer
  55247. * @param indices defines the content of the index buffer
  55248. * @param updatable defines if the index buffer must be updatable
  55249. * @returns a new webGL buffer
  55250. */
  55251. createIndexBuffer(indices: IndicesArray): DataBuffer;
  55252. /**
  55253. * Clear the current render buffer or the current render target (if any is set up)
  55254. * @param color defines the color to use
  55255. * @param backBuffer defines if the back buffer must be cleared
  55256. * @param depth defines if the depth buffer must be cleared
  55257. * @param stencil defines if the stencil buffer must be cleared
  55258. */
  55259. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55260. /**
  55261. * Gets the current render width
  55262. * @param useScreen defines if screen size must be used (or the current render target if any)
  55263. * @returns a number defining the current render width
  55264. */
  55265. getRenderWidth(useScreen?: boolean): number;
  55266. /**
  55267. * Gets the current render height
  55268. * @param useScreen defines if screen size must be used (or the current render target if any)
  55269. * @returns a number defining the current render height
  55270. */
  55271. getRenderHeight(useScreen?: boolean): number;
  55272. /**
  55273. * Set the WebGL's viewport
  55274. * @param viewport defines the viewport element to be used
  55275. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  55276. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  55277. */
  55278. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  55279. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  55280. /**
  55281. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  55282. * @param pipelineContext defines the pipeline context to use
  55283. * @param uniformsNames defines the list of uniform names
  55284. * @returns an array of webGL uniform locations
  55285. */
  55286. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  55287. /**
  55288. * Gets the lsit of active attributes for a given webGL program
  55289. * @param pipelineContext defines the pipeline context to use
  55290. * @param attributesNames defines the list of attribute names to get
  55291. * @returns an array of indices indicating the offset of each attribute
  55292. */
  55293. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55294. /**
  55295. * Binds an effect to the webGL context
  55296. * @param effect defines the effect to bind
  55297. */
  55298. bindSamplers(effect: Effect): void;
  55299. /**
  55300. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  55301. * @param effect defines the effect to activate
  55302. */
  55303. enableEffect(effect: Effect): void;
  55304. /**
  55305. * Set various states to the webGL context
  55306. * @param culling defines backface culling state
  55307. * @param zOffset defines the value to apply to zOffset (0 by default)
  55308. * @param force defines if states must be applied even if cache is up to date
  55309. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  55310. */
  55311. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55312. /**
  55313. * Set the value of an uniform to an array of int32
  55314. * @param uniform defines the webGL uniform location where to store the value
  55315. * @param array defines the array of int32 to store
  55316. * @returns true if value was set
  55317. */
  55318. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55319. /**
  55320. * Set the value of an uniform to an array of int32 (stored as vec2)
  55321. * @param uniform defines the webGL uniform location where to store the value
  55322. * @param array defines the array of int32 to store
  55323. * @returns true if value was set
  55324. */
  55325. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55326. /**
  55327. * Set the value of an uniform to an array of int32 (stored as vec3)
  55328. * @param uniform defines the webGL uniform location where to store the value
  55329. * @param array defines the array of int32 to store
  55330. * @returns true if value was set
  55331. */
  55332. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55333. /**
  55334. * Set the value of an uniform to an array of int32 (stored as vec4)
  55335. * @param uniform defines the webGL uniform location where to store the value
  55336. * @param array defines the array of int32 to store
  55337. * @returns true if value was set
  55338. */
  55339. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55340. /**
  55341. * Set the value of an uniform to an array of float32
  55342. * @param uniform defines the webGL uniform location where to store the value
  55343. * @param array defines the array of float32 to store
  55344. * @returns true if value was set
  55345. */
  55346. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55347. /**
  55348. * Set the value of an uniform to an array of float32 (stored as vec2)
  55349. * @param uniform defines the webGL uniform location where to store the value
  55350. * @param array defines the array of float32 to store
  55351. * @returns true if value was set
  55352. */
  55353. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55354. /**
  55355. * Set the value of an uniform to an array of float32 (stored as vec3)
  55356. * @param uniform defines the webGL uniform location where to store the value
  55357. * @param array defines the array of float32 to store
  55358. * @returns true if value was set
  55359. */
  55360. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55361. /**
  55362. * Set the value of an uniform to an array of float32 (stored as vec4)
  55363. * @param uniform defines the webGL uniform location where to store the value
  55364. * @param array defines the array of float32 to store
  55365. * @returns true if value was set
  55366. */
  55367. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55368. /**
  55369. * Set the value of an uniform to an array of number
  55370. * @param uniform defines the webGL uniform location where to store the value
  55371. * @param array defines the array of number to store
  55372. * @returns true if value was set
  55373. */
  55374. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55375. /**
  55376. * Set the value of an uniform to an array of number (stored as vec2)
  55377. * @param uniform defines the webGL uniform location where to store the value
  55378. * @param array defines the array of number to store
  55379. * @returns true if value was set
  55380. */
  55381. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55382. /**
  55383. * Set the value of an uniform to an array of number (stored as vec3)
  55384. * @param uniform defines the webGL uniform location where to store the value
  55385. * @param array defines the array of number to store
  55386. * @returns true if value was set
  55387. */
  55388. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55389. /**
  55390. * Set the value of an uniform to an array of number (stored as vec4)
  55391. * @param uniform defines the webGL uniform location where to store the value
  55392. * @param array defines the array of number to store
  55393. * @returns true if value was set
  55394. */
  55395. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55396. /**
  55397. * Set the value of an uniform to an array of float32 (stored as matrices)
  55398. * @param uniform defines the webGL uniform location where to store the value
  55399. * @param matrices defines the array of float32 to store
  55400. * @returns true if value was set
  55401. */
  55402. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55403. /**
  55404. * Set the value of an uniform to a matrix (3x3)
  55405. * @param uniform defines the webGL uniform location where to store the value
  55406. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  55407. * @returns true if value was set
  55408. */
  55409. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55410. /**
  55411. * Set the value of an uniform to a matrix (2x2)
  55412. * @param uniform defines the webGL uniform location where to store the value
  55413. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  55414. * @returns true if value was set
  55415. */
  55416. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55417. /**
  55418. * Set the value of an uniform to a number (float)
  55419. * @param uniform defines the webGL uniform location where to store the value
  55420. * @param value defines the float number to store
  55421. * @returns true if value was set
  55422. */
  55423. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55424. /**
  55425. * Set the value of an uniform to a vec2
  55426. * @param uniform defines the webGL uniform location where to store the value
  55427. * @param x defines the 1st component of the value
  55428. * @param y defines the 2nd component of the value
  55429. * @returns true if value was set
  55430. */
  55431. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55432. /**
  55433. * Set the value of an uniform to a vec3
  55434. * @param uniform defines the webGL uniform location where to store the value
  55435. * @param x defines the 1st component of the value
  55436. * @param y defines the 2nd component of the value
  55437. * @param z defines the 3rd component of the value
  55438. * @returns true if value was set
  55439. */
  55440. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55441. /**
  55442. * Set the value of an uniform to a boolean
  55443. * @param uniform defines the webGL uniform location where to store the value
  55444. * @param bool defines the boolean to store
  55445. * @returns true if value was set
  55446. */
  55447. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  55448. /**
  55449. * Set the value of an uniform to a vec4
  55450. * @param uniform defines the webGL uniform location where to store the value
  55451. * @param x defines the 1st component of the value
  55452. * @param y defines the 2nd component of the value
  55453. * @param z defines the 3rd component of the value
  55454. * @param w defines the 4th component of the value
  55455. * @returns true if value was set
  55456. */
  55457. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55458. /**
  55459. * Sets the current alpha mode
  55460. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  55461. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55462. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55463. */
  55464. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55465. /**
  55466. * Bind webGl buffers directly to the webGL context
  55467. * @param vertexBuffers defines the vertex buffer to bind
  55468. * @param indexBuffer defines the index buffer to bind
  55469. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  55470. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  55471. * @param effect defines the effect associated with the vertex buffer
  55472. */
  55473. bindBuffers(vertexBuffers: {
  55474. [key: string]: VertexBuffer;
  55475. }, indexBuffer: DataBuffer, effect: Effect): void;
  55476. /**
  55477. * Force the entire cache to be cleared
  55478. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  55479. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  55480. */
  55481. wipeCaches(bruteForce?: boolean): void;
  55482. /**
  55483. * Send a draw order
  55484. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  55485. * @param indexStart defines the starting index
  55486. * @param indexCount defines the number of index to draw
  55487. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55488. */
  55489. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  55490. /**
  55491. * Draw a list of indexed primitives
  55492. * @param fillMode defines the primitive to use
  55493. * @param indexStart defines the starting index
  55494. * @param indexCount defines the number of index to draw
  55495. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55496. */
  55497. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55498. /**
  55499. * Draw a list of unindexed primitives
  55500. * @param fillMode defines the primitive to use
  55501. * @param verticesStart defines the index of first vertex to draw
  55502. * @param verticesCount defines the count of vertices to draw
  55503. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55504. */
  55505. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55506. /** @hidden */
  55507. _createTexture(): WebGLTexture;
  55508. /** @hidden */
  55509. _releaseTexture(texture: InternalTexture): void;
  55510. /**
  55511. * Usually called from Texture.ts.
  55512. * Passed information to create a WebGLTexture
  55513. * @param urlArg defines a value which contains one of the following:
  55514. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55515. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55516. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55517. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55518. * @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)
  55519. * @param scene needed for loading to the correct scene
  55520. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55521. * @param onLoad optional callback to be called upon successful completion
  55522. * @param onError optional callback to be called upon failure
  55523. * @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
  55524. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55525. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55526. * @param forcedExtension defines the extension to use to pick the right loader
  55527. * @param mimeType defines an optional mime type
  55528. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55529. */
  55530. 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;
  55531. /**
  55532. * Creates a new render target texture
  55533. * @param size defines the size of the texture
  55534. * @param options defines the options used to create the texture
  55535. * @returns a new render target texture stored in an InternalTexture
  55536. */
  55537. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  55538. /**
  55539. * Update the sampling mode of a given texture
  55540. * @param samplingMode defines the required sampling mode
  55541. * @param texture defines the texture to update
  55542. */
  55543. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55544. /**
  55545. * Binds the frame buffer to the specified texture.
  55546. * @param texture The texture to render to or null for the default canvas
  55547. * @param faceIndex The face of the texture to render to in case of cube texture
  55548. * @param requiredWidth The width of the target to render to
  55549. * @param requiredHeight The height of the target to render to
  55550. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  55551. * @param lodLevel defines le lod level to bind to the frame buffer
  55552. */
  55553. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55554. /**
  55555. * Unbind the current render target texture from the webGL context
  55556. * @param texture defines the render target texture to unbind
  55557. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  55558. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  55559. */
  55560. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55561. /**
  55562. * Creates a dynamic vertex buffer
  55563. * @param vertices the data for the dynamic vertex buffer
  55564. * @returns the new WebGL dynamic buffer
  55565. */
  55566. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  55567. /**
  55568. * Update the content of a dynamic texture
  55569. * @param texture defines the texture to update
  55570. * @param canvas defines the canvas containing the source
  55571. * @param invertY defines if data must be stored with Y axis inverted
  55572. * @param premulAlpha defines if alpha is stored as premultiplied
  55573. * @param format defines the format of the data
  55574. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55575. */
  55576. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55577. /**
  55578. * Gets a boolean indicating if all created effects are ready
  55579. * @returns true if all effects are ready
  55580. */
  55581. areAllEffectsReady(): boolean;
  55582. /**
  55583. * @hidden
  55584. * Get the current error code of the webGL context
  55585. * @returns the error code
  55586. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  55587. */
  55588. getError(): number;
  55589. /** @hidden */
  55590. _getUnpackAlignement(): number;
  55591. /** @hidden */
  55592. _unpackFlipY(value: boolean): void;
  55593. /**
  55594. * Update a dynamic index buffer
  55595. * @param indexBuffer defines the target index buffer
  55596. * @param indices defines the data to update
  55597. * @param offset defines the offset in the target index buffer where update should start
  55598. */
  55599. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  55600. /**
  55601. * Updates a dynamic vertex buffer.
  55602. * @param vertexBuffer the vertex buffer to update
  55603. * @param vertices the data used to update the vertex buffer
  55604. * @param byteOffset the byte offset of the data (optional)
  55605. * @param byteLength the byte length of the data (optional)
  55606. */
  55607. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  55608. /** @hidden */
  55609. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  55610. /** @hidden */
  55611. _bindTexture(channel: number, texture: InternalTexture): void;
  55612. protected _deleteBuffer(buffer: WebGLBuffer): void;
  55613. /**
  55614. * 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
  55615. */
  55616. releaseEffects(): void;
  55617. displayLoadingUI(): void;
  55618. hideLoadingUI(): void;
  55619. /** @hidden */
  55620. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55621. /** @hidden */
  55622. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55623. /** @hidden */
  55624. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55625. /** @hidden */
  55626. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55627. }
  55628. }
  55629. declare module BABYLON {
  55630. /**
  55631. * @hidden
  55632. **/
  55633. export class _TimeToken {
  55634. _startTimeQuery: Nullable<WebGLQuery>;
  55635. _endTimeQuery: Nullable<WebGLQuery>;
  55636. _timeElapsedQuery: Nullable<WebGLQuery>;
  55637. _timeElapsedQueryEnded: boolean;
  55638. }
  55639. }
  55640. declare module BABYLON {
  55641. /** @hidden */
  55642. export class _OcclusionDataStorage {
  55643. /** @hidden */
  55644. occlusionInternalRetryCounter: number;
  55645. /** @hidden */
  55646. isOcclusionQueryInProgress: boolean;
  55647. /** @hidden */
  55648. isOccluded: boolean;
  55649. /** @hidden */
  55650. occlusionRetryCount: number;
  55651. /** @hidden */
  55652. occlusionType: number;
  55653. /** @hidden */
  55654. occlusionQueryAlgorithmType: number;
  55655. }
  55656. interface Engine {
  55657. /**
  55658. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  55659. * @return the new query
  55660. */
  55661. createQuery(): WebGLQuery;
  55662. /**
  55663. * Delete and release a webGL query
  55664. * @param query defines the query to delete
  55665. * @return the current engine
  55666. */
  55667. deleteQuery(query: WebGLQuery): Engine;
  55668. /**
  55669. * Check if a given query has resolved and got its value
  55670. * @param query defines the query to check
  55671. * @returns true if the query got its value
  55672. */
  55673. isQueryResultAvailable(query: WebGLQuery): boolean;
  55674. /**
  55675. * Gets the value of a given query
  55676. * @param query defines the query to check
  55677. * @returns the value of the query
  55678. */
  55679. getQueryResult(query: WebGLQuery): number;
  55680. /**
  55681. * Initiates an occlusion query
  55682. * @param algorithmType defines the algorithm to use
  55683. * @param query defines the query to use
  55684. * @returns the current engine
  55685. * @see https://doc.babylonjs.com/features/occlusionquery
  55686. */
  55687. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  55688. /**
  55689. * Ends an occlusion query
  55690. * @see https://doc.babylonjs.com/features/occlusionquery
  55691. * @param algorithmType defines the algorithm to use
  55692. * @returns the current engine
  55693. */
  55694. endOcclusionQuery(algorithmType: number): Engine;
  55695. /**
  55696. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  55697. * Please note that only one query can be issued at a time
  55698. * @returns a time token used to track the time span
  55699. */
  55700. startTimeQuery(): Nullable<_TimeToken>;
  55701. /**
  55702. * Ends a time query
  55703. * @param token defines the token used to measure the time span
  55704. * @returns the time spent (in ns)
  55705. */
  55706. endTimeQuery(token: _TimeToken): int;
  55707. /** @hidden */
  55708. _currentNonTimestampToken: Nullable<_TimeToken>;
  55709. /** @hidden */
  55710. _createTimeQuery(): WebGLQuery;
  55711. /** @hidden */
  55712. _deleteTimeQuery(query: WebGLQuery): void;
  55713. /** @hidden */
  55714. _getGlAlgorithmType(algorithmType: number): number;
  55715. /** @hidden */
  55716. _getTimeQueryResult(query: WebGLQuery): any;
  55717. /** @hidden */
  55718. _getTimeQueryAvailability(query: WebGLQuery): any;
  55719. }
  55720. interface AbstractMesh {
  55721. /**
  55722. * Backing filed
  55723. * @hidden
  55724. */
  55725. __occlusionDataStorage: _OcclusionDataStorage;
  55726. /**
  55727. * Access property
  55728. * @hidden
  55729. */
  55730. _occlusionDataStorage: _OcclusionDataStorage;
  55731. /**
  55732. * 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.
  55733. * The default value is -1 which means don't break the query and wait till the result
  55734. * @see https://doc.babylonjs.com/features/occlusionquery
  55735. */
  55736. occlusionRetryCount: number;
  55737. /**
  55738. * 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:
  55739. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  55740. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  55741. * * 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.
  55742. * @see https://doc.babylonjs.com/features/occlusionquery
  55743. */
  55744. occlusionType: number;
  55745. /**
  55746. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  55747. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  55748. * * 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.
  55749. * @see https://doc.babylonjs.com/features/occlusionquery
  55750. */
  55751. occlusionQueryAlgorithmType: number;
  55752. /**
  55753. * 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
  55754. * @see https://doc.babylonjs.com/features/occlusionquery
  55755. */
  55756. isOccluded: boolean;
  55757. /**
  55758. * Flag to check the progress status of the query
  55759. * @see https://doc.babylonjs.com/features/occlusionquery
  55760. */
  55761. isOcclusionQueryInProgress: boolean;
  55762. }
  55763. }
  55764. declare module BABYLON {
  55765. /** @hidden */
  55766. export var _forceTransformFeedbackToBundle: boolean;
  55767. interface Engine {
  55768. /**
  55769. * Creates a webGL transform feedback object
  55770. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  55771. * @returns the webGL transform feedback object
  55772. */
  55773. createTransformFeedback(): WebGLTransformFeedback;
  55774. /**
  55775. * Delete a webGL transform feedback object
  55776. * @param value defines the webGL transform feedback object to delete
  55777. */
  55778. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  55779. /**
  55780. * Bind a webGL transform feedback object to the webgl context
  55781. * @param value defines the webGL transform feedback object to bind
  55782. */
  55783. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  55784. /**
  55785. * Begins a transform feedback operation
  55786. * @param usePoints defines if points or triangles must be used
  55787. */
  55788. beginTransformFeedback(usePoints: boolean): void;
  55789. /**
  55790. * Ends a transform feedback operation
  55791. */
  55792. endTransformFeedback(): void;
  55793. /**
  55794. * Specify the varyings to use with transform feedback
  55795. * @param program defines the associated webGL program
  55796. * @param value defines the list of strings representing the varying names
  55797. */
  55798. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  55799. /**
  55800. * Bind a webGL buffer for a transform feedback operation
  55801. * @param value defines the webGL buffer to bind
  55802. */
  55803. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  55804. }
  55805. }
  55806. declare module BABYLON {
  55807. /**
  55808. * Class used to define an additional view for the engine
  55809. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55810. */
  55811. export class EngineView {
  55812. /** Defines the canvas where to render the view */
  55813. target: HTMLCanvasElement;
  55814. /** Defines an optional camera used to render the view (will use active camera else) */
  55815. camera?: Camera;
  55816. }
  55817. interface Engine {
  55818. /**
  55819. * Gets or sets the HTML element to use for attaching events
  55820. */
  55821. inputElement: Nullable<HTMLElement>;
  55822. /**
  55823. * Gets the current engine view
  55824. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55825. */
  55826. activeView: Nullable<EngineView>;
  55827. /** Gets or sets the list of views */
  55828. views: EngineView[];
  55829. /**
  55830. * Register a new child canvas
  55831. * @param canvas defines the canvas to register
  55832. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  55833. * @returns the associated view
  55834. */
  55835. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  55836. /**
  55837. * Remove a registered child canvas
  55838. * @param canvas defines the canvas to remove
  55839. * @returns the current engine
  55840. */
  55841. unRegisterView(canvas: HTMLCanvasElement): Engine;
  55842. }
  55843. }
  55844. declare module BABYLON {
  55845. interface Engine {
  55846. /** @hidden */
  55847. _excludedCompressedTextures: string[];
  55848. /** @hidden */
  55849. _textureFormatInUse: string;
  55850. /**
  55851. * Gets the list of texture formats supported
  55852. */
  55853. readonly texturesSupported: Array<string>;
  55854. /**
  55855. * Gets the texture format in use
  55856. */
  55857. readonly textureFormatInUse: Nullable<string>;
  55858. /**
  55859. * Set the compressed texture extensions or file names to skip.
  55860. *
  55861. * @param skippedFiles defines the list of those texture files you want to skip
  55862. * Example: [".dds", ".env", "myfile.png"]
  55863. */
  55864. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  55865. /**
  55866. * Set the compressed texture format to use, based on the formats you have, and the formats
  55867. * supported by the hardware / browser.
  55868. *
  55869. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  55870. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  55871. * to API arguments needed to compressed textures. This puts the burden on the container
  55872. * generator to house the arcane code for determining these for current & future formats.
  55873. *
  55874. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55875. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55876. *
  55877. * Note: The result of this call is not taken into account when a texture is base64.
  55878. *
  55879. * @param formatsAvailable defines the list of those format families you have created
  55880. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  55881. *
  55882. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  55883. * @returns The extension selected.
  55884. */
  55885. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  55886. }
  55887. }
  55888. declare module BABYLON {
  55889. /** @hidden */
  55890. export var rgbdEncodePixelShader: {
  55891. name: string;
  55892. shader: string;
  55893. };
  55894. }
  55895. declare module BABYLON {
  55896. /**
  55897. * Raw texture data and descriptor sufficient for WebGL texture upload
  55898. */
  55899. export interface EnvironmentTextureInfo {
  55900. /**
  55901. * Version of the environment map
  55902. */
  55903. version: number;
  55904. /**
  55905. * Width of image
  55906. */
  55907. width: number;
  55908. /**
  55909. * Irradiance information stored in the file.
  55910. */
  55911. irradiance: any;
  55912. /**
  55913. * Specular information stored in the file.
  55914. */
  55915. specular: any;
  55916. }
  55917. /**
  55918. * Defines One Image in the file. It requires only the position in the file
  55919. * as well as the length.
  55920. */
  55921. interface BufferImageData {
  55922. /**
  55923. * Length of the image data.
  55924. */
  55925. length: number;
  55926. /**
  55927. * Position of the data from the null terminator delimiting the end of the JSON.
  55928. */
  55929. position: number;
  55930. }
  55931. /**
  55932. * Defines the specular data enclosed in the file.
  55933. * This corresponds to the version 1 of the data.
  55934. */
  55935. export interface EnvironmentTextureSpecularInfoV1 {
  55936. /**
  55937. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  55938. */
  55939. specularDataPosition?: number;
  55940. /**
  55941. * This contains all the images data needed to reconstruct the cubemap.
  55942. */
  55943. mipmaps: Array<BufferImageData>;
  55944. /**
  55945. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  55946. */
  55947. lodGenerationScale: number;
  55948. }
  55949. /**
  55950. * Sets of helpers addressing the serialization and deserialization of environment texture
  55951. * stored in a BabylonJS env file.
  55952. * Those files are usually stored as .env files.
  55953. */
  55954. export class EnvironmentTextureTools {
  55955. /**
  55956. * Magic number identifying the env file.
  55957. */
  55958. private static _MagicBytes;
  55959. /**
  55960. * Gets the environment info from an env file.
  55961. * @param data The array buffer containing the .env bytes.
  55962. * @returns the environment file info (the json header) if successfully parsed.
  55963. */
  55964. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  55965. /**
  55966. * Creates an environment texture from a loaded cube texture.
  55967. * @param texture defines the cube texture to convert in env file
  55968. * @return a promise containing the environment data if succesfull.
  55969. */
  55970. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  55971. /**
  55972. * Creates a JSON representation of the spherical data.
  55973. * @param texture defines the texture containing the polynomials
  55974. * @return the JSON representation of the spherical info
  55975. */
  55976. private static _CreateEnvTextureIrradiance;
  55977. /**
  55978. * Creates the ArrayBufferViews used for initializing environment texture image data.
  55979. * @param data the image data
  55980. * @param info parameters that determine what views will be created for accessing the underlying buffer
  55981. * @return the views described by info providing access to the underlying buffer
  55982. */
  55983. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  55984. /**
  55985. * Uploads the texture info contained in the env file to the GPU.
  55986. * @param texture defines the internal texture to upload to
  55987. * @param data defines the data to load
  55988. * @param info defines the texture info retrieved through the GetEnvInfo method
  55989. * @returns a promise
  55990. */
  55991. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  55992. private static _OnImageReadyAsync;
  55993. /**
  55994. * Uploads the levels of image data to the GPU.
  55995. * @param texture defines the internal texture to upload to
  55996. * @param imageData defines the array buffer views of image data [mipmap][face]
  55997. * @returns a promise
  55998. */
  55999. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  56000. /**
  56001. * Uploads spherical polynomials information to the texture.
  56002. * @param texture defines the texture we are trying to upload the information to
  56003. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  56004. */
  56005. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  56006. /** @hidden */
  56007. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56008. }
  56009. }
  56010. declare module BABYLON {
  56011. /**
  56012. * Class used to inline functions in shader code
  56013. */
  56014. export class ShaderCodeInliner {
  56015. private static readonly _RegexpFindFunctionNameAndType;
  56016. private _sourceCode;
  56017. private _functionDescr;
  56018. private _numMaxIterations;
  56019. /** Gets or sets the token used to mark the functions to inline */
  56020. inlineToken: string;
  56021. /** Gets or sets the debug mode */
  56022. debug: boolean;
  56023. /** Gets the code after the inlining process */
  56024. get code(): string;
  56025. /**
  56026. * Initializes the inliner
  56027. * @param sourceCode shader code source to inline
  56028. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  56029. */
  56030. constructor(sourceCode: string, numMaxIterations?: number);
  56031. /**
  56032. * Start the processing of the shader code
  56033. */
  56034. processCode(): void;
  56035. private _collectFunctions;
  56036. private _processInlining;
  56037. private _extractBetweenMarkers;
  56038. private _skipWhitespaces;
  56039. private _removeComments;
  56040. private _replaceFunctionCallsByCode;
  56041. private _findBackward;
  56042. private _escapeRegExp;
  56043. private _replaceNames;
  56044. }
  56045. }
  56046. declare module BABYLON {
  56047. /**
  56048. * Container for accessors for natively-stored mesh data buffers.
  56049. */
  56050. class NativeDataBuffer extends DataBuffer {
  56051. /**
  56052. * Accessor value used to identify/retrieve a natively-stored index buffer.
  56053. */
  56054. nativeIndexBuffer?: any;
  56055. /**
  56056. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  56057. */
  56058. nativeVertexBuffer?: any;
  56059. }
  56060. /** @hidden */
  56061. class NativeTexture extends InternalTexture {
  56062. getInternalTexture(): InternalTexture;
  56063. getViewCount(): number;
  56064. }
  56065. /** @hidden */
  56066. export class NativeEngine extends Engine {
  56067. private readonly _native;
  56068. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  56069. private readonly INVALID_HANDLE;
  56070. private _boundBuffersVertexArray;
  56071. private _currentDepthTest;
  56072. getHardwareScalingLevel(): number;
  56073. constructor();
  56074. dispose(): void;
  56075. /**
  56076. * Can be used to override the current requestAnimationFrame requester.
  56077. * @hidden
  56078. */
  56079. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  56080. /**
  56081. * Override default engine behavior.
  56082. * @param color
  56083. * @param backBuffer
  56084. * @param depth
  56085. * @param stencil
  56086. */
  56087. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  56088. /**
  56089. * Gets host document
  56090. * @returns the host document object
  56091. */
  56092. getHostDocument(): Nullable<Document>;
  56093. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56094. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  56095. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  56096. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  56097. [key: string]: VertexBuffer;
  56098. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56099. bindBuffers(vertexBuffers: {
  56100. [key: string]: VertexBuffer;
  56101. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  56102. recordVertexArrayObject(vertexBuffers: {
  56103. [key: string]: VertexBuffer;
  56104. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  56105. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56106. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  56107. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56108. /**
  56109. * Draw a list of indexed primitives
  56110. * @param fillMode defines the primitive to use
  56111. * @param indexStart defines the starting index
  56112. * @param indexCount defines the number of index to draw
  56113. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56114. */
  56115. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56116. /**
  56117. * Draw a list of unindexed primitives
  56118. * @param fillMode defines the primitive to use
  56119. * @param verticesStart defines the index of first vertex to draw
  56120. * @param verticesCount defines the count of vertices to draw
  56121. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56122. */
  56123. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56124. createPipelineContext(): IPipelineContext;
  56125. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  56126. /** @hidden */
  56127. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  56128. /** @hidden */
  56129. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  56130. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56131. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  56132. protected _setProgram(program: WebGLProgram): void;
  56133. _releaseEffect(effect: Effect): void;
  56134. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  56135. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  56136. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  56137. bindSamplers(effect: Effect): void;
  56138. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  56139. getRenderWidth(useScreen?: boolean): number;
  56140. getRenderHeight(useScreen?: boolean): number;
  56141. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  56142. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56143. /**
  56144. * Set the z offset to apply to current rendering
  56145. * @param value defines the offset to apply
  56146. */
  56147. setZOffset(value: number): void;
  56148. /**
  56149. * Gets the current value of the zOffset
  56150. * @returns the current zOffset state
  56151. */
  56152. getZOffset(): number;
  56153. /**
  56154. * Enable or disable depth buffering
  56155. * @param enable defines the state to set
  56156. */
  56157. setDepthBuffer(enable: boolean): void;
  56158. /**
  56159. * Gets a boolean indicating if depth writing is enabled
  56160. * @returns the current depth writing state
  56161. */
  56162. getDepthWrite(): boolean;
  56163. setDepthFunctionToGreater(): void;
  56164. setDepthFunctionToGreaterOrEqual(): void;
  56165. setDepthFunctionToLess(): void;
  56166. setDepthFunctionToLessOrEqual(): void;
  56167. /**
  56168. * Enable or disable depth writing
  56169. * @param enable defines the state to set
  56170. */
  56171. setDepthWrite(enable: boolean): void;
  56172. /**
  56173. * Enable or disable color writing
  56174. * @param enable defines the state to set
  56175. */
  56176. setColorWrite(enable: boolean): void;
  56177. /**
  56178. * Gets a boolean indicating if color writing is enabled
  56179. * @returns the current color writing state
  56180. */
  56181. getColorWrite(): boolean;
  56182. /**
  56183. * Sets alpha constants used by some alpha blending modes
  56184. * @param r defines the red component
  56185. * @param g defines the green component
  56186. * @param b defines the blue component
  56187. * @param a defines the alpha component
  56188. */
  56189. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  56190. /**
  56191. * Sets the current alpha mode
  56192. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  56193. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56194. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56195. */
  56196. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56197. /**
  56198. * Gets the current alpha mode
  56199. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56200. * @returns the current alpha mode
  56201. */
  56202. getAlphaMode(): number;
  56203. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  56204. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56205. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56206. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56207. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56208. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56209. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56210. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56211. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56212. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56213. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56214. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56215. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56216. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56217. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56218. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56219. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56220. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56221. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56222. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56223. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  56224. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  56225. wipeCaches(bruteForce?: boolean): void;
  56226. _createTexture(): WebGLTexture;
  56227. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  56228. /**
  56229. * Update the content of a dynamic texture
  56230. * @param texture defines the texture to update
  56231. * @param canvas defines the canvas containing the source
  56232. * @param invertY defines if data must be stored with Y axis inverted
  56233. * @param premulAlpha defines if alpha is stored as premultiplied
  56234. * @param format defines the format of the data
  56235. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  56236. */
  56237. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  56238. /**
  56239. * Usually called from Texture.ts.
  56240. * Passed information to create a WebGLTexture
  56241. * @param url defines a value which contains one of the following:
  56242. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  56243. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  56244. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  56245. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  56246. * @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)
  56247. * @param scene needed for loading to the correct scene
  56248. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  56249. * @param onLoad optional callback to be called upon successful completion
  56250. * @param onError optional callback to be called upon failure
  56251. * @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
  56252. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  56253. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  56254. * @param forcedExtension defines the extension to use to pick the right loader
  56255. * @param mimeType defines an optional mime type
  56256. * @param loaderOptions options to be passed to the loader
  56257. * @returns a InternalTexture for assignment back into BABYLON.Texture
  56258. */
  56259. 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;
  56260. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  56261. _releaseFramebufferObjects(texture: InternalTexture): void;
  56262. /**
  56263. * Creates a cube texture
  56264. * @param rootUrl defines the url where the files to load is located
  56265. * @param scene defines the current scene
  56266. * @param files defines the list of files to load (1 per face)
  56267. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  56268. * @param onLoad defines an optional callback raised when the texture is loaded
  56269. * @param onError defines an optional callback raised if there is an issue to load the texture
  56270. * @param format defines the format of the data
  56271. * @param forcedExtension defines the extension to use to pick the right loader
  56272. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  56273. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56274. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56275. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  56276. * @returns the cube texture as an InternalTexture
  56277. */
  56278. 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;
  56279. createRenderTargetTexture(size: number | {
  56280. width: number;
  56281. height: number;
  56282. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  56283. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56284. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56285. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56286. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  56287. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  56288. /**
  56289. * Updates a dynamic vertex buffer.
  56290. * @param vertexBuffer the vertex buffer to update
  56291. * @param data the data used to update the vertex buffer
  56292. * @param byteOffset the byte offset of the data (optional)
  56293. * @param byteLength the byte length of the data (optional)
  56294. */
  56295. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  56296. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  56297. private _updateAnisotropicLevel;
  56298. private _getAddressMode;
  56299. /** @hidden */
  56300. _bindTexture(channel: number, texture: InternalTexture): void;
  56301. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  56302. releaseEffects(): void;
  56303. /** @hidden */
  56304. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56305. /** @hidden */
  56306. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56307. /** @hidden */
  56308. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56309. /** @hidden */
  56310. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56311. private _getNativeSamplingMode;
  56312. private _getNativeTextureFormat;
  56313. private _getNativeAlphaMode;
  56314. private _getNativeAttribType;
  56315. }
  56316. }
  56317. declare module BABYLON {
  56318. /**
  56319. * Gather the list of clipboard event types as constants.
  56320. */
  56321. export class ClipboardEventTypes {
  56322. /**
  56323. * The clipboard event is fired when a copy command is active (pressed).
  56324. */
  56325. static readonly COPY: number;
  56326. /**
  56327. * The clipboard event is fired when a cut command is active (pressed).
  56328. */
  56329. static readonly CUT: number;
  56330. /**
  56331. * The clipboard event is fired when a paste command is active (pressed).
  56332. */
  56333. static readonly PASTE: number;
  56334. }
  56335. /**
  56336. * This class is used to store clipboard related info for the onClipboardObservable event.
  56337. */
  56338. export class ClipboardInfo {
  56339. /**
  56340. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56341. */
  56342. type: number;
  56343. /**
  56344. * Defines the related dom event
  56345. */
  56346. event: ClipboardEvent;
  56347. /**
  56348. *Creates an instance of ClipboardInfo.
  56349. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  56350. * @param event Defines the related dom event
  56351. */
  56352. constructor(
  56353. /**
  56354. * Defines the type of event (BABYLON.ClipboardEventTypes)
  56355. */
  56356. type: number,
  56357. /**
  56358. * Defines the related dom event
  56359. */
  56360. event: ClipboardEvent);
  56361. /**
  56362. * Get the clipboard event's type from the keycode.
  56363. * @param keyCode Defines the keyCode for the current keyboard event.
  56364. * @return {number}
  56365. */
  56366. static GetTypeFromCharacter(keyCode: number): number;
  56367. }
  56368. }
  56369. declare module BABYLON {
  56370. /**
  56371. * Google Daydream controller
  56372. */
  56373. export class DaydreamController extends WebVRController {
  56374. /**
  56375. * Base Url for the controller model.
  56376. */
  56377. static MODEL_BASE_URL: string;
  56378. /**
  56379. * File name for the controller model.
  56380. */
  56381. static MODEL_FILENAME: string;
  56382. /**
  56383. * Gamepad Id prefix used to identify Daydream Controller.
  56384. */
  56385. static readonly GAMEPAD_ID_PREFIX: string;
  56386. /**
  56387. * Creates a new DaydreamController from a gamepad
  56388. * @param vrGamepad the gamepad that the controller should be created from
  56389. */
  56390. constructor(vrGamepad: any);
  56391. /**
  56392. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56393. * @param scene scene in which to add meshes
  56394. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56395. */
  56396. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56397. /**
  56398. * Called once for each button that changed state since the last frame
  56399. * @param buttonIdx Which button index changed
  56400. * @param state New state of the button
  56401. * @param changes Which properties on the state changed since last frame
  56402. */
  56403. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56404. }
  56405. }
  56406. declare module BABYLON {
  56407. /**
  56408. * Gear VR Controller
  56409. */
  56410. export class GearVRController extends WebVRController {
  56411. /**
  56412. * Base Url for the controller model.
  56413. */
  56414. static MODEL_BASE_URL: string;
  56415. /**
  56416. * File name for the controller model.
  56417. */
  56418. static MODEL_FILENAME: string;
  56419. /**
  56420. * Gamepad Id prefix used to identify this controller.
  56421. */
  56422. static readonly GAMEPAD_ID_PREFIX: string;
  56423. private readonly _buttonIndexToObservableNameMap;
  56424. /**
  56425. * Creates a new GearVRController from a gamepad
  56426. * @param vrGamepad the gamepad that the controller should be created from
  56427. */
  56428. constructor(vrGamepad: any);
  56429. /**
  56430. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56431. * @param scene scene in which to add meshes
  56432. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56433. */
  56434. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56435. /**
  56436. * Called once for each button that changed state since the last frame
  56437. * @param buttonIdx Which button index changed
  56438. * @param state New state of the button
  56439. * @param changes Which properties on the state changed since last frame
  56440. */
  56441. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56442. }
  56443. }
  56444. declare module BABYLON {
  56445. /**
  56446. * Generic Controller
  56447. */
  56448. export class GenericController extends WebVRController {
  56449. /**
  56450. * Base Url for the controller model.
  56451. */
  56452. static readonly MODEL_BASE_URL: string;
  56453. /**
  56454. * File name for the controller model.
  56455. */
  56456. static readonly MODEL_FILENAME: string;
  56457. /**
  56458. * Creates a new GenericController from a gamepad
  56459. * @param vrGamepad the gamepad that the controller should be created from
  56460. */
  56461. constructor(vrGamepad: any);
  56462. /**
  56463. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56464. * @param scene scene in which to add meshes
  56465. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56466. */
  56467. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56468. /**
  56469. * Called once for each button that changed state since the last frame
  56470. * @param buttonIdx Which button index changed
  56471. * @param state New state of the button
  56472. * @param changes Which properties on the state changed since last frame
  56473. */
  56474. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56475. }
  56476. }
  56477. declare module BABYLON {
  56478. /**
  56479. * Oculus Touch Controller
  56480. */
  56481. export class OculusTouchController extends WebVRController {
  56482. /**
  56483. * Base Url for the controller model.
  56484. */
  56485. static MODEL_BASE_URL: string;
  56486. /**
  56487. * File name for the left controller model.
  56488. */
  56489. static MODEL_LEFT_FILENAME: string;
  56490. /**
  56491. * File name for the right controller model.
  56492. */
  56493. static MODEL_RIGHT_FILENAME: string;
  56494. /**
  56495. * Base Url for the Quest controller model.
  56496. */
  56497. static QUEST_MODEL_BASE_URL: string;
  56498. /**
  56499. * @hidden
  56500. * If the controllers are running on a device that needs the updated Quest controller models
  56501. */
  56502. static _IsQuest: boolean;
  56503. /**
  56504. * Fired when the secondary trigger on this controller is modified
  56505. */
  56506. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  56507. /**
  56508. * Fired when the thumb rest on this controller is modified
  56509. */
  56510. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  56511. /**
  56512. * Creates a new OculusTouchController from a gamepad
  56513. * @param vrGamepad the gamepad that the controller should be created from
  56514. */
  56515. constructor(vrGamepad: any);
  56516. /**
  56517. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56518. * @param scene scene in which to add meshes
  56519. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56520. */
  56521. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56522. /**
  56523. * Fired when the A button on this controller is modified
  56524. */
  56525. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56526. /**
  56527. * Fired when the B button on this controller is modified
  56528. */
  56529. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56530. /**
  56531. * Fired when the X button on this controller is modified
  56532. */
  56533. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56534. /**
  56535. * Fired when the Y button on this controller is modified
  56536. */
  56537. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56538. /**
  56539. * Called once for each button that changed state since the last frame
  56540. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  56541. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  56542. * 2) secondary trigger (same)
  56543. * 3) A (right) X (left), touch, pressed = value
  56544. * 4) B / Y
  56545. * 5) thumb rest
  56546. * @param buttonIdx Which button index changed
  56547. * @param state New state of the button
  56548. * @param changes Which properties on the state changed since last frame
  56549. */
  56550. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56551. }
  56552. }
  56553. declare module BABYLON {
  56554. /**
  56555. * Vive Controller
  56556. */
  56557. export class ViveController extends WebVRController {
  56558. /**
  56559. * Base Url for the controller model.
  56560. */
  56561. static MODEL_BASE_URL: string;
  56562. /**
  56563. * File name for the controller model.
  56564. */
  56565. static MODEL_FILENAME: string;
  56566. /**
  56567. * Creates a new ViveController from a gamepad
  56568. * @param vrGamepad the gamepad that the controller should be created from
  56569. */
  56570. constructor(vrGamepad: any);
  56571. /**
  56572. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56573. * @param scene scene in which to add meshes
  56574. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56575. */
  56576. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56577. /**
  56578. * Fired when the left button on this controller is modified
  56579. */
  56580. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56581. /**
  56582. * Fired when the right button on this controller is modified
  56583. */
  56584. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56585. /**
  56586. * Fired when the menu button on this controller is modified
  56587. */
  56588. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56589. /**
  56590. * Called once for each button that changed state since the last frame
  56591. * Vive mapping:
  56592. * 0: touchpad
  56593. * 1: trigger
  56594. * 2: left AND right buttons
  56595. * 3: menu button
  56596. * @param buttonIdx Which button index changed
  56597. * @param state New state of the button
  56598. * @param changes Which properties on the state changed since last frame
  56599. */
  56600. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56601. }
  56602. }
  56603. declare module BABYLON {
  56604. /**
  56605. * Defines the WindowsMotionController object that the state of the windows motion controller
  56606. */
  56607. export class WindowsMotionController extends WebVRController {
  56608. /**
  56609. * The base url used to load the left and right controller models
  56610. */
  56611. static MODEL_BASE_URL: string;
  56612. /**
  56613. * The name of the left controller model file
  56614. */
  56615. static MODEL_LEFT_FILENAME: string;
  56616. /**
  56617. * The name of the right controller model file
  56618. */
  56619. static MODEL_RIGHT_FILENAME: string;
  56620. /**
  56621. * The controller name prefix for this controller type
  56622. */
  56623. static readonly GAMEPAD_ID_PREFIX: string;
  56624. /**
  56625. * The controller id pattern for this controller type
  56626. */
  56627. private static readonly GAMEPAD_ID_PATTERN;
  56628. private _loadedMeshInfo;
  56629. protected readonly _mapping: {
  56630. buttons: string[];
  56631. buttonMeshNames: {
  56632. trigger: string;
  56633. menu: string;
  56634. grip: string;
  56635. thumbstick: string;
  56636. trackpad: string;
  56637. };
  56638. buttonObservableNames: {
  56639. trigger: string;
  56640. menu: string;
  56641. grip: string;
  56642. thumbstick: string;
  56643. trackpad: string;
  56644. };
  56645. axisMeshNames: string[];
  56646. pointingPoseMeshName: string;
  56647. };
  56648. /**
  56649. * Fired when the trackpad on this controller is clicked
  56650. */
  56651. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56652. /**
  56653. * Fired when the trackpad on this controller is modified
  56654. */
  56655. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56656. /**
  56657. * The current x and y values of this controller's trackpad
  56658. */
  56659. trackpad: StickValues;
  56660. /**
  56661. * Creates a new WindowsMotionController from a gamepad
  56662. * @param vrGamepad the gamepad that the controller should be created from
  56663. */
  56664. constructor(vrGamepad: any);
  56665. /**
  56666. * Fired when the trigger on this controller is modified
  56667. */
  56668. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56669. /**
  56670. * Fired when the menu button on this controller is modified
  56671. */
  56672. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56673. /**
  56674. * Fired when the grip button on this controller is modified
  56675. */
  56676. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56677. /**
  56678. * Fired when the thumbstick button on this controller is modified
  56679. */
  56680. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56681. /**
  56682. * Fired when the touchpad button on this controller is modified
  56683. */
  56684. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56685. /**
  56686. * Fired when the touchpad values on this controller are modified
  56687. */
  56688. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  56689. protected _updateTrackpad(): void;
  56690. /**
  56691. * Called once per frame by the engine.
  56692. */
  56693. update(): void;
  56694. /**
  56695. * Called once for each button that changed state since the last frame
  56696. * @param buttonIdx Which button index changed
  56697. * @param state New state of the button
  56698. * @param changes Which properties on the state changed since last frame
  56699. */
  56700. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56701. /**
  56702. * Moves the buttons on the controller mesh based on their current state
  56703. * @param buttonName the name of the button to move
  56704. * @param buttonValue the value of the button which determines the buttons new position
  56705. */
  56706. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  56707. /**
  56708. * Moves the axis on the controller mesh based on its current state
  56709. * @param axis the index of the axis
  56710. * @param axisValue the value of the axis which determines the meshes new position
  56711. * @hidden
  56712. */
  56713. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  56714. /**
  56715. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56716. * @param scene scene in which to add meshes
  56717. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56718. */
  56719. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  56720. /**
  56721. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  56722. * can be transformed by button presses and axes values, based on this._mapping.
  56723. *
  56724. * @param scene scene in which the meshes exist
  56725. * @param meshes list of meshes that make up the controller model to process
  56726. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  56727. */
  56728. private processModel;
  56729. private createMeshInfo;
  56730. /**
  56731. * Gets the ray of the controller in the direction the controller is pointing
  56732. * @param length the length the resulting ray should be
  56733. * @returns a ray in the direction the controller is pointing
  56734. */
  56735. getForwardRay(length?: number): Ray;
  56736. /**
  56737. * Disposes of the controller
  56738. */
  56739. dispose(): void;
  56740. }
  56741. /**
  56742. * This class represents a new windows motion controller in XR.
  56743. */
  56744. export class XRWindowsMotionController extends WindowsMotionController {
  56745. /**
  56746. * Changing the original WIndowsMotionController mapping to fir the new mapping
  56747. */
  56748. protected readonly _mapping: {
  56749. buttons: string[];
  56750. buttonMeshNames: {
  56751. trigger: string;
  56752. menu: string;
  56753. grip: string;
  56754. thumbstick: string;
  56755. trackpad: string;
  56756. };
  56757. buttonObservableNames: {
  56758. trigger: string;
  56759. menu: string;
  56760. grip: string;
  56761. thumbstick: string;
  56762. trackpad: string;
  56763. };
  56764. axisMeshNames: string[];
  56765. pointingPoseMeshName: string;
  56766. };
  56767. /**
  56768. * Construct a new XR-Based windows motion controller
  56769. *
  56770. * @param gamepadInfo the gamepad object from the browser
  56771. */
  56772. constructor(gamepadInfo: any);
  56773. /**
  56774. * holds the thumbstick values (X,Y)
  56775. */
  56776. thumbstickValues: StickValues;
  56777. /**
  56778. * Fired when the thumbstick on this controller is clicked
  56779. */
  56780. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  56781. /**
  56782. * Fired when the thumbstick on this controller is modified
  56783. */
  56784. onThumbstickValuesChangedObservable: Observable<StickValues>;
  56785. /**
  56786. * Fired when the touchpad button on this controller is modified
  56787. */
  56788. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56789. /**
  56790. * Fired when the touchpad values on this controller are modified
  56791. */
  56792. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56793. /**
  56794. * Fired when the thumbstick button on this controller is modified
  56795. * here to prevent breaking changes
  56796. */
  56797. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56798. /**
  56799. * updating the thumbstick(!) and not the trackpad.
  56800. * This is named this way due to the difference between WebVR and XR and to avoid
  56801. * changing the parent class.
  56802. */
  56803. protected _updateTrackpad(): void;
  56804. /**
  56805. * Disposes the class with joy
  56806. */
  56807. dispose(): void;
  56808. }
  56809. }
  56810. declare module BABYLON {
  56811. /**
  56812. * Class containing static functions to help procedurally build meshes
  56813. */
  56814. export class PolyhedronBuilder {
  56815. /**
  56816. * Creates a polyhedron mesh
  56817. * * 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
  56818. * * The parameter `size` (positive float, default 1) sets the polygon size
  56819. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56820. * * 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`
  56821. * * 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
  56822. * * 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)`)
  56823. * * 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
  56824. * * 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
  56825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56826. * * 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
  56827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56828. * @param name defines the name of the mesh
  56829. * @param options defines the options used to create the mesh
  56830. * @param scene defines the hosting scene
  56831. * @returns the polyhedron mesh
  56832. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56833. */
  56834. static CreatePolyhedron(name: string, options: {
  56835. type?: number;
  56836. size?: number;
  56837. sizeX?: number;
  56838. sizeY?: number;
  56839. sizeZ?: number;
  56840. custom?: any;
  56841. faceUV?: Vector4[];
  56842. faceColors?: Color4[];
  56843. flat?: boolean;
  56844. updatable?: boolean;
  56845. sideOrientation?: number;
  56846. frontUVs?: Vector4;
  56847. backUVs?: Vector4;
  56848. }, scene?: Nullable<Scene>): Mesh;
  56849. }
  56850. }
  56851. declare module BABYLON {
  56852. /**
  56853. * Gizmo that enables scaling a mesh along 3 axis
  56854. */
  56855. export class ScaleGizmo extends Gizmo {
  56856. /**
  56857. * Internal gizmo used for interactions on the x axis
  56858. */
  56859. xGizmo: AxisScaleGizmo;
  56860. /**
  56861. * Internal gizmo used for interactions on the y axis
  56862. */
  56863. yGizmo: AxisScaleGizmo;
  56864. /**
  56865. * Internal gizmo used for interactions on the z axis
  56866. */
  56867. zGizmo: AxisScaleGizmo;
  56868. /**
  56869. * Internal gizmo used to scale all axis equally
  56870. */
  56871. uniformScaleGizmo: AxisScaleGizmo;
  56872. private _meshAttached;
  56873. private _nodeAttached;
  56874. private _snapDistance;
  56875. private _uniformScalingMesh;
  56876. private _octahedron;
  56877. private _sensitivity;
  56878. /** Fires an event when any of it's sub gizmos are dragged */
  56879. onDragStartObservable: Observable<unknown>;
  56880. /** Fires an event when any of it's sub gizmos are released from dragging */
  56881. onDragEndObservable: Observable<unknown>;
  56882. get attachedMesh(): Nullable<AbstractMesh>;
  56883. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56884. get attachedNode(): Nullable<Node>;
  56885. set attachedNode(node: Nullable<Node>);
  56886. /**
  56887. * True when the mouse pointer is hovering a gizmo mesh
  56888. */
  56889. get isHovered(): boolean;
  56890. /**
  56891. * Creates a ScaleGizmo
  56892. * @param gizmoLayer The utility layer the gizmo will be added to
  56893. * @param thickness display gizmo axis thickness
  56894. */
  56895. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56896. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56897. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56898. /**
  56899. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56900. */
  56901. set snapDistance(value: number);
  56902. get snapDistance(): number;
  56903. /**
  56904. * Ratio for the scale of the gizmo (Default: 1)
  56905. */
  56906. set scaleRatio(value: number);
  56907. get scaleRatio(): number;
  56908. /**
  56909. * Sensitivity factor for dragging (Default: 1)
  56910. */
  56911. set sensitivity(value: number);
  56912. get sensitivity(): number;
  56913. /**
  56914. * Disposes of the gizmo
  56915. */
  56916. dispose(): void;
  56917. }
  56918. }
  56919. declare module BABYLON {
  56920. /**
  56921. * Single axis scale gizmo
  56922. */
  56923. export class AxisScaleGizmo extends Gizmo {
  56924. /**
  56925. * Drag behavior responsible for the gizmos dragging interactions
  56926. */
  56927. dragBehavior: PointerDragBehavior;
  56928. private _pointerObserver;
  56929. /**
  56930. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56931. */
  56932. snapDistance: number;
  56933. /**
  56934. * Event that fires each time the gizmo snaps to a new location.
  56935. * * snapDistance is the the change in distance
  56936. */
  56937. onSnapObservable: Observable<{
  56938. snapDistance: number;
  56939. }>;
  56940. /**
  56941. * If the scaling operation should be done on all axis (default: false)
  56942. */
  56943. uniformScaling: boolean;
  56944. /**
  56945. * Custom sensitivity value for the drag strength
  56946. */
  56947. sensitivity: number;
  56948. private _isEnabled;
  56949. private _parent;
  56950. private _arrow;
  56951. private _coloredMaterial;
  56952. private _hoverMaterial;
  56953. /**
  56954. * Creates an AxisScaleGizmo
  56955. * @param gizmoLayer The utility layer the gizmo will be added to
  56956. * @param dragAxis The axis which the gizmo will be able to scale on
  56957. * @param color The color of the gizmo
  56958. * @param thickness display gizmo axis thickness
  56959. */
  56960. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56961. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56962. /**
  56963. * If the gizmo is enabled
  56964. */
  56965. set isEnabled(value: boolean);
  56966. get isEnabled(): boolean;
  56967. /**
  56968. * Disposes of the gizmo
  56969. */
  56970. dispose(): void;
  56971. /**
  56972. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56973. * @param mesh The mesh to replace the default mesh of the gizmo
  56974. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56975. */
  56976. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56977. }
  56978. }
  56979. declare module BABYLON {
  56980. /**
  56981. * Bounding box gizmo
  56982. */
  56983. export class BoundingBoxGizmo extends Gizmo {
  56984. private _lineBoundingBox;
  56985. private _rotateSpheresParent;
  56986. private _scaleBoxesParent;
  56987. private _boundingDimensions;
  56988. private _renderObserver;
  56989. private _pointerObserver;
  56990. private _scaleDragSpeed;
  56991. private _tmpQuaternion;
  56992. private _tmpVector;
  56993. private _tmpRotationMatrix;
  56994. /**
  56995. * 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)
  56996. */
  56997. ignoreChildren: boolean;
  56998. /**
  56999. * 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)
  57000. */
  57001. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  57002. /**
  57003. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  57004. */
  57005. rotationSphereSize: number;
  57006. /**
  57007. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  57008. */
  57009. scaleBoxSize: number;
  57010. /**
  57011. * 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)
  57012. */
  57013. fixedDragMeshScreenSize: boolean;
  57014. /**
  57015. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  57016. */
  57017. fixedDragMeshScreenSizeDistanceFactor: number;
  57018. /**
  57019. * Fired when a rotation sphere or scale box is dragged
  57020. */
  57021. onDragStartObservable: Observable<{}>;
  57022. /**
  57023. * Fired when a scale box is dragged
  57024. */
  57025. onScaleBoxDragObservable: Observable<{}>;
  57026. /**
  57027. * Fired when a scale box drag is ended
  57028. */
  57029. onScaleBoxDragEndObservable: Observable<{}>;
  57030. /**
  57031. * Fired when a rotation sphere is dragged
  57032. */
  57033. onRotationSphereDragObservable: Observable<{}>;
  57034. /**
  57035. * Fired when a rotation sphere drag is ended
  57036. */
  57037. onRotationSphereDragEndObservable: Observable<{}>;
  57038. /**
  57039. * 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)
  57040. */
  57041. scalePivot: Nullable<Vector3>;
  57042. /**
  57043. * Mesh used as a pivot to rotate the attached node
  57044. */
  57045. private _anchorMesh;
  57046. private _existingMeshScale;
  57047. private _dragMesh;
  57048. private pointerDragBehavior;
  57049. private coloredMaterial;
  57050. private hoverColoredMaterial;
  57051. /**
  57052. * Sets the color of the bounding box gizmo
  57053. * @param color the color to set
  57054. */
  57055. setColor(color: Color3): void;
  57056. /**
  57057. * Creates an BoundingBoxGizmo
  57058. * @param gizmoLayer The utility layer the gizmo will be added to
  57059. * @param color The color of the gizmo
  57060. */
  57061. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57062. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57063. private _selectNode;
  57064. /**
  57065. * Updates the bounding box information for the Gizmo
  57066. */
  57067. updateBoundingBox(): void;
  57068. private _updateRotationSpheres;
  57069. private _updateScaleBoxes;
  57070. /**
  57071. * Enables rotation on the specified axis and disables rotation on the others
  57072. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57073. */
  57074. setEnabledRotationAxis(axis: string): void;
  57075. /**
  57076. * Enables/disables scaling
  57077. * @param enable if scaling should be enabled
  57078. * @param homogeneousScaling defines if scaling should only be homogeneous
  57079. */
  57080. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57081. private _updateDummy;
  57082. /**
  57083. * Enables a pointer drag behavior on the bounding box of the gizmo
  57084. */
  57085. enableDragBehavior(): void;
  57086. /**
  57087. * Disposes of the gizmo
  57088. */
  57089. dispose(): void;
  57090. /**
  57091. * 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)
  57092. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57093. * @returns the bounding box mesh with the passed in mesh as a child
  57094. */
  57095. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57096. /**
  57097. * CustomMeshes are not supported by this gizmo
  57098. * @param mesh The mesh to replace the default mesh of the gizmo
  57099. */
  57100. setCustomMesh(mesh: Mesh): void;
  57101. }
  57102. }
  57103. declare module BABYLON {
  57104. /**
  57105. * Single plane rotation gizmo
  57106. */
  57107. export class PlaneRotationGizmo extends Gizmo {
  57108. /**
  57109. * Drag behavior responsible for the gizmos dragging interactions
  57110. */
  57111. dragBehavior: PointerDragBehavior;
  57112. private _pointerObserver;
  57113. /**
  57114. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57115. */
  57116. snapDistance: number;
  57117. /**
  57118. * Event that fires each time the gizmo snaps to a new location.
  57119. * * snapDistance is the the change in distance
  57120. */
  57121. onSnapObservable: Observable<{
  57122. snapDistance: number;
  57123. }>;
  57124. private _isEnabled;
  57125. private _parent;
  57126. /**
  57127. * Creates a PlaneRotationGizmo
  57128. * @param gizmoLayer The utility layer the gizmo will be added to
  57129. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57130. * @param color The color of the gizmo
  57131. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57132. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57133. * @param thickness display gizmo axis thickness
  57134. */
  57135. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57136. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57137. /**
  57138. * If the gizmo is enabled
  57139. */
  57140. set isEnabled(value: boolean);
  57141. get isEnabled(): boolean;
  57142. /**
  57143. * Disposes of the gizmo
  57144. */
  57145. dispose(): void;
  57146. }
  57147. }
  57148. declare module BABYLON {
  57149. /**
  57150. * Gizmo that enables rotating a mesh along 3 axis
  57151. */
  57152. export class RotationGizmo extends Gizmo {
  57153. /**
  57154. * Internal gizmo used for interactions on the x axis
  57155. */
  57156. xGizmo: PlaneRotationGizmo;
  57157. /**
  57158. * Internal gizmo used for interactions on the y axis
  57159. */
  57160. yGizmo: PlaneRotationGizmo;
  57161. /**
  57162. * Internal gizmo used for interactions on the z axis
  57163. */
  57164. zGizmo: PlaneRotationGizmo;
  57165. /** Fires an event when any of it's sub gizmos are dragged */
  57166. onDragStartObservable: Observable<unknown>;
  57167. /** Fires an event when any of it's sub gizmos are released from dragging */
  57168. onDragEndObservable: Observable<unknown>;
  57169. private _meshAttached;
  57170. private _nodeAttached;
  57171. get attachedMesh(): Nullable<AbstractMesh>;
  57172. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57173. get attachedNode(): Nullable<Node>;
  57174. set attachedNode(node: Nullable<Node>);
  57175. protected _checkBillboardTransform(): void;
  57176. /**
  57177. * True when the mouse pointer is hovering a gizmo mesh
  57178. */
  57179. get isHovered(): boolean;
  57180. /**
  57181. * Creates a RotationGizmo
  57182. * @param gizmoLayer The utility layer the gizmo will be added to
  57183. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57184. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57185. * @param thickness display gizmo axis thickness
  57186. */
  57187. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  57188. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57189. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57190. /**
  57191. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57192. */
  57193. set snapDistance(value: number);
  57194. get snapDistance(): number;
  57195. /**
  57196. * Ratio for the scale of the gizmo (Default: 1)
  57197. */
  57198. set scaleRatio(value: number);
  57199. get scaleRatio(): number;
  57200. /**
  57201. * Disposes of the gizmo
  57202. */
  57203. dispose(): void;
  57204. /**
  57205. * CustomMeshes are not supported by this gizmo
  57206. * @param mesh The mesh to replace the default mesh of the gizmo
  57207. */
  57208. setCustomMesh(mesh: Mesh): void;
  57209. }
  57210. }
  57211. declare module BABYLON {
  57212. /**
  57213. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57214. */
  57215. export class GizmoManager implements IDisposable {
  57216. private scene;
  57217. /**
  57218. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57219. */
  57220. gizmos: {
  57221. positionGizmo: Nullable<PositionGizmo>;
  57222. rotationGizmo: Nullable<RotationGizmo>;
  57223. scaleGizmo: Nullable<ScaleGizmo>;
  57224. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57225. };
  57226. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57227. clearGizmoOnEmptyPointerEvent: boolean;
  57228. /** Fires an event when the manager is attached to a mesh */
  57229. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57230. /** Fires an event when the manager is attached to a node */
  57231. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57232. private _gizmosEnabled;
  57233. private _pointerObserver;
  57234. private _attachedMesh;
  57235. private _attachedNode;
  57236. private _boundingBoxColor;
  57237. private _defaultUtilityLayer;
  57238. private _defaultKeepDepthUtilityLayer;
  57239. private _thickness;
  57240. /**
  57241. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57242. */
  57243. boundingBoxDragBehavior: SixDofDragBehavior;
  57244. /**
  57245. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57246. */
  57247. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57248. /**
  57249. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57250. */
  57251. attachableNodes: Nullable<Array<Node>>;
  57252. /**
  57253. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57254. */
  57255. usePointerToAttachGizmos: boolean;
  57256. /**
  57257. * Utility layer that the bounding box gizmo belongs to
  57258. */
  57259. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57260. /**
  57261. * Utility layer that all gizmos besides bounding box belong to
  57262. */
  57263. get utilityLayer(): UtilityLayerRenderer;
  57264. /**
  57265. * True when the mouse pointer is hovering a gizmo mesh
  57266. */
  57267. get isHovered(): boolean;
  57268. /**
  57269. * Instatiates a gizmo manager
  57270. * @param scene the scene to overlay the gizmos on top of
  57271. * @param thickness display gizmo axis thickness
  57272. */
  57273. constructor(scene: Scene, thickness?: number);
  57274. /**
  57275. * Attaches a set of gizmos to the specified mesh
  57276. * @param mesh The mesh the gizmo's should be attached to
  57277. */
  57278. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57279. /**
  57280. * Attaches a set of gizmos to the specified node
  57281. * @param node The node the gizmo's should be attached to
  57282. */
  57283. attachToNode(node: Nullable<Node>): void;
  57284. /**
  57285. * If the position gizmo is enabled
  57286. */
  57287. set positionGizmoEnabled(value: boolean);
  57288. get positionGizmoEnabled(): boolean;
  57289. /**
  57290. * If the rotation gizmo is enabled
  57291. */
  57292. set rotationGizmoEnabled(value: boolean);
  57293. get rotationGizmoEnabled(): boolean;
  57294. /**
  57295. * If the scale gizmo is enabled
  57296. */
  57297. set scaleGizmoEnabled(value: boolean);
  57298. get scaleGizmoEnabled(): boolean;
  57299. /**
  57300. * If the boundingBox gizmo is enabled
  57301. */
  57302. set boundingBoxGizmoEnabled(value: boolean);
  57303. get boundingBoxGizmoEnabled(): boolean;
  57304. /**
  57305. * Disposes of the gizmo manager
  57306. */
  57307. dispose(): void;
  57308. }
  57309. }
  57310. declare module BABYLON {
  57311. /**
  57312. * A directional light is defined by a direction (what a surprise!).
  57313. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57314. * 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.
  57315. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57316. */
  57317. export class DirectionalLight extends ShadowLight {
  57318. private _shadowFrustumSize;
  57319. /**
  57320. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57321. */
  57322. get shadowFrustumSize(): number;
  57323. /**
  57324. * Specifies a fix frustum size for the shadow generation.
  57325. */
  57326. set shadowFrustumSize(value: number);
  57327. private _shadowOrthoScale;
  57328. /**
  57329. * Gets the shadow projection scale against the optimal computed one.
  57330. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57331. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57332. */
  57333. get shadowOrthoScale(): number;
  57334. /**
  57335. * Sets the shadow projection scale against the optimal computed one.
  57336. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57337. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57338. */
  57339. set shadowOrthoScale(value: number);
  57340. /**
  57341. * Automatically compute the projection matrix to best fit (including all the casters)
  57342. * on each frame.
  57343. */
  57344. autoUpdateExtends: boolean;
  57345. /**
  57346. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57347. * on each frame. autoUpdateExtends must be set to true for this to work
  57348. */
  57349. autoCalcShadowZBounds: boolean;
  57350. private _orthoLeft;
  57351. private _orthoRight;
  57352. private _orthoTop;
  57353. private _orthoBottom;
  57354. /**
  57355. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57356. * The directional light is emitted from everywhere in the given direction.
  57357. * It can cast shadows.
  57358. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57359. * @param name The friendly name of the light
  57360. * @param direction The direction of the light
  57361. * @param scene The scene the light belongs to
  57362. */
  57363. constructor(name: string, direction: Vector3, scene: Scene);
  57364. /**
  57365. * Returns the string "DirectionalLight".
  57366. * @return The class name
  57367. */
  57368. getClassName(): string;
  57369. /**
  57370. * Returns the integer 1.
  57371. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57372. */
  57373. getTypeID(): number;
  57374. /**
  57375. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57376. * Returns the DirectionalLight Shadow projection matrix.
  57377. */
  57378. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57379. /**
  57380. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57381. * Returns the DirectionalLight Shadow projection matrix.
  57382. */
  57383. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57384. /**
  57385. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57386. * Returns the DirectionalLight Shadow projection matrix.
  57387. */
  57388. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57389. protected _buildUniformLayout(): void;
  57390. /**
  57391. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57392. * @param effect The effect to update
  57393. * @param lightIndex The index of the light in the effect to update
  57394. * @returns The directional light
  57395. */
  57396. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57397. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57398. /**
  57399. * Gets the minZ used for shadow according to both the scene and the light.
  57400. *
  57401. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57402. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57403. * @param activeCamera The camera we are returning the min for
  57404. * @returns the depth min z
  57405. */
  57406. getDepthMinZ(activeCamera: Camera): number;
  57407. /**
  57408. * Gets the maxZ used for shadow according to both the scene and the light.
  57409. *
  57410. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57411. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57412. * @param activeCamera The camera we are returning the max for
  57413. * @returns the depth max z
  57414. */
  57415. getDepthMaxZ(activeCamera: Camera): number;
  57416. /**
  57417. * Prepares the list of defines specific to the light type.
  57418. * @param defines the list of defines
  57419. * @param lightIndex defines the index of the light for the effect
  57420. */
  57421. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57422. }
  57423. }
  57424. declare module BABYLON {
  57425. /**
  57426. * Class containing static functions to help procedurally build meshes
  57427. */
  57428. export class HemisphereBuilder {
  57429. /**
  57430. * Creates a hemisphere mesh
  57431. * @param name defines the name of the mesh
  57432. * @param options defines the options used to create the mesh
  57433. * @param scene defines the hosting scene
  57434. * @returns the hemisphere mesh
  57435. */
  57436. static CreateHemisphere(name: string, options: {
  57437. segments?: number;
  57438. diameter?: number;
  57439. sideOrientation?: number;
  57440. }, scene: any): Mesh;
  57441. }
  57442. }
  57443. declare module BABYLON {
  57444. /**
  57445. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57446. * These values define a cone of light starting from the position, emitting toward the direction.
  57447. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57448. * and the exponent defines the speed of the decay of the light with distance (reach).
  57449. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57450. */
  57451. export class SpotLight extends ShadowLight {
  57452. private _angle;
  57453. private _innerAngle;
  57454. private _cosHalfAngle;
  57455. private _lightAngleScale;
  57456. private _lightAngleOffset;
  57457. /**
  57458. * Gets the cone angle of the spot light in Radians.
  57459. */
  57460. get angle(): number;
  57461. /**
  57462. * Sets the cone angle of the spot light in Radians.
  57463. */
  57464. set angle(value: number);
  57465. /**
  57466. * Only used in gltf falloff mode, this defines the angle where
  57467. * the directional falloff will start before cutting at angle which could be seen
  57468. * as outer angle.
  57469. */
  57470. get innerAngle(): number;
  57471. /**
  57472. * Only used in gltf falloff mode, this defines the angle where
  57473. * the directional falloff will start before cutting at angle which could be seen
  57474. * as outer angle.
  57475. */
  57476. set innerAngle(value: number);
  57477. private _shadowAngleScale;
  57478. /**
  57479. * Allows scaling the angle of the light for shadow generation only.
  57480. */
  57481. get shadowAngleScale(): number;
  57482. /**
  57483. * Allows scaling the angle of the light for shadow generation only.
  57484. */
  57485. set shadowAngleScale(value: number);
  57486. /**
  57487. * The light decay speed with the distance from the emission spot.
  57488. */
  57489. exponent: number;
  57490. private _projectionTextureMatrix;
  57491. /**
  57492. * Allows reading the projecton texture
  57493. */
  57494. get projectionTextureMatrix(): Matrix;
  57495. protected _projectionTextureLightNear: number;
  57496. /**
  57497. * Gets the near clip of the Spotlight for texture projection.
  57498. */
  57499. get projectionTextureLightNear(): number;
  57500. /**
  57501. * Sets the near clip of the Spotlight for texture projection.
  57502. */
  57503. set projectionTextureLightNear(value: number);
  57504. protected _projectionTextureLightFar: number;
  57505. /**
  57506. * Gets the far clip of the Spotlight for texture projection.
  57507. */
  57508. get projectionTextureLightFar(): number;
  57509. /**
  57510. * Sets the far clip of the Spotlight for texture projection.
  57511. */
  57512. set projectionTextureLightFar(value: number);
  57513. protected _projectionTextureUpDirection: Vector3;
  57514. /**
  57515. * Gets the Up vector of the Spotlight for texture projection.
  57516. */
  57517. get projectionTextureUpDirection(): Vector3;
  57518. /**
  57519. * Sets the Up vector of the Spotlight for texture projection.
  57520. */
  57521. set projectionTextureUpDirection(value: Vector3);
  57522. private _projectionTexture;
  57523. /**
  57524. * Gets the projection texture of the light.
  57525. */
  57526. get projectionTexture(): Nullable<BaseTexture>;
  57527. /**
  57528. * Sets the projection texture of the light.
  57529. */
  57530. set projectionTexture(value: Nullable<BaseTexture>);
  57531. private _projectionTextureViewLightDirty;
  57532. private _projectionTextureProjectionLightDirty;
  57533. private _projectionTextureDirty;
  57534. private _projectionTextureViewTargetVector;
  57535. private _projectionTextureViewLightMatrix;
  57536. private _projectionTextureProjectionLightMatrix;
  57537. private _projectionTextureScalingMatrix;
  57538. /**
  57539. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57540. * It can cast shadows.
  57541. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57542. * @param name The light friendly name
  57543. * @param position The position of the spot light in the scene
  57544. * @param direction The direction of the light in the scene
  57545. * @param angle The cone angle of the light in Radians
  57546. * @param exponent The light decay speed with the distance from the emission spot
  57547. * @param scene The scene the lights belongs to
  57548. */
  57549. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  57550. /**
  57551. * Returns the string "SpotLight".
  57552. * @returns the class name
  57553. */
  57554. getClassName(): string;
  57555. /**
  57556. * Returns the integer 2.
  57557. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57558. */
  57559. getTypeID(): number;
  57560. /**
  57561. * Overrides the direction setter to recompute the projection texture view light Matrix.
  57562. */
  57563. protected _setDirection(value: Vector3): void;
  57564. /**
  57565. * Overrides the position setter to recompute the projection texture view light Matrix.
  57566. */
  57567. protected _setPosition(value: Vector3): void;
  57568. /**
  57569. * 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.
  57570. * Returns the SpotLight.
  57571. */
  57572. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57573. protected _computeProjectionTextureViewLightMatrix(): void;
  57574. protected _computeProjectionTextureProjectionLightMatrix(): void;
  57575. /**
  57576. * Main function for light texture projection matrix computing.
  57577. */
  57578. protected _computeProjectionTextureMatrix(): void;
  57579. protected _buildUniformLayout(): void;
  57580. private _computeAngleValues;
  57581. /**
  57582. * Sets the passed Effect "effect" with the Light textures.
  57583. * @param effect The effect to update
  57584. * @param lightIndex The index of the light in the effect to update
  57585. * @returns The light
  57586. */
  57587. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  57588. /**
  57589. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  57590. * @param effect The effect to update
  57591. * @param lightIndex The index of the light in the effect to update
  57592. * @returns The spot light
  57593. */
  57594. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  57595. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57596. /**
  57597. * Disposes the light and the associated resources.
  57598. */
  57599. dispose(): void;
  57600. /**
  57601. * Prepares the list of defines specific to the light type.
  57602. * @param defines the list of defines
  57603. * @param lightIndex defines the index of the light for the effect
  57604. */
  57605. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57606. }
  57607. }
  57608. declare module BABYLON {
  57609. /**
  57610. * Gizmo that enables viewing a light
  57611. */
  57612. export class LightGizmo extends Gizmo {
  57613. private _lightMesh;
  57614. private _material;
  57615. private _cachedPosition;
  57616. private _cachedForward;
  57617. private _attachedMeshParent;
  57618. private _pointerObserver;
  57619. /**
  57620. * Event that fires each time the gizmo is clicked
  57621. */
  57622. onClickedObservable: Observable<Light>;
  57623. /**
  57624. * Creates a LightGizmo
  57625. * @param gizmoLayer The utility layer the gizmo will be added to
  57626. */
  57627. constructor(gizmoLayer?: UtilityLayerRenderer);
  57628. private _light;
  57629. /**
  57630. * The light that the gizmo is attached to
  57631. */
  57632. set light(light: Nullable<Light>);
  57633. get light(): Nullable<Light>;
  57634. /**
  57635. * Gets the material used to render the light gizmo
  57636. */
  57637. get material(): StandardMaterial;
  57638. /**
  57639. * @hidden
  57640. * Updates the gizmo to match the attached mesh's position/rotation
  57641. */
  57642. protected _update(): void;
  57643. private static _Scale;
  57644. /**
  57645. * Creates the lines for a light mesh
  57646. */
  57647. private static _CreateLightLines;
  57648. /**
  57649. * Disposes of the light gizmo
  57650. */
  57651. dispose(): void;
  57652. private static _CreateHemisphericLightMesh;
  57653. private static _CreatePointLightMesh;
  57654. private static _CreateSpotLightMesh;
  57655. private static _CreateDirectionalLightMesh;
  57656. }
  57657. }
  57658. declare module BABYLON {
  57659. /**
  57660. * Gizmo that enables viewing a camera
  57661. */
  57662. export class CameraGizmo extends Gizmo {
  57663. private _cameraMesh;
  57664. private _cameraLinesMesh;
  57665. private _material;
  57666. private _pointerObserver;
  57667. /**
  57668. * Event that fires each time the gizmo is clicked
  57669. */
  57670. onClickedObservable: Observable<Camera>;
  57671. /**
  57672. * Creates a CameraGizmo
  57673. * @param gizmoLayer The utility layer the gizmo will be added to
  57674. */
  57675. constructor(gizmoLayer?: UtilityLayerRenderer);
  57676. private _camera;
  57677. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  57678. get displayFrustum(): boolean;
  57679. set displayFrustum(value: boolean);
  57680. /**
  57681. * The camera that the gizmo is attached to
  57682. */
  57683. set camera(camera: Nullable<Camera>);
  57684. get camera(): Nullable<Camera>;
  57685. /**
  57686. * Gets the material used to render the camera gizmo
  57687. */
  57688. get material(): StandardMaterial;
  57689. /**
  57690. * @hidden
  57691. * Updates the gizmo to match the attached mesh's position/rotation
  57692. */
  57693. protected _update(): void;
  57694. private static _Scale;
  57695. private _invProjection;
  57696. /**
  57697. * Disposes of the camera gizmo
  57698. */
  57699. dispose(): void;
  57700. private static _CreateCameraMesh;
  57701. private static _CreateCameraFrustum;
  57702. }
  57703. }
  57704. declare module BABYLON {
  57705. /** @hidden */
  57706. export var backgroundFragmentDeclaration: {
  57707. name: string;
  57708. shader: string;
  57709. };
  57710. }
  57711. declare module BABYLON {
  57712. /** @hidden */
  57713. export var backgroundUboDeclaration: {
  57714. name: string;
  57715. shader: string;
  57716. };
  57717. }
  57718. declare module BABYLON {
  57719. /** @hidden */
  57720. export var backgroundPixelShader: {
  57721. name: string;
  57722. shader: string;
  57723. };
  57724. }
  57725. declare module BABYLON {
  57726. /** @hidden */
  57727. export var backgroundVertexDeclaration: {
  57728. name: string;
  57729. shader: string;
  57730. };
  57731. }
  57732. declare module BABYLON {
  57733. /** @hidden */
  57734. export var backgroundVertexShader: {
  57735. name: string;
  57736. shader: string;
  57737. };
  57738. }
  57739. declare module BABYLON {
  57740. /**
  57741. * Background material used to create an efficient environement around your scene.
  57742. */
  57743. export class BackgroundMaterial extends PushMaterial {
  57744. /**
  57745. * Standard reflectance value at parallel view angle.
  57746. */
  57747. static StandardReflectance0: number;
  57748. /**
  57749. * Standard reflectance value at grazing angle.
  57750. */
  57751. static StandardReflectance90: number;
  57752. protected _primaryColor: Color3;
  57753. /**
  57754. * Key light Color (multiply against the environement texture)
  57755. */
  57756. primaryColor: Color3;
  57757. protected __perceptualColor: Nullable<Color3>;
  57758. /**
  57759. * Experimental Internal Use Only.
  57760. *
  57761. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  57762. * This acts as a helper to set the primary color to a more "human friendly" value.
  57763. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  57764. * output color as close as possible from the chosen value.
  57765. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  57766. * part of lighting setup.)
  57767. */
  57768. get _perceptualColor(): Nullable<Color3>;
  57769. set _perceptualColor(value: Nullable<Color3>);
  57770. protected _primaryColorShadowLevel: float;
  57771. /**
  57772. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  57773. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  57774. */
  57775. get primaryColorShadowLevel(): float;
  57776. set primaryColorShadowLevel(value: float);
  57777. protected _primaryColorHighlightLevel: float;
  57778. /**
  57779. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  57780. * The primary color is used at the level chosen to define what the white area would look.
  57781. */
  57782. get primaryColorHighlightLevel(): float;
  57783. set primaryColorHighlightLevel(value: float);
  57784. protected _reflectionTexture: Nullable<BaseTexture>;
  57785. /**
  57786. * Reflection Texture used in the material.
  57787. * Should be author in a specific way for the best result (refer to the documentation).
  57788. */
  57789. reflectionTexture: Nullable<BaseTexture>;
  57790. protected _reflectionBlur: float;
  57791. /**
  57792. * Reflection Texture level of blur.
  57793. *
  57794. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  57795. * texture twice.
  57796. */
  57797. reflectionBlur: float;
  57798. protected _diffuseTexture: Nullable<BaseTexture>;
  57799. /**
  57800. * Diffuse Texture used in the material.
  57801. * Should be author in a specific way for the best result (refer to the documentation).
  57802. */
  57803. diffuseTexture: Nullable<BaseTexture>;
  57804. protected _shadowLights: Nullable<IShadowLight[]>;
  57805. /**
  57806. * Specify the list of lights casting shadow on the material.
  57807. * All scene shadow lights will be included if null.
  57808. */
  57809. shadowLights: Nullable<IShadowLight[]>;
  57810. protected _shadowLevel: float;
  57811. /**
  57812. * Helps adjusting the shadow to a softer level if required.
  57813. * 0 means black shadows and 1 means no shadows.
  57814. */
  57815. shadowLevel: float;
  57816. protected _sceneCenter: Vector3;
  57817. /**
  57818. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57819. * It is usually zero but might be interesting to modify according to your setup.
  57820. */
  57821. sceneCenter: Vector3;
  57822. protected _opacityFresnel: boolean;
  57823. /**
  57824. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57825. * This helps ensuring a nice transition when the camera goes under the ground.
  57826. */
  57827. opacityFresnel: boolean;
  57828. protected _reflectionFresnel: boolean;
  57829. /**
  57830. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57831. * This helps adding a mirror texture on the ground.
  57832. */
  57833. reflectionFresnel: boolean;
  57834. protected _reflectionFalloffDistance: number;
  57835. /**
  57836. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57837. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57838. */
  57839. reflectionFalloffDistance: number;
  57840. protected _reflectionAmount: number;
  57841. /**
  57842. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57843. */
  57844. reflectionAmount: number;
  57845. protected _reflectionReflectance0: number;
  57846. /**
  57847. * This specifies the weight of the reflection at grazing angle.
  57848. */
  57849. reflectionReflectance0: number;
  57850. protected _reflectionReflectance90: number;
  57851. /**
  57852. * This specifies the weight of the reflection at a perpendicular point of view.
  57853. */
  57854. reflectionReflectance90: number;
  57855. /**
  57856. * Sets the reflection reflectance fresnel values according to the default standard
  57857. * empirically know to work well :-)
  57858. */
  57859. set reflectionStandardFresnelWeight(value: number);
  57860. protected _useRGBColor: boolean;
  57861. /**
  57862. * Helps to directly use the maps channels instead of their level.
  57863. */
  57864. useRGBColor: boolean;
  57865. protected _enableNoise: boolean;
  57866. /**
  57867. * This helps reducing the banding effect that could occur on the background.
  57868. */
  57869. enableNoise: boolean;
  57870. /**
  57871. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57872. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57873. * Recommended to be keep at 1.0 except for special cases.
  57874. */
  57875. get fovMultiplier(): number;
  57876. set fovMultiplier(value: number);
  57877. private _fovMultiplier;
  57878. /**
  57879. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57880. */
  57881. useEquirectangularFOV: boolean;
  57882. private _maxSimultaneousLights;
  57883. /**
  57884. * Number of Simultaneous lights allowed on the material.
  57885. */
  57886. maxSimultaneousLights: int;
  57887. private _shadowOnly;
  57888. /**
  57889. * Make the material only render shadows
  57890. */
  57891. shadowOnly: boolean;
  57892. /**
  57893. * Default configuration related to image processing available in the Background Material.
  57894. */
  57895. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57896. /**
  57897. * Keep track of the image processing observer to allow dispose and replace.
  57898. */
  57899. private _imageProcessingObserver;
  57900. /**
  57901. * Attaches a new image processing configuration to the PBR Material.
  57902. * @param configuration (if null the scene configuration will be use)
  57903. */
  57904. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57905. /**
  57906. * Gets the image processing configuration used either in this material.
  57907. */
  57908. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57909. /**
  57910. * Sets the Default image processing configuration used either in the this material.
  57911. *
  57912. * If sets to null, the scene one is in use.
  57913. */
  57914. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57915. /**
  57916. * Gets wether the color curves effect is enabled.
  57917. */
  57918. get cameraColorCurvesEnabled(): boolean;
  57919. /**
  57920. * Sets wether the color curves effect is enabled.
  57921. */
  57922. set cameraColorCurvesEnabled(value: boolean);
  57923. /**
  57924. * Gets wether the color grading effect is enabled.
  57925. */
  57926. get cameraColorGradingEnabled(): boolean;
  57927. /**
  57928. * Gets wether the color grading effect is enabled.
  57929. */
  57930. set cameraColorGradingEnabled(value: boolean);
  57931. /**
  57932. * Gets wether tonemapping is enabled or not.
  57933. */
  57934. get cameraToneMappingEnabled(): boolean;
  57935. /**
  57936. * Sets wether tonemapping is enabled or not
  57937. */
  57938. set cameraToneMappingEnabled(value: boolean);
  57939. /**
  57940. * The camera exposure used on this material.
  57941. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57942. * This corresponds to a photographic exposure.
  57943. */
  57944. get cameraExposure(): float;
  57945. /**
  57946. * The camera exposure used on this material.
  57947. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57948. * This corresponds to a photographic exposure.
  57949. */
  57950. set cameraExposure(value: float);
  57951. /**
  57952. * Gets The camera contrast used on this material.
  57953. */
  57954. get cameraContrast(): float;
  57955. /**
  57956. * Sets The camera contrast used on this material.
  57957. */
  57958. set cameraContrast(value: float);
  57959. /**
  57960. * Gets the Color Grading 2D Lookup Texture.
  57961. */
  57962. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57963. /**
  57964. * Sets the Color Grading 2D Lookup Texture.
  57965. */
  57966. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57967. /**
  57968. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57969. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57970. * 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;
  57971. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57972. */
  57973. get cameraColorCurves(): Nullable<ColorCurves>;
  57974. /**
  57975. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57976. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57977. * 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;
  57978. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57979. */
  57980. set cameraColorCurves(value: Nullable<ColorCurves>);
  57981. /**
  57982. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57983. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57984. */
  57985. switchToBGR: boolean;
  57986. private _renderTargets;
  57987. private _reflectionControls;
  57988. private _white;
  57989. private _primaryShadowColor;
  57990. private _primaryHighlightColor;
  57991. /**
  57992. * Instantiates a Background Material in the given scene
  57993. * @param name The friendly name of the material
  57994. * @param scene The scene to add the material to
  57995. */
  57996. constructor(name: string, scene: Scene);
  57997. /**
  57998. * Gets a boolean indicating that current material needs to register RTT
  57999. */
  58000. get hasRenderTargetTextures(): boolean;
  58001. /**
  58002. * The entire material has been created in order to prevent overdraw.
  58003. * @returns false
  58004. */
  58005. needAlphaTesting(): boolean;
  58006. /**
  58007. * The entire material has been created in order to prevent overdraw.
  58008. * @returns true if blending is enable
  58009. */
  58010. needAlphaBlending(): boolean;
  58011. /**
  58012. * Checks wether the material is ready to be rendered for a given mesh.
  58013. * @param mesh The mesh to render
  58014. * @param subMesh The submesh to check against
  58015. * @param useInstances Specify wether or not the material is used with instances
  58016. * @returns true if all the dependencies are ready (Textures, Effects...)
  58017. */
  58018. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58019. /**
  58020. * Compute the primary color according to the chosen perceptual color.
  58021. */
  58022. private _computePrimaryColorFromPerceptualColor;
  58023. /**
  58024. * Compute the highlights and shadow colors according to their chosen levels.
  58025. */
  58026. private _computePrimaryColors;
  58027. /**
  58028. * Build the uniform buffer used in the material.
  58029. */
  58030. buildUniformLayout(): void;
  58031. /**
  58032. * Unbind the material.
  58033. */
  58034. unbind(): void;
  58035. /**
  58036. * Bind only the world matrix to the material.
  58037. * @param world The world matrix to bind.
  58038. */
  58039. bindOnlyWorldMatrix(world: Matrix): void;
  58040. /**
  58041. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  58042. * @param world The world matrix to bind.
  58043. * @param subMesh The submesh to bind for.
  58044. */
  58045. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58046. /**
  58047. * Checks to see if a texture is used in the material.
  58048. * @param texture - Base texture to use.
  58049. * @returns - Boolean specifying if a texture is used in the material.
  58050. */
  58051. hasTexture(texture: BaseTexture): boolean;
  58052. /**
  58053. * Dispose the material.
  58054. * @param forceDisposeEffect Force disposal of the associated effect.
  58055. * @param forceDisposeTextures Force disposal of the associated textures.
  58056. */
  58057. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58058. /**
  58059. * Clones the material.
  58060. * @param name The cloned name.
  58061. * @returns The cloned material.
  58062. */
  58063. clone(name: string): BackgroundMaterial;
  58064. /**
  58065. * Serializes the current material to its JSON representation.
  58066. * @returns The JSON representation.
  58067. */
  58068. serialize(): any;
  58069. /**
  58070. * Gets the class name of the material
  58071. * @returns "BackgroundMaterial"
  58072. */
  58073. getClassName(): string;
  58074. /**
  58075. * Parse a JSON input to create back a background material.
  58076. * @param source The JSON data to parse
  58077. * @param scene The scene to create the parsed material in
  58078. * @param rootUrl The root url of the assets the material depends upon
  58079. * @returns the instantiated BackgroundMaterial.
  58080. */
  58081. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  58082. }
  58083. }
  58084. declare module BABYLON {
  58085. /**
  58086. * Represents the different options available during the creation of
  58087. * a Environment helper.
  58088. *
  58089. * This can control the default ground, skybox and image processing setup of your scene.
  58090. */
  58091. export interface IEnvironmentHelperOptions {
  58092. /**
  58093. * Specifies whether or not to create a ground.
  58094. * True by default.
  58095. */
  58096. createGround: boolean;
  58097. /**
  58098. * Specifies the ground size.
  58099. * 15 by default.
  58100. */
  58101. groundSize: number;
  58102. /**
  58103. * The texture used on the ground for the main color.
  58104. * Comes from the BabylonJS CDN by default.
  58105. *
  58106. * Remarks: Can be either a texture or a url.
  58107. */
  58108. groundTexture: string | BaseTexture;
  58109. /**
  58110. * The color mixed in the ground texture by default.
  58111. * BabylonJS clearColor by default.
  58112. */
  58113. groundColor: Color3;
  58114. /**
  58115. * Specifies the ground opacity.
  58116. * 1 by default.
  58117. */
  58118. groundOpacity: number;
  58119. /**
  58120. * Enables the ground to receive shadows.
  58121. * True by default.
  58122. */
  58123. enableGroundShadow: boolean;
  58124. /**
  58125. * Helps preventing the shadow to be fully black on the ground.
  58126. * 0.5 by default.
  58127. */
  58128. groundShadowLevel: number;
  58129. /**
  58130. * Creates a mirror texture attach to the ground.
  58131. * false by default.
  58132. */
  58133. enableGroundMirror: boolean;
  58134. /**
  58135. * Specifies the ground mirror size ratio.
  58136. * 0.3 by default as the default kernel is 64.
  58137. */
  58138. groundMirrorSizeRatio: number;
  58139. /**
  58140. * Specifies the ground mirror blur kernel size.
  58141. * 64 by default.
  58142. */
  58143. groundMirrorBlurKernel: number;
  58144. /**
  58145. * Specifies the ground mirror visibility amount.
  58146. * 1 by default
  58147. */
  58148. groundMirrorAmount: number;
  58149. /**
  58150. * Specifies the ground mirror reflectance weight.
  58151. * This uses the standard weight of the background material to setup the fresnel effect
  58152. * of the mirror.
  58153. * 1 by default.
  58154. */
  58155. groundMirrorFresnelWeight: number;
  58156. /**
  58157. * Specifies the ground mirror Falloff distance.
  58158. * This can helps reducing the size of the reflection.
  58159. * 0 by Default.
  58160. */
  58161. groundMirrorFallOffDistance: number;
  58162. /**
  58163. * Specifies the ground mirror texture type.
  58164. * Unsigned Int by Default.
  58165. */
  58166. groundMirrorTextureType: number;
  58167. /**
  58168. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  58169. * the shown objects.
  58170. */
  58171. groundYBias: number;
  58172. /**
  58173. * Specifies whether or not to create a skybox.
  58174. * True by default.
  58175. */
  58176. createSkybox: boolean;
  58177. /**
  58178. * Specifies the skybox size.
  58179. * 20 by default.
  58180. */
  58181. skyboxSize: number;
  58182. /**
  58183. * The texture used on the skybox for the main color.
  58184. * Comes from the BabylonJS CDN by default.
  58185. *
  58186. * Remarks: Can be either a texture or a url.
  58187. */
  58188. skyboxTexture: string | BaseTexture;
  58189. /**
  58190. * The color mixed in the skybox texture by default.
  58191. * BabylonJS clearColor by default.
  58192. */
  58193. skyboxColor: Color3;
  58194. /**
  58195. * The background rotation around the Y axis of the scene.
  58196. * This helps aligning the key lights of your scene with the background.
  58197. * 0 by default.
  58198. */
  58199. backgroundYRotation: number;
  58200. /**
  58201. * Compute automatically the size of the elements to best fit with the scene.
  58202. */
  58203. sizeAuto: boolean;
  58204. /**
  58205. * Default position of the rootMesh if autoSize is not true.
  58206. */
  58207. rootPosition: Vector3;
  58208. /**
  58209. * Sets up the image processing in the scene.
  58210. * true by default.
  58211. */
  58212. setupImageProcessing: boolean;
  58213. /**
  58214. * The texture used as your environment texture in the scene.
  58215. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  58216. *
  58217. * Remarks: Can be either a texture or a url.
  58218. */
  58219. environmentTexture: string | BaseTexture;
  58220. /**
  58221. * The value of the exposure to apply to the scene.
  58222. * 0.6 by default if setupImageProcessing is true.
  58223. */
  58224. cameraExposure: number;
  58225. /**
  58226. * The value of the contrast to apply to the scene.
  58227. * 1.6 by default if setupImageProcessing is true.
  58228. */
  58229. cameraContrast: number;
  58230. /**
  58231. * Specifies whether or not tonemapping should be enabled in the scene.
  58232. * true by default if setupImageProcessing is true.
  58233. */
  58234. toneMappingEnabled: boolean;
  58235. }
  58236. /**
  58237. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  58238. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  58239. * It also helps with the default setup of your imageProcessing configuration.
  58240. */
  58241. export class EnvironmentHelper {
  58242. /**
  58243. * Default ground texture URL.
  58244. */
  58245. private static _groundTextureCDNUrl;
  58246. /**
  58247. * Default skybox texture URL.
  58248. */
  58249. private static _skyboxTextureCDNUrl;
  58250. /**
  58251. * Default environment texture URL.
  58252. */
  58253. private static _environmentTextureCDNUrl;
  58254. /**
  58255. * Creates the default options for the helper.
  58256. */
  58257. private static _getDefaultOptions;
  58258. private _rootMesh;
  58259. /**
  58260. * Gets the root mesh created by the helper.
  58261. */
  58262. get rootMesh(): Mesh;
  58263. private _skybox;
  58264. /**
  58265. * Gets the skybox created by the helper.
  58266. */
  58267. get skybox(): Nullable<Mesh>;
  58268. private _skyboxTexture;
  58269. /**
  58270. * Gets the skybox texture created by the helper.
  58271. */
  58272. get skyboxTexture(): Nullable<BaseTexture>;
  58273. private _skyboxMaterial;
  58274. /**
  58275. * Gets the skybox material created by the helper.
  58276. */
  58277. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58278. private _ground;
  58279. /**
  58280. * Gets the ground mesh created by the helper.
  58281. */
  58282. get ground(): Nullable<Mesh>;
  58283. private _groundTexture;
  58284. /**
  58285. * Gets the ground texture created by the helper.
  58286. */
  58287. get groundTexture(): Nullable<BaseTexture>;
  58288. private _groundMirror;
  58289. /**
  58290. * Gets the ground mirror created by the helper.
  58291. */
  58292. get groundMirror(): Nullable<MirrorTexture>;
  58293. /**
  58294. * Gets the ground mirror render list to helps pushing the meshes
  58295. * you wish in the ground reflection.
  58296. */
  58297. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58298. private _groundMaterial;
  58299. /**
  58300. * Gets the ground material created by the helper.
  58301. */
  58302. get groundMaterial(): Nullable<BackgroundMaterial>;
  58303. /**
  58304. * Stores the creation options.
  58305. */
  58306. private readonly _scene;
  58307. private _options;
  58308. /**
  58309. * This observable will be notified with any error during the creation of the environment,
  58310. * mainly texture creation errors.
  58311. */
  58312. onErrorObservable: Observable<{
  58313. message?: string;
  58314. exception?: any;
  58315. }>;
  58316. /**
  58317. * constructor
  58318. * @param options Defines the options we want to customize the helper
  58319. * @param scene The scene to add the material to
  58320. */
  58321. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58322. /**
  58323. * Updates the background according to the new options
  58324. * @param options
  58325. */
  58326. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58327. /**
  58328. * Sets the primary color of all the available elements.
  58329. * @param color the main color to affect to the ground and the background
  58330. */
  58331. setMainColor(color: Color3): void;
  58332. /**
  58333. * Setup the image processing according to the specified options.
  58334. */
  58335. private _setupImageProcessing;
  58336. /**
  58337. * Setup the environment texture according to the specified options.
  58338. */
  58339. private _setupEnvironmentTexture;
  58340. /**
  58341. * Setup the background according to the specified options.
  58342. */
  58343. private _setupBackground;
  58344. /**
  58345. * Get the scene sizes according to the setup.
  58346. */
  58347. private _getSceneSize;
  58348. /**
  58349. * Setup the ground according to the specified options.
  58350. */
  58351. private _setupGround;
  58352. /**
  58353. * Setup the ground material according to the specified options.
  58354. */
  58355. private _setupGroundMaterial;
  58356. /**
  58357. * Setup the ground diffuse texture according to the specified options.
  58358. */
  58359. private _setupGroundDiffuseTexture;
  58360. /**
  58361. * Setup the ground mirror texture according to the specified options.
  58362. */
  58363. private _setupGroundMirrorTexture;
  58364. /**
  58365. * Setup the ground to receive the mirror texture.
  58366. */
  58367. private _setupMirrorInGroundMaterial;
  58368. /**
  58369. * Setup the skybox according to the specified options.
  58370. */
  58371. private _setupSkybox;
  58372. /**
  58373. * Setup the skybox material according to the specified options.
  58374. */
  58375. private _setupSkyboxMaterial;
  58376. /**
  58377. * Setup the skybox reflection texture according to the specified options.
  58378. */
  58379. private _setupSkyboxReflectionTexture;
  58380. private _errorHandler;
  58381. /**
  58382. * Dispose all the elements created by the Helper.
  58383. */
  58384. dispose(): void;
  58385. }
  58386. }
  58387. declare module BABYLON {
  58388. /**
  58389. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58390. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58391. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58392. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58393. */
  58394. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58395. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58396. /**
  58397. * Define the source as a Monoscopic panoramic 360/180.
  58398. */
  58399. static readonly MODE_MONOSCOPIC: number;
  58400. /**
  58401. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58402. */
  58403. static readonly MODE_TOPBOTTOM: number;
  58404. /**
  58405. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58406. */
  58407. static readonly MODE_SIDEBYSIDE: number;
  58408. private _halfDome;
  58409. private _crossEye;
  58410. protected _useDirectMapping: boolean;
  58411. /**
  58412. * The texture being displayed on the sphere
  58413. */
  58414. protected _texture: T;
  58415. /**
  58416. * Gets the texture being displayed on the sphere
  58417. */
  58418. get texture(): T;
  58419. /**
  58420. * Sets the texture being displayed on the sphere
  58421. */
  58422. set texture(newTexture: T);
  58423. /**
  58424. * The skybox material
  58425. */
  58426. protected _material: BackgroundMaterial;
  58427. /**
  58428. * The surface used for the dome
  58429. */
  58430. protected _mesh: Mesh;
  58431. /**
  58432. * Gets the mesh used for the dome.
  58433. */
  58434. get mesh(): Mesh;
  58435. /**
  58436. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58437. */
  58438. private _halfDomeMask;
  58439. /**
  58440. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58441. * Also see the options.resolution property.
  58442. */
  58443. get fovMultiplier(): number;
  58444. set fovMultiplier(value: number);
  58445. protected _textureMode: number;
  58446. /**
  58447. * Gets or set the current texture mode for the texture. It can be:
  58448. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58449. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58450. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58451. */
  58452. get textureMode(): number;
  58453. /**
  58454. * Sets the current texture mode for the texture. It can be:
  58455. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58456. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58457. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58458. */
  58459. set textureMode(value: number);
  58460. /**
  58461. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58462. */
  58463. get halfDome(): boolean;
  58464. /**
  58465. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58466. */
  58467. set halfDome(enabled: boolean);
  58468. /**
  58469. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58470. */
  58471. set crossEye(enabled: boolean);
  58472. /**
  58473. * Is it a cross-eye texture?
  58474. */
  58475. get crossEye(): boolean;
  58476. /**
  58477. * The background material of this dome.
  58478. */
  58479. get material(): BackgroundMaterial;
  58480. /**
  58481. * Oberserver used in Stereoscopic VR Mode.
  58482. */
  58483. private _onBeforeCameraRenderObserver;
  58484. /**
  58485. * Observable raised when an error occured while loading the 360 image
  58486. */
  58487. onLoadErrorObservable: Observable<string>;
  58488. /**
  58489. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58490. * @param name Element's name, child elements will append suffixes for their own names.
  58491. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58492. * @param options An object containing optional or exposed sub element properties
  58493. */
  58494. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58495. resolution?: number;
  58496. clickToPlay?: boolean;
  58497. autoPlay?: boolean;
  58498. loop?: boolean;
  58499. size?: number;
  58500. poster?: string;
  58501. faceForward?: boolean;
  58502. useDirectMapping?: boolean;
  58503. halfDomeMode?: boolean;
  58504. crossEyeMode?: boolean;
  58505. generateMipMaps?: boolean;
  58506. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58507. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58508. protected _changeTextureMode(value: number): void;
  58509. /**
  58510. * Releases resources associated with this node.
  58511. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58512. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58513. */
  58514. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58515. }
  58516. }
  58517. declare module BABYLON {
  58518. /**
  58519. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58520. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58521. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58522. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58523. */
  58524. export class PhotoDome extends TextureDome<Texture> {
  58525. /**
  58526. * Define the image as a Monoscopic panoramic 360 image.
  58527. */
  58528. static readonly MODE_MONOSCOPIC: number;
  58529. /**
  58530. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58531. */
  58532. static readonly MODE_TOPBOTTOM: number;
  58533. /**
  58534. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58535. */
  58536. static readonly MODE_SIDEBYSIDE: number;
  58537. /**
  58538. * Gets or sets the texture being displayed on the sphere
  58539. */
  58540. get photoTexture(): Texture;
  58541. /**
  58542. * sets the texture being displayed on the sphere
  58543. */
  58544. set photoTexture(value: Texture);
  58545. /**
  58546. * Gets the current video mode for the video. It can be:
  58547. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58548. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58549. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58550. */
  58551. get imageMode(): number;
  58552. /**
  58553. * Sets the current video mode for the video. It can be:
  58554. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58555. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58556. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58557. */
  58558. set imageMode(value: number);
  58559. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  58560. }
  58561. }
  58562. declare module BABYLON {
  58563. /**
  58564. * Direct draw surface info
  58565. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58566. */
  58567. export interface DDSInfo {
  58568. /**
  58569. * Width of the texture
  58570. */
  58571. width: number;
  58572. /**
  58573. * Width of the texture
  58574. */
  58575. height: number;
  58576. /**
  58577. * Number of Mipmaps for the texture
  58578. * @see https://en.wikipedia.org/wiki/Mipmap
  58579. */
  58580. mipmapCount: number;
  58581. /**
  58582. * If the textures format is a known fourCC format
  58583. * @see https://www.fourcc.org/
  58584. */
  58585. isFourCC: boolean;
  58586. /**
  58587. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58588. */
  58589. isRGB: boolean;
  58590. /**
  58591. * If the texture is a lumincance format
  58592. */
  58593. isLuminance: boolean;
  58594. /**
  58595. * If this is a cube texture
  58596. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58597. */
  58598. isCube: boolean;
  58599. /**
  58600. * If the texture is a compressed format eg. FOURCC_DXT1
  58601. */
  58602. isCompressed: boolean;
  58603. /**
  58604. * The dxgiFormat of the texture
  58605. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58606. */
  58607. dxgiFormat: number;
  58608. /**
  58609. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58610. */
  58611. textureType: number;
  58612. /**
  58613. * Sphericle polynomial created for the dds texture
  58614. */
  58615. sphericalPolynomial?: SphericalPolynomial;
  58616. }
  58617. /**
  58618. * Class used to provide DDS decompression tools
  58619. */
  58620. export class DDSTools {
  58621. /**
  58622. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58623. */
  58624. static StoreLODInAlphaChannel: boolean;
  58625. /**
  58626. * Gets DDS information from an array buffer
  58627. * @param data defines the array buffer view to read data from
  58628. * @returns the DDS information
  58629. */
  58630. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58631. private static _FloatView;
  58632. private static _Int32View;
  58633. private static _ToHalfFloat;
  58634. private static _FromHalfFloat;
  58635. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58636. private static _GetHalfFloatRGBAArrayBuffer;
  58637. private static _GetFloatRGBAArrayBuffer;
  58638. private static _GetFloatAsUIntRGBAArrayBuffer;
  58639. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58640. private static _GetRGBAArrayBuffer;
  58641. private static _ExtractLongWordOrder;
  58642. private static _GetRGBArrayBuffer;
  58643. private static _GetLuminanceArrayBuffer;
  58644. /**
  58645. * Uploads DDS Levels to a Babylon Texture
  58646. * @hidden
  58647. */
  58648. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58649. }
  58650. interface ThinEngine {
  58651. /**
  58652. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58653. * @param rootUrl defines the url where the file to load is located
  58654. * @param scene defines the current scene
  58655. * @param lodScale defines scale to apply to the mip map selection
  58656. * @param lodOffset defines offset to apply to the mip map selection
  58657. * @param onLoad defines an optional callback raised when the texture is loaded
  58658. * @param onError defines an optional callback raised if there is an issue to load the texture
  58659. * @param format defines the format of the data
  58660. * @param forcedExtension defines the extension to use to pick the right loader
  58661. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58662. * @returns the cube texture as an InternalTexture
  58663. */
  58664. 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;
  58665. }
  58666. }
  58667. declare module BABYLON {
  58668. /**
  58669. * Implementation of the DDS Texture Loader.
  58670. * @hidden
  58671. */
  58672. export class _DDSTextureLoader implements IInternalTextureLoader {
  58673. /**
  58674. * Defines wether the loader supports cascade loading the different faces.
  58675. */
  58676. readonly supportCascades: boolean;
  58677. /**
  58678. * This returns if the loader support the current file information.
  58679. * @param extension defines the file extension of the file being loaded
  58680. * @returns true if the loader can load the specified file
  58681. */
  58682. canLoad(extension: string): boolean;
  58683. /**
  58684. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58685. * @param data contains the texture data
  58686. * @param texture defines the BabylonJS internal texture
  58687. * @param createPolynomials will be true if polynomials have been requested
  58688. * @param onLoad defines the callback to trigger once the texture is ready
  58689. * @param onError defines the callback to trigger in case of error
  58690. */
  58691. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58692. /**
  58693. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58694. * @param data contains the texture data
  58695. * @param texture defines the BabylonJS internal texture
  58696. * @param callback defines the method to call once ready to upload
  58697. */
  58698. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58699. }
  58700. }
  58701. declare module BABYLON {
  58702. /**
  58703. * Implementation of the ENV Texture Loader.
  58704. * @hidden
  58705. */
  58706. export class _ENVTextureLoader implements IInternalTextureLoader {
  58707. /**
  58708. * Defines wether the loader supports cascade loading the different faces.
  58709. */
  58710. readonly supportCascades: boolean;
  58711. /**
  58712. * This returns if the loader support the current file information.
  58713. * @param extension defines the file extension of the file being loaded
  58714. * @returns true if the loader can load the specified file
  58715. */
  58716. canLoad(extension: string): boolean;
  58717. /**
  58718. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58719. * @param data contains the texture data
  58720. * @param texture defines the BabylonJS internal texture
  58721. * @param createPolynomials will be true if polynomials have been requested
  58722. * @param onLoad defines the callback to trigger once the texture is ready
  58723. * @param onError defines the callback to trigger in case of error
  58724. */
  58725. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58726. /**
  58727. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58728. * @param data contains the texture data
  58729. * @param texture defines the BabylonJS internal texture
  58730. * @param callback defines the method to call once ready to upload
  58731. */
  58732. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58733. }
  58734. }
  58735. declare module BABYLON {
  58736. /**
  58737. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58738. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58739. */
  58740. export class KhronosTextureContainer {
  58741. /** contents of the KTX container file */
  58742. data: ArrayBufferView;
  58743. private static HEADER_LEN;
  58744. private static COMPRESSED_2D;
  58745. private static COMPRESSED_3D;
  58746. private static TEX_2D;
  58747. private static TEX_3D;
  58748. /**
  58749. * Gets the openGL type
  58750. */
  58751. glType: number;
  58752. /**
  58753. * Gets the openGL type size
  58754. */
  58755. glTypeSize: number;
  58756. /**
  58757. * Gets the openGL format
  58758. */
  58759. glFormat: number;
  58760. /**
  58761. * Gets the openGL internal format
  58762. */
  58763. glInternalFormat: number;
  58764. /**
  58765. * Gets the base internal format
  58766. */
  58767. glBaseInternalFormat: number;
  58768. /**
  58769. * Gets image width in pixel
  58770. */
  58771. pixelWidth: number;
  58772. /**
  58773. * Gets image height in pixel
  58774. */
  58775. pixelHeight: number;
  58776. /**
  58777. * Gets image depth in pixels
  58778. */
  58779. pixelDepth: number;
  58780. /**
  58781. * Gets the number of array elements
  58782. */
  58783. numberOfArrayElements: number;
  58784. /**
  58785. * Gets the number of faces
  58786. */
  58787. numberOfFaces: number;
  58788. /**
  58789. * Gets the number of mipmap levels
  58790. */
  58791. numberOfMipmapLevels: number;
  58792. /**
  58793. * Gets the bytes of key value data
  58794. */
  58795. bytesOfKeyValueData: number;
  58796. /**
  58797. * Gets the load type
  58798. */
  58799. loadType: number;
  58800. /**
  58801. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58802. */
  58803. isInvalid: boolean;
  58804. /**
  58805. * Creates a new KhronosTextureContainer
  58806. * @param data contents of the KTX container file
  58807. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58808. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58809. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58810. */
  58811. constructor(
  58812. /** contents of the KTX container file */
  58813. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58814. /**
  58815. * Uploads KTX content to a Babylon Texture.
  58816. * It is assumed that the texture has already been created & is currently bound
  58817. * @hidden
  58818. */
  58819. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58820. private _upload2DCompressedLevels;
  58821. /**
  58822. * Checks if the given data starts with a KTX file identifier.
  58823. * @param data the data to check
  58824. * @returns true if the data is a KTX file or false otherwise
  58825. */
  58826. static IsValid(data: ArrayBufferView): boolean;
  58827. }
  58828. }
  58829. declare module BABYLON {
  58830. /**
  58831. * Helper class to push actions to a pool of workers.
  58832. */
  58833. export class WorkerPool implements IDisposable {
  58834. private _workerInfos;
  58835. private _pendingActions;
  58836. /**
  58837. * Constructor
  58838. * @param workers Array of workers to use for actions
  58839. */
  58840. constructor(workers: Array<Worker>);
  58841. /**
  58842. * Terminates all workers and clears any pending actions.
  58843. */
  58844. dispose(): void;
  58845. /**
  58846. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58847. * pended until a worker has completed its action.
  58848. * @param action The action to perform. Call onComplete when the action is complete.
  58849. */
  58850. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58851. private _execute;
  58852. }
  58853. }
  58854. declare module BABYLON {
  58855. /**
  58856. * Class for loading KTX2 files
  58857. */
  58858. export class KhronosTextureContainer2 {
  58859. private static _WorkerPoolPromise?;
  58860. private static _Initialized;
  58861. private static _Ktx2Decoder;
  58862. /**
  58863. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  58864. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  58865. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  58866. * Urls you can change:
  58867. * URLConfig.jsDecoderModule
  58868. * URLConfig.wasmUASTCToASTC
  58869. * URLConfig.wasmUASTCToBC7
  58870. * URLConfig.jsMSCTranscoder
  58871. * URLConfig.wasmMSCTranscoder
  58872. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  58873. */
  58874. static URLConfig: {
  58875. jsDecoderModule: string;
  58876. wasmUASTCToASTC: null;
  58877. wasmUASTCToBC7: null;
  58878. jsMSCTranscoder: null;
  58879. wasmMSCTranscoder: null;
  58880. };
  58881. /**
  58882. * Default number of workers used to handle data decoding
  58883. */
  58884. static DefaultNumWorkers: number;
  58885. private static GetDefaultNumWorkers;
  58886. private _engine;
  58887. private static _CreateWorkerPool;
  58888. /**
  58889. * Constructor
  58890. * @param engine The engine to use
  58891. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58892. */
  58893. constructor(engine: ThinEngine, numWorkers?: number);
  58894. /** @hidden */
  58895. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  58896. /**
  58897. * Stop all async operations and release resources.
  58898. */
  58899. dispose(): void;
  58900. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  58901. /**
  58902. * Checks if the given data starts with a KTX2 file identifier.
  58903. * @param data the data to check
  58904. * @returns true if the data is a KTX2 file or false otherwise
  58905. */
  58906. static IsValid(data: ArrayBufferView): boolean;
  58907. }
  58908. }
  58909. declare module BABYLON {
  58910. /**
  58911. * Implementation of the KTX Texture Loader.
  58912. * @hidden
  58913. */
  58914. export class _KTXTextureLoader implements IInternalTextureLoader {
  58915. /**
  58916. * Defines wether the loader supports cascade loading the different faces.
  58917. */
  58918. readonly supportCascades: boolean;
  58919. /**
  58920. * This returns if the loader support the current file information.
  58921. * @param extension defines the file extension of the file being loaded
  58922. * @param mimeType defines the optional mime type of the file being loaded
  58923. * @returns true if the loader can load the specified file
  58924. */
  58925. canLoad(extension: string, mimeType?: string): boolean;
  58926. /**
  58927. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58928. * @param data contains the texture data
  58929. * @param texture defines the BabylonJS internal texture
  58930. * @param createPolynomials will be true if polynomials have been requested
  58931. * @param onLoad defines the callback to trigger once the texture is ready
  58932. * @param onError defines the callback to trigger in case of error
  58933. */
  58934. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58935. /**
  58936. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58937. * @param data contains the texture data
  58938. * @param texture defines the BabylonJS internal texture
  58939. * @param callback defines the method to call once ready to upload
  58940. */
  58941. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  58942. }
  58943. }
  58944. declare module BABYLON {
  58945. /** @hidden */
  58946. export var _forceSceneHelpersToBundle: boolean;
  58947. interface Scene {
  58948. /**
  58949. * Creates a default light for the scene.
  58950. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58951. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58952. */
  58953. createDefaultLight(replace?: boolean): void;
  58954. /**
  58955. * Creates a default camera for the scene.
  58956. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58957. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58958. * @param replace has default false, when true replaces the active camera in the scene
  58959. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58960. */
  58961. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58962. /**
  58963. * Creates a default camera and a default light.
  58964. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58965. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58966. * @param replace has the default false, when true replaces the active camera/light in the scene
  58967. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58968. */
  58969. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58970. /**
  58971. * Creates a new sky box
  58972. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58973. * @param environmentTexture defines the texture to use as environment texture
  58974. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58975. * @param scale defines the overall scale of the skybox
  58976. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58977. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58978. * @returns a new mesh holding the sky box
  58979. */
  58980. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58981. /**
  58982. * Creates a new environment
  58983. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58984. * @param options defines the options you can use to configure the environment
  58985. * @returns the new EnvironmentHelper
  58986. */
  58987. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58988. /**
  58989. * Creates a new VREXperienceHelper
  58990. * @see https://doc.babylonjs.com/how_to/webvr_helper
  58991. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58992. * @returns a new VREXperienceHelper
  58993. */
  58994. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58995. /**
  58996. * Creates a new WebXRDefaultExperience
  58997. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  58998. * @param options experience options
  58999. * @returns a promise for a new WebXRDefaultExperience
  59000. */
  59001. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59002. }
  59003. }
  59004. declare module BABYLON {
  59005. /**
  59006. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59007. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59008. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59009. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59010. */
  59011. export class VideoDome extends TextureDome<VideoTexture> {
  59012. /**
  59013. * Define the video source as a Monoscopic panoramic 360 video.
  59014. */
  59015. static readonly MODE_MONOSCOPIC: number;
  59016. /**
  59017. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59018. */
  59019. static readonly MODE_TOPBOTTOM: number;
  59020. /**
  59021. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59022. */
  59023. static readonly MODE_SIDEBYSIDE: number;
  59024. /**
  59025. * Get the video texture associated with this video dome
  59026. */
  59027. get videoTexture(): VideoTexture;
  59028. /**
  59029. * Get the video mode of this dome
  59030. */
  59031. get videoMode(): number;
  59032. /**
  59033. * Set the video mode of this dome.
  59034. * @see textureMode
  59035. */
  59036. set videoMode(value: number);
  59037. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  59038. }
  59039. }
  59040. declare module BABYLON {
  59041. /**
  59042. * This class can be used to get instrumentation data from a Babylon engine
  59043. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59044. */
  59045. export class EngineInstrumentation implements IDisposable {
  59046. /**
  59047. * Define the instrumented engine.
  59048. */
  59049. engine: Engine;
  59050. private _captureGPUFrameTime;
  59051. private _gpuFrameTimeToken;
  59052. private _gpuFrameTime;
  59053. private _captureShaderCompilationTime;
  59054. private _shaderCompilationTime;
  59055. private _onBeginFrameObserver;
  59056. private _onEndFrameObserver;
  59057. private _onBeforeShaderCompilationObserver;
  59058. private _onAfterShaderCompilationObserver;
  59059. /**
  59060. * Gets the perf counter used for GPU frame time
  59061. */
  59062. get gpuFrameTimeCounter(): PerfCounter;
  59063. /**
  59064. * Gets the GPU frame time capture status
  59065. */
  59066. get captureGPUFrameTime(): boolean;
  59067. /**
  59068. * Enable or disable the GPU frame time capture
  59069. */
  59070. set captureGPUFrameTime(value: boolean);
  59071. /**
  59072. * Gets the perf counter used for shader compilation time
  59073. */
  59074. get shaderCompilationTimeCounter(): PerfCounter;
  59075. /**
  59076. * Gets the shader compilation time capture status
  59077. */
  59078. get captureShaderCompilationTime(): boolean;
  59079. /**
  59080. * Enable or disable the shader compilation time capture
  59081. */
  59082. set captureShaderCompilationTime(value: boolean);
  59083. /**
  59084. * Instantiates a new engine instrumentation.
  59085. * This class can be used to get instrumentation data from a Babylon engine
  59086. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59087. * @param engine Defines the engine to instrument
  59088. */
  59089. constructor(
  59090. /**
  59091. * Define the instrumented engine.
  59092. */
  59093. engine: Engine);
  59094. /**
  59095. * Dispose and release associated resources.
  59096. */
  59097. dispose(): void;
  59098. }
  59099. }
  59100. declare module BABYLON {
  59101. /**
  59102. * This class can be used to get instrumentation data from a Babylon engine
  59103. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59104. */
  59105. export class SceneInstrumentation implements IDisposable {
  59106. /**
  59107. * Defines the scene to instrument
  59108. */
  59109. scene: Scene;
  59110. private _captureActiveMeshesEvaluationTime;
  59111. private _activeMeshesEvaluationTime;
  59112. private _captureRenderTargetsRenderTime;
  59113. private _renderTargetsRenderTime;
  59114. private _captureFrameTime;
  59115. private _frameTime;
  59116. private _captureRenderTime;
  59117. private _renderTime;
  59118. private _captureInterFrameTime;
  59119. private _interFrameTime;
  59120. private _captureParticlesRenderTime;
  59121. private _particlesRenderTime;
  59122. private _captureSpritesRenderTime;
  59123. private _spritesRenderTime;
  59124. private _capturePhysicsTime;
  59125. private _physicsTime;
  59126. private _captureAnimationsTime;
  59127. private _animationsTime;
  59128. private _captureCameraRenderTime;
  59129. private _cameraRenderTime;
  59130. private _onBeforeActiveMeshesEvaluationObserver;
  59131. private _onAfterActiveMeshesEvaluationObserver;
  59132. private _onBeforeRenderTargetsRenderObserver;
  59133. private _onAfterRenderTargetsRenderObserver;
  59134. private _onAfterRenderObserver;
  59135. private _onBeforeDrawPhaseObserver;
  59136. private _onAfterDrawPhaseObserver;
  59137. private _onBeforeAnimationsObserver;
  59138. private _onBeforeParticlesRenderingObserver;
  59139. private _onAfterParticlesRenderingObserver;
  59140. private _onBeforeSpritesRenderingObserver;
  59141. private _onAfterSpritesRenderingObserver;
  59142. private _onBeforePhysicsObserver;
  59143. private _onAfterPhysicsObserver;
  59144. private _onAfterAnimationsObserver;
  59145. private _onBeforeCameraRenderObserver;
  59146. private _onAfterCameraRenderObserver;
  59147. /**
  59148. * Gets the perf counter used for active meshes evaluation time
  59149. */
  59150. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59151. /**
  59152. * Gets the active meshes evaluation time capture status
  59153. */
  59154. get captureActiveMeshesEvaluationTime(): boolean;
  59155. /**
  59156. * Enable or disable the active meshes evaluation time capture
  59157. */
  59158. set captureActiveMeshesEvaluationTime(value: boolean);
  59159. /**
  59160. * Gets the perf counter used for render targets render time
  59161. */
  59162. get renderTargetsRenderTimeCounter(): PerfCounter;
  59163. /**
  59164. * Gets the render targets render time capture status
  59165. */
  59166. get captureRenderTargetsRenderTime(): boolean;
  59167. /**
  59168. * Enable or disable the render targets render time capture
  59169. */
  59170. set captureRenderTargetsRenderTime(value: boolean);
  59171. /**
  59172. * Gets the perf counter used for particles render time
  59173. */
  59174. get particlesRenderTimeCounter(): PerfCounter;
  59175. /**
  59176. * Gets the particles render time capture status
  59177. */
  59178. get captureParticlesRenderTime(): boolean;
  59179. /**
  59180. * Enable or disable the particles render time capture
  59181. */
  59182. set captureParticlesRenderTime(value: boolean);
  59183. /**
  59184. * Gets the perf counter used for sprites render time
  59185. */
  59186. get spritesRenderTimeCounter(): PerfCounter;
  59187. /**
  59188. * Gets the sprites render time capture status
  59189. */
  59190. get captureSpritesRenderTime(): boolean;
  59191. /**
  59192. * Enable or disable the sprites render time capture
  59193. */
  59194. set captureSpritesRenderTime(value: boolean);
  59195. /**
  59196. * Gets the perf counter used for physics time
  59197. */
  59198. get physicsTimeCounter(): PerfCounter;
  59199. /**
  59200. * Gets the physics time capture status
  59201. */
  59202. get capturePhysicsTime(): boolean;
  59203. /**
  59204. * Enable or disable the physics time capture
  59205. */
  59206. set capturePhysicsTime(value: boolean);
  59207. /**
  59208. * Gets the perf counter used for animations time
  59209. */
  59210. get animationsTimeCounter(): PerfCounter;
  59211. /**
  59212. * Gets the animations time capture status
  59213. */
  59214. get captureAnimationsTime(): boolean;
  59215. /**
  59216. * Enable or disable the animations time capture
  59217. */
  59218. set captureAnimationsTime(value: boolean);
  59219. /**
  59220. * Gets the perf counter used for frame time capture
  59221. */
  59222. get frameTimeCounter(): PerfCounter;
  59223. /**
  59224. * Gets the frame time capture status
  59225. */
  59226. get captureFrameTime(): boolean;
  59227. /**
  59228. * Enable or disable the frame time capture
  59229. */
  59230. set captureFrameTime(value: boolean);
  59231. /**
  59232. * Gets the perf counter used for inter-frames time capture
  59233. */
  59234. get interFrameTimeCounter(): PerfCounter;
  59235. /**
  59236. * Gets the inter-frames time capture status
  59237. */
  59238. get captureInterFrameTime(): boolean;
  59239. /**
  59240. * Enable or disable the inter-frames time capture
  59241. */
  59242. set captureInterFrameTime(value: boolean);
  59243. /**
  59244. * Gets the perf counter used for render time capture
  59245. */
  59246. get renderTimeCounter(): PerfCounter;
  59247. /**
  59248. * Gets the render time capture status
  59249. */
  59250. get captureRenderTime(): boolean;
  59251. /**
  59252. * Enable or disable the render time capture
  59253. */
  59254. set captureRenderTime(value: boolean);
  59255. /**
  59256. * Gets the perf counter used for camera render time capture
  59257. */
  59258. get cameraRenderTimeCounter(): PerfCounter;
  59259. /**
  59260. * Gets the camera render time capture status
  59261. */
  59262. get captureCameraRenderTime(): boolean;
  59263. /**
  59264. * Enable or disable the camera render time capture
  59265. */
  59266. set captureCameraRenderTime(value: boolean);
  59267. /**
  59268. * Gets the perf counter used for draw calls
  59269. */
  59270. get drawCallsCounter(): PerfCounter;
  59271. /**
  59272. * Instantiates a new scene instrumentation.
  59273. * This class can be used to get instrumentation data from a Babylon engine
  59274. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59275. * @param scene Defines the scene to instrument
  59276. */
  59277. constructor(
  59278. /**
  59279. * Defines the scene to instrument
  59280. */
  59281. scene: Scene);
  59282. /**
  59283. * Dispose and release associated resources.
  59284. */
  59285. dispose(): void;
  59286. }
  59287. }
  59288. declare module BABYLON {
  59289. /** @hidden */
  59290. export var glowMapGenerationPixelShader: {
  59291. name: string;
  59292. shader: string;
  59293. };
  59294. }
  59295. declare module BABYLON {
  59296. /** @hidden */
  59297. export var glowMapGenerationVertexShader: {
  59298. name: string;
  59299. shader: string;
  59300. };
  59301. }
  59302. declare module BABYLON {
  59303. /**
  59304. * Effect layer options. This helps customizing the behaviour
  59305. * of the effect layer.
  59306. */
  59307. export interface IEffectLayerOptions {
  59308. /**
  59309. * Multiplication factor apply to the canvas size to compute the render target size
  59310. * used to generated the objects (the smaller the faster).
  59311. */
  59312. mainTextureRatio: number;
  59313. /**
  59314. * Enforces a fixed size texture to ensure effect stability across devices.
  59315. */
  59316. mainTextureFixedSize?: number;
  59317. /**
  59318. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59319. */
  59320. alphaBlendingMode: number;
  59321. /**
  59322. * The camera attached to the layer.
  59323. */
  59324. camera: Nullable<Camera>;
  59325. /**
  59326. * The rendering group to draw the layer in.
  59327. */
  59328. renderingGroupId: number;
  59329. }
  59330. /**
  59331. * The effect layer Helps adding post process effect blended with the main pass.
  59332. *
  59333. * This can be for instance use to generate glow or higlight effects on the scene.
  59334. *
  59335. * The effect layer class can not be used directly and is intented to inherited from to be
  59336. * customized per effects.
  59337. */
  59338. export abstract class EffectLayer {
  59339. private _vertexBuffers;
  59340. private _indexBuffer;
  59341. private _cachedDefines;
  59342. private _effectLayerMapGenerationEffect;
  59343. private _effectLayerOptions;
  59344. private _mergeEffect;
  59345. protected _scene: Scene;
  59346. protected _engine: Engine;
  59347. protected _maxSize: number;
  59348. protected _mainTextureDesiredSize: ISize;
  59349. protected _mainTexture: RenderTargetTexture;
  59350. protected _shouldRender: boolean;
  59351. protected _postProcesses: PostProcess[];
  59352. protected _textures: BaseTexture[];
  59353. protected _emissiveTextureAndColor: {
  59354. texture: Nullable<BaseTexture>;
  59355. color: Color4;
  59356. };
  59357. /**
  59358. * The name of the layer
  59359. */
  59360. name: string;
  59361. /**
  59362. * The clear color of the texture used to generate the glow map.
  59363. */
  59364. neutralColor: Color4;
  59365. /**
  59366. * Specifies whether the highlight layer is enabled or not.
  59367. */
  59368. isEnabled: boolean;
  59369. /**
  59370. * Gets the camera attached to the layer.
  59371. */
  59372. get camera(): Nullable<Camera>;
  59373. /**
  59374. * Gets the rendering group id the layer should render in.
  59375. */
  59376. get renderingGroupId(): number;
  59377. set renderingGroupId(renderingGroupId: number);
  59378. /**
  59379. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59380. */
  59381. disableBoundingBoxesFromEffectLayer: boolean;
  59382. /**
  59383. * An event triggered when the effect layer has been disposed.
  59384. */
  59385. onDisposeObservable: Observable<EffectLayer>;
  59386. /**
  59387. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59388. */
  59389. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59390. /**
  59391. * An event triggered when the generated texture is being merged in the scene.
  59392. */
  59393. onBeforeComposeObservable: Observable<EffectLayer>;
  59394. /**
  59395. * An event triggered when the mesh is rendered into the effect render target.
  59396. */
  59397. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59398. /**
  59399. * An event triggered after the mesh has been rendered into the effect render target.
  59400. */
  59401. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59402. /**
  59403. * An event triggered when the generated texture has been merged in the scene.
  59404. */
  59405. onAfterComposeObservable: Observable<EffectLayer>;
  59406. /**
  59407. * An event triggered when the efffect layer changes its size.
  59408. */
  59409. onSizeChangedObservable: Observable<EffectLayer>;
  59410. /** @hidden */
  59411. static _SceneComponentInitialization: (scene: Scene) => void;
  59412. /**
  59413. * Instantiates a new effect Layer and references it in the scene.
  59414. * @param name The name of the layer
  59415. * @param scene The scene to use the layer in
  59416. */
  59417. constructor(
  59418. /** The Friendly of the effect in the scene */
  59419. name: string, scene: Scene);
  59420. /**
  59421. * Get the effect name of the layer.
  59422. * @return The effect name
  59423. */
  59424. abstract getEffectName(): string;
  59425. /**
  59426. * Checks for the readiness of the element composing the layer.
  59427. * @param subMesh the mesh to check for
  59428. * @param useInstances specify whether or not to use instances to render the mesh
  59429. * @return true if ready otherwise, false
  59430. */
  59431. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59432. /**
  59433. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59434. * @returns true if the effect requires stencil during the main canvas render pass.
  59435. */
  59436. abstract needStencil(): boolean;
  59437. /**
  59438. * Create the merge effect. This is the shader use to blit the information back
  59439. * to the main canvas at the end of the scene rendering.
  59440. * @returns The effect containing the shader used to merge the effect on the main canvas
  59441. */
  59442. protected abstract _createMergeEffect(): Effect;
  59443. /**
  59444. * Creates the render target textures and post processes used in the effect layer.
  59445. */
  59446. protected abstract _createTextureAndPostProcesses(): void;
  59447. /**
  59448. * Implementation specific of rendering the generating effect on the main canvas.
  59449. * @param effect The effect used to render through
  59450. */
  59451. protected abstract _internalRender(effect: Effect): void;
  59452. /**
  59453. * Sets the required values for both the emissive texture and and the main color.
  59454. */
  59455. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59456. /**
  59457. * Free any resources and references associated to a mesh.
  59458. * Internal use
  59459. * @param mesh The mesh to free.
  59460. */
  59461. abstract _disposeMesh(mesh: Mesh): void;
  59462. /**
  59463. * Serializes this layer (Glow or Highlight for example)
  59464. * @returns a serialized layer object
  59465. */
  59466. abstract serialize?(): any;
  59467. /**
  59468. * Initializes the effect layer with the required options.
  59469. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59470. */
  59471. protected _init(options: Partial<IEffectLayerOptions>): void;
  59472. /**
  59473. * Generates the index buffer of the full screen quad blending to the main canvas.
  59474. */
  59475. private _generateIndexBuffer;
  59476. /**
  59477. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59478. */
  59479. private _generateVertexBuffer;
  59480. /**
  59481. * Sets the main texture desired size which is the closest power of two
  59482. * of the engine canvas size.
  59483. */
  59484. private _setMainTextureSize;
  59485. /**
  59486. * Creates the main texture for the effect layer.
  59487. */
  59488. protected _createMainTexture(): void;
  59489. /**
  59490. * Adds specific effects defines.
  59491. * @param defines The defines to add specifics to.
  59492. */
  59493. protected _addCustomEffectDefines(defines: string[]): void;
  59494. /**
  59495. * Checks for the readiness of the element composing the layer.
  59496. * @param subMesh the mesh to check for
  59497. * @param useInstances specify whether or not to use instances to render the mesh
  59498. * @param emissiveTexture the associated emissive texture used to generate the glow
  59499. * @return true if ready otherwise, false
  59500. */
  59501. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59502. /**
  59503. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59504. */
  59505. render(): void;
  59506. /**
  59507. * Determine if a given mesh will be used in the current effect.
  59508. * @param mesh mesh to test
  59509. * @returns true if the mesh will be used
  59510. */
  59511. hasMesh(mesh: AbstractMesh): boolean;
  59512. /**
  59513. * Returns true if the layer contains information to display, otherwise false.
  59514. * @returns true if the glow layer should be rendered
  59515. */
  59516. shouldRender(): boolean;
  59517. /**
  59518. * Returns true if the mesh should render, otherwise false.
  59519. * @param mesh The mesh to render
  59520. * @returns true if it should render otherwise false
  59521. */
  59522. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59523. /**
  59524. * Returns true if the mesh can be rendered, otherwise false.
  59525. * @param mesh The mesh to render
  59526. * @param material The material used on the mesh
  59527. * @returns true if it can be rendered otherwise false
  59528. */
  59529. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59530. /**
  59531. * Returns true if the mesh should render, otherwise false.
  59532. * @param mesh The mesh to render
  59533. * @returns true if it should render otherwise false
  59534. */
  59535. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59536. /**
  59537. * Renders the submesh passed in parameter to the generation map.
  59538. */
  59539. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59540. /**
  59541. * Defines whether the current material of the mesh should be use to render the effect.
  59542. * @param mesh defines the current mesh to render
  59543. */
  59544. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59545. /**
  59546. * Rebuild the required buffers.
  59547. * @hidden Internal use only.
  59548. */
  59549. _rebuild(): void;
  59550. /**
  59551. * Dispose only the render target textures and post process.
  59552. */
  59553. private _disposeTextureAndPostProcesses;
  59554. /**
  59555. * Dispose the highlight layer and free resources.
  59556. */
  59557. dispose(): void;
  59558. /**
  59559. * Gets the class name of the effect layer
  59560. * @returns the string with the class name of the effect layer
  59561. */
  59562. getClassName(): string;
  59563. /**
  59564. * Creates an effect layer from parsed effect layer data
  59565. * @param parsedEffectLayer defines effect layer data
  59566. * @param scene defines the current scene
  59567. * @param rootUrl defines the root URL containing the effect layer information
  59568. * @returns a parsed effect Layer
  59569. */
  59570. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59571. }
  59572. }
  59573. declare module BABYLON {
  59574. interface AbstractScene {
  59575. /**
  59576. * The list of effect layers (highlights/glow) added to the scene
  59577. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59578. * @see https://doc.babylonjs.com/how_to/glow_layer
  59579. */
  59580. effectLayers: Array<EffectLayer>;
  59581. /**
  59582. * Removes the given effect layer from this scene.
  59583. * @param toRemove defines the effect layer to remove
  59584. * @returns the index of the removed effect layer
  59585. */
  59586. removeEffectLayer(toRemove: EffectLayer): number;
  59587. /**
  59588. * Adds the given effect layer to this scene
  59589. * @param newEffectLayer defines the effect layer to add
  59590. */
  59591. addEffectLayer(newEffectLayer: EffectLayer): void;
  59592. }
  59593. /**
  59594. * Defines the layer scene component responsible to manage any effect layers
  59595. * in a given scene.
  59596. */
  59597. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59598. /**
  59599. * The component name helpfull to identify the component in the list of scene components.
  59600. */
  59601. readonly name: string;
  59602. /**
  59603. * The scene the component belongs to.
  59604. */
  59605. scene: Scene;
  59606. private _engine;
  59607. private _renderEffects;
  59608. private _needStencil;
  59609. private _previousStencilState;
  59610. /**
  59611. * Creates a new instance of the component for the given scene
  59612. * @param scene Defines the scene to register the component in
  59613. */
  59614. constructor(scene: Scene);
  59615. /**
  59616. * Registers the component in a given scene
  59617. */
  59618. register(): void;
  59619. /**
  59620. * Rebuilds the elements related to this component in case of
  59621. * context lost for instance.
  59622. */
  59623. rebuild(): void;
  59624. /**
  59625. * Serializes the component data to the specified json object
  59626. * @param serializationObject The object to serialize to
  59627. */
  59628. serialize(serializationObject: any): void;
  59629. /**
  59630. * Adds all the elements from the container to the scene
  59631. * @param container the container holding the elements
  59632. */
  59633. addFromContainer(container: AbstractScene): void;
  59634. /**
  59635. * Removes all the elements in the container from the scene
  59636. * @param container contains the elements to remove
  59637. * @param dispose if the removed element should be disposed (default: false)
  59638. */
  59639. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59640. /**
  59641. * Disposes the component and the associated ressources.
  59642. */
  59643. dispose(): void;
  59644. private _isReadyForMesh;
  59645. private _renderMainTexture;
  59646. private _setStencil;
  59647. private _setStencilBack;
  59648. private _draw;
  59649. private _drawCamera;
  59650. private _drawRenderingGroup;
  59651. }
  59652. }
  59653. declare module BABYLON {
  59654. /** @hidden */
  59655. export var glowMapMergePixelShader: {
  59656. name: string;
  59657. shader: string;
  59658. };
  59659. }
  59660. declare module BABYLON {
  59661. /** @hidden */
  59662. export var glowMapMergeVertexShader: {
  59663. name: string;
  59664. shader: string;
  59665. };
  59666. }
  59667. declare module BABYLON {
  59668. interface AbstractScene {
  59669. /**
  59670. * Return a the first highlight layer of the scene with a given name.
  59671. * @param name The name of the highlight layer to look for.
  59672. * @return The highlight layer if found otherwise null.
  59673. */
  59674. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59675. }
  59676. /**
  59677. * Glow layer options. This helps customizing the behaviour
  59678. * of the glow layer.
  59679. */
  59680. export interface IGlowLayerOptions {
  59681. /**
  59682. * Multiplication factor apply to the canvas size to compute the render target size
  59683. * used to generated the glowing objects (the smaller the faster).
  59684. */
  59685. mainTextureRatio: number;
  59686. /**
  59687. * Enforces a fixed size texture to ensure resize independant blur.
  59688. */
  59689. mainTextureFixedSize?: number;
  59690. /**
  59691. * How big is the kernel of the blur texture.
  59692. */
  59693. blurKernelSize: number;
  59694. /**
  59695. * The camera attached to the layer.
  59696. */
  59697. camera: Nullable<Camera>;
  59698. /**
  59699. * Enable MSAA by chosing the number of samples.
  59700. */
  59701. mainTextureSamples?: number;
  59702. /**
  59703. * The rendering group to draw the layer in.
  59704. */
  59705. renderingGroupId: number;
  59706. }
  59707. /**
  59708. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59709. *
  59710. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59711. *
  59712. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59713. */
  59714. export class GlowLayer extends EffectLayer {
  59715. /**
  59716. * Effect Name of the layer.
  59717. */
  59718. static readonly EffectName: string;
  59719. /**
  59720. * The default blur kernel size used for the glow.
  59721. */
  59722. static DefaultBlurKernelSize: number;
  59723. /**
  59724. * The default texture size ratio used for the glow.
  59725. */
  59726. static DefaultTextureRatio: number;
  59727. /**
  59728. * Sets the kernel size of the blur.
  59729. */
  59730. set blurKernelSize(value: number);
  59731. /**
  59732. * Gets the kernel size of the blur.
  59733. */
  59734. get blurKernelSize(): number;
  59735. /**
  59736. * Sets the glow intensity.
  59737. */
  59738. set intensity(value: number);
  59739. /**
  59740. * Gets the glow intensity.
  59741. */
  59742. get intensity(): number;
  59743. private _options;
  59744. private _intensity;
  59745. private _horizontalBlurPostprocess1;
  59746. private _verticalBlurPostprocess1;
  59747. private _horizontalBlurPostprocess2;
  59748. private _verticalBlurPostprocess2;
  59749. private _blurTexture1;
  59750. private _blurTexture2;
  59751. private _postProcesses1;
  59752. private _postProcesses2;
  59753. private _includedOnlyMeshes;
  59754. private _excludedMeshes;
  59755. private _meshesUsingTheirOwnMaterials;
  59756. /**
  59757. * Callback used to let the user override the color selection on a per mesh basis
  59758. */
  59759. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59760. /**
  59761. * Callback used to let the user override the texture selection on a per mesh basis
  59762. */
  59763. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59764. /**
  59765. * Instantiates a new glow Layer and references it to the scene.
  59766. * @param name The name of the layer
  59767. * @param scene The scene to use the layer in
  59768. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59769. */
  59770. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59771. /**
  59772. * Get the effect name of the layer.
  59773. * @return The effect name
  59774. */
  59775. getEffectName(): string;
  59776. /**
  59777. * Create the merge effect. This is the shader use to blit the information back
  59778. * to the main canvas at the end of the scene rendering.
  59779. */
  59780. protected _createMergeEffect(): Effect;
  59781. /**
  59782. * Creates the render target textures and post processes used in the glow layer.
  59783. */
  59784. protected _createTextureAndPostProcesses(): void;
  59785. /**
  59786. * Checks for the readiness of the element composing the layer.
  59787. * @param subMesh the mesh to check for
  59788. * @param useInstances specify wether or not to use instances to render the mesh
  59789. * @param emissiveTexture the associated emissive texture used to generate the glow
  59790. * @return true if ready otherwise, false
  59791. */
  59792. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59793. /**
  59794. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59795. */
  59796. needStencil(): boolean;
  59797. /**
  59798. * Returns true if the mesh can be rendered, otherwise false.
  59799. * @param mesh The mesh to render
  59800. * @param material The material used on the mesh
  59801. * @returns true if it can be rendered otherwise false
  59802. */
  59803. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59804. /**
  59805. * Implementation specific of rendering the generating effect on the main canvas.
  59806. * @param effect The effect used to render through
  59807. */
  59808. protected _internalRender(effect: Effect): void;
  59809. /**
  59810. * Sets the required values for both the emissive texture and and the main color.
  59811. */
  59812. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59813. /**
  59814. * Returns true if the mesh should render, otherwise false.
  59815. * @param mesh The mesh to render
  59816. * @returns true if it should render otherwise false
  59817. */
  59818. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59819. /**
  59820. * Adds specific effects defines.
  59821. * @param defines The defines to add specifics to.
  59822. */
  59823. protected _addCustomEffectDefines(defines: string[]): void;
  59824. /**
  59825. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59826. * @param mesh The mesh to exclude from the glow layer
  59827. */
  59828. addExcludedMesh(mesh: Mesh): void;
  59829. /**
  59830. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59831. * @param mesh The mesh to remove
  59832. */
  59833. removeExcludedMesh(mesh: Mesh): void;
  59834. /**
  59835. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59836. * @param mesh The mesh to include in the glow layer
  59837. */
  59838. addIncludedOnlyMesh(mesh: Mesh): void;
  59839. /**
  59840. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59841. * @param mesh The mesh to remove
  59842. */
  59843. removeIncludedOnlyMesh(mesh: Mesh): void;
  59844. /**
  59845. * Determine if a given mesh will be used in the glow layer
  59846. * @param mesh The mesh to test
  59847. * @returns true if the mesh will be highlighted by the current glow layer
  59848. */
  59849. hasMesh(mesh: AbstractMesh): boolean;
  59850. /**
  59851. * Defines whether the current material of the mesh should be use to render the effect.
  59852. * @param mesh defines the current mesh to render
  59853. */
  59854. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59855. /**
  59856. * Add a mesh to be rendered through its own material and not with emissive only.
  59857. * @param mesh The mesh for which we need to use its material
  59858. */
  59859. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59860. /**
  59861. * Remove a mesh from being rendered through its own material and not with emissive only.
  59862. * @param mesh The mesh for which we need to not use its material
  59863. */
  59864. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59865. /**
  59866. * Free any resources and references associated to a mesh.
  59867. * Internal use
  59868. * @param mesh The mesh to free.
  59869. * @hidden
  59870. */
  59871. _disposeMesh(mesh: Mesh): void;
  59872. /**
  59873. * Gets the class name of the effect layer
  59874. * @returns the string with the class name of the effect layer
  59875. */
  59876. getClassName(): string;
  59877. /**
  59878. * Serializes this glow layer
  59879. * @returns a serialized glow layer object
  59880. */
  59881. serialize(): any;
  59882. /**
  59883. * Creates a Glow Layer from parsed glow layer data
  59884. * @param parsedGlowLayer defines glow layer data
  59885. * @param scene defines the current scene
  59886. * @param rootUrl defines the root URL containing the glow layer information
  59887. * @returns a parsed Glow Layer
  59888. */
  59889. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59890. }
  59891. }
  59892. declare module BABYLON {
  59893. /** @hidden */
  59894. export var glowBlurPostProcessPixelShader: {
  59895. name: string;
  59896. shader: string;
  59897. };
  59898. }
  59899. declare module BABYLON {
  59900. interface AbstractScene {
  59901. /**
  59902. * Return a the first highlight layer of the scene with a given name.
  59903. * @param name The name of the highlight layer to look for.
  59904. * @return The highlight layer if found otherwise null.
  59905. */
  59906. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59907. }
  59908. /**
  59909. * Highlight layer options. This helps customizing the behaviour
  59910. * of the highlight layer.
  59911. */
  59912. export interface IHighlightLayerOptions {
  59913. /**
  59914. * Multiplication factor apply to the canvas size to compute the render target size
  59915. * used to generated the glowing objects (the smaller the faster).
  59916. */
  59917. mainTextureRatio: number;
  59918. /**
  59919. * Enforces a fixed size texture to ensure resize independant blur.
  59920. */
  59921. mainTextureFixedSize?: number;
  59922. /**
  59923. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59924. * of the picture to blur (the smaller the faster).
  59925. */
  59926. blurTextureSizeRatio: number;
  59927. /**
  59928. * How big in texel of the blur texture is the vertical blur.
  59929. */
  59930. blurVerticalSize: number;
  59931. /**
  59932. * How big in texel of the blur texture is the horizontal blur.
  59933. */
  59934. blurHorizontalSize: number;
  59935. /**
  59936. * Alpha blending mode used to apply the blur. Default is combine.
  59937. */
  59938. alphaBlendingMode: number;
  59939. /**
  59940. * The camera attached to the layer.
  59941. */
  59942. camera: Nullable<Camera>;
  59943. /**
  59944. * Should we display highlight as a solid stroke?
  59945. */
  59946. isStroke?: boolean;
  59947. /**
  59948. * The rendering group to draw the layer in.
  59949. */
  59950. renderingGroupId: number;
  59951. }
  59952. /**
  59953. * The highlight layer Helps adding a glow effect around a mesh.
  59954. *
  59955. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59956. * glowy meshes to your scene.
  59957. *
  59958. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59959. */
  59960. export class HighlightLayer extends EffectLayer {
  59961. name: string;
  59962. /**
  59963. * Effect Name of the highlight layer.
  59964. */
  59965. static readonly EffectName: string;
  59966. /**
  59967. * The neutral color used during the preparation of the glow effect.
  59968. * This is black by default as the blend operation is a blend operation.
  59969. */
  59970. static NeutralColor: Color4;
  59971. /**
  59972. * Stencil value used for glowing meshes.
  59973. */
  59974. static GlowingMeshStencilReference: number;
  59975. /**
  59976. * Stencil value used for the other meshes in the scene.
  59977. */
  59978. static NormalMeshStencilReference: number;
  59979. /**
  59980. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59981. */
  59982. innerGlow: boolean;
  59983. /**
  59984. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59985. */
  59986. outerGlow: boolean;
  59987. /**
  59988. * Specifies the horizontal size of the blur.
  59989. */
  59990. set blurHorizontalSize(value: number);
  59991. /**
  59992. * Specifies the vertical size of the blur.
  59993. */
  59994. set blurVerticalSize(value: number);
  59995. /**
  59996. * Gets the horizontal size of the blur.
  59997. */
  59998. get blurHorizontalSize(): number;
  59999. /**
  60000. * Gets the vertical size of the blur.
  60001. */
  60002. get blurVerticalSize(): number;
  60003. /**
  60004. * An event triggered when the highlight layer is being blurred.
  60005. */
  60006. onBeforeBlurObservable: Observable<HighlightLayer>;
  60007. /**
  60008. * An event triggered when the highlight layer has been blurred.
  60009. */
  60010. onAfterBlurObservable: Observable<HighlightLayer>;
  60011. private _instanceGlowingMeshStencilReference;
  60012. private _options;
  60013. private _downSamplePostprocess;
  60014. private _horizontalBlurPostprocess;
  60015. private _verticalBlurPostprocess;
  60016. private _blurTexture;
  60017. private _meshes;
  60018. private _excludedMeshes;
  60019. /**
  60020. * Instantiates a new highlight Layer and references it to the scene..
  60021. * @param name The name of the layer
  60022. * @param scene The scene to use the layer in
  60023. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60024. */
  60025. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60026. /**
  60027. * Get the effect name of the layer.
  60028. * @return The effect name
  60029. */
  60030. getEffectName(): string;
  60031. /**
  60032. * Create the merge effect. This is the shader use to blit the information back
  60033. * to the main canvas at the end of the scene rendering.
  60034. */
  60035. protected _createMergeEffect(): Effect;
  60036. /**
  60037. * Creates the render target textures and post processes used in the highlight layer.
  60038. */
  60039. protected _createTextureAndPostProcesses(): void;
  60040. /**
  60041. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60042. */
  60043. needStencil(): boolean;
  60044. /**
  60045. * Checks for the readiness of the element composing the layer.
  60046. * @param subMesh the mesh to check for
  60047. * @param useInstances specify wether or not to use instances to render the mesh
  60048. * @param emissiveTexture the associated emissive texture used to generate the glow
  60049. * @return true if ready otherwise, false
  60050. */
  60051. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60052. /**
  60053. * Implementation specific of rendering the generating effect on the main canvas.
  60054. * @param effect The effect used to render through
  60055. */
  60056. protected _internalRender(effect: Effect): void;
  60057. /**
  60058. * Returns true if the layer contains information to display, otherwise false.
  60059. */
  60060. shouldRender(): boolean;
  60061. /**
  60062. * Returns true if the mesh should render, otherwise false.
  60063. * @param mesh The mesh to render
  60064. * @returns true if it should render otherwise false
  60065. */
  60066. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60067. /**
  60068. * Returns true if the mesh can be rendered, otherwise false.
  60069. * @param mesh The mesh to render
  60070. * @param material The material used on the mesh
  60071. * @returns true if it can be rendered otherwise false
  60072. */
  60073. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60074. /**
  60075. * Adds specific effects defines.
  60076. * @param defines The defines to add specifics to.
  60077. */
  60078. protected _addCustomEffectDefines(defines: string[]): void;
  60079. /**
  60080. * Sets the required values for both the emissive texture and and the main color.
  60081. */
  60082. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60083. /**
  60084. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60085. * @param mesh The mesh to exclude from the highlight layer
  60086. */
  60087. addExcludedMesh(mesh: Mesh): void;
  60088. /**
  60089. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60090. * @param mesh The mesh to highlight
  60091. */
  60092. removeExcludedMesh(mesh: Mesh): void;
  60093. /**
  60094. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60095. * @param mesh mesh to test
  60096. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60097. */
  60098. hasMesh(mesh: AbstractMesh): boolean;
  60099. /**
  60100. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60101. * @param mesh The mesh to highlight
  60102. * @param color The color of the highlight
  60103. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60104. */
  60105. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60106. /**
  60107. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60108. * @param mesh The mesh to highlight
  60109. */
  60110. removeMesh(mesh: Mesh): void;
  60111. /**
  60112. * Remove all the meshes currently referenced in the highlight layer
  60113. */
  60114. removeAllMeshes(): void;
  60115. /**
  60116. * Force the stencil to the normal expected value for none glowing parts
  60117. */
  60118. private _defaultStencilReference;
  60119. /**
  60120. * Free any resources and references associated to a mesh.
  60121. * Internal use
  60122. * @param mesh The mesh to free.
  60123. * @hidden
  60124. */
  60125. _disposeMesh(mesh: Mesh): void;
  60126. /**
  60127. * Dispose the highlight layer and free resources.
  60128. */
  60129. dispose(): void;
  60130. /**
  60131. * Gets the class name of the effect layer
  60132. * @returns the string with the class name of the effect layer
  60133. */
  60134. getClassName(): string;
  60135. /**
  60136. * Serializes this Highlight layer
  60137. * @returns a serialized Highlight layer object
  60138. */
  60139. serialize(): any;
  60140. /**
  60141. * Creates a Highlight layer from parsed Highlight layer data
  60142. * @param parsedHightlightLayer defines the Highlight layer data
  60143. * @param scene defines the current scene
  60144. * @param rootUrl defines the root URL containing the Highlight layer information
  60145. * @returns a parsed Highlight layer
  60146. */
  60147. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60148. }
  60149. }
  60150. declare module BABYLON {
  60151. interface AbstractScene {
  60152. /**
  60153. * The list of layers (background and foreground) of the scene
  60154. */
  60155. layers: Array<Layer>;
  60156. }
  60157. /**
  60158. * Defines the layer scene component responsible to manage any layers
  60159. * in a given scene.
  60160. */
  60161. export class LayerSceneComponent implements ISceneComponent {
  60162. /**
  60163. * The component name helpfull to identify the component in the list of scene components.
  60164. */
  60165. readonly name: string;
  60166. /**
  60167. * The scene the component belongs to.
  60168. */
  60169. scene: Scene;
  60170. private _engine;
  60171. /**
  60172. * Creates a new instance of the component for the given scene
  60173. * @param scene Defines the scene to register the component in
  60174. */
  60175. constructor(scene: Scene);
  60176. /**
  60177. * Registers the component in a given scene
  60178. */
  60179. register(): void;
  60180. /**
  60181. * Rebuilds the elements related to this component in case of
  60182. * context lost for instance.
  60183. */
  60184. rebuild(): void;
  60185. /**
  60186. * Disposes the component and the associated ressources.
  60187. */
  60188. dispose(): void;
  60189. private _draw;
  60190. private _drawCameraPredicate;
  60191. private _drawCameraBackground;
  60192. private _drawCameraForeground;
  60193. private _drawRenderTargetPredicate;
  60194. private _drawRenderTargetBackground;
  60195. private _drawRenderTargetForeground;
  60196. /**
  60197. * Adds all the elements from the container to the scene
  60198. * @param container the container holding the elements
  60199. */
  60200. addFromContainer(container: AbstractScene): void;
  60201. /**
  60202. * Removes all the elements in the container from the scene
  60203. * @param container contains the elements to remove
  60204. * @param dispose if the removed element should be disposed (default: false)
  60205. */
  60206. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60207. }
  60208. }
  60209. declare module BABYLON {
  60210. /** @hidden */
  60211. export var layerPixelShader: {
  60212. name: string;
  60213. shader: string;
  60214. };
  60215. }
  60216. declare module BABYLON {
  60217. /** @hidden */
  60218. export var layerVertexShader: {
  60219. name: string;
  60220. shader: string;
  60221. };
  60222. }
  60223. declare module BABYLON {
  60224. /**
  60225. * This represents a full screen 2d layer.
  60226. * This can be useful to display a picture in the background of your scene for instance.
  60227. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60228. */
  60229. export class Layer {
  60230. /**
  60231. * Define the name of the layer.
  60232. */
  60233. name: string;
  60234. /**
  60235. * Define the texture the layer should display.
  60236. */
  60237. texture: Nullable<Texture>;
  60238. /**
  60239. * Is the layer in background or foreground.
  60240. */
  60241. isBackground: boolean;
  60242. /**
  60243. * Define the color of the layer (instead of texture).
  60244. */
  60245. color: Color4;
  60246. /**
  60247. * Define the scale of the layer in order to zoom in out of the texture.
  60248. */
  60249. scale: Vector2;
  60250. /**
  60251. * Define an offset for the layer in order to shift the texture.
  60252. */
  60253. offset: Vector2;
  60254. /**
  60255. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60256. */
  60257. alphaBlendingMode: number;
  60258. /**
  60259. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60260. * Alpha test will not mix with the background color in case of transparency.
  60261. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60262. */
  60263. alphaTest: boolean;
  60264. /**
  60265. * Define a mask to restrict the layer to only some of the scene cameras.
  60266. */
  60267. layerMask: number;
  60268. /**
  60269. * Define the list of render target the layer is visible into.
  60270. */
  60271. renderTargetTextures: RenderTargetTexture[];
  60272. /**
  60273. * Define if the layer is only used in renderTarget or if it also
  60274. * renders in the main frame buffer of the canvas.
  60275. */
  60276. renderOnlyInRenderTargetTextures: boolean;
  60277. private _scene;
  60278. private _vertexBuffers;
  60279. private _indexBuffer;
  60280. private _effect;
  60281. private _previousDefines;
  60282. /**
  60283. * An event triggered when the layer is disposed.
  60284. */
  60285. onDisposeObservable: Observable<Layer>;
  60286. private _onDisposeObserver;
  60287. /**
  60288. * Back compatibility with callback before the onDisposeObservable existed.
  60289. * The set callback will be triggered when the layer has been disposed.
  60290. */
  60291. set onDispose(callback: () => void);
  60292. /**
  60293. * An event triggered before rendering the scene
  60294. */
  60295. onBeforeRenderObservable: Observable<Layer>;
  60296. private _onBeforeRenderObserver;
  60297. /**
  60298. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60299. * The set callback will be triggered just before rendering the layer.
  60300. */
  60301. set onBeforeRender(callback: () => void);
  60302. /**
  60303. * An event triggered after rendering the scene
  60304. */
  60305. onAfterRenderObservable: Observable<Layer>;
  60306. private _onAfterRenderObserver;
  60307. /**
  60308. * Back compatibility with callback before the onAfterRenderObservable existed.
  60309. * The set callback will be triggered just after rendering the layer.
  60310. */
  60311. set onAfterRender(callback: () => void);
  60312. /**
  60313. * Instantiates a new layer.
  60314. * This represents a full screen 2d layer.
  60315. * This can be useful to display a picture in the background of your scene for instance.
  60316. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60317. * @param name Define the name of the layer in the scene
  60318. * @param imgUrl Define the url of the texture to display in the layer
  60319. * @param scene Define the scene the layer belongs to
  60320. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60321. * @param color Defines a color for the layer
  60322. */
  60323. constructor(
  60324. /**
  60325. * Define the name of the layer.
  60326. */
  60327. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60328. private _createIndexBuffer;
  60329. /** @hidden */
  60330. _rebuild(): void;
  60331. /**
  60332. * Renders the layer in the scene.
  60333. */
  60334. render(): void;
  60335. /**
  60336. * Disposes and releases the associated ressources.
  60337. */
  60338. dispose(): void;
  60339. }
  60340. }
  60341. declare module BABYLON {
  60342. /** @hidden */
  60343. export var lensFlarePixelShader: {
  60344. name: string;
  60345. shader: string;
  60346. };
  60347. }
  60348. declare module BABYLON {
  60349. /** @hidden */
  60350. export var lensFlareVertexShader: {
  60351. name: string;
  60352. shader: string;
  60353. };
  60354. }
  60355. declare module BABYLON {
  60356. /**
  60357. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60358. * It is usually composed of several `lensFlare`.
  60359. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60360. */
  60361. export class LensFlareSystem {
  60362. /**
  60363. * Define the name of the lens flare system
  60364. */
  60365. name: string;
  60366. /**
  60367. * List of lens flares used in this system.
  60368. */
  60369. lensFlares: LensFlare[];
  60370. /**
  60371. * Define a limit from the border the lens flare can be visible.
  60372. */
  60373. borderLimit: number;
  60374. /**
  60375. * Define a viewport border we do not want to see the lens flare in.
  60376. */
  60377. viewportBorder: number;
  60378. /**
  60379. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60380. */
  60381. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60382. /**
  60383. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60384. */
  60385. layerMask: number;
  60386. /**
  60387. * Define the id of the lens flare system in the scene.
  60388. * (equal to name by default)
  60389. */
  60390. id: string;
  60391. private _scene;
  60392. private _emitter;
  60393. private _vertexBuffers;
  60394. private _indexBuffer;
  60395. private _effect;
  60396. private _positionX;
  60397. private _positionY;
  60398. private _isEnabled;
  60399. /** @hidden */
  60400. static _SceneComponentInitialization: (scene: Scene) => void;
  60401. /**
  60402. * Instantiates a lens flare system.
  60403. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60404. * It is usually composed of several `lensFlare`.
  60405. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60406. * @param name Define the name of the lens flare system in the scene
  60407. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60408. * @param scene Define the scene the lens flare system belongs to
  60409. */
  60410. constructor(
  60411. /**
  60412. * Define the name of the lens flare system
  60413. */
  60414. name: string, emitter: any, scene: Scene);
  60415. /**
  60416. * Define if the lens flare system is enabled.
  60417. */
  60418. get isEnabled(): boolean;
  60419. set isEnabled(value: boolean);
  60420. /**
  60421. * Get the scene the effects belongs to.
  60422. * @returns the scene holding the lens flare system
  60423. */
  60424. getScene(): Scene;
  60425. /**
  60426. * Get the emitter of the lens flare system.
  60427. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60428. * @returns the emitter of the lens flare system
  60429. */
  60430. getEmitter(): any;
  60431. /**
  60432. * Set the emitter of the lens flare system.
  60433. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60434. * @param newEmitter Define the new emitter of the system
  60435. */
  60436. setEmitter(newEmitter: any): void;
  60437. /**
  60438. * Get the lens flare system emitter position.
  60439. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60440. * @returns the position
  60441. */
  60442. getEmitterPosition(): Vector3;
  60443. /**
  60444. * @hidden
  60445. */
  60446. computeEffectivePosition(globalViewport: Viewport): boolean;
  60447. /** @hidden */
  60448. _isVisible(): boolean;
  60449. /**
  60450. * @hidden
  60451. */
  60452. render(): boolean;
  60453. /**
  60454. * Dispose and release the lens flare with its associated resources.
  60455. */
  60456. dispose(): void;
  60457. /**
  60458. * Parse a lens flare system from a JSON repressentation
  60459. * @param parsedLensFlareSystem Define the JSON to parse
  60460. * @param scene Define the scene the parsed system should be instantiated in
  60461. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60462. * @returns the parsed system
  60463. */
  60464. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60465. /**
  60466. * Serialize the current Lens Flare System into a JSON representation.
  60467. * @returns the serialized JSON
  60468. */
  60469. serialize(): any;
  60470. }
  60471. }
  60472. declare module BABYLON {
  60473. /**
  60474. * This represents one of the lens effect in a `lensFlareSystem`.
  60475. * It controls one of the indiviual texture used in the effect.
  60476. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60477. */
  60478. export class LensFlare {
  60479. /**
  60480. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60481. */
  60482. size: number;
  60483. /**
  60484. * 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.
  60485. */
  60486. position: number;
  60487. /**
  60488. * Define the lens color.
  60489. */
  60490. color: Color3;
  60491. /**
  60492. * Define the lens texture.
  60493. */
  60494. texture: Nullable<Texture>;
  60495. /**
  60496. * Define the alpha mode to render this particular lens.
  60497. */
  60498. alphaMode: number;
  60499. private _system;
  60500. /**
  60501. * Creates a new Lens Flare.
  60502. * This represents one of the lens effect in a `lensFlareSystem`.
  60503. * It controls one of the indiviual texture used in the effect.
  60504. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60505. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60506. * @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.
  60507. * @param color Define the lens color
  60508. * @param imgUrl Define the lens texture url
  60509. * @param system Define the `lensFlareSystem` this flare is part of
  60510. * @returns The newly created Lens Flare
  60511. */
  60512. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60513. /**
  60514. * Instantiates a new Lens Flare.
  60515. * This represents one of the lens effect in a `lensFlareSystem`.
  60516. * It controls one of the indiviual texture used in the effect.
  60517. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60518. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60519. * @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.
  60520. * @param color Define the lens color
  60521. * @param imgUrl Define the lens texture url
  60522. * @param system Define the `lensFlareSystem` this flare is part of
  60523. */
  60524. constructor(
  60525. /**
  60526. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60527. */
  60528. size: number,
  60529. /**
  60530. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  60531. */
  60532. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60533. /**
  60534. * Dispose and release the lens flare with its associated resources.
  60535. */
  60536. dispose(): void;
  60537. }
  60538. }
  60539. declare module BABYLON {
  60540. interface AbstractScene {
  60541. /**
  60542. * The list of lens flare system added to the scene
  60543. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60544. */
  60545. lensFlareSystems: Array<LensFlareSystem>;
  60546. /**
  60547. * Removes the given lens flare system from this scene.
  60548. * @param toRemove The lens flare system to remove
  60549. * @returns The index of the removed lens flare system
  60550. */
  60551. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60552. /**
  60553. * Adds the given lens flare system to this scene
  60554. * @param newLensFlareSystem The lens flare system to add
  60555. */
  60556. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60557. /**
  60558. * Gets a lens flare system using its name
  60559. * @param name defines the name to look for
  60560. * @returns the lens flare system or null if not found
  60561. */
  60562. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60563. /**
  60564. * Gets a lens flare system using its id
  60565. * @param id defines the id to look for
  60566. * @returns the lens flare system or null if not found
  60567. */
  60568. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60569. }
  60570. /**
  60571. * Defines the lens flare scene component responsible to manage any lens flares
  60572. * in a given scene.
  60573. */
  60574. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60575. /**
  60576. * The component name helpfull to identify the component in the list of scene components.
  60577. */
  60578. readonly name: string;
  60579. /**
  60580. * The scene the component belongs to.
  60581. */
  60582. scene: Scene;
  60583. /**
  60584. * Creates a new instance of the component for the given scene
  60585. * @param scene Defines the scene to register the component in
  60586. */
  60587. constructor(scene: Scene);
  60588. /**
  60589. * Registers the component in a given scene
  60590. */
  60591. register(): void;
  60592. /**
  60593. * Rebuilds the elements related to this component in case of
  60594. * context lost for instance.
  60595. */
  60596. rebuild(): void;
  60597. /**
  60598. * Adds all the elements from the container to the scene
  60599. * @param container the container holding the elements
  60600. */
  60601. addFromContainer(container: AbstractScene): void;
  60602. /**
  60603. * Removes all the elements in the container from the scene
  60604. * @param container contains the elements to remove
  60605. * @param dispose if the removed element should be disposed (default: false)
  60606. */
  60607. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60608. /**
  60609. * Serializes the component data to the specified json object
  60610. * @param serializationObject The object to serialize to
  60611. */
  60612. serialize(serializationObject: any): void;
  60613. /**
  60614. * Disposes the component and the associated ressources.
  60615. */
  60616. dispose(): void;
  60617. private _draw;
  60618. }
  60619. }
  60620. declare module BABYLON {
  60621. /** @hidden */
  60622. export var depthPixelShader: {
  60623. name: string;
  60624. shader: string;
  60625. };
  60626. }
  60627. declare module BABYLON {
  60628. /** @hidden */
  60629. export var depthVertexShader: {
  60630. name: string;
  60631. shader: string;
  60632. };
  60633. }
  60634. declare module BABYLON {
  60635. /**
  60636. * This represents a depth renderer in Babylon.
  60637. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60638. */
  60639. export class DepthRenderer {
  60640. private _scene;
  60641. private _depthMap;
  60642. private _effect;
  60643. private readonly _storeNonLinearDepth;
  60644. private readonly _clearColor;
  60645. /** Get if the depth renderer is using packed depth or not */
  60646. readonly isPacked: boolean;
  60647. private _cachedDefines;
  60648. private _camera;
  60649. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60650. enabled: boolean;
  60651. /**
  60652. * Specifiess that the depth renderer will only be used within
  60653. * the camera it is created for.
  60654. * This can help forcing its rendering during the camera processing.
  60655. */
  60656. useOnlyInActiveCamera: boolean;
  60657. /** @hidden */
  60658. static _SceneComponentInitialization: (scene: Scene) => void;
  60659. /**
  60660. * Instantiates a depth renderer
  60661. * @param scene The scene the renderer belongs to
  60662. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60663. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60664. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60665. */
  60666. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60667. /**
  60668. * Creates the depth rendering effect and checks if the effect is ready.
  60669. * @param subMesh The submesh to be used to render the depth map of
  60670. * @param useInstances If multiple world instances should be used
  60671. * @returns if the depth renderer is ready to render the depth map
  60672. */
  60673. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60674. /**
  60675. * Gets the texture which the depth map will be written to.
  60676. * @returns The depth map texture
  60677. */
  60678. getDepthMap(): RenderTargetTexture;
  60679. /**
  60680. * Disposes of the depth renderer.
  60681. */
  60682. dispose(): void;
  60683. }
  60684. }
  60685. declare module BABYLON {
  60686. /** @hidden */
  60687. export var minmaxReduxPixelShader: {
  60688. name: string;
  60689. shader: string;
  60690. };
  60691. }
  60692. declare module BABYLON {
  60693. /**
  60694. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60695. * and maximum values from all values of the texture.
  60696. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60697. * The source values are read from the red channel of the texture.
  60698. */
  60699. export class MinMaxReducer {
  60700. /**
  60701. * Observable triggered when the computation has been performed
  60702. */
  60703. onAfterReductionPerformed: Observable<{
  60704. min: number;
  60705. max: number;
  60706. }>;
  60707. protected _camera: Camera;
  60708. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60709. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60710. protected _postProcessManager: PostProcessManager;
  60711. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60712. protected _forceFullscreenViewport: boolean;
  60713. /**
  60714. * Creates a min/max reducer
  60715. * @param camera The camera to use for the post processes
  60716. */
  60717. constructor(camera: Camera);
  60718. /**
  60719. * Gets the texture used to read the values from.
  60720. */
  60721. get sourceTexture(): Nullable<RenderTargetTexture>;
  60722. /**
  60723. * Sets the source texture to read the values from.
  60724. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60725. * because in such textures '1' value must not be taken into account to compute the maximum
  60726. * as this value is used to clear the texture.
  60727. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60728. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60729. * @param depthRedux Indicates if the texture is a depth texture or not
  60730. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60731. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60732. */
  60733. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60734. /**
  60735. * Defines the refresh rate of the computation.
  60736. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60737. */
  60738. get refreshRate(): number;
  60739. set refreshRate(value: number);
  60740. protected _activated: boolean;
  60741. /**
  60742. * Gets the activation status of the reducer
  60743. */
  60744. get activated(): boolean;
  60745. /**
  60746. * Activates the reduction computation.
  60747. * When activated, the observers registered in onAfterReductionPerformed are
  60748. * called after the compuation is performed
  60749. */
  60750. activate(): void;
  60751. /**
  60752. * Deactivates the reduction computation.
  60753. */
  60754. deactivate(): void;
  60755. /**
  60756. * Disposes the min/max reducer
  60757. * @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.
  60758. */
  60759. dispose(disposeAll?: boolean): void;
  60760. }
  60761. }
  60762. declare module BABYLON {
  60763. /**
  60764. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60765. */
  60766. export class DepthReducer extends MinMaxReducer {
  60767. private _depthRenderer;
  60768. private _depthRendererId;
  60769. /**
  60770. * Gets the depth renderer used for the computation.
  60771. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60772. */
  60773. get depthRenderer(): Nullable<DepthRenderer>;
  60774. /**
  60775. * Creates a depth reducer
  60776. * @param camera The camera used to render the depth texture
  60777. */
  60778. constructor(camera: Camera);
  60779. /**
  60780. * Sets the depth renderer to use to generate the depth map
  60781. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60782. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60783. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60784. */
  60785. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60786. /** @hidden */
  60787. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60788. /**
  60789. * Activates the reduction computation.
  60790. * When activated, the observers registered in onAfterReductionPerformed are
  60791. * called after the compuation is performed
  60792. */
  60793. activate(): void;
  60794. /**
  60795. * Deactivates the reduction computation.
  60796. */
  60797. deactivate(): void;
  60798. /**
  60799. * Disposes the depth reducer
  60800. * @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.
  60801. */
  60802. dispose(disposeAll?: boolean): void;
  60803. }
  60804. }
  60805. declare module BABYLON {
  60806. /**
  60807. * A CSM implementation allowing casting shadows on large scenes.
  60808. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60809. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60810. */
  60811. export class CascadedShadowGenerator extends ShadowGenerator {
  60812. private static readonly frustumCornersNDCSpace;
  60813. /**
  60814. * Name of the CSM class
  60815. */
  60816. static CLASSNAME: string;
  60817. /**
  60818. * Defines the default number of cascades used by the CSM.
  60819. */
  60820. static readonly DEFAULT_CASCADES_COUNT: number;
  60821. /**
  60822. * Defines the minimum number of cascades used by the CSM.
  60823. */
  60824. static readonly MIN_CASCADES_COUNT: number;
  60825. /**
  60826. * Defines the maximum number of cascades used by the CSM.
  60827. */
  60828. static readonly MAX_CASCADES_COUNT: number;
  60829. protected _validateFilter(filter: number): number;
  60830. /**
  60831. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60832. */
  60833. penumbraDarkness: number;
  60834. private _numCascades;
  60835. /**
  60836. * Gets or set the number of cascades used by the CSM.
  60837. */
  60838. get numCascades(): number;
  60839. set numCascades(value: number);
  60840. /**
  60841. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60842. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60843. */
  60844. stabilizeCascades: boolean;
  60845. private _freezeShadowCastersBoundingInfo;
  60846. private _freezeShadowCastersBoundingInfoObservable;
  60847. /**
  60848. * Enables or disables the shadow casters bounding info computation.
  60849. * If your shadow casters don't move, you can disable this feature.
  60850. * If it is enabled, the bounding box computation is done every frame.
  60851. */
  60852. get freezeShadowCastersBoundingInfo(): boolean;
  60853. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60854. private _scbiMin;
  60855. private _scbiMax;
  60856. protected _computeShadowCastersBoundingInfo(): void;
  60857. protected _shadowCastersBoundingInfo: BoundingInfo;
  60858. /**
  60859. * Gets or sets the shadow casters bounding info.
  60860. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60861. * so that the system won't overwrite the bounds you provide
  60862. */
  60863. get shadowCastersBoundingInfo(): BoundingInfo;
  60864. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60865. protected _breaksAreDirty: boolean;
  60866. protected _minDistance: number;
  60867. protected _maxDistance: number;
  60868. /**
  60869. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60870. *
  60871. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60872. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60873. * @param min minimal distance for the breaks (default to 0.)
  60874. * @param max maximal distance for the breaks (default to 1.)
  60875. */
  60876. setMinMaxDistance(min: number, max: number): void;
  60877. /** Gets the minimal distance used in the cascade break computation */
  60878. get minDistance(): number;
  60879. /** Gets the maximal distance used in the cascade break computation */
  60880. get maxDistance(): number;
  60881. /**
  60882. * Gets the class name of that object
  60883. * @returns "CascadedShadowGenerator"
  60884. */
  60885. getClassName(): string;
  60886. private _cascadeMinExtents;
  60887. private _cascadeMaxExtents;
  60888. /**
  60889. * Gets a cascade minimum extents
  60890. * @param cascadeIndex index of the cascade
  60891. * @returns the minimum cascade extents
  60892. */
  60893. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60894. /**
  60895. * Gets a cascade maximum extents
  60896. * @param cascadeIndex index of the cascade
  60897. * @returns the maximum cascade extents
  60898. */
  60899. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60900. private _cascades;
  60901. private _currentLayer;
  60902. private _viewSpaceFrustumsZ;
  60903. private _viewMatrices;
  60904. private _projectionMatrices;
  60905. private _transformMatrices;
  60906. private _transformMatricesAsArray;
  60907. private _frustumLengths;
  60908. private _lightSizeUVCorrection;
  60909. private _depthCorrection;
  60910. private _frustumCornersWorldSpace;
  60911. private _frustumCenter;
  60912. private _shadowCameraPos;
  60913. private _shadowMaxZ;
  60914. /**
  60915. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60916. * It defaults to camera.maxZ
  60917. */
  60918. get shadowMaxZ(): number;
  60919. /**
  60920. * Sets the shadow max z distance.
  60921. */
  60922. set shadowMaxZ(value: number);
  60923. protected _debug: boolean;
  60924. /**
  60925. * Gets or sets the debug flag.
  60926. * When enabled, the cascades are materialized by different colors on the screen.
  60927. */
  60928. get debug(): boolean;
  60929. set debug(dbg: boolean);
  60930. private _depthClamp;
  60931. /**
  60932. * Gets or sets the depth clamping value.
  60933. *
  60934. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60935. * to account for the shadow casters far away.
  60936. *
  60937. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60938. */
  60939. get depthClamp(): boolean;
  60940. set depthClamp(value: boolean);
  60941. private _cascadeBlendPercentage;
  60942. /**
  60943. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60944. * It defaults to 0.1 (10% blending).
  60945. */
  60946. get cascadeBlendPercentage(): number;
  60947. set cascadeBlendPercentage(value: number);
  60948. private _lambda;
  60949. /**
  60950. * Gets or set the lambda parameter.
  60951. * This parameter is used to split the camera frustum and create the cascades.
  60952. * 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.
  60953. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60954. */
  60955. get lambda(): number;
  60956. set lambda(value: number);
  60957. /**
  60958. * Gets the view matrix corresponding to a given cascade
  60959. * @param cascadeNum cascade to retrieve the view matrix from
  60960. * @returns the cascade view matrix
  60961. */
  60962. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60963. /**
  60964. * Gets the projection matrix corresponding to a given cascade
  60965. * @param cascadeNum cascade to retrieve the projection matrix from
  60966. * @returns the cascade projection matrix
  60967. */
  60968. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60969. /**
  60970. * Gets the transformation matrix corresponding to a given cascade
  60971. * @param cascadeNum cascade to retrieve the transformation matrix from
  60972. * @returns the cascade transformation matrix
  60973. */
  60974. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60975. private _depthRenderer;
  60976. /**
  60977. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60978. *
  60979. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60980. *
  60981. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60982. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60983. * @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
  60984. */
  60985. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60986. private _depthReducer;
  60987. private _autoCalcDepthBounds;
  60988. /**
  60989. * Gets or sets the autoCalcDepthBounds property.
  60990. *
  60991. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60992. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60993. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60994. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60995. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60996. */
  60997. get autoCalcDepthBounds(): boolean;
  60998. set autoCalcDepthBounds(value: boolean);
  60999. /**
  61000. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61001. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61002. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61003. * for setting the refresh rate on the renderer yourself!
  61004. */
  61005. get autoCalcDepthBoundsRefreshRate(): number;
  61006. set autoCalcDepthBoundsRefreshRate(value: number);
  61007. /**
  61008. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61009. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61010. * you change the camera near/far planes!
  61011. */
  61012. splitFrustum(): void;
  61013. private _splitFrustum;
  61014. private _computeMatrices;
  61015. private _computeFrustumInWorldSpace;
  61016. private _computeCascadeFrustum;
  61017. /**
  61018. * Support test.
  61019. */
  61020. static get IsSupported(): boolean;
  61021. /** @hidden */
  61022. static _SceneComponentInitialization: (scene: Scene) => void;
  61023. /**
  61024. * Creates a Cascaded Shadow Generator object.
  61025. * A ShadowGenerator is the required tool to use the shadows.
  61026. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61027. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61028. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61029. * @param light The directional light object generating the shadows.
  61030. * @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.
  61031. */
  61032. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61033. protected _initializeGenerator(): void;
  61034. protected _createTargetRenderTexture(): void;
  61035. protected _initializeShadowMap(): void;
  61036. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61037. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61038. /**
  61039. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61040. * @param defines Defines of the material we want to update
  61041. * @param lightIndex Index of the light in the enabled light list of the material
  61042. */
  61043. prepareDefines(defines: any, lightIndex: number): void;
  61044. /**
  61045. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61046. * defined in the generator but impacting the effect).
  61047. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61048. * @param effect The effect we are binfing the information for
  61049. */
  61050. bindShadowLight(lightIndex: string, effect: Effect): void;
  61051. /**
  61052. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61053. * (eq to view projection * shadow projection matrices)
  61054. * @returns The transform matrix used to create the shadow map
  61055. */
  61056. getTransformMatrix(): Matrix;
  61057. /**
  61058. * Disposes the ShadowGenerator.
  61059. * Returns nothing.
  61060. */
  61061. dispose(): void;
  61062. /**
  61063. * Serializes the shadow generator setup to a json object.
  61064. * @returns The serialized JSON object
  61065. */
  61066. serialize(): any;
  61067. /**
  61068. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61069. * @param parsedShadowGenerator The JSON object to parse
  61070. * @param scene The scene to create the shadow map for
  61071. * @returns The parsed shadow generator
  61072. */
  61073. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61074. }
  61075. }
  61076. declare module BABYLON {
  61077. /**
  61078. * Defines the shadow generator component responsible to manage any shadow generators
  61079. * in a given scene.
  61080. */
  61081. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61082. /**
  61083. * The component name helpfull to identify the component in the list of scene components.
  61084. */
  61085. readonly name: string;
  61086. /**
  61087. * The scene the component belongs to.
  61088. */
  61089. scene: Scene;
  61090. /**
  61091. * Creates a new instance of the component for the given scene
  61092. * @param scene Defines the scene to register the component in
  61093. */
  61094. constructor(scene: Scene);
  61095. /**
  61096. * Registers the component in a given scene
  61097. */
  61098. register(): void;
  61099. /**
  61100. * Rebuilds the elements related to this component in case of
  61101. * context lost for instance.
  61102. */
  61103. rebuild(): void;
  61104. /**
  61105. * Serializes the component data to the specified json object
  61106. * @param serializationObject The object to serialize to
  61107. */
  61108. serialize(serializationObject: any): void;
  61109. /**
  61110. * Adds all the elements from the container to the scene
  61111. * @param container the container holding the elements
  61112. */
  61113. addFromContainer(container: AbstractScene): void;
  61114. /**
  61115. * Removes all the elements in the container from the scene
  61116. * @param container contains the elements to remove
  61117. * @param dispose if the removed element should be disposed (default: false)
  61118. */
  61119. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61120. /**
  61121. * Rebuilds the elements related to this component in case of
  61122. * context lost for instance.
  61123. */
  61124. dispose(): void;
  61125. private _gatherRenderTargets;
  61126. }
  61127. }
  61128. declare module BABYLON {
  61129. /**
  61130. * A point light is a light defined by an unique point in world space.
  61131. * The light is emitted in every direction from this point.
  61132. * A good example of a point light is a standard light bulb.
  61133. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61134. */
  61135. export class PointLight extends ShadowLight {
  61136. private _shadowAngle;
  61137. /**
  61138. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61139. * This specifies what angle the shadow will use to be created.
  61140. *
  61141. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61142. */
  61143. get shadowAngle(): number;
  61144. /**
  61145. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61146. * This specifies what angle the shadow will use to be created.
  61147. *
  61148. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61149. */
  61150. set shadowAngle(value: number);
  61151. /**
  61152. * Gets the direction if it has been set.
  61153. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61154. */
  61155. get direction(): Vector3;
  61156. /**
  61157. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61158. */
  61159. set direction(value: Vector3);
  61160. /**
  61161. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61162. * A PointLight emits the light in every direction.
  61163. * It can cast shadows.
  61164. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61165. * ```javascript
  61166. * var pointLight = new PointLight("pl", camera.position, scene);
  61167. * ```
  61168. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61169. * @param name The light friendly name
  61170. * @param position The position of the point light in the scene
  61171. * @param scene The scene the lights belongs to
  61172. */
  61173. constructor(name: string, position: Vector3, scene: Scene);
  61174. /**
  61175. * Returns the string "PointLight"
  61176. * @returns the class name
  61177. */
  61178. getClassName(): string;
  61179. /**
  61180. * Returns the integer 0.
  61181. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61182. */
  61183. getTypeID(): number;
  61184. /**
  61185. * Specifies wether or not the shadowmap should be a cube texture.
  61186. * @returns true if the shadowmap needs to be a cube texture.
  61187. */
  61188. needCube(): boolean;
  61189. /**
  61190. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61191. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61192. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61193. */
  61194. getShadowDirection(faceIndex?: number): Vector3;
  61195. /**
  61196. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61197. * - fov = PI / 2
  61198. * - aspect ratio : 1.0
  61199. * - z-near and far equal to the active camera minZ and maxZ.
  61200. * Returns the PointLight.
  61201. */
  61202. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61203. protected _buildUniformLayout(): void;
  61204. /**
  61205. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61206. * @param effect The effect to update
  61207. * @param lightIndex The index of the light in the effect to update
  61208. * @returns The point light
  61209. */
  61210. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61211. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61212. /**
  61213. * Prepares the list of defines specific to the light type.
  61214. * @param defines the list of defines
  61215. * @param lightIndex defines the index of the light for the effect
  61216. */
  61217. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61218. }
  61219. }
  61220. declare module BABYLON {
  61221. /**
  61222. * Header information of HDR texture files.
  61223. */
  61224. export interface HDRInfo {
  61225. /**
  61226. * The height of the texture in pixels.
  61227. */
  61228. height: number;
  61229. /**
  61230. * The width of the texture in pixels.
  61231. */
  61232. width: number;
  61233. /**
  61234. * The index of the beginning of the data in the binary file.
  61235. */
  61236. dataPosition: number;
  61237. }
  61238. /**
  61239. * This groups tools to convert HDR texture to native colors array.
  61240. */
  61241. export class HDRTools {
  61242. private static Ldexp;
  61243. private static Rgbe2float;
  61244. private static readStringLine;
  61245. /**
  61246. * Reads header information from an RGBE texture stored in a native array.
  61247. * More information on this format are available here:
  61248. * https://en.wikipedia.org/wiki/RGBE_image_format
  61249. *
  61250. * @param uint8array The binary file stored in native array.
  61251. * @return The header information.
  61252. */
  61253. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61254. /**
  61255. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61256. * This RGBE texture needs to store the information as a panorama.
  61257. *
  61258. * More information on this format are available here:
  61259. * https://en.wikipedia.org/wiki/RGBE_image_format
  61260. *
  61261. * @param buffer The binary file stored in an array buffer.
  61262. * @param size The expected size of the extracted cubemap.
  61263. * @return The Cube Map information.
  61264. */
  61265. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61266. /**
  61267. * Returns the pixels data extracted from an RGBE texture.
  61268. * This pixels will be stored left to right up to down in the R G B order in one array.
  61269. *
  61270. * More information on this format are available here:
  61271. * https://en.wikipedia.org/wiki/RGBE_image_format
  61272. *
  61273. * @param uint8array The binary file stored in an array buffer.
  61274. * @param hdrInfo The header information of the file.
  61275. * @return The pixels data in RGB right to left up to down order.
  61276. */
  61277. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61278. private static RGBE_ReadPixels_RLE;
  61279. private static RGBE_ReadPixels_NOT_RLE;
  61280. }
  61281. }
  61282. declare module BABYLON {
  61283. /**
  61284. * Effect Render Options
  61285. */
  61286. export interface IEffectRendererOptions {
  61287. /**
  61288. * Defines the vertices positions.
  61289. */
  61290. positions?: number[];
  61291. /**
  61292. * Defines the indices.
  61293. */
  61294. indices?: number[];
  61295. }
  61296. /**
  61297. * Helper class to render one or more effects.
  61298. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61299. */
  61300. export class EffectRenderer {
  61301. private engine;
  61302. private static _DefaultOptions;
  61303. private _vertexBuffers;
  61304. private _indexBuffer;
  61305. private _fullscreenViewport;
  61306. /**
  61307. * Creates an effect renderer
  61308. * @param engine the engine to use for rendering
  61309. * @param options defines the options of the effect renderer
  61310. */
  61311. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61312. /**
  61313. * Sets the current viewport in normalized coordinates 0-1
  61314. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61315. */
  61316. setViewport(viewport?: Viewport): void;
  61317. /**
  61318. * Binds the embedded attributes buffer to the effect.
  61319. * @param effect Defines the effect to bind the attributes for
  61320. */
  61321. bindBuffers(effect: Effect): void;
  61322. /**
  61323. * Sets the current effect wrapper to use during draw.
  61324. * The effect needs to be ready before calling this api.
  61325. * This also sets the default full screen position attribute.
  61326. * @param effectWrapper Defines the effect to draw with
  61327. */
  61328. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61329. /**
  61330. * Restores engine states
  61331. */
  61332. restoreStates(): void;
  61333. /**
  61334. * Draws a full screen quad.
  61335. */
  61336. draw(): void;
  61337. private isRenderTargetTexture;
  61338. /**
  61339. * renders one or more effects to a specified texture
  61340. * @param effectWrapper the effect to renderer
  61341. * @param outputTexture texture to draw to, if null it will render to the screen.
  61342. */
  61343. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61344. /**
  61345. * Disposes of the effect renderer
  61346. */
  61347. dispose(): void;
  61348. }
  61349. /**
  61350. * Options to create an EffectWrapper
  61351. */
  61352. interface EffectWrapperCreationOptions {
  61353. /**
  61354. * Engine to use to create the effect
  61355. */
  61356. engine: ThinEngine;
  61357. /**
  61358. * Fragment shader for the effect
  61359. */
  61360. fragmentShader: string;
  61361. /**
  61362. * Use the shader store instead of direct source code
  61363. */
  61364. useShaderStore?: boolean;
  61365. /**
  61366. * Vertex shader for the effect
  61367. */
  61368. vertexShader?: string;
  61369. /**
  61370. * Attributes to use in the shader
  61371. */
  61372. attributeNames?: Array<string>;
  61373. /**
  61374. * Uniforms to use in the shader
  61375. */
  61376. uniformNames?: Array<string>;
  61377. /**
  61378. * Texture sampler names to use in the shader
  61379. */
  61380. samplerNames?: Array<string>;
  61381. /**
  61382. * Defines to use in the shader
  61383. */
  61384. defines?: Array<string>;
  61385. /**
  61386. * Callback when effect is compiled
  61387. */
  61388. onCompiled?: Nullable<(effect: Effect) => void>;
  61389. /**
  61390. * The friendly name of the effect displayed in Spector.
  61391. */
  61392. name?: string;
  61393. }
  61394. /**
  61395. * Wraps an effect to be used for rendering
  61396. */
  61397. export class EffectWrapper {
  61398. /**
  61399. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61400. */
  61401. onApplyObservable: Observable<{}>;
  61402. /**
  61403. * The underlying effect
  61404. */
  61405. effect: Effect;
  61406. /**
  61407. * Creates an effect to be renderer
  61408. * @param creationOptions options to create the effect
  61409. */
  61410. constructor(creationOptions: EffectWrapperCreationOptions);
  61411. /**
  61412. * Disposes of the effect wrapper
  61413. */
  61414. dispose(): void;
  61415. }
  61416. }
  61417. declare module BABYLON {
  61418. /** @hidden */
  61419. export var hdrFilteringVertexShader: {
  61420. name: string;
  61421. shader: string;
  61422. };
  61423. }
  61424. declare module BABYLON {
  61425. /** @hidden */
  61426. export var hdrFilteringPixelShader: {
  61427. name: string;
  61428. shader: string;
  61429. };
  61430. }
  61431. declare module BABYLON {
  61432. /**
  61433. * Options for texture filtering
  61434. */
  61435. interface IHDRFilteringOptions {
  61436. /**
  61437. * Scales pixel intensity for the input HDR map.
  61438. */
  61439. hdrScale?: number;
  61440. /**
  61441. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61442. */
  61443. quality?: number;
  61444. }
  61445. /**
  61446. * Filters HDR maps to get correct renderings of PBR reflections
  61447. */
  61448. export class HDRFiltering {
  61449. private _engine;
  61450. private _effectRenderer;
  61451. private _effectWrapper;
  61452. private _lodGenerationOffset;
  61453. private _lodGenerationScale;
  61454. /**
  61455. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61456. * you care about baking speed.
  61457. */
  61458. quality: number;
  61459. /**
  61460. * Scales pixel intensity for the input HDR map.
  61461. */
  61462. hdrScale: number;
  61463. /**
  61464. * Instantiates HDR filter for reflection maps
  61465. *
  61466. * @param engine Thin engine
  61467. * @param options Options
  61468. */
  61469. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61470. private _createRenderTarget;
  61471. private _prefilterInternal;
  61472. private _createEffect;
  61473. /**
  61474. * Get a value indicating if the filter is ready to be used
  61475. * @param texture Texture to filter
  61476. * @returns true if the filter is ready
  61477. */
  61478. isReady(texture: BaseTexture): boolean;
  61479. /**
  61480. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61481. * Prefiltering will be invoked at the end of next rendering pass.
  61482. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61483. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61484. * @param texture Texture to filter
  61485. * @param onFinished Callback when filtering is done
  61486. * @return Promise called when prefiltering is done
  61487. */
  61488. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61489. }
  61490. }
  61491. declare module BABYLON {
  61492. /**
  61493. * This represents a texture coming from an HDR input.
  61494. *
  61495. * The only supported format is currently panorama picture stored in RGBE format.
  61496. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61497. */
  61498. export class HDRCubeTexture extends BaseTexture {
  61499. private static _facesMapping;
  61500. private _generateHarmonics;
  61501. private _noMipmap;
  61502. private _prefilterOnLoad;
  61503. private _textureMatrix;
  61504. private _size;
  61505. private _onLoad;
  61506. private _onError;
  61507. /**
  61508. * The texture URL.
  61509. */
  61510. url: string;
  61511. protected _isBlocking: boolean;
  61512. /**
  61513. * Sets wether or not the texture is blocking during loading.
  61514. */
  61515. set isBlocking(value: boolean);
  61516. /**
  61517. * Gets wether or not the texture is blocking during loading.
  61518. */
  61519. get isBlocking(): boolean;
  61520. protected _rotationY: number;
  61521. /**
  61522. * Sets texture matrix rotation angle around Y axis in radians.
  61523. */
  61524. set rotationY(value: number);
  61525. /**
  61526. * Gets texture matrix rotation angle around Y axis radians.
  61527. */
  61528. get rotationY(): number;
  61529. /**
  61530. * Gets or sets the center of the bounding box associated with the cube texture
  61531. * It must define where the camera used to render the texture was set
  61532. */
  61533. boundingBoxPosition: Vector3;
  61534. private _boundingBoxSize;
  61535. /**
  61536. * Gets or sets the size of the bounding box associated with the cube texture
  61537. * When defined, the cubemap will switch to local mode
  61538. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61539. * @example https://www.babylonjs-playground.com/#RNASML
  61540. */
  61541. set boundingBoxSize(value: Vector3);
  61542. get boundingBoxSize(): Vector3;
  61543. /**
  61544. * Instantiates an HDRTexture from the following parameters.
  61545. *
  61546. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61547. * @param sceneOrEngine The scene or engine the texture will be used in
  61548. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61549. * @param noMipmap Forces to not generate the mipmap if true
  61550. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61551. * @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)
  61552. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61553. */
  61554. 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>);
  61555. /**
  61556. * Get the current class name of the texture useful for serialization or dynamic coding.
  61557. * @returns "HDRCubeTexture"
  61558. */
  61559. getClassName(): string;
  61560. /**
  61561. * Occurs when the file is raw .hdr file.
  61562. */
  61563. private loadTexture;
  61564. clone(): HDRCubeTexture;
  61565. delayLoad(): void;
  61566. /**
  61567. * Get the texture reflection matrix used to rotate/transform the reflection.
  61568. * @returns the reflection matrix
  61569. */
  61570. getReflectionTextureMatrix(): Matrix;
  61571. /**
  61572. * Set the texture reflection matrix used to rotate/transform the reflection.
  61573. * @param value Define the reflection matrix to set
  61574. */
  61575. setReflectionTextureMatrix(value: Matrix): void;
  61576. /**
  61577. * Parses a JSON representation of an HDR Texture in order to create the texture
  61578. * @param parsedTexture Define the JSON representation
  61579. * @param scene Define the scene the texture should be created in
  61580. * @param rootUrl Define the root url in case we need to load relative dependencies
  61581. * @returns the newly created texture after parsing
  61582. */
  61583. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61584. serialize(): any;
  61585. }
  61586. }
  61587. declare module BABYLON {
  61588. /**
  61589. * Class used to control physics engine
  61590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61591. */
  61592. export class PhysicsEngine implements IPhysicsEngine {
  61593. private _physicsPlugin;
  61594. /**
  61595. * Global value used to control the smallest number supported by the simulation
  61596. */
  61597. static Epsilon: number;
  61598. private _impostors;
  61599. private _joints;
  61600. private _subTimeStep;
  61601. /**
  61602. * Gets the gravity vector used by the simulation
  61603. */
  61604. gravity: Vector3;
  61605. /**
  61606. * Factory used to create the default physics plugin.
  61607. * @returns The default physics plugin
  61608. */
  61609. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61610. /**
  61611. * Creates a new Physics Engine
  61612. * @param gravity defines the gravity vector used by the simulation
  61613. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61614. */
  61615. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61616. /**
  61617. * Sets the gravity vector used by the simulation
  61618. * @param gravity defines the gravity vector to use
  61619. */
  61620. setGravity(gravity: Vector3): void;
  61621. /**
  61622. * Set the time step of the physics engine.
  61623. * Default is 1/60.
  61624. * To slow it down, enter 1/600 for example.
  61625. * To speed it up, 1/30
  61626. * @param newTimeStep defines the new timestep to apply to this world.
  61627. */
  61628. setTimeStep(newTimeStep?: number): void;
  61629. /**
  61630. * Get the time step of the physics engine.
  61631. * @returns the current time step
  61632. */
  61633. getTimeStep(): number;
  61634. /**
  61635. * Set the sub time step of the physics engine.
  61636. * Default is 0 meaning there is no sub steps
  61637. * To increase physics resolution precision, set a small value (like 1 ms)
  61638. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61639. */
  61640. setSubTimeStep(subTimeStep?: number): void;
  61641. /**
  61642. * Get the sub time step of the physics engine.
  61643. * @returns the current sub time step
  61644. */
  61645. getSubTimeStep(): number;
  61646. /**
  61647. * Release all resources
  61648. */
  61649. dispose(): void;
  61650. /**
  61651. * Gets the name of the current physics plugin
  61652. * @returns the name of the plugin
  61653. */
  61654. getPhysicsPluginName(): string;
  61655. /**
  61656. * Adding a new impostor for the impostor tracking.
  61657. * This will be done by the impostor itself.
  61658. * @param impostor the impostor to add
  61659. */
  61660. addImpostor(impostor: PhysicsImpostor): void;
  61661. /**
  61662. * Remove an impostor from the engine.
  61663. * This impostor and its mesh will not longer be updated by the physics engine.
  61664. * @param impostor the impostor to remove
  61665. */
  61666. removeImpostor(impostor: PhysicsImpostor): void;
  61667. /**
  61668. * Add a joint to the physics engine
  61669. * @param mainImpostor defines the main impostor to which the joint is added.
  61670. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61671. * @param joint defines the joint that will connect both impostors.
  61672. */
  61673. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61674. /**
  61675. * Removes a joint from the simulation
  61676. * @param mainImpostor defines the impostor used with the joint
  61677. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61678. * @param joint defines the joint to remove
  61679. */
  61680. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61681. /**
  61682. * Called by the scene. No need to call it.
  61683. * @param delta defines the timespam between frames
  61684. */
  61685. _step(delta: number): void;
  61686. /**
  61687. * Gets the current plugin used to run the simulation
  61688. * @returns current plugin
  61689. */
  61690. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61691. /**
  61692. * Gets the list of physic impostors
  61693. * @returns an array of PhysicsImpostor
  61694. */
  61695. getImpostors(): Array<PhysicsImpostor>;
  61696. /**
  61697. * Gets the impostor for a physics enabled object
  61698. * @param object defines the object impersonated by the impostor
  61699. * @returns the PhysicsImpostor or null if not found
  61700. */
  61701. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61702. /**
  61703. * Gets the impostor for a physics body object
  61704. * @param body defines physics body used by the impostor
  61705. * @returns the PhysicsImpostor or null if not found
  61706. */
  61707. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61708. /**
  61709. * Does a raycast in the physics world
  61710. * @param from when should the ray start?
  61711. * @param to when should the ray end?
  61712. * @returns PhysicsRaycastResult
  61713. */
  61714. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61715. }
  61716. }
  61717. declare module BABYLON {
  61718. /** @hidden */
  61719. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61720. private _useDeltaForWorldStep;
  61721. world: any;
  61722. name: string;
  61723. private _physicsMaterials;
  61724. private _fixedTimeStep;
  61725. private _cannonRaycastResult;
  61726. private _raycastResult;
  61727. private _physicsBodysToRemoveAfterStep;
  61728. private _firstFrame;
  61729. BJSCANNON: any;
  61730. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61731. setGravity(gravity: Vector3): void;
  61732. setTimeStep(timeStep: number): void;
  61733. getTimeStep(): number;
  61734. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61735. private _removeMarkedPhysicsBodiesFromWorld;
  61736. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61737. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61738. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61739. private _processChildMeshes;
  61740. removePhysicsBody(impostor: PhysicsImpostor): void;
  61741. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61742. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61743. private _addMaterial;
  61744. private _checkWithEpsilon;
  61745. private _createShape;
  61746. private _createHeightmap;
  61747. private _minus90X;
  61748. private _plus90X;
  61749. private _tmpPosition;
  61750. private _tmpDeltaPosition;
  61751. private _tmpUnityRotation;
  61752. private _updatePhysicsBodyTransformation;
  61753. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61754. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61755. isSupported(): boolean;
  61756. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61757. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61758. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61759. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61760. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61761. getBodyMass(impostor: PhysicsImpostor): number;
  61762. getBodyFriction(impostor: PhysicsImpostor): number;
  61763. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61764. getBodyRestitution(impostor: PhysicsImpostor): number;
  61765. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61766. sleepBody(impostor: PhysicsImpostor): void;
  61767. wakeUpBody(impostor: PhysicsImpostor): void;
  61768. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61769. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61770. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61771. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61772. getRadius(impostor: PhysicsImpostor): number;
  61773. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61774. dispose(): void;
  61775. private _extendNamespace;
  61776. /**
  61777. * Does a raycast in the physics world
  61778. * @param from when should the ray start?
  61779. * @param to when should the ray end?
  61780. * @returns PhysicsRaycastResult
  61781. */
  61782. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61783. }
  61784. }
  61785. declare module BABYLON {
  61786. /** @hidden */
  61787. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61788. private _useDeltaForWorldStep;
  61789. world: any;
  61790. name: string;
  61791. BJSOIMO: any;
  61792. private _raycastResult;
  61793. private _fixedTimeStep;
  61794. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61795. setGravity(gravity: Vector3): void;
  61796. setTimeStep(timeStep: number): void;
  61797. getTimeStep(): number;
  61798. private _tmpImpostorsArray;
  61799. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61800. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61801. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61802. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61803. private _tmpPositionVector;
  61804. removePhysicsBody(impostor: PhysicsImpostor): void;
  61805. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61806. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61807. isSupported(): boolean;
  61808. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61809. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61810. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61811. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61812. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61813. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61814. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61815. getBodyMass(impostor: PhysicsImpostor): number;
  61816. getBodyFriction(impostor: PhysicsImpostor): number;
  61817. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61818. getBodyRestitution(impostor: PhysicsImpostor): number;
  61819. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61820. sleepBody(impostor: PhysicsImpostor): void;
  61821. wakeUpBody(impostor: PhysicsImpostor): void;
  61822. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61823. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61824. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61825. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61826. getRadius(impostor: PhysicsImpostor): number;
  61827. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61828. dispose(): void;
  61829. /**
  61830. * Does a raycast in the physics world
  61831. * @param from when should the ray start?
  61832. * @param to when should the ray end?
  61833. * @returns PhysicsRaycastResult
  61834. */
  61835. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61836. }
  61837. }
  61838. declare module BABYLON {
  61839. /**
  61840. * AmmoJS Physics plugin
  61841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61842. * @see https://github.com/kripken/ammo.js/
  61843. */
  61844. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61845. private _useDeltaForWorldStep;
  61846. /**
  61847. * Reference to the Ammo library
  61848. */
  61849. bjsAMMO: any;
  61850. /**
  61851. * Created ammoJS world which physics bodies are added to
  61852. */
  61853. world: any;
  61854. /**
  61855. * Name of the plugin
  61856. */
  61857. name: string;
  61858. private _timeStep;
  61859. private _fixedTimeStep;
  61860. private _maxSteps;
  61861. private _tmpQuaternion;
  61862. private _tmpAmmoTransform;
  61863. private _tmpAmmoQuaternion;
  61864. private _tmpAmmoConcreteContactResultCallback;
  61865. private _collisionConfiguration;
  61866. private _dispatcher;
  61867. private _overlappingPairCache;
  61868. private _solver;
  61869. private _softBodySolver;
  61870. private _tmpAmmoVectorA;
  61871. private _tmpAmmoVectorB;
  61872. private _tmpAmmoVectorC;
  61873. private _tmpAmmoVectorD;
  61874. private _tmpContactCallbackResult;
  61875. private _tmpAmmoVectorRCA;
  61876. private _tmpAmmoVectorRCB;
  61877. private _raycastResult;
  61878. private _tmpContactPoint;
  61879. private static readonly DISABLE_COLLISION_FLAG;
  61880. private static readonly KINEMATIC_FLAG;
  61881. private static readonly DISABLE_DEACTIVATION_FLAG;
  61882. /**
  61883. * Initializes the ammoJS plugin
  61884. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61885. * @param ammoInjection can be used to inject your own ammo reference
  61886. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61887. */
  61888. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61889. /**
  61890. * Sets the gravity of the physics world (m/(s^2))
  61891. * @param gravity Gravity to set
  61892. */
  61893. setGravity(gravity: Vector3): void;
  61894. /**
  61895. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61896. * @param timeStep timestep to use in seconds
  61897. */
  61898. setTimeStep(timeStep: number): void;
  61899. /**
  61900. * 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)
  61901. * @param fixedTimeStep fixedTimeStep to use in seconds
  61902. */
  61903. setFixedTimeStep(fixedTimeStep: number): void;
  61904. /**
  61905. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61906. * @param maxSteps the maximum number of steps by the physics engine per frame
  61907. */
  61908. setMaxSteps(maxSteps: number): void;
  61909. /**
  61910. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61911. * @returns the current timestep in seconds
  61912. */
  61913. getTimeStep(): number;
  61914. /**
  61915. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61916. */
  61917. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61918. private _isImpostorInContact;
  61919. private _isImpostorPairInContact;
  61920. private _stepSimulation;
  61921. /**
  61922. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61923. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61924. * After the step the babylon meshes are set to the position of the physics imposters
  61925. * @param delta amount of time to step forward
  61926. * @param impostors array of imposters to update before/after the step
  61927. */
  61928. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61929. /**
  61930. * Update babylon mesh to match physics world object
  61931. * @param impostor imposter to match
  61932. */
  61933. private _afterSoftStep;
  61934. /**
  61935. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61936. * @param impostor imposter to match
  61937. */
  61938. private _ropeStep;
  61939. /**
  61940. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61941. * @param impostor imposter to match
  61942. */
  61943. private _softbodyOrClothStep;
  61944. private _tmpMatrix;
  61945. /**
  61946. * Applies an impulse on the imposter
  61947. * @param impostor imposter to apply impulse to
  61948. * @param force amount of force to be applied to the imposter
  61949. * @param contactPoint the location to apply the impulse on the imposter
  61950. */
  61951. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61952. /**
  61953. * Applies a force on the imposter
  61954. * @param impostor imposter to apply force
  61955. * @param force amount of force to be applied to the imposter
  61956. * @param contactPoint the location to apply the force on the imposter
  61957. */
  61958. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61959. /**
  61960. * Creates a physics body using the plugin
  61961. * @param impostor the imposter to create the physics body on
  61962. */
  61963. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61964. /**
  61965. * Removes the physics body from the imposter and disposes of the body's memory
  61966. * @param impostor imposter to remove the physics body from
  61967. */
  61968. removePhysicsBody(impostor: PhysicsImpostor): void;
  61969. /**
  61970. * Generates a joint
  61971. * @param impostorJoint the imposter joint to create the joint with
  61972. */
  61973. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61974. /**
  61975. * Removes a joint
  61976. * @param impostorJoint the imposter joint to remove the joint from
  61977. */
  61978. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61979. private _addMeshVerts;
  61980. /**
  61981. * Initialise the soft body vertices to match its object's (mesh) vertices
  61982. * Softbody vertices (nodes) are in world space and to match this
  61983. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61984. * @param impostor to create the softbody for
  61985. */
  61986. private _softVertexData;
  61987. /**
  61988. * Create an impostor's soft body
  61989. * @param impostor to create the softbody for
  61990. */
  61991. private _createSoftbody;
  61992. /**
  61993. * Create cloth for an impostor
  61994. * @param impostor to create the softbody for
  61995. */
  61996. private _createCloth;
  61997. /**
  61998. * Create rope for an impostor
  61999. * @param impostor to create the softbody for
  62000. */
  62001. private _createRope;
  62002. /**
  62003. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62004. * @param impostor to create the custom physics shape for
  62005. */
  62006. private _createCustom;
  62007. private _addHullVerts;
  62008. private _createShape;
  62009. /**
  62010. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62011. * @param impostor imposter containing the physics body and babylon object
  62012. */
  62013. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62014. /**
  62015. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62016. * @param impostor imposter containing the physics body and babylon object
  62017. * @param newPosition new position
  62018. * @param newRotation new rotation
  62019. */
  62020. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62021. /**
  62022. * If this plugin is supported
  62023. * @returns true if its supported
  62024. */
  62025. isSupported(): boolean;
  62026. /**
  62027. * Sets the linear velocity of the physics body
  62028. * @param impostor imposter to set the velocity on
  62029. * @param velocity velocity to set
  62030. */
  62031. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62032. /**
  62033. * Sets the angular velocity of the physics body
  62034. * @param impostor imposter to set the velocity on
  62035. * @param velocity velocity to set
  62036. */
  62037. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62038. /**
  62039. * gets the linear velocity
  62040. * @param impostor imposter to get linear velocity from
  62041. * @returns linear velocity
  62042. */
  62043. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62044. /**
  62045. * gets the angular velocity
  62046. * @param impostor imposter to get angular velocity from
  62047. * @returns angular velocity
  62048. */
  62049. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62050. /**
  62051. * Sets the mass of physics body
  62052. * @param impostor imposter to set the mass on
  62053. * @param mass mass to set
  62054. */
  62055. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62056. /**
  62057. * Gets the mass of the physics body
  62058. * @param impostor imposter to get the mass from
  62059. * @returns mass
  62060. */
  62061. getBodyMass(impostor: PhysicsImpostor): number;
  62062. /**
  62063. * Gets friction of the impostor
  62064. * @param impostor impostor to get friction from
  62065. * @returns friction value
  62066. */
  62067. getBodyFriction(impostor: PhysicsImpostor): number;
  62068. /**
  62069. * Sets friction of the impostor
  62070. * @param impostor impostor to set friction on
  62071. * @param friction friction value
  62072. */
  62073. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62074. /**
  62075. * Gets restitution of the impostor
  62076. * @param impostor impostor to get restitution from
  62077. * @returns restitution value
  62078. */
  62079. getBodyRestitution(impostor: PhysicsImpostor): number;
  62080. /**
  62081. * Sets resitution of the impostor
  62082. * @param impostor impostor to set resitution on
  62083. * @param restitution resitution value
  62084. */
  62085. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62086. /**
  62087. * Gets pressure inside the impostor
  62088. * @param impostor impostor to get pressure from
  62089. * @returns pressure value
  62090. */
  62091. getBodyPressure(impostor: PhysicsImpostor): number;
  62092. /**
  62093. * Sets pressure inside a soft body impostor
  62094. * Cloth and rope must remain 0 pressure
  62095. * @param impostor impostor to set pressure on
  62096. * @param pressure pressure value
  62097. */
  62098. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62099. /**
  62100. * Gets stiffness of the impostor
  62101. * @param impostor impostor to get stiffness from
  62102. * @returns pressure value
  62103. */
  62104. getBodyStiffness(impostor: PhysicsImpostor): number;
  62105. /**
  62106. * Sets stiffness of the impostor
  62107. * @param impostor impostor to set stiffness on
  62108. * @param stiffness stiffness value from 0 to 1
  62109. */
  62110. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62111. /**
  62112. * Gets velocityIterations of the impostor
  62113. * @param impostor impostor to get velocity iterations from
  62114. * @returns velocityIterations value
  62115. */
  62116. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62117. /**
  62118. * Sets velocityIterations of the impostor
  62119. * @param impostor impostor to set velocity iterations on
  62120. * @param velocityIterations velocityIterations value
  62121. */
  62122. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62123. /**
  62124. * Gets positionIterations of the impostor
  62125. * @param impostor impostor to get position iterations from
  62126. * @returns positionIterations value
  62127. */
  62128. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62129. /**
  62130. * Sets positionIterations of the impostor
  62131. * @param impostor impostor to set position on
  62132. * @param positionIterations positionIterations value
  62133. */
  62134. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62135. /**
  62136. * Append an anchor to a cloth object
  62137. * @param impostor is the cloth impostor to add anchor to
  62138. * @param otherImpostor is the rigid impostor to anchor to
  62139. * @param width ratio across width from 0 to 1
  62140. * @param height ratio up height from 0 to 1
  62141. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62142. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62143. */
  62144. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62145. /**
  62146. * Append an hook to a rope object
  62147. * @param impostor is the rope impostor to add hook to
  62148. * @param otherImpostor is the rigid impostor to hook to
  62149. * @param length ratio along the rope from 0 to 1
  62150. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62151. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62152. */
  62153. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62154. /**
  62155. * Sleeps the physics body and stops it from being active
  62156. * @param impostor impostor to sleep
  62157. */
  62158. sleepBody(impostor: PhysicsImpostor): void;
  62159. /**
  62160. * Activates the physics body
  62161. * @param impostor impostor to activate
  62162. */
  62163. wakeUpBody(impostor: PhysicsImpostor): void;
  62164. /**
  62165. * Updates the distance parameters of the joint
  62166. * @param joint joint to update
  62167. * @param maxDistance maximum distance of the joint
  62168. * @param minDistance minimum distance of the joint
  62169. */
  62170. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62171. /**
  62172. * Sets a motor on the joint
  62173. * @param joint joint to set motor on
  62174. * @param speed speed of the motor
  62175. * @param maxForce maximum force of the motor
  62176. * @param motorIndex index of the motor
  62177. */
  62178. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62179. /**
  62180. * Sets the motors limit
  62181. * @param joint joint to set limit on
  62182. * @param upperLimit upper limit
  62183. * @param lowerLimit lower limit
  62184. */
  62185. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62186. /**
  62187. * Syncs the position and rotation of a mesh with the impostor
  62188. * @param mesh mesh to sync
  62189. * @param impostor impostor to update the mesh with
  62190. */
  62191. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62192. /**
  62193. * Gets the radius of the impostor
  62194. * @param impostor impostor to get radius from
  62195. * @returns the radius
  62196. */
  62197. getRadius(impostor: PhysicsImpostor): number;
  62198. /**
  62199. * Gets the box size of the impostor
  62200. * @param impostor impostor to get box size from
  62201. * @param result the resulting box size
  62202. */
  62203. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62204. /**
  62205. * Disposes of the impostor
  62206. */
  62207. dispose(): void;
  62208. /**
  62209. * Does a raycast in the physics world
  62210. * @param from when should the ray start?
  62211. * @param to when should the ray end?
  62212. * @returns PhysicsRaycastResult
  62213. */
  62214. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62215. }
  62216. }
  62217. declare module BABYLON {
  62218. interface AbstractScene {
  62219. /**
  62220. * The list of reflection probes added to the scene
  62221. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62222. */
  62223. reflectionProbes: Array<ReflectionProbe>;
  62224. /**
  62225. * Removes the given reflection probe from this scene.
  62226. * @param toRemove The reflection probe to remove
  62227. * @returns The index of the removed reflection probe
  62228. */
  62229. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62230. /**
  62231. * Adds the given reflection probe to this scene.
  62232. * @param newReflectionProbe The reflection probe to add
  62233. */
  62234. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62235. }
  62236. /**
  62237. * Class used to generate realtime reflection / refraction cube textures
  62238. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62239. */
  62240. export class ReflectionProbe {
  62241. /** defines the name of the probe */
  62242. name: string;
  62243. private _scene;
  62244. private _renderTargetTexture;
  62245. private _projectionMatrix;
  62246. private _viewMatrix;
  62247. private _target;
  62248. private _add;
  62249. private _attachedMesh;
  62250. private _invertYAxis;
  62251. /** Gets or sets probe position (center of the cube map) */
  62252. position: Vector3;
  62253. /**
  62254. * Creates a new reflection probe
  62255. * @param name defines the name of the probe
  62256. * @param size defines the texture resolution (for each face)
  62257. * @param scene defines the hosting scene
  62258. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62259. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62260. */
  62261. constructor(
  62262. /** defines the name of the probe */
  62263. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62264. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62265. get samples(): number;
  62266. set samples(value: number);
  62267. /** Gets or sets the refresh rate to use (on every frame by default) */
  62268. get refreshRate(): number;
  62269. set refreshRate(value: number);
  62270. /**
  62271. * Gets the hosting scene
  62272. * @returns a Scene
  62273. */
  62274. getScene(): Scene;
  62275. /** Gets the internal CubeTexture used to render to */
  62276. get cubeTexture(): RenderTargetTexture;
  62277. /** Gets the list of meshes to render */
  62278. get renderList(): Nullable<AbstractMesh[]>;
  62279. /**
  62280. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62281. * @param mesh defines the mesh to attach to
  62282. */
  62283. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62284. /**
  62285. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62286. * @param renderingGroupId The rendering group id corresponding to its index
  62287. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62288. */
  62289. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62290. /**
  62291. * Clean all associated resources
  62292. */
  62293. dispose(): void;
  62294. /**
  62295. * Converts the reflection probe information to a readable string for debug purpose.
  62296. * @param fullDetails Supports for multiple levels of logging within scene loading
  62297. * @returns the human readable reflection probe info
  62298. */
  62299. toString(fullDetails?: boolean): string;
  62300. /**
  62301. * Get the class name of the relfection probe.
  62302. * @returns "ReflectionProbe"
  62303. */
  62304. getClassName(): string;
  62305. /**
  62306. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62307. * @returns The JSON representation of the texture
  62308. */
  62309. serialize(): any;
  62310. /**
  62311. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62312. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62313. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62314. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62315. * @returns The parsed reflection probe if successful
  62316. */
  62317. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62318. }
  62319. }
  62320. declare module BABYLON {
  62321. /** @hidden */
  62322. export var _BabylonLoaderRegistered: boolean;
  62323. /**
  62324. * Helps setting up some configuration for the babylon file loader.
  62325. */
  62326. export class BabylonFileLoaderConfiguration {
  62327. /**
  62328. * The loader does not allow injecting custom physix engine into the plugins.
  62329. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62330. * So you could set this variable to your engine import to make it work.
  62331. */
  62332. static LoaderInjectedPhysicsEngine: any;
  62333. }
  62334. }
  62335. declare module BABYLON {
  62336. /**
  62337. * The Physically based simple base material of BJS.
  62338. *
  62339. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62340. * It is used as the base class for both the specGloss and metalRough conventions.
  62341. */
  62342. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62343. /**
  62344. * Number of Simultaneous lights allowed on the material.
  62345. */
  62346. maxSimultaneousLights: number;
  62347. /**
  62348. * If sets to true, disables all the lights affecting the material.
  62349. */
  62350. disableLighting: boolean;
  62351. /**
  62352. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62353. */
  62354. environmentTexture: BaseTexture;
  62355. /**
  62356. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62357. */
  62358. invertNormalMapX: boolean;
  62359. /**
  62360. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62361. */
  62362. invertNormalMapY: boolean;
  62363. /**
  62364. * Normal map used in the model.
  62365. */
  62366. normalTexture: BaseTexture;
  62367. /**
  62368. * Emissivie color used to self-illuminate the model.
  62369. */
  62370. emissiveColor: Color3;
  62371. /**
  62372. * Emissivie texture used to self-illuminate the model.
  62373. */
  62374. emissiveTexture: BaseTexture;
  62375. /**
  62376. * Occlusion Channel Strenght.
  62377. */
  62378. occlusionStrength: number;
  62379. /**
  62380. * Occlusion Texture of the material (adding extra occlusion effects).
  62381. */
  62382. occlusionTexture: BaseTexture;
  62383. /**
  62384. * Defines the alpha limits in alpha test mode.
  62385. */
  62386. alphaCutOff: number;
  62387. /**
  62388. * Gets the current double sided mode.
  62389. */
  62390. get doubleSided(): boolean;
  62391. /**
  62392. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62393. */
  62394. set doubleSided(value: boolean);
  62395. /**
  62396. * Stores the pre-calculated light information of a mesh in a texture.
  62397. */
  62398. lightmapTexture: BaseTexture;
  62399. /**
  62400. * If true, the light map contains occlusion information instead of lighting info.
  62401. */
  62402. useLightmapAsShadowmap: boolean;
  62403. /**
  62404. * Instantiates a new PBRMaterial instance.
  62405. *
  62406. * @param name The material name
  62407. * @param scene The scene the material will be use in.
  62408. */
  62409. constructor(name: string, scene: Scene);
  62410. getClassName(): string;
  62411. }
  62412. }
  62413. declare module BABYLON {
  62414. /**
  62415. * The PBR material of BJS following the metal roughness convention.
  62416. *
  62417. * This fits to the PBR convention in the GLTF definition:
  62418. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62419. */
  62420. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62421. /**
  62422. * The base color has two different interpretations depending on the value of metalness.
  62423. * When the material is a metal, the base color is the specific measured reflectance value
  62424. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62425. * of the material.
  62426. */
  62427. baseColor: Color3;
  62428. /**
  62429. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62430. * well as opacity information in the alpha channel.
  62431. */
  62432. baseTexture: BaseTexture;
  62433. /**
  62434. * Specifies the metallic scalar value of the material.
  62435. * Can also be used to scale the metalness values of the metallic texture.
  62436. */
  62437. metallic: number;
  62438. /**
  62439. * Specifies the roughness scalar value of the material.
  62440. * Can also be used to scale the roughness values of the metallic texture.
  62441. */
  62442. roughness: number;
  62443. /**
  62444. * Texture containing both the metallic value in the B channel and the
  62445. * roughness value in the G channel to keep better precision.
  62446. */
  62447. metallicRoughnessTexture: BaseTexture;
  62448. /**
  62449. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62450. *
  62451. * @param name The material name
  62452. * @param scene The scene the material will be use in.
  62453. */
  62454. constructor(name: string, scene: Scene);
  62455. /**
  62456. * Return the currrent class name of the material.
  62457. */
  62458. getClassName(): string;
  62459. /**
  62460. * Makes a duplicate of the current material.
  62461. * @param name - name to use for the new material.
  62462. */
  62463. clone(name: string): PBRMetallicRoughnessMaterial;
  62464. /**
  62465. * Serialize the material to a parsable JSON object.
  62466. */
  62467. serialize(): any;
  62468. /**
  62469. * Parses a JSON object correponding to the serialize function.
  62470. */
  62471. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62472. }
  62473. }
  62474. declare module BABYLON {
  62475. /**
  62476. * The PBR material of BJS following the specular glossiness convention.
  62477. *
  62478. * This fits to the PBR convention in the GLTF definition:
  62479. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62480. */
  62481. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62482. /**
  62483. * Specifies the diffuse color of the material.
  62484. */
  62485. diffuseColor: Color3;
  62486. /**
  62487. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62488. * channel.
  62489. */
  62490. diffuseTexture: BaseTexture;
  62491. /**
  62492. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62493. */
  62494. specularColor: Color3;
  62495. /**
  62496. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62497. */
  62498. glossiness: number;
  62499. /**
  62500. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62501. */
  62502. specularGlossinessTexture: BaseTexture;
  62503. /**
  62504. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62505. *
  62506. * @param name The material name
  62507. * @param scene The scene the material will be use in.
  62508. */
  62509. constructor(name: string, scene: Scene);
  62510. /**
  62511. * Return the currrent class name of the material.
  62512. */
  62513. getClassName(): string;
  62514. /**
  62515. * Makes a duplicate of the current material.
  62516. * @param name - name to use for the new material.
  62517. */
  62518. clone(name: string): PBRSpecularGlossinessMaterial;
  62519. /**
  62520. * Serialize the material to a parsable JSON object.
  62521. */
  62522. serialize(): any;
  62523. /**
  62524. * Parses a JSON object correponding to the serialize function.
  62525. */
  62526. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62527. }
  62528. }
  62529. declare module BABYLON {
  62530. /**
  62531. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62532. * It can help converting any input color in a desired output one. This can then be used to create effects
  62533. * from sepia, black and white to sixties or futuristic rendering...
  62534. *
  62535. * The only supported format is currently 3dl.
  62536. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62537. */
  62538. export class ColorGradingTexture extends BaseTexture {
  62539. /**
  62540. * The texture URL.
  62541. */
  62542. url: string;
  62543. /**
  62544. * Empty line regex stored for GC.
  62545. */
  62546. private static _noneEmptyLineRegex;
  62547. private _textureMatrix;
  62548. private _onLoad;
  62549. /**
  62550. * Instantiates a ColorGradingTexture from the following parameters.
  62551. *
  62552. * @param url The location of the color gradind data (currently only supporting 3dl)
  62553. * @param sceneOrEngine The scene or engine the texture will be used in
  62554. * @param onLoad defines a callback triggered when the texture has been loaded
  62555. */
  62556. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62557. /**
  62558. * Fires the onload event from the constructor if requested.
  62559. */
  62560. private _triggerOnLoad;
  62561. /**
  62562. * Returns the texture matrix used in most of the material.
  62563. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62564. */
  62565. getTextureMatrix(): Matrix;
  62566. /**
  62567. * Occurs when the file being loaded is a .3dl LUT file.
  62568. */
  62569. private load3dlTexture;
  62570. /**
  62571. * Starts the loading process of the texture.
  62572. */
  62573. private loadTexture;
  62574. /**
  62575. * Clones the color gradind texture.
  62576. */
  62577. clone(): ColorGradingTexture;
  62578. /**
  62579. * Called during delayed load for textures.
  62580. */
  62581. delayLoad(): void;
  62582. /**
  62583. * Parses a color grading texture serialized by Babylon.
  62584. * @param parsedTexture The texture information being parsedTexture
  62585. * @param scene The scene to load the texture in
  62586. * @param rootUrl The root url of the data assets to load
  62587. * @return A color gradind texture
  62588. */
  62589. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62590. /**
  62591. * Serializes the LUT texture to json format.
  62592. */
  62593. serialize(): any;
  62594. }
  62595. }
  62596. declare module BABYLON {
  62597. /**
  62598. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62599. */
  62600. export class EquiRectangularCubeTexture extends BaseTexture {
  62601. /** The six faces of the cube. */
  62602. private static _FacesMapping;
  62603. private _noMipmap;
  62604. private _onLoad;
  62605. private _onError;
  62606. /** The size of the cubemap. */
  62607. private _size;
  62608. /** The buffer of the image. */
  62609. private _buffer;
  62610. /** The width of the input image. */
  62611. private _width;
  62612. /** The height of the input image. */
  62613. private _height;
  62614. /** The URL to the image. */
  62615. url: string;
  62616. /**
  62617. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62618. * @param url The location of the image
  62619. * @param scene The scene the texture will be used in
  62620. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62621. * @param noMipmap Forces to not generate the mipmap if true
  62622. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62623. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62624. * @param onLoad — defines a callback called when texture is loaded
  62625. * @param onError — defines a callback called if there is an error
  62626. */
  62627. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62628. /**
  62629. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62630. */
  62631. private loadImage;
  62632. /**
  62633. * Convert the image buffer into a cubemap and create a CubeTexture.
  62634. */
  62635. private loadTexture;
  62636. /**
  62637. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62638. * @param buffer The ArrayBuffer that should be converted.
  62639. * @returns The buffer as Float32Array.
  62640. */
  62641. private getFloat32ArrayFromArrayBuffer;
  62642. /**
  62643. * Get the current class name of the texture useful for serialization or dynamic coding.
  62644. * @returns "EquiRectangularCubeTexture"
  62645. */
  62646. getClassName(): string;
  62647. /**
  62648. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62649. * @returns A clone of the current EquiRectangularCubeTexture.
  62650. */
  62651. clone(): EquiRectangularCubeTexture;
  62652. }
  62653. }
  62654. declare module BABYLON {
  62655. /**
  62656. * Defines the options related to the creation of an HtmlElementTexture
  62657. */
  62658. export interface IHtmlElementTextureOptions {
  62659. /**
  62660. * Defines wether mip maps should be created or not.
  62661. */
  62662. generateMipMaps?: boolean;
  62663. /**
  62664. * Defines the sampling mode of the texture.
  62665. */
  62666. samplingMode?: number;
  62667. /**
  62668. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62669. */
  62670. engine: Nullable<ThinEngine>;
  62671. /**
  62672. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62673. */
  62674. scene: Nullable<Scene>;
  62675. }
  62676. /**
  62677. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62678. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62679. * is automatically managed.
  62680. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62681. * in your application.
  62682. *
  62683. * As the update is not automatic, you need to call them manually.
  62684. */
  62685. export class HtmlElementTexture extends BaseTexture {
  62686. /**
  62687. * The texture URL.
  62688. */
  62689. element: HTMLVideoElement | HTMLCanvasElement;
  62690. private static readonly DefaultOptions;
  62691. private _textureMatrix;
  62692. private _isVideo;
  62693. private _generateMipMaps;
  62694. private _samplingMode;
  62695. /**
  62696. * Instantiates a HtmlElementTexture from the following parameters.
  62697. *
  62698. * @param name Defines the name of the texture
  62699. * @param element Defines the video or canvas the texture is filled with
  62700. * @param options Defines the other none mandatory texture creation options
  62701. */
  62702. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62703. private _createInternalTexture;
  62704. /**
  62705. * Returns the texture matrix used in most of the material.
  62706. */
  62707. getTextureMatrix(): Matrix;
  62708. /**
  62709. * Updates the content of the texture.
  62710. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62711. */
  62712. update(invertY?: Nullable<boolean>): void;
  62713. }
  62714. }
  62715. declare module BABYLON {
  62716. /**
  62717. * Based on jsTGALoader - Javascript loader for TGA file
  62718. * By Vincent Thibault
  62719. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62720. */
  62721. export class TGATools {
  62722. private static _TYPE_INDEXED;
  62723. private static _TYPE_RGB;
  62724. private static _TYPE_GREY;
  62725. private static _TYPE_RLE_INDEXED;
  62726. private static _TYPE_RLE_RGB;
  62727. private static _TYPE_RLE_GREY;
  62728. private static _ORIGIN_MASK;
  62729. private static _ORIGIN_SHIFT;
  62730. private static _ORIGIN_BL;
  62731. private static _ORIGIN_BR;
  62732. private static _ORIGIN_UL;
  62733. private static _ORIGIN_UR;
  62734. /**
  62735. * Gets the header of a TGA file
  62736. * @param data defines the TGA data
  62737. * @returns the header
  62738. */
  62739. static GetTGAHeader(data: Uint8Array): any;
  62740. /**
  62741. * Uploads TGA content to a Babylon Texture
  62742. * @hidden
  62743. */
  62744. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62745. /** @hidden */
  62746. 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;
  62747. /** @hidden */
  62748. 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;
  62749. /** @hidden */
  62750. 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;
  62751. /** @hidden */
  62752. 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;
  62753. /** @hidden */
  62754. 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;
  62755. /** @hidden */
  62756. 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;
  62757. }
  62758. }
  62759. declare module BABYLON {
  62760. /**
  62761. * Implementation of the TGA Texture Loader.
  62762. * @hidden
  62763. */
  62764. export class _TGATextureLoader implements IInternalTextureLoader {
  62765. /**
  62766. * Defines wether the loader supports cascade loading the different faces.
  62767. */
  62768. readonly supportCascades: boolean;
  62769. /**
  62770. * This returns if the loader support the current file information.
  62771. * @param extension defines the file extension of the file being loaded
  62772. * @returns true if the loader can load the specified file
  62773. */
  62774. canLoad(extension: string): boolean;
  62775. /**
  62776. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62777. * @param data contains the texture data
  62778. * @param texture defines the BabylonJS internal texture
  62779. * @param createPolynomials will be true if polynomials have been requested
  62780. * @param onLoad defines the callback to trigger once the texture is ready
  62781. * @param onError defines the callback to trigger in case of error
  62782. */
  62783. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62784. /**
  62785. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62786. * @param data contains the texture data
  62787. * @param texture defines the BabylonJS internal texture
  62788. * @param callback defines the method to call once ready to upload
  62789. */
  62790. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62791. }
  62792. }
  62793. declare module BABYLON {
  62794. /**
  62795. * Info about the .basis files
  62796. */
  62797. class BasisFileInfo {
  62798. /**
  62799. * If the file has alpha
  62800. */
  62801. hasAlpha: boolean;
  62802. /**
  62803. * Info about each image of the basis file
  62804. */
  62805. images: Array<{
  62806. levels: Array<{
  62807. width: number;
  62808. height: number;
  62809. transcodedPixels: ArrayBufferView;
  62810. }>;
  62811. }>;
  62812. }
  62813. /**
  62814. * Result of transcoding a basis file
  62815. */
  62816. class TranscodeResult {
  62817. /**
  62818. * Info about the .basis file
  62819. */
  62820. fileInfo: BasisFileInfo;
  62821. /**
  62822. * Format to use when loading the file
  62823. */
  62824. format: number;
  62825. }
  62826. /**
  62827. * Configuration options for the Basis transcoder
  62828. */
  62829. export class BasisTranscodeConfiguration {
  62830. /**
  62831. * Supported compression formats used to determine the supported output format of the transcoder
  62832. */
  62833. supportedCompressionFormats?: {
  62834. /**
  62835. * etc1 compression format
  62836. */
  62837. etc1?: boolean;
  62838. /**
  62839. * s3tc compression format
  62840. */
  62841. s3tc?: boolean;
  62842. /**
  62843. * pvrtc compression format
  62844. */
  62845. pvrtc?: boolean;
  62846. /**
  62847. * etc2 compression format
  62848. */
  62849. etc2?: boolean;
  62850. };
  62851. /**
  62852. * If mipmap levels should be loaded for transcoded images (Default: true)
  62853. */
  62854. loadMipmapLevels?: boolean;
  62855. /**
  62856. * Index of a single image to load (Default: all images)
  62857. */
  62858. loadSingleImage?: number;
  62859. }
  62860. /**
  62861. * Used to load .Basis files
  62862. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62863. */
  62864. export class BasisTools {
  62865. private static _IgnoreSupportedFormats;
  62866. /**
  62867. * URL to use when loading the basis transcoder
  62868. */
  62869. static JSModuleURL: string;
  62870. /**
  62871. * URL to use when loading the wasm module for the transcoder
  62872. */
  62873. static WasmModuleURL: string;
  62874. /**
  62875. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62876. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62877. * @returns internal format corresponding to the Basis format
  62878. */
  62879. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62880. private static _WorkerPromise;
  62881. private static _Worker;
  62882. private static _actionId;
  62883. private static _CreateWorkerAsync;
  62884. /**
  62885. * Transcodes a loaded image file to compressed pixel data
  62886. * @param data image data to transcode
  62887. * @param config configuration options for the transcoding
  62888. * @returns a promise resulting in the transcoded image
  62889. */
  62890. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62891. /**
  62892. * Loads a texture from the transcode result
  62893. * @param texture texture load to
  62894. * @param transcodeResult the result of transcoding the basis file to load from
  62895. */
  62896. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62897. }
  62898. }
  62899. declare module BABYLON {
  62900. /**
  62901. * Loader for .basis file format
  62902. */
  62903. export class _BasisTextureLoader implements IInternalTextureLoader {
  62904. /**
  62905. * Defines whether the loader supports cascade loading the different faces.
  62906. */
  62907. readonly supportCascades: boolean;
  62908. /**
  62909. * This returns if the loader support the current file information.
  62910. * @param extension defines the file extension of the file being loaded
  62911. * @returns true if the loader can load the specified file
  62912. */
  62913. canLoad(extension: string): boolean;
  62914. /**
  62915. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62916. * @param data contains the texture data
  62917. * @param texture defines the BabylonJS internal texture
  62918. * @param createPolynomials will be true if polynomials have been requested
  62919. * @param onLoad defines the callback to trigger once the texture is ready
  62920. * @param onError defines the callback to trigger in case of error
  62921. */
  62922. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62923. /**
  62924. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62925. * @param data contains the texture data
  62926. * @param texture defines the BabylonJS internal texture
  62927. * @param callback defines the method to call once ready to upload
  62928. */
  62929. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62930. }
  62931. }
  62932. declare module BABYLON {
  62933. /**
  62934. * Defines the basic options interface of a TexturePacker Frame
  62935. */
  62936. export interface ITexturePackerFrame {
  62937. /**
  62938. * The frame ID
  62939. */
  62940. id: number;
  62941. /**
  62942. * The frames Scale
  62943. */
  62944. scale: Vector2;
  62945. /**
  62946. * The Frames offset
  62947. */
  62948. offset: Vector2;
  62949. }
  62950. /**
  62951. * This is a support class for frame Data on texture packer sets.
  62952. */
  62953. export class TexturePackerFrame implements ITexturePackerFrame {
  62954. /**
  62955. * The frame ID
  62956. */
  62957. id: number;
  62958. /**
  62959. * The frames Scale
  62960. */
  62961. scale: Vector2;
  62962. /**
  62963. * The Frames offset
  62964. */
  62965. offset: Vector2;
  62966. /**
  62967. * Initializes a texture package frame.
  62968. * @param id The numerical frame identifier
  62969. * @param scale Scalar Vector2 for UV frame
  62970. * @param offset Vector2 for the frame position in UV units.
  62971. * @returns TexturePackerFrame
  62972. */
  62973. constructor(id: number, scale: Vector2, offset: Vector2);
  62974. }
  62975. }
  62976. declare module BABYLON {
  62977. /**
  62978. * Defines the basic options interface of a TexturePacker
  62979. */
  62980. export interface ITexturePackerOptions {
  62981. /**
  62982. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62983. */
  62984. map?: string[];
  62985. /**
  62986. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62987. */
  62988. uvsIn?: string;
  62989. /**
  62990. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62991. */
  62992. uvsOut?: string;
  62993. /**
  62994. * number representing the layout style. Defaults to LAYOUT_STRIP
  62995. */
  62996. layout?: number;
  62997. /**
  62998. * number of columns if using custom column count layout(2). This defaults to 4.
  62999. */
  63000. colnum?: number;
  63001. /**
  63002. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63003. */
  63004. updateInputMeshes?: boolean;
  63005. /**
  63006. * boolean flag to dispose all the source textures. Defaults to true.
  63007. */
  63008. disposeSources?: boolean;
  63009. /**
  63010. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63011. */
  63012. fillBlanks?: boolean;
  63013. /**
  63014. * string value representing the context fill style color. Defaults to 'black'.
  63015. */
  63016. customFillColor?: string;
  63017. /**
  63018. * Width and Height Value of each Frame in the TexturePacker Sets
  63019. */
  63020. frameSize?: number;
  63021. /**
  63022. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63023. */
  63024. paddingRatio?: number;
  63025. /**
  63026. * Number that declares the fill method for the padding gutter.
  63027. */
  63028. paddingMode?: number;
  63029. /**
  63030. * If in SUBUV_COLOR padding mode what color to use.
  63031. */
  63032. paddingColor?: Color3 | Color4;
  63033. }
  63034. /**
  63035. * Defines the basic interface of a TexturePacker JSON File
  63036. */
  63037. export interface ITexturePackerJSON {
  63038. /**
  63039. * The frame ID
  63040. */
  63041. name: string;
  63042. /**
  63043. * The base64 channel data
  63044. */
  63045. sets: any;
  63046. /**
  63047. * The options of the Packer
  63048. */
  63049. options: ITexturePackerOptions;
  63050. /**
  63051. * The frame data of the Packer
  63052. */
  63053. frames: Array<number>;
  63054. }
  63055. /**
  63056. * This is a support class that generates a series of packed texture sets.
  63057. * @see https://doc.babylonjs.com/babylon101/materials
  63058. */
  63059. export class TexturePacker {
  63060. /** Packer Layout Constant 0 */
  63061. static readonly LAYOUT_STRIP: number;
  63062. /** Packer Layout Constant 1 */
  63063. static readonly LAYOUT_POWER2: number;
  63064. /** Packer Layout Constant 2 */
  63065. static readonly LAYOUT_COLNUM: number;
  63066. /** Packer Layout Constant 0 */
  63067. static readonly SUBUV_WRAP: number;
  63068. /** Packer Layout Constant 1 */
  63069. static readonly SUBUV_EXTEND: number;
  63070. /** Packer Layout Constant 2 */
  63071. static readonly SUBUV_COLOR: number;
  63072. /** The Name of the Texture Package */
  63073. name: string;
  63074. /** The scene scope of the TexturePacker */
  63075. scene: Scene;
  63076. /** The Meshes to target */
  63077. meshes: AbstractMesh[];
  63078. /** Arguments passed with the Constructor */
  63079. options: ITexturePackerOptions;
  63080. /** The promise that is started upon initialization */
  63081. promise: Nullable<Promise<TexturePacker | string>>;
  63082. /** The Container object for the channel sets that are generated */
  63083. sets: object;
  63084. /** The Container array for the frames that are generated */
  63085. frames: TexturePackerFrame[];
  63086. /** The expected number of textures the system is parsing. */
  63087. private _expecting;
  63088. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63089. private _paddingValue;
  63090. /**
  63091. * Initializes a texture package series from an array of meshes or a single mesh.
  63092. * @param name The name of the package
  63093. * @param meshes The target meshes to compose the package from
  63094. * @param options The arguments that texture packer should follow while building.
  63095. * @param scene The scene which the textures are scoped to.
  63096. * @returns TexturePacker
  63097. */
  63098. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63099. /**
  63100. * Starts the package process
  63101. * @param resolve The promises resolution function
  63102. * @returns TexturePacker
  63103. */
  63104. private _createFrames;
  63105. /**
  63106. * Calculates the Size of the Channel Sets
  63107. * @returns Vector2
  63108. */
  63109. private _calculateSize;
  63110. /**
  63111. * Calculates the UV data for the frames.
  63112. * @param baseSize the base frameSize
  63113. * @param padding the base frame padding
  63114. * @param dtSize size of the Dynamic Texture for that channel
  63115. * @param dtUnits is 1/dtSize
  63116. * @param update flag to update the input meshes
  63117. */
  63118. private _calculateMeshUVFrames;
  63119. /**
  63120. * Calculates the frames Offset.
  63121. * @param index of the frame
  63122. * @returns Vector2
  63123. */
  63124. private _getFrameOffset;
  63125. /**
  63126. * Updates a Mesh to the frame data
  63127. * @param mesh that is the target
  63128. * @param frameID or the frame index
  63129. */
  63130. private _updateMeshUV;
  63131. /**
  63132. * Updates a Meshes materials to use the texture packer channels
  63133. * @param m is the mesh to target
  63134. * @param force all channels on the packer to be set.
  63135. */
  63136. private _updateTextureReferences;
  63137. /**
  63138. * Public method to set a Mesh to a frame
  63139. * @param m that is the target
  63140. * @param frameID or the frame index
  63141. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63142. */
  63143. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63144. /**
  63145. * Starts the async promise to compile the texture packer.
  63146. * @returns Promise<void>
  63147. */
  63148. processAsync(): Promise<void>;
  63149. /**
  63150. * Disposes all textures associated with this packer
  63151. */
  63152. dispose(): void;
  63153. /**
  63154. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63155. * @param imageType is the image type to use.
  63156. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63157. */
  63158. download(imageType?: string, quality?: number): void;
  63159. /**
  63160. * Public method to load a texturePacker JSON file.
  63161. * @param data of the JSON file in string format.
  63162. */
  63163. updateFromJSON(data: string): void;
  63164. }
  63165. }
  63166. declare module BABYLON {
  63167. /**
  63168. * 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.
  63169. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63170. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63171. */
  63172. export class CustomProceduralTexture extends ProceduralTexture {
  63173. private _animate;
  63174. private _time;
  63175. private _config;
  63176. private _texturePath;
  63177. /**
  63178. * Instantiates a new Custom Procedural Texture.
  63179. * 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.
  63180. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63181. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63182. * @param name Define the name of the texture
  63183. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63184. * @param size Define the size of the texture to create
  63185. * @param scene Define the scene the texture belongs to
  63186. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63187. * @param generateMipMaps Define if the texture should creates mip maps or not
  63188. */
  63189. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63190. private _loadJson;
  63191. /**
  63192. * Is the texture ready to be used ? (rendered at least once)
  63193. * @returns true if ready, otherwise, false.
  63194. */
  63195. isReady(): boolean;
  63196. /**
  63197. * Render the texture to its associated render target.
  63198. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63199. */
  63200. render(useCameraPostProcess?: boolean): void;
  63201. /**
  63202. * Update the list of dependant textures samplers in the shader.
  63203. */
  63204. updateTextures(): void;
  63205. /**
  63206. * Update the uniform values of the procedural texture in the shader.
  63207. */
  63208. updateShaderUniforms(): void;
  63209. /**
  63210. * Define if the texture animates or not.
  63211. */
  63212. get animate(): boolean;
  63213. set animate(value: boolean);
  63214. }
  63215. }
  63216. declare module BABYLON {
  63217. /** @hidden */
  63218. export var noisePixelShader: {
  63219. name: string;
  63220. shader: string;
  63221. };
  63222. }
  63223. declare module BABYLON {
  63224. /**
  63225. * Class used to generate noise procedural textures
  63226. */
  63227. export class NoiseProceduralTexture extends ProceduralTexture {
  63228. /** Gets or sets the start time (default is 0) */
  63229. time: number;
  63230. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63231. brightness: number;
  63232. /** Defines the number of octaves to process */
  63233. octaves: number;
  63234. /** Defines the level of persistence (0.8 by default) */
  63235. persistence: number;
  63236. /** Gets or sets animation speed factor (default is 1) */
  63237. animationSpeedFactor: number;
  63238. /**
  63239. * Creates a new NoiseProceduralTexture
  63240. * @param name defines the name fo the texture
  63241. * @param size defines the size of the texture (default is 256)
  63242. * @param scene defines the hosting scene
  63243. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63244. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63245. */
  63246. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63247. private _updateShaderUniforms;
  63248. protected _getDefines(): string;
  63249. /** Generate the current state of the procedural texture */
  63250. render(useCameraPostProcess?: boolean): void;
  63251. /**
  63252. * Serializes this noise procedural texture
  63253. * @returns a serialized noise procedural texture object
  63254. */
  63255. serialize(): any;
  63256. /**
  63257. * Clone the texture.
  63258. * @returns the cloned texture
  63259. */
  63260. clone(): NoiseProceduralTexture;
  63261. /**
  63262. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63263. * @param parsedTexture defines parsed texture data
  63264. * @param scene defines the current scene
  63265. * @param rootUrl defines the root URL containing noise procedural texture information
  63266. * @returns a parsed NoiseProceduralTexture
  63267. */
  63268. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63269. }
  63270. }
  63271. declare module BABYLON {
  63272. /**
  63273. * Raw cube texture where the raw buffers are passed in
  63274. */
  63275. export class RawCubeTexture extends CubeTexture {
  63276. /**
  63277. * Creates a cube texture where the raw buffers are passed in.
  63278. * @param scene defines the scene the texture is attached to
  63279. * @param data defines the array of data to use to create each face
  63280. * @param size defines the size of the textures
  63281. * @param format defines the format of the data
  63282. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63283. * @param generateMipMaps defines if the engine should generate the mip levels
  63284. * @param invertY defines if data must be stored with Y axis inverted
  63285. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63286. * @param compression defines the compression used (null by default)
  63287. */
  63288. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63289. /**
  63290. * Updates the raw cube texture.
  63291. * @param data defines the data to store
  63292. * @param format defines the data format
  63293. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63294. * @param invertY defines if data must be stored with Y axis inverted
  63295. * @param compression defines the compression used (null by default)
  63296. * @param level defines which level of the texture to update
  63297. */
  63298. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63299. /**
  63300. * Updates a raw cube texture with RGBD encoded data.
  63301. * @param data defines the array of data [mipmap][face] to use to create each face
  63302. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63303. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63304. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63305. * @returns a promsie that resolves when the operation is complete
  63306. */
  63307. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63308. /**
  63309. * Clones the raw cube texture.
  63310. * @return a new cube texture
  63311. */
  63312. clone(): CubeTexture;
  63313. /** @hidden */
  63314. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63315. }
  63316. }
  63317. declare module BABYLON {
  63318. /**
  63319. * Class used to store 2D array textures containing user data
  63320. */
  63321. export class RawTexture2DArray extends Texture {
  63322. /** Gets or sets the texture format to use */
  63323. format: number;
  63324. /**
  63325. * Create a new RawTexture2DArray
  63326. * @param data defines the data of the texture
  63327. * @param width defines the width of the texture
  63328. * @param height defines the height of the texture
  63329. * @param depth defines the number of layers of the texture
  63330. * @param format defines the texture format to use
  63331. * @param scene defines the hosting scene
  63332. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63333. * @param invertY defines if texture must be stored with Y axis inverted
  63334. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63335. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63336. */
  63337. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63338. /** Gets or sets the texture format to use */
  63339. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63340. /**
  63341. * Update the texture with new data
  63342. * @param data defines the data to store in the texture
  63343. */
  63344. update(data: ArrayBufferView): void;
  63345. }
  63346. }
  63347. declare module BABYLON {
  63348. /**
  63349. * Class used to store 3D textures containing user data
  63350. */
  63351. export class RawTexture3D extends Texture {
  63352. /** Gets or sets the texture format to use */
  63353. format: number;
  63354. /**
  63355. * Create a new RawTexture3D
  63356. * @param data defines the data of the texture
  63357. * @param width defines the width of the texture
  63358. * @param height defines the height of the texture
  63359. * @param depth defines the depth of the texture
  63360. * @param format defines the texture format to use
  63361. * @param scene defines the hosting scene
  63362. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63363. * @param invertY defines if texture must be stored with Y axis inverted
  63364. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63365. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63366. */
  63367. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63368. /** Gets or sets the texture format to use */
  63369. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63370. /**
  63371. * Update the texture with new data
  63372. * @param data defines the data to store in the texture
  63373. */
  63374. update(data: ArrayBufferView): void;
  63375. }
  63376. }
  63377. declare module BABYLON {
  63378. /**
  63379. * Creates a refraction texture used by refraction channel of the standard material.
  63380. * It is like a mirror but to see through a material.
  63381. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63382. */
  63383. export class RefractionTexture extends RenderTargetTexture {
  63384. /**
  63385. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63386. * 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.
  63387. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63388. */
  63389. refractionPlane: Plane;
  63390. /**
  63391. * Define how deep under the surface we should see.
  63392. */
  63393. depth: number;
  63394. /**
  63395. * Creates a refraction texture used by refraction channel of the standard material.
  63396. * It is like a mirror but to see through a material.
  63397. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63398. * @param name Define the texture name
  63399. * @param size Define the size of the underlying texture
  63400. * @param scene Define the scene the refraction belongs to
  63401. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63402. */
  63403. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63404. /**
  63405. * Clone the refraction texture.
  63406. * @returns the cloned texture
  63407. */
  63408. clone(): RefractionTexture;
  63409. /**
  63410. * Serialize the texture to a JSON representation you could use in Parse later on
  63411. * @returns the serialized JSON representation
  63412. */
  63413. serialize(): any;
  63414. }
  63415. }
  63416. declare module BABYLON {
  63417. /**
  63418. * Block used to add support for vertex skinning (bones)
  63419. */
  63420. export class BonesBlock extends NodeMaterialBlock {
  63421. /**
  63422. * Creates a new BonesBlock
  63423. * @param name defines the block name
  63424. */
  63425. constructor(name: string);
  63426. /**
  63427. * Initialize the block and prepare the context for build
  63428. * @param state defines the state that will be used for the build
  63429. */
  63430. initialize(state: NodeMaterialBuildState): void;
  63431. /**
  63432. * Gets the current class name
  63433. * @returns the class name
  63434. */
  63435. getClassName(): string;
  63436. /**
  63437. * Gets the matrix indices input component
  63438. */
  63439. get matricesIndices(): NodeMaterialConnectionPoint;
  63440. /**
  63441. * Gets the matrix weights input component
  63442. */
  63443. get matricesWeights(): NodeMaterialConnectionPoint;
  63444. /**
  63445. * Gets the extra matrix indices input component
  63446. */
  63447. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63448. /**
  63449. * Gets the extra matrix weights input component
  63450. */
  63451. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63452. /**
  63453. * Gets the world input component
  63454. */
  63455. get world(): NodeMaterialConnectionPoint;
  63456. /**
  63457. * Gets the output component
  63458. */
  63459. get output(): NodeMaterialConnectionPoint;
  63460. autoConfigure(material: NodeMaterial): void;
  63461. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63462. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63463. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63464. protected _buildBlock(state: NodeMaterialBuildState): this;
  63465. }
  63466. }
  63467. declare module BABYLON {
  63468. /**
  63469. * Block used to add support for instances
  63470. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63471. */
  63472. export class InstancesBlock extends NodeMaterialBlock {
  63473. /**
  63474. * Creates a new InstancesBlock
  63475. * @param name defines the block name
  63476. */
  63477. constructor(name: string);
  63478. /**
  63479. * Gets the current class name
  63480. * @returns the class name
  63481. */
  63482. getClassName(): string;
  63483. /**
  63484. * Gets the first world row input component
  63485. */
  63486. get world0(): NodeMaterialConnectionPoint;
  63487. /**
  63488. * Gets the second world row input component
  63489. */
  63490. get world1(): NodeMaterialConnectionPoint;
  63491. /**
  63492. * Gets the third world row input component
  63493. */
  63494. get world2(): NodeMaterialConnectionPoint;
  63495. /**
  63496. * Gets the forth world row input component
  63497. */
  63498. get world3(): NodeMaterialConnectionPoint;
  63499. /**
  63500. * Gets the world input component
  63501. */
  63502. get world(): NodeMaterialConnectionPoint;
  63503. /**
  63504. * Gets the output component
  63505. */
  63506. get output(): NodeMaterialConnectionPoint;
  63507. /**
  63508. * Gets the isntanceID component
  63509. */
  63510. get instanceID(): NodeMaterialConnectionPoint;
  63511. autoConfigure(material: NodeMaterial): void;
  63512. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63513. protected _buildBlock(state: NodeMaterialBuildState): this;
  63514. }
  63515. }
  63516. declare module BABYLON {
  63517. /**
  63518. * Block used to add morph targets support to vertex shader
  63519. */
  63520. export class MorphTargetsBlock extends NodeMaterialBlock {
  63521. private _repeatableContentAnchor;
  63522. /**
  63523. * Create a new MorphTargetsBlock
  63524. * @param name defines the block name
  63525. */
  63526. constructor(name: string);
  63527. /**
  63528. * Gets the current class name
  63529. * @returns the class name
  63530. */
  63531. getClassName(): string;
  63532. /**
  63533. * Gets the position input component
  63534. */
  63535. get position(): NodeMaterialConnectionPoint;
  63536. /**
  63537. * Gets the normal input component
  63538. */
  63539. get normal(): NodeMaterialConnectionPoint;
  63540. /**
  63541. * Gets the tangent input component
  63542. */
  63543. get tangent(): NodeMaterialConnectionPoint;
  63544. /**
  63545. * Gets the tangent input component
  63546. */
  63547. get uv(): NodeMaterialConnectionPoint;
  63548. /**
  63549. * Gets the position output component
  63550. */
  63551. get positionOutput(): NodeMaterialConnectionPoint;
  63552. /**
  63553. * Gets the normal output component
  63554. */
  63555. get normalOutput(): NodeMaterialConnectionPoint;
  63556. /**
  63557. * Gets the tangent output component
  63558. */
  63559. get tangentOutput(): NodeMaterialConnectionPoint;
  63560. /**
  63561. * Gets the tangent output component
  63562. */
  63563. get uvOutput(): NodeMaterialConnectionPoint;
  63564. initialize(state: NodeMaterialBuildState): void;
  63565. autoConfigure(material: NodeMaterial): void;
  63566. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63567. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63568. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63569. protected _buildBlock(state: NodeMaterialBuildState): this;
  63570. }
  63571. }
  63572. declare module BABYLON {
  63573. /**
  63574. * Block used to get data information from a light
  63575. */
  63576. export class LightInformationBlock extends NodeMaterialBlock {
  63577. private _lightDataUniformName;
  63578. private _lightColorUniformName;
  63579. private _lightTypeDefineName;
  63580. /**
  63581. * Gets or sets the light associated with this block
  63582. */
  63583. light: Nullable<Light>;
  63584. /**
  63585. * Creates a new LightInformationBlock
  63586. * @param name defines the block name
  63587. */
  63588. constructor(name: string);
  63589. /**
  63590. * Gets the current class name
  63591. * @returns the class name
  63592. */
  63593. getClassName(): string;
  63594. /**
  63595. * Gets the world position input component
  63596. */
  63597. get worldPosition(): NodeMaterialConnectionPoint;
  63598. /**
  63599. * Gets the direction output component
  63600. */
  63601. get direction(): NodeMaterialConnectionPoint;
  63602. /**
  63603. * Gets the direction output component
  63604. */
  63605. get color(): NodeMaterialConnectionPoint;
  63606. /**
  63607. * Gets the direction output component
  63608. */
  63609. get intensity(): NodeMaterialConnectionPoint;
  63610. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63611. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63612. protected _buildBlock(state: NodeMaterialBuildState): this;
  63613. serialize(): any;
  63614. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63615. }
  63616. }
  63617. declare module BABYLON {
  63618. /**
  63619. * Block used to add image processing support to fragment shader
  63620. */
  63621. export class ImageProcessingBlock extends NodeMaterialBlock {
  63622. /**
  63623. * Create a new ImageProcessingBlock
  63624. * @param name defines the block name
  63625. */
  63626. constructor(name: string);
  63627. /**
  63628. * Gets the current class name
  63629. * @returns the class name
  63630. */
  63631. getClassName(): string;
  63632. /**
  63633. * Gets the color input component
  63634. */
  63635. get color(): NodeMaterialConnectionPoint;
  63636. /**
  63637. * Gets the output component
  63638. */
  63639. get output(): NodeMaterialConnectionPoint;
  63640. /**
  63641. * Initialize the block and prepare the context for build
  63642. * @param state defines the state that will be used for the build
  63643. */
  63644. initialize(state: NodeMaterialBuildState): void;
  63645. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63646. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63647. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63648. protected _buildBlock(state: NodeMaterialBuildState): this;
  63649. }
  63650. }
  63651. declare module BABYLON {
  63652. /**
  63653. * Block used to pertub normals based on a normal map
  63654. */
  63655. export class PerturbNormalBlock extends NodeMaterialBlock {
  63656. private _tangentSpaceParameterName;
  63657. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63658. invertX: boolean;
  63659. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63660. invertY: boolean;
  63661. /**
  63662. * Create a new PerturbNormalBlock
  63663. * @param name defines the block name
  63664. */
  63665. constructor(name: string);
  63666. /**
  63667. * Gets the current class name
  63668. * @returns the class name
  63669. */
  63670. getClassName(): string;
  63671. /**
  63672. * Gets the world position input component
  63673. */
  63674. get worldPosition(): NodeMaterialConnectionPoint;
  63675. /**
  63676. * Gets the world normal input component
  63677. */
  63678. get worldNormal(): NodeMaterialConnectionPoint;
  63679. /**
  63680. * Gets the world tangent input component
  63681. */
  63682. get worldTangent(): NodeMaterialConnectionPoint;
  63683. /**
  63684. * Gets the uv input component
  63685. */
  63686. get uv(): NodeMaterialConnectionPoint;
  63687. /**
  63688. * Gets the normal map color input component
  63689. */
  63690. get normalMapColor(): NodeMaterialConnectionPoint;
  63691. /**
  63692. * Gets the strength input component
  63693. */
  63694. get strength(): NodeMaterialConnectionPoint;
  63695. /**
  63696. * Gets the output component
  63697. */
  63698. get output(): NodeMaterialConnectionPoint;
  63699. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63700. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63701. autoConfigure(material: NodeMaterial): void;
  63702. protected _buildBlock(state: NodeMaterialBuildState): this;
  63703. protected _dumpPropertiesCode(): string;
  63704. serialize(): any;
  63705. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63706. }
  63707. }
  63708. declare module BABYLON {
  63709. /**
  63710. * Block used to discard a pixel if a value is smaller than a cutoff
  63711. */
  63712. export class DiscardBlock extends NodeMaterialBlock {
  63713. /**
  63714. * Create a new DiscardBlock
  63715. * @param name defines the block name
  63716. */
  63717. constructor(name: string);
  63718. /**
  63719. * Gets the current class name
  63720. * @returns the class name
  63721. */
  63722. getClassName(): string;
  63723. /**
  63724. * Gets the color input component
  63725. */
  63726. get value(): NodeMaterialConnectionPoint;
  63727. /**
  63728. * Gets the cutoff input component
  63729. */
  63730. get cutoff(): NodeMaterialConnectionPoint;
  63731. protected _buildBlock(state: NodeMaterialBuildState): this;
  63732. }
  63733. }
  63734. declare module BABYLON {
  63735. /**
  63736. * Block used to test if the fragment shader is front facing
  63737. */
  63738. export class FrontFacingBlock extends NodeMaterialBlock {
  63739. /**
  63740. * Creates a new FrontFacingBlock
  63741. * @param name defines the block name
  63742. */
  63743. constructor(name: string);
  63744. /**
  63745. * Gets the current class name
  63746. * @returns the class name
  63747. */
  63748. getClassName(): string;
  63749. /**
  63750. * Gets the output component
  63751. */
  63752. get output(): NodeMaterialConnectionPoint;
  63753. protected _buildBlock(state: NodeMaterialBuildState): this;
  63754. }
  63755. }
  63756. declare module BABYLON {
  63757. /**
  63758. * Block used to get the derivative value on x and y of a given input
  63759. */
  63760. export class DerivativeBlock extends NodeMaterialBlock {
  63761. /**
  63762. * Create a new DerivativeBlock
  63763. * @param name defines the block name
  63764. */
  63765. constructor(name: string);
  63766. /**
  63767. * Gets the current class name
  63768. * @returns the class name
  63769. */
  63770. getClassName(): string;
  63771. /**
  63772. * Gets the input component
  63773. */
  63774. get input(): NodeMaterialConnectionPoint;
  63775. /**
  63776. * Gets the derivative output on x
  63777. */
  63778. get dx(): NodeMaterialConnectionPoint;
  63779. /**
  63780. * Gets the derivative output on y
  63781. */
  63782. get dy(): NodeMaterialConnectionPoint;
  63783. protected _buildBlock(state: NodeMaterialBuildState): this;
  63784. }
  63785. }
  63786. declare module BABYLON {
  63787. /**
  63788. * Block used to make gl_FragCoord available
  63789. */
  63790. export class FragCoordBlock extends NodeMaterialBlock {
  63791. /**
  63792. * Creates a new FragCoordBlock
  63793. * @param name defines the block name
  63794. */
  63795. constructor(name: string);
  63796. /**
  63797. * Gets the current class name
  63798. * @returns the class name
  63799. */
  63800. getClassName(): string;
  63801. /**
  63802. * Gets the xy component
  63803. */
  63804. get xy(): NodeMaterialConnectionPoint;
  63805. /**
  63806. * Gets the xyz component
  63807. */
  63808. get xyz(): NodeMaterialConnectionPoint;
  63809. /**
  63810. * Gets the xyzw component
  63811. */
  63812. get xyzw(): NodeMaterialConnectionPoint;
  63813. /**
  63814. * Gets the x component
  63815. */
  63816. get x(): NodeMaterialConnectionPoint;
  63817. /**
  63818. * Gets the y component
  63819. */
  63820. get y(): NodeMaterialConnectionPoint;
  63821. /**
  63822. * Gets the z component
  63823. */
  63824. get z(): NodeMaterialConnectionPoint;
  63825. /**
  63826. * Gets the w component
  63827. */
  63828. get output(): NodeMaterialConnectionPoint;
  63829. protected writeOutputs(state: NodeMaterialBuildState): string;
  63830. protected _buildBlock(state: NodeMaterialBuildState): this;
  63831. }
  63832. }
  63833. declare module BABYLON {
  63834. /**
  63835. * Block used to get the screen sizes
  63836. */
  63837. export class ScreenSizeBlock extends NodeMaterialBlock {
  63838. private _varName;
  63839. private _scene;
  63840. /**
  63841. * Creates a new ScreenSizeBlock
  63842. * @param name defines the block name
  63843. */
  63844. constructor(name: string);
  63845. /**
  63846. * Gets the current class name
  63847. * @returns the class name
  63848. */
  63849. getClassName(): string;
  63850. /**
  63851. * Gets the xy component
  63852. */
  63853. get xy(): NodeMaterialConnectionPoint;
  63854. /**
  63855. * Gets the x component
  63856. */
  63857. get x(): NodeMaterialConnectionPoint;
  63858. /**
  63859. * Gets the y component
  63860. */
  63861. get y(): NodeMaterialConnectionPoint;
  63862. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63863. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  63864. protected _buildBlock(state: NodeMaterialBuildState): this;
  63865. }
  63866. }
  63867. declare module BABYLON {
  63868. /**
  63869. * Block used to add support for scene fog
  63870. */
  63871. export class FogBlock extends NodeMaterialBlock {
  63872. private _fogDistanceName;
  63873. private _fogParameters;
  63874. /**
  63875. * Create a new FogBlock
  63876. * @param name defines the block name
  63877. */
  63878. constructor(name: string);
  63879. /**
  63880. * Gets the current class name
  63881. * @returns the class name
  63882. */
  63883. getClassName(): string;
  63884. /**
  63885. * Gets the world position input component
  63886. */
  63887. get worldPosition(): NodeMaterialConnectionPoint;
  63888. /**
  63889. * Gets the view input component
  63890. */
  63891. get view(): NodeMaterialConnectionPoint;
  63892. /**
  63893. * Gets the color input component
  63894. */
  63895. get input(): NodeMaterialConnectionPoint;
  63896. /**
  63897. * Gets the fog color input component
  63898. */
  63899. get fogColor(): NodeMaterialConnectionPoint;
  63900. /**
  63901. * Gets the output component
  63902. */
  63903. get output(): NodeMaterialConnectionPoint;
  63904. autoConfigure(material: NodeMaterial): void;
  63905. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63906. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63907. protected _buildBlock(state: NodeMaterialBuildState): this;
  63908. }
  63909. }
  63910. declare module BABYLON {
  63911. /**
  63912. * Block used to add light in the fragment shader
  63913. */
  63914. export class LightBlock extends NodeMaterialBlock {
  63915. private _lightId;
  63916. /**
  63917. * Gets or sets the light associated with this block
  63918. */
  63919. light: Nullable<Light>;
  63920. /**
  63921. * Create a new LightBlock
  63922. * @param name defines the block name
  63923. */
  63924. constructor(name: string);
  63925. /**
  63926. * Gets the current class name
  63927. * @returns the class name
  63928. */
  63929. getClassName(): string;
  63930. /**
  63931. * Gets the world position input component
  63932. */
  63933. get worldPosition(): NodeMaterialConnectionPoint;
  63934. /**
  63935. * Gets the world normal input component
  63936. */
  63937. get worldNormal(): NodeMaterialConnectionPoint;
  63938. /**
  63939. * Gets the camera (or eye) position component
  63940. */
  63941. get cameraPosition(): NodeMaterialConnectionPoint;
  63942. /**
  63943. * Gets the glossiness component
  63944. */
  63945. get glossiness(): NodeMaterialConnectionPoint;
  63946. /**
  63947. * Gets the glossinness power component
  63948. */
  63949. get glossPower(): NodeMaterialConnectionPoint;
  63950. /**
  63951. * Gets the diffuse color component
  63952. */
  63953. get diffuseColor(): NodeMaterialConnectionPoint;
  63954. /**
  63955. * Gets the specular color component
  63956. */
  63957. get specularColor(): NodeMaterialConnectionPoint;
  63958. /**
  63959. * Gets the view matrix component
  63960. */
  63961. get view(): NodeMaterialConnectionPoint;
  63962. /**
  63963. * Gets the diffuse output component
  63964. */
  63965. get diffuseOutput(): NodeMaterialConnectionPoint;
  63966. /**
  63967. * Gets the specular output component
  63968. */
  63969. get specularOutput(): NodeMaterialConnectionPoint;
  63970. /**
  63971. * Gets the shadow output component
  63972. */
  63973. get shadow(): NodeMaterialConnectionPoint;
  63974. autoConfigure(material: NodeMaterial): void;
  63975. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63976. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63977. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63978. private _injectVertexCode;
  63979. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63980. serialize(): any;
  63981. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63982. }
  63983. }
  63984. declare module BABYLON {
  63985. /**
  63986. * Block used to read a reflection texture from a sampler
  63987. */
  63988. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63989. /**
  63990. * Create a new ReflectionTextureBlock
  63991. * @param name defines the block name
  63992. */
  63993. constructor(name: string);
  63994. /**
  63995. * Gets the current class name
  63996. * @returns the class name
  63997. */
  63998. getClassName(): string;
  63999. /**
  64000. * Gets the world position input component
  64001. */
  64002. get position(): NodeMaterialConnectionPoint;
  64003. /**
  64004. * Gets the world position input component
  64005. */
  64006. get worldPosition(): NodeMaterialConnectionPoint;
  64007. /**
  64008. * Gets the world normal input component
  64009. */
  64010. get worldNormal(): NodeMaterialConnectionPoint;
  64011. /**
  64012. * Gets the world input component
  64013. */
  64014. get world(): NodeMaterialConnectionPoint;
  64015. /**
  64016. * Gets the camera (or eye) position component
  64017. */
  64018. get cameraPosition(): NodeMaterialConnectionPoint;
  64019. /**
  64020. * Gets the view input component
  64021. */
  64022. get view(): NodeMaterialConnectionPoint;
  64023. /**
  64024. * Gets the rgb output component
  64025. */
  64026. get rgb(): NodeMaterialConnectionPoint;
  64027. /**
  64028. * Gets the rgba output component
  64029. */
  64030. get rgba(): NodeMaterialConnectionPoint;
  64031. /**
  64032. * Gets the r output component
  64033. */
  64034. get r(): NodeMaterialConnectionPoint;
  64035. /**
  64036. * Gets the g output component
  64037. */
  64038. get g(): NodeMaterialConnectionPoint;
  64039. /**
  64040. * Gets the b output component
  64041. */
  64042. get b(): NodeMaterialConnectionPoint;
  64043. /**
  64044. * Gets the a output component
  64045. */
  64046. get a(): NodeMaterialConnectionPoint;
  64047. autoConfigure(material: NodeMaterial): void;
  64048. protected _buildBlock(state: NodeMaterialBuildState): this;
  64049. }
  64050. }
  64051. declare module BABYLON {
  64052. /**
  64053. * Block used to add 2 vectors
  64054. */
  64055. export class AddBlock extends NodeMaterialBlock {
  64056. /**
  64057. * Creates a new AddBlock
  64058. * @param name defines the block name
  64059. */
  64060. constructor(name: string);
  64061. /**
  64062. * Gets the current class name
  64063. * @returns the class name
  64064. */
  64065. getClassName(): string;
  64066. /**
  64067. * Gets the left operand input component
  64068. */
  64069. get left(): NodeMaterialConnectionPoint;
  64070. /**
  64071. * Gets the right operand input component
  64072. */
  64073. get right(): NodeMaterialConnectionPoint;
  64074. /**
  64075. * Gets the output component
  64076. */
  64077. get output(): NodeMaterialConnectionPoint;
  64078. protected _buildBlock(state: NodeMaterialBuildState): this;
  64079. }
  64080. }
  64081. declare module BABYLON {
  64082. /**
  64083. * Block used to scale a vector by a float
  64084. */
  64085. export class ScaleBlock extends NodeMaterialBlock {
  64086. /**
  64087. * Creates a new ScaleBlock
  64088. * @param name defines the block name
  64089. */
  64090. constructor(name: string);
  64091. /**
  64092. * Gets the current class name
  64093. * @returns the class name
  64094. */
  64095. getClassName(): string;
  64096. /**
  64097. * Gets the input component
  64098. */
  64099. get input(): NodeMaterialConnectionPoint;
  64100. /**
  64101. * Gets the factor input component
  64102. */
  64103. get factor(): NodeMaterialConnectionPoint;
  64104. /**
  64105. * Gets the output component
  64106. */
  64107. get output(): NodeMaterialConnectionPoint;
  64108. protected _buildBlock(state: NodeMaterialBuildState): this;
  64109. }
  64110. }
  64111. declare module BABYLON {
  64112. /**
  64113. * Block used to clamp a float
  64114. */
  64115. export class ClampBlock extends NodeMaterialBlock {
  64116. /** Gets or sets the minimum range */
  64117. minimum: number;
  64118. /** Gets or sets the maximum range */
  64119. maximum: number;
  64120. /**
  64121. * Creates a new ClampBlock
  64122. * @param name defines the block name
  64123. */
  64124. constructor(name: string);
  64125. /**
  64126. * Gets the current class name
  64127. * @returns the class name
  64128. */
  64129. getClassName(): string;
  64130. /**
  64131. * Gets the value input component
  64132. */
  64133. get value(): NodeMaterialConnectionPoint;
  64134. /**
  64135. * Gets the output component
  64136. */
  64137. get output(): NodeMaterialConnectionPoint;
  64138. protected _buildBlock(state: NodeMaterialBuildState): this;
  64139. protected _dumpPropertiesCode(): string;
  64140. serialize(): any;
  64141. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64142. }
  64143. }
  64144. declare module BABYLON {
  64145. /**
  64146. * Block used to apply a cross product between 2 vectors
  64147. */
  64148. export class CrossBlock extends NodeMaterialBlock {
  64149. /**
  64150. * Creates a new CrossBlock
  64151. * @param name defines the block name
  64152. */
  64153. constructor(name: string);
  64154. /**
  64155. * Gets the current class name
  64156. * @returns the class name
  64157. */
  64158. getClassName(): string;
  64159. /**
  64160. * Gets the left operand input component
  64161. */
  64162. get left(): NodeMaterialConnectionPoint;
  64163. /**
  64164. * Gets the right operand input component
  64165. */
  64166. get right(): NodeMaterialConnectionPoint;
  64167. /**
  64168. * Gets the output component
  64169. */
  64170. get output(): NodeMaterialConnectionPoint;
  64171. protected _buildBlock(state: NodeMaterialBuildState): this;
  64172. }
  64173. }
  64174. declare module BABYLON {
  64175. /**
  64176. * Block used to apply a dot product between 2 vectors
  64177. */
  64178. export class DotBlock extends NodeMaterialBlock {
  64179. /**
  64180. * Creates a new DotBlock
  64181. * @param name defines the block name
  64182. */
  64183. constructor(name: string);
  64184. /**
  64185. * Gets the current class name
  64186. * @returns the class name
  64187. */
  64188. getClassName(): string;
  64189. /**
  64190. * Gets the left operand input component
  64191. */
  64192. get left(): NodeMaterialConnectionPoint;
  64193. /**
  64194. * Gets the right operand input component
  64195. */
  64196. get right(): NodeMaterialConnectionPoint;
  64197. /**
  64198. * Gets the output component
  64199. */
  64200. get output(): NodeMaterialConnectionPoint;
  64201. protected _buildBlock(state: NodeMaterialBuildState): this;
  64202. }
  64203. }
  64204. declare module BABYLON {
  64205. /**
  64206. * Block used to normalize a vector
  64207. */
  64208. export class NormalizeBlock extends NodeMaterialBlock {
  64209. /**
  64210. * Creates a new NormalizeBlock
  64211. * @param name defines the block name
  64212. */
  64213. constructor(name: string);
  64214. /**
  64215. * Gets the current class name
  64216. * @returns the class name
  64217. */
  64218. getClassName(): string;
  64219. /**
  64220. * Gets the input component
  64221. */
  64222. get input(): NodeMaterialConnectionPoint;
  64223. /**
  64224. * Gets the output component
  64225. */
  64226. get output(): NodeMaterialConnectionPoint;
  64227. protected _buildBlock(state: NodeMaterialBuildState): this;
  64228. }
  64229. }
  64230. declare module BABYLON {
  64231. /**
  64232. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64233. */
  64234. export class ColorMergerBlock extends NodeMaterialBlock {
  64235. /**
  64236. * Create a new ColorMergerBlock
  64237. * @param name defines the block name
  64238. */
  64239. constructor(name: string);
  64240. /**
  64241. * Gets the current class name
  64242. * @returns the class name
  64243. */
  64244. getClassName(): string;
  64245. /**
  64246. * Gets the rgb component (input)
  64247. */
  64248. get rgbIn(): NodeMaterialConnectionPoint;
  64249. /**
  64250. * Gets the r component (input)
  64251. */
  64252. get r(): NodeMaterialConnectionPoint;
  64253. /**
  64254. * Gets the g component (input)
  64255. */
  64256. get g(): NodeMaterialConnectionPoint;
  64257. /**
  64258. * Gets the b component (input)
  64259. */
  64260. get b(): NodeMaterialConnectionPoint;
  64261. /**
  64262. * Gets the a component (input)
  64263. */
  64264. get a(): NodeMaterialConnectionPoint;
  64265. /**
  64266. * Gets the rgba component (output)
  64267. */
  64268. get rgba(): NodeMaterialConnectionPoint;
  64269. /**
  64270. * Gets the rgb component (output)
  64271. */
  64272. get rgbOut(): NodeMaterialConnectionPoint;
  64273. /**
  64274. * Gets the rgb component (output)
  64275. * @deprecated Please use rgbOut instead.
  64276. */
  64277. get rgb(): NodeMaterialConnectionPoint;
  64278. protected _buildBlock(state: NodeMaterialBuildState): this;
  64279. }
  64280. }
  64281. declare module BABYLON {
  64282. /**
  64283. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64284. */
  64285. export class VectorSplitterBlock extends NodeMaterialBlock {
  64286. /**
  64287. * Create a new VectorSplitterBlock
  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 xyzw component (input)
  64298. */
  64299. get xyzw(): NodeMaterialConnectionPoint;
  64300. /**
  64301. * Gets the xyz component (input)
  64302. */
  64303. get xyzIn(): NodeMaterialConnectionPoint;
  64304. /**
  64305. * Gets the xy component (input)
  64306. */
  64307. get xyIn(): NodeMaterialConnectionPoint;
  64308. /**
  64309. * Gets the xyz component (output)
  64310. */
  64311. get xyzOut(): NodeMaterialConnectionPoint;
  64312. /**
  64313. * Gets the xy component (output)
  64314. */
  64315. get xyOut(): NodeMaterialConnectionPoint;
  64316. /**
  64317. * Gets the x component (output)
  64318. */
  64319. get x(): NodeMaterialConnectionPoint;
  64320. /**
  64321. * Gets the y component (output)
  64322. */
  64323. get y(): NodeMaterialConnectionPoint;
  64324. /**
  64325. * Gets the z component (output)
  64326. */
  64327. get z(): NodeMaterialConnectionPoint;
  64328. /**
  64329. * Gets the w component (output)
  64330. */
  64331. get w(): NodeMaterialConnectionPoint;
  64332. protected _inputRename(name: string): string;
  64333. protected _outputRename(name: string): string;
  64334. protected _buildBlock(state: NodeMaterialBuildState): this;
  64335. }
  64336. }
  64337. declare module BABYLON {
  64338. /**
  64339. * Block used to lerp between 2 values
  64340. */
  64341. export class LerpBlock extends NodeMaterialBlock {
  64342. /**
  64343. * Creates a new LerpBlock
  64344. * @param name defines the block name
  64345. */
  64346. constructor(name: string);
  64347. /**
  64348. * Gets the current class name
  64349. * @returns the class name
  64350. */
  64351. getClassName(): string;
  64352. /**
  64353. * Gets the left operand input component
  64354. */
  64355. get left(): NodeMaterialConnectionPoint;
  64356. /**
  64357. * Gets the right operand input component
  64358. */
  64359. get right(): NodeMaterialConnectionPoint;
  64360. /**
  64361. * Gets the gradient operand input component
  64362. */
  64363. get gradient(): NodeMaterialConnectionPoint;
  64364. /**
  64365. * Gets the output component
  64366. */
  64367. get output(): NodeMaterialConnectionPoint;
  64368. protected _buildBlock(state: NodeMaterialBuildState): this;
  64369. }
  64370. }
  64371. declare module BABYLON {
  64372. /**
  64373. * Block used to divide 2 vectors
  64374. */
  64375. export class DivideBlock extends NodeMaterialBlock {
  64376. /**
  64377. * Creates a new DivideBlock
  64378. * @param name defines the block name
  64379. */
  64380. constructor(name: string);
  64381. /**
  64382. * Gets the current class name
  64383. * @returns the class name
  64384. */
  64385. getClassName(): string;
  64386. /**
  64387. * Gets the left operand input component
  64388. */
  64389. get left(): NodeMaterialConnectionPoint;
  64390. /**
  64391. * Gets the right operand input component
  64392. */
  64393. get right(): NodeMaterialConnectionPoint;
  64394. /**
  64395. * Gets the output component
  64396. */
  64397. get output(): NodeMaterialConnectionPoint;
  64398. protected _buildBlock(state: NodeMaterialBuildState): this;
  64399. }
  64400. }
  64401. declare module BABYLON {
  64402. /**
  64403. * Block used to subtract 2 vectors
  64404. */
  64405. export class SubtractBlock extends NodeMaterialBlock {
  64406. /**
  64407. * Creates a new SubtractBlock
  64408. * @param name defines the block name
  64409. */
  64410. constructor(name: string);
  64411. /**
  64412. * Gets the current class name
  64413. * @returns the class name
  64414. */
  64415. getClassName(): string;
  64416. /**
  64417. * Gets the left operand input component
  64418. */
  64419. get left(): NodeMaterialConnectionPoint;
  64420. /**
  64421. * Gets the right operand input component
  64422. */
  64423. get right(): NodeMaterialConnectionPoint;
  64424. /**
  64425. * Gets the output component
  64426. */
  64427. get output(): NodeMaterialConnectionPoint;
  64428. protected _buildBlock(state: NodeMaterialBuildState): this;
  64429. }
  64430. }
  64431. declare module BABYLON {
  64432. /**
  64433. * Block used to step a value
  64434. */
  64435. export class StepBlock extends NodeMaterialBlock {
  64436. /**
  64437. * Creates a new StepBlock
  64438. * @param name defines the block name
  64439. */
  64440. constructor(name: string);
  64441. /**
  64442. * Gets the current class name
  64443. * @returns the class name
  64444. */
  64445. getClassName(): string;
  64446. /**
  64447. * Gets the value operand input component
  64448. */
  64449. get value(): NodeMaterialConnectionPoint;
  64450. /**
  64451. * Gets the edge operand input component
  64452. */
  64453. get edge(): NodeMaterialConnectionPoint;
  64454. /**
  64455. * Gets the output component
  64456. */
  64457. get output(): NodeMaterialConnectionPoint;
  64458. protected _buildBlock(state: NodeMaterialBuildState): this;
  64459. }
  64460. }
  64461. declare module BABYLON {
  64462. /**
  64463. * Block used to get the opposite (1 - x) of a value
  64464. */
  64465. export class OneMinusBlock extends NodeMaterialBlock {
  64466. /**
  64467. * Creates a new OneMinusBlock
  64468. * @param name defines the block name
  64469. */
  64470. constructor(name: string);
  64471. /**
  64472. * Gets the current class name
  64473. * @returns the class name
  64474. */
  64475. getClassName(): string;
  64476. /**
  64477. * Gets the input component
  64478. */
  64479. get input(): NodeMaterialConnectionPoint;
  64480. /**
  64481. * Gets the output component
  64482. */
  64483. get output(): NodeMaterialConnectionPoint;
  64484. protected _buildBlock(state: NodeMaterialBuildState): this;
  64485. }
  64486. }
  64487. declare module BABYLON {
  64488. /**
  64489. * Block used to get the view direction
  64490. */
  64491. export class ViewDirectionBlock extends NodeMaterialBlock {
  64492. /**
  64493. * Creates a new ViewDirectionBlock
  64494. * @param name defines the block name
  64495. */
  64496. constructor(name: string);
  64497. /**
  64498. * Gets the current class name
  64499. * @returns the class name
  64500. */
  64501. getClassName(): string;
  64502. /**
  64503. * Gets the world position component
  64504. */
  64505. get worldPosition(): NodeMaterialConnectionPoint;
  64506. /**
  64507. * Gets the camera position component
  64508. */
  64509. get cameraPosition(): NodeMaterialConnectionPoint;
  64510. /**
  64511. * Gets the output component
  64512. */
  64513. get output(): NodeMaterialConnectionPoint;
  64514. autoConfigure(material: NodeMaterial): void;
  64515. protected _buildBlock(state: NodeMaterialBuildState): this;
  64516. }
  64517. }
  64518. declare module BABYLON {
  64519. /**
  64520. * Block used to compute fresnel value
  64521. */
  64522. export class FresnelBlock extends NodeMaterialBlock {
  64523. /**
  64524. * Create a new FresnelBlock
  64525. * @param name defines the block name
  64526. */
  64527. constructor(name: string);
  64528. /**
  64529. * Gets the current class name
  64530. * @returns the class name
  64531. */
  64532. getClassName(): string;
  64533. /**
  64534. * Gets the world normal input component
  64535. */
  64536. get worldNormal(): NodeMaterialConnectionPoint;
  64537. /**
  64538. * Gets the view direction input component
  64539. */
  64540. get viewDirection(): NodeMaterialConnectionPoint;
  64541. /**
  64542. * Gets the bias input component
  64543. */
  64544. get bias(): NodeMaterialConnectionPoint;
  64545. /**
  64546. * Gets the camera (or eye) position component
  64547. */
  64548. get power(): NodeMaterialConnectionPoint;
  64549. /**
  64550. * Gets the fresnel output component
  64551. */
  64552. get fresnel(): NodeMaterialConnectionPoint;
  64553. autoConfigure(material: NodeMaterial): void;
  64554. protected _buildBlock(state: NodeMaterialBuildState): this;
  64555. }
  64556. }
  64557. declare module BABYLON {
  64558. /**
  64559. * Block used to get the max of 2 values
  64560. */
  64561. export class MaxBlock extends NodeMaterialBlock {
  64562. /**
  64563. * Creates a new MaxBlock
  64564. * @param name defines the block name
  64565. */
  64566. constructor(name: string);
  64567. /**
  64568. * Gets the current class name
  64569. * @returns the class name
  64570. */
  64571. getClassName(): string;
  64572. /**
  64573. * Gets the left operand input component
  64574. */
  64575. get left(): NodeMaterialConnectionPoint;
  64576. /**
  64577. * Gets the right operand input component
  64578. */
  64579. get right(): NodeMaterialConnectionPoint;
  64580. /**
  64581. * Gets the output component
  64582. */
  64583. get output(): NodeMaterialConnectionPoint;
  64584. protected _buildBlock(state: NodeMaterialBuildState): this;
  64585. }
  64586. }
  64587. declare module BABYLON {
  64588. /**
  64589. * Block used to get the min of 2 values
  64590. */
  64591. export class MinBlock extends NodeMaterialBlock {
  64592. /**
  64593. * Creates a new MinBlock
  64594. * @param name defines the block name
  64595. */
  64596. constructor(name: string);
  64597. /**
  64598. * Gets the current class name
  64599. * @returns the class name
  64600. */
  64601. getClassName(): string;
  64602. /**
  64603. * Gets the left operand input component
  64604. */
  64605. get left(): NodeMaterialConnectionPoint;
  64606. /**
  64607. * Gets the right operand input component
  64608. */
  64609. get right(): NodeMaterialConnectionPoint;
  64610. /**
  64611. * Gets the output component
  64612. */
  64613. get output(): NodeMaterialConnectionPoint;
  64614. protected _buildBlock(state: NodeMaterialBuildState): this;
  64615. }
  64616. }
  64617. declare module BABYLON {
  64618. /**
  64619. * Block used to get the distance between 2 values
  64620. */
  64621. export class DistanceBlock extends NodeMaterialBlock {
  64622. /**
  64623. * Creates a new DistanceBlock
  64624. * @param name defines the block name
  64625. */
  64626. constructor(name: string);
  64627. /**
  64628. * Gets the current class name
  64629. * @returns the class name
  64630. */
  64631. getClassName(): string;
  64632. /**
  64633. * Gets the left operand input component
  64634. */
  64635. get left(): NodeMaterialConnectionPoint;
  64636. /**
  64637. * Gets the right operand input component
  64638. */
  64639. get right(): NodeMaterialConnectionPoint;
  64640. /**
  64641. * Gets the output component
  64642. */
  64643. get output(): NodeMaterialConnectionPoint;
  64644. protected _buildBlock(state: NodeMaterialBuildState): this;
  64645. }
  64646. }
  64647. declare module BABYLON {
  64648. /**
  64649. * Block used to get the length of a vector
  64650. */
  64651. export class LengthBlock extends NodeMaterialBlock {
  64652. /**
  64653. * Creates a new LengthBlock
  64654. * @param name defines the block name
  64655. */
  64656. constructor(name: string);
  64657. /**
  64658. * Gets the current class name
  64659. * @returns the class name
  64660. */
  64661. getClassName(): string;
  64662. /**
  64663. * Gets the value input component
  64664. */
  64665. get value(): NodeMaterialConnectionPoint;
  64666. /**
  64667. * Gets the output component
  64668. */
  64669. get output(): NodeMaterialConnectionPoint;
  64670. protected _buildBlock(state: NodeMaterialBuildState): this;
  64671. }
  64672. }
  64673. declare module BABYLON {
  64674. /**
  64675. * Block used to get negative version of a value (i.e. x * -1)
  64676. */
  64677. export class NegateBlock extends NodeMaterialBlock {
  64678. /**
  64679. * Creates a new NegateBlock
  64680. * @param name defines the block name
  64681. */
  64682. constructor(name: string);
  64683. /**
  64684. * Gets the current class name
  64685. * @returns the class name
  64686. */
  64687. getClassName(): string;
  64688. /**
  64689. * Gets the value input component
  64690. */
  64691. get value(): NodeMaterialConnectionPoint;
  64692. /**
  64693. * Gets the output component
  64694. */
  64695. get output(): NodeMaterialConnectionPoint;
  64696. protected _buildBlock(state: NodeMaterialBuildState): this;
  64697. }
  64698. }
  64699. declare module BABYLON {
  64700. /**
  64701. * Block used to get the value of the first parameter raised to the power of the second
  64702. */
  64703. export class PowBlock extends NodeMaterialBlock {
  64704. /**
  64705. * Creates a new PowBlock
  64706. * @param name defines the block name
  64707. */
  64708. constructor(name: string);
  64709. /**
  64710. * Gets the current class name
  64711. * @returns the class name
  64712. */
  64713. getClassName(): string;
  64714. /**
  64715. * Gets the value operand input component
  64716. */
  64717. get value(): NodeMaterialConnectionPoint;
  64718. /**
  64719. * Gets the power operand input component
  64720. */
  64721. get power(): NodeMaterialConnectionPoint;
  64722. /**
  64723. * Gets the output component
  64724. */
  64725. get output(): NodeMaterialConnectionPoint;
  64726. protected _buildBlock(state: NodeMaterialBuildState): this;
  64727. }
  64728. }
  64729. declare module BABYLON {
  64730. /**
  64731. * Block used to get a random number
  64732. */
  64733. export class RandomNumberBlock extends NodeMaterialBlock {
  64734. /**
  64735. * Creates a new RandomNumberBlock
  64736. * @param name defines the block name
  64737. */
  64738. constructor(name: string);
  64739. /**
  64740. * Gets the current class name
  64741. * @returns the class name
  64742. */
  64743. getClassName(): string;
  64744. /**
  64745. * Gets the seed input component
  64746. */
  64747. get seed(): NodeMaterialConnectionPoint;
  64748. /**
  64749. * Gets the output component
  64750. */
  64751. get output(): NodeMaterialConnectionPoint;
  64752. protected _buildBlock(state: NodeMaterialBuildState): this;
  64753. }
  64754. }
  64755. declare module BABYLON {
  64756. /**
  64757. * Block used to compute arc tangent of 2 values
  64758. */
  64759. export class ArcTan2Block extends NodeMaterialBlock {
  64760. /**
  64761. * Creates a new ArcTan2Block
  64762. * @param name defines the block name
  64763. */
  64764. constructor(name: string);
  64765. /**
  64766. * Gets the current class name
  64767. * @returns the class name
  64768. */
  64769. getClassName(): string;
  64770. /**
  64771. * Gets the x operand input component
  64772. */
  64773. get x(): NodeMaterialConnectionPoint;
  64774. /**
  64775. * Gets the y operand input component
  64776. */
  64777. get y(): NodeMaterialConnectionPoint;
  64778. /**
  64779. * Gets the output component
  64780. */
  64781. get output(): NodeMaterialConnectionPoint;
  64782. protected _buildBlock(state: NodeMaterialBuildState): this;
  64783. }
  64784. }
  64785. declare module BABYLON {
  64786. /**
  64787. * Block used to smooth step a value
  64788. */
  64789. export class SmoothStepBlock extends NodeMaterialBlock {
  64790. /**
  64791. * Creates a new SmoothStepBlock
  64792. * @param name defines the block name
  64793. */
  64794. constructor(name: string);
  64795. /**
  64796. * Gets the current class name
  64797. * @returns the class name
  64798. */
  64799. getClassName(): string;
  64800. /**
  64801. * Gets the value operand input component
  64802. */
  64803. get value(): NodeMaterialConnectionPoint;
  64804. /**
  64805. * Gets the first edge operand input component
  64806. */
  64807. get edge0(): NodeMaterialConnectionPoint;
  64808. /**
  64809. * Gets the second edge operand input component
  64810. */
  64811. get edge1(): NodeMaterialConnectionPoint;
  64812. /**
  64813. * Gets the output component
  64814. */
  64815. get output(): NodeMaterialConnectionPoint;
  64816. protected _buildBlock(state: NodeMaterialBuildState): this;
  64817. }
  64818. }
  64819. declare module BABYLON {
  64820. /**
  64821. * Block used to get the reciprocal (1 / x) of a value
  64822. */
  64823. export class ReciprocalBlock extends NodeMaterialBlock {
  64824. /**
  64825. * Creates a new ReciprocalBlock
  64826. * @param name defines the block name
  64827. */
  64828. constructor(name: string);
  64829. /**
  64830. * Gets the current class name
  64831. * @returns the class name
  64832. */
  64833. getClassName(): string;
  64834. /**
  64835. * Gets the input component
  64836. */
  64837. get input(): NodeMaterialConnectionPoint;
  64838. /**
  64839. * Gets the output component
  64840. */
  64841. get output(): NodeMaterialConnectionPoint;
  64842. protected _buildBlock(state: NodeMaterialBuildState): this;
  64843. }
  64844. }
  64845. declare module BABYLON {
  64846. /**
  64847. * Block used to replace a color by another one
  64848. */
  64849. export class ReplaceColorBlock extends NodeMaterialBlock {
  64850. /**
  64851. * Creates a new ReplaceColorBlock
  64852. * @param name defines the block name
  64853. */
  64854. constructor(name: string);
  64855. /**
  64856. * Gets the current class name
  64857. * @returns the class name
  64858. */
  64859. getClassName(): string;
  64860. /**
  64861. * Gets the value input component
  64862. */
  64863. get value(): NodeMaterialConnectionPoint;
  64864. /**
  64865. * Gets the reference input component
  64866. */
  64867. get reference(): NodeMaterialConnectionPoint;
  64868. /**
  64869. * Gets the distance input component
  64870. */
  64871. get distance(): NodeMaterialConnectionPoint;
  64872. /**
  64873. * Gets the replacement input component
  64874. */
  64875. get replacement(): NodeMaterialConnectionPoint;
  64876. /**
  64877. * Gets the output component
  64878. */
  64879. get output(): NodeMaterialConnectionPoint;
  64880. protected _buildBlock(state: NodeMaterialBuildState): this;
  64881. }
  64882. }
  64883. declare module BABYLON {
  64884. /**
  64885. * Block used to posterize a value
  64886. * @see https://en.wikipedia.org/wiki/Posterization
  64887. */
  64888. export class PosterizeBlock extends NodeMaterialBlock {
  64889. /**
  64890. * Creates a new PosterizeBlock
  64891. * @param name defines the block name
  64892. */
  64893. constructor(name: string);
  64894. /**
  64895. * Gets the current class name
  64896. * @returns the class name
  64897. */
  64898. getClassName(): string;
  64899. /**
  64900. * Gets the value input component
  64901. */
  64902. get value(): NodeMaterialConnectionPoint;
  64903. /**
  64904. * Gets the steps input component
  64905. */
  64906. get steps(): NodeMaterialConnectionPoint;
  64907. /**
  64908. * Gets the output component
  64909. */
  64910. get output(): NodeMaterialConnectionPoint;
  64911. protected _buildBlock(state: NodeMaterialBuildState): this;
  64912. }
  64913. }
  64914. declare module BABYLON {
  64915. /**
  64916. * Operations supported by the Wave block
  64917. */
  64918. export enum WaveBlockKind {
  64919. /** SawTooth */
  64920. SawTooth = 0,
  64921. /** Square */
  64922. Square = 1,
  64923. /** Triangle */
  64924. Triangle = 2
  64925. }
  64926. /**
  64927. * Block used to apply wave operation to floats
  64928. */
  64929. export class WaveBlock extends NodeMaterialBlock {
  64930. /**
  64931. * Gets or sets the kibnd of wave to be applied by the block
  64932. */
  64933. kind: WaveBlockKind;
  64934. /**
  64935. * Creates a new WaveBlock
  64936. * @param name defines the block name
  64937. */
  64938. constructor(name: string);
  64939. /**
  64940. * Gets the current class name
  64941. * @returns the class name
  64942. */
  64943. getClassName(): string;
  64944. /**
  64945. * Gets the input component
  64946. */
  64947. get input(): NodeMaterialConnectionPoint;
  64948. /**
  64949. * Gets the output component
  64950. */
  64951. get output(): NodeMaterialConnectionPoint;
  64952. protected _buildBlock(state: NodeMaterialBuildState): this;
  64953. serialize(): any;
  64954. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64955. }
  64956. }
  64957. declare module BABYLON {
  64958. /**
  64959. * Class used to store a color step for the GradientBlock
  64960. */
  64961. export class GradientBlockColorStep {
  64962. private _step;
  64963. /**
  64964. * Gets value indicating which step this color is associated with (between 0 and 1)
  64965. */
  64966. get step(): number;
  64967. /**
  64968. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64969. */
  64970. set step(val: number);
  64971. private _color;
  64972. /**
  64973. * Gets the color associated with this step
  64974. */
  64975. get color(): Color3;
  64976. /**
  64977. * Sets the color associated with this step
  64978. */
  64979. set color(val: Color3);
  64980. /**
  64981. * Creates a new GradientBlockColorStep
  64982. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64983. * @param color defines the color associated with this step
  64984. */
  64985. constructor(step: number, color: Color3);
  64986. }
  64987. /**
  64988. * Block used to return a color from a gradient based on an input value between 0 and 1
  64989. */
  64990. export class GradientBlock extends NodeMaterialBlock {
  64991. /**
  64992. * Gets or sets the list of color steps
  64993. */
  64994. colorSteps: GradientBlockColorStep[];
  64995. /** Gets an observable raised when the value is changed */
  64996. onValueChangedObservable: Observable<GradientBlock>;
  64997. /** calls observable when the value is changed*/
  64998. colorStepsUpdated(): void;
  64999. /**
  65000. * Creates a new GradientBlock
  65001. * @param name defines the block name
  65002. */
  65003. constructor(name: string);
  65004. /**
  65005. * Gets the current class name
  65006. * @returns the class name
  65007. */
  65008. getClassName(): string;
  65009. /**
  65010. * Gets the gradient input component
  65011. */
  65012. get gradient(): NodeMaterialConnectionPoint;
  65013. /**
  65014. * Gets the output component
  65015. */
  65016. get output(): NodeMaterialConnectionPoint;
  65017. private _writeColorConstant;
  65018. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65019. serialize(): any;
  65020. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65021. protected _dumpPropertiesCode(): string;
  65022. }
  65023. }
  65024. declare module BABYLON {
  65025. /**
  65026. * Block used to normalize lerp between 2 values
  65027. */
  65028. export class NLerpBlock extends NodeMaterialBlock {
  65029. /**
  65030. * Creates a new NLerpBlock
  65031. * @param name defines the block name
  65032. */
  65033. constructor(name: string);
  65034. /**
  65035. * Gets the current class name
  65036. * @returns the class name
  65037. */
  65038. getClassName(): string;
  65039. /**
  65040. * Gets the left operand input component
  65041. */
  65042. get left(): NodeMaterialConnectionPoint;
  65043. /**
  65044. * Gets the right operand input component
  65045. */
  65046. get right(): NodeMaterialConnectionPoint;
  65047. /**
  65048. * Gets the gradient operand input component
  65049. */
  65050. get gradient(): NodeMaterialConnectionPoint;
  65051. /**
  65052. * Gets the output component
  65053. */
  65054. get output(): NodeMaterialConnectionPoint;
  65055. protected _buildBlock(state: NodeMaterialBuildState): this;
  65056. }
  65057. }
  65058. declare module BABYLON {
  65059. /**
  65060. * block used to Generate a Worley Noise 3D Noise Pattern
  65061. */
  65062. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65063. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65064. manhattanDistance: boolean;
  65065. /**
  65066. * Creates a new WorleyNoise3DBlock
  65067. * @param name defines the block name
  65068. */
  65069. constructor(name: string);
  65070. /**
  65071. * Gets the current class name
  65072. * @returns the class name
  65073. */
  65074. getClassName(): string;
  65075. /**
  65076. * Gets the seed input component
  65077. */
  65078. get seed(): NodeMaterialConnectionPoint;
  65079. /**
  65080. * Gets the jitter input component
  65081. */
  65082. get jitter(): NodeMaterialConnectionPoint;
  65083. /**
  65084. * Gets the output component
  65085. */
  65086. get output(): NodeMaterialConnectionPoint;
  65087. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65088. /**
  65089. * Exposes the properties to the UI?
  65090. */
  65091. protected _dumpPropertiesCode(): string;
  65092. /**
  65093. * Exposes the properties to the Seralize?
  65094. */
  65095. serialize(): any;
  65096. /**
  65097. * Exposes the properties to the deseralize?
  65098. */
  65099. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65100. }
  65101. }
  65102. declare module BABYLON {
  65103. /**
  65104. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65105. */
  65106. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65107. /**
  65108. * Creates a new SimplexPerlin3DBlock
  65109. * @param name defines the block name
  65110. */
  65111. constructor(name: string);
  65112. /**
  65113. * Gets the current class name
  65114. * @returns the class name
  65115. */
  65116. getClassName(): string;
  65117. /**
  65118. * Gets the seed operand input component
  65119. */
  65120. get seed(): NodeMaterialConnectionPoint;
  65121. /**
  65122. * Gets the output component
  65123. */
  65124. get output(): NodeMaterialConnectionPoint;
  65125. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65126. }
  65127. }
  65128. declare module BABYLON {
  65129. /**
  65130. * Block used to blend normals
  65131. */
  65132. export class NormalBlendBlock extends NodeMaterialBlock {
  65133. /**
  65134. * Creates a new NormalBlendBlock
  65135. * @param name defines the block name
  65136. */
  65137. constructor(name: string);
  65138. /**
  65139. * Gets the current class name
  65140. * @returns the class name
  65141. */
  65142. getClassName(): string;
  65143. /**
  65144. * Gets the first input component
  65145. */
  65146. get normalMap0(): NodeMaterialConnectionPoint;
  65147. /**
  65148. * Gets the second input component
  65149. */
  65150. get normalMap1(): NodeMaterialConnectionPoint;
  65151. /**
  65152. * Gets the output component
  65153. */
  65154. get output(): NodeMaterialConnectionPoint;
  65155. protected _buildBlock(state: NodeMaterialBuildState): this;
  65156. }
  65157. }
  65158. declare module BABYLON {
  65159. /**
  65160. * Block used to rotate a 2d vector by a given angle
  65161. */
  65162. export class Rotate2dBlock extends NodeMaterialBlock {
  65163. /**
  65164. * Creates a new Rotate2dBlock
  65165. * @param name defines the block name
  65166. */
  65167. constructor(name: string);
  65168. /**
  65169. * Gets the current class name
  65170. * @returns the class name
  65171. */
  65172. getClassName(): string;
  65173. /**
  65174. * Gets the input vector
  65175. */
  65176. get input(): NodeMaterialConnectionPoint;
  65177. /**
  65178. * Gets the input angle
  65179. */
  65180. get angle(): NodeMaterialConnectionPoint;
  65181. /**
  65182. * Gets the output component
  65183. */
  65184. get output(): NodeMaterialConnectionPoint;
  65185. autoConfigure(material: NodeMaterial): void;
  65186. protected _buildBlock(state: NodeMaterialBuildState): this;
  65187. }
  65188. }
  65189. declare module BABYLON {
  65190. /**
  65191. * Block used to get the reflected vector from a direction and a normal
  65192. */
  65193. export class ReflectBlock extends NodeMaterialBlock {
  65194. /**
  65195. * Creates a new ReflectBlock
  65196. * @param name defines the block name
  65197. */
  65198. constructor(name: string);
  65199. /**
  65200. * Gets the current class name
  65201. * @returns the class name
  65202. */
  65203. getClassName(): string;
  65204. /**
  65205. * Gets the incident component
  65206. */
  65207. get incident(): NodeMaterialConnectionPoint;
  65208. /**
  65209. * Gets the normal component
  65210. */
  65211. get normal(): NodeMaterialConnectionPoint;
  65212. /**
  65213. * Gets the output component
  65214. */
  65215. get output(): NodeMaterialConnectionPoint;
  65216. protected _buildBlock(state: NodeMaterialBuildState): this;
  65217. }
  65218. }
  65219. declare module BABYLON {
  65220. /**
  65221. * Block used to get the refracted vector from a direction and a normal
  65222. */
  65223. export class RefractBlock extends NodeMaterialBlock {
  65224. /**
  65225. * Creates a new RefractBlock
  65226. * @param name defines the block name
  65227. */
  65228. constructor(name: string);
  65229. /**
  65230. * Gets the current class name
  65231. * @returns the class name
  65232. */
  65233. getClassName(): string;
  65234. /**
  65235. * Gets the incident component
  65236. */
  65237. get incident(): NodeMaterialConnectionPoint;
  65238. /**
  65239. * Gets the normal component
  65240. */
  65241. get normal(): NodeMaterialConnectionPoint;
  65242. /**
  65243. * Gets the index of refraction component
  65244. */
  65245. get ior(): NodeMaterialConnectionPoint;
  65246. /**
  65247. * Gets the output component
  65248. */
  65249. get output(): NodeMaterialConnectionPoint;
  65250. protected _buildBlock(state: NodeMaterialBuildState): this;
  65251. }
  65252. }
  65253. declare module BABYLON {
  65254. /**
  65255. * Block used to desaturate a color
  65256. */
  65257. export class DesaturateBlock extends NodeMaterialBlock {
  65258. /**
  65259. * Creates a new DesaturateBlock
  65260. * @param name defines the block name
  65261. */
  65262. constructor(name: string);
  65263. /**
  65264. * Gets the current class name
  65265. * @returns the class name
  65266. */
  65267. getClassName(): string;
  65268. /**
  65269. * Gets the color operand input component
  65270. */
  65271. get color(): NodeMaterialConnectionPoint;
  65272. /**
  65273. * Gets the level operand input component
  65274. */
  65275. get level(): NodeMaterialConnectionPoint;
  65276. /**
  65277. * Gets the output component
  65278. */
  65279. get output(): NodeMaterialConnectionPoint;
  65280. protected _buildBlock(state: NodeMaterialBuildState): this;
  65281. }
  65282. }
  65283. declare module BABYLON {
  65284. /**
  65285. * Block used to implement the ambient occlusion module of the PBR material
  65286. */
  65287. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  65288. /**
  65289. * Create a new AmbientOcclusionBlock
  65290. * @param name defines the block name
  65291. */
  65292. constructor(name: string);
  65293. /**
  65294. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  65295. */
  65296. useAmbientInGrayScale: boolean;
  65297. /**
  65298. * Initialize the block and prepare the context for build
  65299. * @param state defines the state that will be used for the build
  65300. */
  65301. initialize(state: NodeMaterialBuildState): void;
  65302. /**
  65303. * Gets the current class name
  65304. * @returns the class name
  65305. */
  65306. getClassName(): string;
  65307. /**
  65308. * Gets the texture input component
  65309. */
  65310. get texture(): NodeMaterialConnectionPoint;
  65311. /**
  65312. * Gets the texture intensity component
  65313. */
  65314. get intensity(): NodeMaterialConnectionPoint;
  65315. /**
  65316. * Gets the direct light intensity input component
  65317. */
  65318. get directLightIntensity(): NodeMaterialConnectionPoint;
  65319. /**
  65320. * Gets the ambient occlusion object output component
  65321. */
  65322. get ambientOcc(): NodeMaterialConnectionPoint;
  65323. /**
  65324. * Gets the main code of the block (fragment side)
  65325. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  65326. * @returns the shader code
  65327. */
  65328. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  65329. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65330. protected _buildBlock(state: NodeMaterialBuildState): this;
  65331. protected _dumpPropertiesCode(): string;
  65332. serialize(): any;
  65333. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65334. }
  65335. }
  65336. declare module BABYLON {
  65337. /**
  65338. * Block used to implement the reflection module of the PBR material
  65339. */
  65340. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65341. /** @hidden */
  65342. _defineLODReflectionAlpha: string;
  65343. /** @hidden */
  65344. _defineLinearSpecularReflection: string;
  65345. private _vEnvironmentIrradianceName;
  65346. /** @hidden */
  65347. _vReflectionMicrosurfaceInfosName: string;
  65348. /** @hidden */
  65349. _vReflectionInfosName: string;
  65350. /** @hidden */
  65351. _vReflectionFilteringInfoName: string;
  65352. private _scene;
  65353. /**
  65354. * The three properties below are set by the main PBR block prior to calling methods of this class.
  65355. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65356. * It's less burden on the user side in the editor part.
  65357. */
  65358. /** @hidden */
  65359. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65360. /** @hidden */
  65361. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65362. /** @hidden */
  65363. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65364. /**
  65365. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65366. * diffuse part of the IBL.
  65367. */
  65368. useSphericalHarmonics: boolean;
  65369. /**
  65370. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65371. */
  65372. forceIrradianceInFragment: boolean;
  65373. /**
  65374. * Create a new ReflectionBlock
  65375. * @param name defines the block name
  65376. */
  65377. constructor(name: string);
  65378. /**
  65379. * Gets the current class name
  65380. * @returns the class name
  65381. */
  65382. getClassName(): string;
  65383. /**
  65384. * Gets the position input component
  65385. */
  65386. get position(): NodeMaterialConnectionPoint;
  65387. /**
  65388. * Gets the world position input component
  65389. */
  65390. get worldPosition(): NodeMaterialConnectionPoint;
  65391. /**
  65392. * Gets the world normal input component
  65393. */
  65394. get worldNormal(): NodeMaterialConnectionPoint;
  65395. /**
  65396. * Gets the world input component
  65397. */
  65398. get world(): NodeMaterialConnectionPoint;
  65399. /**
  65400. * Gets the camera (or eye) position component
  65401. */
  65402. get cameraPosition(): NodeMaterialConnectionPoint;
  65403. /**
  65404. * Gets the view input component
  65405. */
  65406. get view(): NodeMaterialConnectionPoint;
  65407. /**
  65408. * Gets the color input component
  65409. */
  65410. get color(): NodeMaterialConnectionPoint;
  65411. /**
  65412. * Gets the reflection object output component
  65413. */
  65414. get reflection(): NodeMaterialConnectionPoint;
  65415. /**
  65416. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65417. */
  65418. get hasTexture(): boolean;
  65419. /**
  65420. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65421. */
  65422. get reflectionColor(): string;
  65423. protected _getTexture(): Nullable<BaseTexture>;
  65424. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65425. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65426. /**
  65427. * Gets the code to inject in the vertex shader
  65428. * @param state current state of the node material building
  65429. * @returns the shader code
  65430. */
  65431. handleVertexSide(state: NodeMaterialBuildState): string;
  65432. /**
  65433. * Gets the main code of the block (fragment side)
  65434. * @param state current state of the node material building
  65435. * @param normalVarName name of the existing variable corresponding to the normal
  65436. * @returns the shader code
  65437. */
  65438. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65439. protected _buildBlock(state: NodeMaterialBuildState): this;
  65440. protected _dumpPropertiesCode(): string;
  65441. serialize(): any;
  65442. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65443. }
  65444. }
  65445. declare module BABYLON {
  65446. /**
  65447. * Block used to implement the sheen module of the PBR material
  65448. */
  65449. export class SheenBlock extends NodeMaterialBlock {
  65450. /**
  65451. * Create a new SheenBlock
  65452. * @param name defines the block name
  65453. */
  65454. constructor(name: string);
  65455. /**
  65456. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65457. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65458. * making it easier to setup and tweak the effect
  65459. */
  65460. albedoScaling: boolean;
  65461. /**
  65462. * Defines if the sheen is linked to the sheen color.
  65463. */
  65464. linkSheenWithAlbedo: boolean;
  65465. /**
  65466. * Initialize the block and prepare the context for build
  65467. * @param state defines the state that will be used for the build
  65468. */
  65469. initialize(state: NodeMaterialBuildState): void;
  65470. /**
  65471. * Gets the current class name
  65472. * @returns the class name
  65473. */
  65474. getClassName(): string;
  65475. /**
  65476. * Gets the intensity input component
  65477. */
  65478. get intensity(): NodeMaterialConnectionPoint;
  65479. /**
  65480. * Gets the color input component
  65481. */
  65482. get color(): NodeMaterialConnectionPoint;
  65483. /**
  65484. * Gets the roughness input component
  65485. */
  65486. get roughness(): NodeMaterialConnectionPoint;
  65487. /**
  65488. * Gets the sheen object output component
  65489. */
  65490. get sheen(): NodeMaterialConnectionPoint;
  65491. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65492. /**
  65493. * Gets the main code of the block (fragment side)
  65494. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65495. * @returns the shader code
  65496. */
  65497. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65498. protected _buildBlock(state: NodeMaterialBuildState): this;
  65499. protected _dumpPropertiesCode(): string;
  65500. serialize(): any;
  65501. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65502. }
  65503. }
  65504. declare module BABYLON {
  65505. /**
  65506. * Block used to implement the reflectivity module of the PBR material
  65507. */
  65508. export class ReflectivityBlock extends NodeMaterialBlock {
  65509. private _metallicReflectanceColor;
  65510. private _metallicF0Factor;
  65511. /** @hidden */
  65512. _vMetallicReflectanceFactorsName: string;
  65513. /**
  65514. * The property below is set by the main PBR block prior to calling methods of this class.
  65515. */
  65516. /** @hidden */
  65517. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  65518. /**
  65519. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65520. */
  65521. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65522. /**
  65523. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65524. */
  65525. useMetallnessFromMetallicTextureBlue: boolean;
  65526. /**
  65527. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65528. */
  65529. useRoughnessFromMetallicTextureAlpha: boolean;
  65530. /**
  65531. * Specifies if the metallic texture contains the roughness information in its green channel.
  65532. */
  65533. useRoughnessFromMetallicTextureGreen: boolean;
  65534. /**
  65535. * Create a new ReflectivityBlock
  65536. * @param name defines the block name
  65537. */
  65538. constructor(name: string);
  65539. /**
  65540. * Initialize the block and prepare the context for build
  65541. * @param state defines the state that will be used for the build
  65542. */
  65543. initialize(state: NodeMaterialBuildState): void;
  65544. /**
  65545. * Gets the current class name
  65546. * @returns the class name
  65547. */
  65548. getClassName(): string;
  65549. /**
  65550. * Gets the metallic input component
  65551. */
  65552. get metallic(): NodeMaterialConnectionPoint;
  65553. /**
  65554. * Gets the roughness input component
  65555. */
  65556. get roughness(): NodeMaterialConnectionPoint;
  65557. /**
  65558. * Gets the texture input component
  65559. */
  65560. get texture(): NodeMaterialConnectionPoint;
  65561. /**
  65562. * Gets the reflectivity object output component
  65563. */
  65564. get reflectivity(): NodeMaterialConnectionPoint;
  65565. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65566. /**
  65567. * Gets the main code of the block (fragment side)
  65568. * @param state current state of the node material building
  65569. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65570. * @returns the shader code
  65571. */
  65572. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  65573. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65574. protected _buildBlock(state: NodeMaterialBuildState): this;
  65575. protected _dumpPropertiesCode(): string;
  65576. serialize(): any;
  65577. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65578. }
  65579. }
  65580. declare module BABYLON {
  65581. /**
  65582. * Block used to implement the anisotropy module of the PBR material
  65583. */
  65584. export class AnisotropyBlock extends NodeMaterialBlock {
  65585. /**
  65586. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65587. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65588. * It's less burden on the user side in the editor part.
  65589. */
  65590. /** @hidden */
  65591. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65592. /** @hidden */
  65593. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65594. /**
  65595. * Create a new AnisotropyBlock
  65596. * @param name defines the block name
  65597. */
  65598. constructor(name: string);
  65599. /**
  65600. * Initialize the block and prepare the context for build
  65601. * @param state defines the state that will be used for the build
  65602. */
  65603. initialize(state: NodeMaterialBuildState): void;
  65604. /**
  65605. * Gets the current class name
  65606. * @returns the class name
  65607. */
  65608. getClassName(): string;
  65609. /**
  65610. * Gets the intensity input component
  65611. */
  65612. get intensity(): NodeMaterialConnectionPoint;
  65613. /**
  65614. * Gets the direction input component
  65615. */
  65616. get direction(): NodeMaterialConnectionPoint;
  65617. /**
  65618. * Gets the texture input component
  65619. */
  65620. get texture(): NodeMaterialConnectionPoint;
  65621. /**
  65622. * Gets the uv input component
  65623. */
  65624. get uv(): NodeMaterialConnectionPoint;
  65625. /**
  65626. * Gets the worldTangent input component
  65627. */
  65628. get worldTangent(): NodeMaterialConnectionPoint;
  65629. /**
  65630. * Gets the anisotropy object output component
  65631. */
  65632. get anisotropy(): NodeMaterialConnectionPoint;
  65633. private _generateTBNSpace;
  65634. /**
  65635. * Gets the main code of the block (fragment side)
  65636. * @param state current state of the node material building
  65637. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65638. * @returns the shader code
  65639. */
  65640. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65641. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65642. protected _buildBlock(state: NodeMaterialBuildState): this;
  65643. }
  65644. }
  65645. declare module BABYLON {
  65646. /**
  65647. * Block used to implement the clear coat module of the PBR material
  65648. */
  65649. export class ClearCoatBlock extends NodeMaterialBlock {
  65650. private _scene;
  65651. /**
  65652. * Create a new ClearCoatBlock
  65653. * @param name defines the block name
  65654. */
  65655. constructor(name: string);
  65656. /**
  65657. * Initialize the block and prepare the context for build
  65658. * @param state defines the state that will be used for the build
  65659. */
  65660. initialize(state: NodeMaterialBuildState): void;
  65661. /**
  65662. * Gets the current class name
  65663. * @returns the class name
  65664. */
  65665. getClassName(): string;
  65666. /**
  65667. * Gets the intensity input component
  65668. */
  65669. get intensity(): NodeMaterialConnectionPoint;
  65670. /**
  65671. * Gets the roughness input component
  65672. */
  65673. get roughness(): NodeMaterialConnectionPoint;
  65674. /**
  65675. * Gets the ior input component
  65676. */
  65677. get ior(): NodeMaterialConnectionPoint;
  65678. /**
  65679. * Gets the texture input component
  65680. */
  65681. get texture(): NodeMaterialConnectionPoint;
  65682. /**
  65683. * Gets the bump texture input component
  65684. */
  65685. get bumpTexture(): NodeMaterialConnectionPoint;
  65686. /**
  65687. * Gets the uv input component
  65688. */
  65689. get uv(): NodeMaterialConnectionPoint;
  65690. /**
  65691. * Gets the tint color input component
  65692. */
  65693. get tintColor(): NodeMaterialConnectionPoint;
  65694. /**
  65695. * Gets the tint "at distance" input component
  65696. */
  65697. get tintAtDistance(): NodeMaterialConnectionPoint;
  65698. /**
  65699. * Gets the tint thickness input component
  65700. */
  65701. get tintThickness(): NodeMaterialConnectionPoint;
  65702. /**
  65703. * Gets the world tangent input component
  65704. */
  65705. get worldTangent(): NodeMaterialConnectionPoint;
  65706. /**
  65707. * Gets the clear coat object output component
  65708. */
  65709. get clearcoat(): NodeMaterialConnectionPoint;
  65710. autoConfigure(material: NodeMaterial): void;
  65711. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65712. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65713. private _generateTBNSpace;
  65714. /**
  65715. * Gets the main code of the block (fragment side)
  65716. * @param state current state of the node material building
  65717. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65718. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65719. * @param worldPosVarName name of the variable holding the world position
  65720. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65721. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65722. * @param worldNormalVarName name of the variable holding the world normal
  65723. * @returns the shader code
  65724. */
  65725. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65726. protected _buildBlock(state: NodeMaterialBuildState): this;
  65727. }
  65728. }
  65729. declare module BABYLON {
  65730. /**
  65731. * Block used to implement the sub surface module of the PBR material
  65732. */
  65733. export class SubSurfaceBlock extends NodeMaterialBlock {
  65734. /**
  65735. * Create a new SubSurfaceBlock
  65736. * @param name defines the block name
  65737. */
  65738. constructor(name: string);
  65739. /**
  65740. * Stores the intensity of the different subsurface effects in the thickness texture.
  65741. * * the green channel is the translucency intensity.
  65742. * * the blue channel is the scattering intensity.
  65743. * * the alpha channel is the refraction intensity.
  65744. */
  65745. useMaskFromThicknessTexture: boolean;
  65746. /**
  65747. * Initialize the block and prepare the context for build
  65748. * @param state defines the state that will be used for the build
  65749. */
  65750. initialize(state: NodeMaterialBuildState): void;
  65751. /**
  65752. * Gets the current class name
  65753. * @returns the class name
  65754. */
  65755. getClassName(): string;
  65756. /**
  65757. * Gets the min thickness input component
  65758. */
  65759. get minThickness(): NodeMaterialConnectionPoint;
  65760. /**
  65761. * Gets the max thickness input component
  65762. */
  65763. get maxThickness(): NodeMaterialConnectionPoint;
  65764. /**
  65765. * Gets the thickness texture component
  65766. */
  65767. get thicknessTexture(): NodeMaterialConnectionPoint;
  65768. /**
  65769. * Gets the tint color input component
  65770. */
  65771. get tintColor(): NodeMaterialConnectionPoint;
  65772. /**
  65773. * Gets the translucency intensity input component
  65774. */
  65775. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65776. /**
  65777. * Gets the translucency diffusion distance input component
  65778. */
  65779. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65780. /**
  65781. * Gets the refraction object parameters
  65782. */
  65783. get refraction(): NodeMaterialConnectionPoint;
  65784. /**
  65785. * Gets the sub surface object output component
  65786. */
  65787. get subsurface(): NodeMaterialConnectionPoint;
  65788. autoConfigure(material: NodeMaterial): void;
  65789. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65790. /**
  65791. * Gets the main code of the block (fragment side)
  65792. * @param state current state of the node material building
  65793. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65794. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65795. * @param worldPosVarName name of the variable holding the world position
  65796. * @returns the shader code
  65797. */
  65798. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65799. protected _buildBlock(state: NodeMaterialBuildState): this;
  65800. }
  65801. }
  65802. declare module BABYLON {
  65803. /**
  65804. * Block used to implement the PBR metallic/roughness model
  65805. */
  65806. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65807. /**
  65808. * Gets or sets the light associated with this block
  65809. */
  65810. light: Nullable<Light>;
  65811. private _lightId;
  65812. private _scene;
  65813. private _environmentBRDFTexture;
  65814. private _environmentBrdfSamplerName;
  65815. private _vNormalWName;
  65816. private _invertNormalName;
  65817. /**
  65818. * Create a new ReflectionBlock
  65819. * @param name defines the block name
  65820. */
  65821. constructor(name: string);
  65822. /**
  65823. * Intensity of the direct lights e.g. the four lights available in your scene.
  65824. * This impacts both the direct diffuse and specular highlights.
  65825. */
  65826. directIntensity: number;
  65827. /**
  65828. * Intensity of the environment e.g. how much the environment will light the object
  65829. * either through harmonics for rough material or through the refelction for shiny ones.
  65830. */
  65831. environmentIntensity: number;
  65832. /**
  65833. * This is a special control allowing the reduction of the specular highlights coming from the
  65834. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65835. */
  65836. specularIntensity: number;
  65837. /**
  65838. * Defines the falloff type used in this material.
  65839. * It by default is Physical.
  65840. */
  65841. lightFalloff: number;
  65842. /**
  65843. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65844. */
  65845. useAlphaFromAlbedoTexture: boolean;
  65846. /**
  65847. * Specifies that alpha test should be used
  65848. */
  65849. useAlphaTest: boolean;
  65850. /**
  65851. * Defines the alpha limits in alpha test mode.
  65852. */
  65853. alphaTestCutoff: number;
  65854. /**
  65855. * Specifies that alpha blending should be used
  65856. */
  65857. useAlphaBlending: boolean;
  65858. /**
  65859. * Defines if the alpha value should be determined via the rgb values.
  65860. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65861. */
  65862. opacityRGB: boolean;
  65863. /**
  65864. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65865. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65866. */
  65867. useRadianceOverAlpha: boolean;
  65868. /**
  65869. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65870. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65871. */
  65872. useSpecularOverAlpha: boolean;
  65873. /**
  65874. * Enables specular anti aliasing in the PBR shader.
  65875. * It will both interacts on the Geometry for analytical and IBL lighting.
  65876. * It also prefilter the roughness map based on the bump values.
  65877. */
  65878. enableSpecularAntiAliasing: boolean;
  65879. /**
  65880. * Enables realtime filtering on the texture.
  65881. */
  65882. realTimeFiltering: boolean;
  65883. /**
  65884. * Quality switch for realtime filtering
  65885. */
  65886. realTimeFilteringQuality: number;
  65887. /**
  65888. * Defines if the material uses energy conservation.
  65889. */
  65890. useEnergyConservation: boolean;
  65891. /**
  65892. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65893. * too much the area relying on ambient texture to define their ambient occlusion.
  65894. */
  65895. useRadianceOcclusion: boolean;
  65896. /**
  65897. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65898. * makes the reflect vector face the model (under horizon).
  65899. */
  65900. useHorizonOcclusion: boolean;
  65901. /**
  65902. * If set to true, no lighting calculations will be applied.
  65903. */
  65904. unlit: boolean;
  65905. /**
  65906. * Force normal to face away from face.
  65907. */
  65908. forceNormalForward: boolean;
  65909. /**
  65910. * Defines the material debug mode.
  65911. * It helps seeing only some components of the material while troubleshooting.
  65912. */
  65913. debugMode: number;
  65914. /**
  65915. * Specify from where on screen the debug mode should start.
  65916. * The value goes from -1 (full screen) to 1 (not visible)
  65917. * It helps with side by side comparison against the final render
  65918. * This defaults to 0
  65919. */
  65920. debugLimit: number;
  65921. /**
  65922. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65923. * You can use the factor to better multiply the final value.
  65924. */
  65925. debugFactor: number;
  65926. /**
  65927. * Initialize the block and prepare the context for build
  65928. * @param state defines the state that will be used for the build
  65929. */
  65930. initialize(state: NodeMaterialBuildState): void;
  65931. /**
  65932. * Gets the current class name
  65933. * @returns the class name
  65934. */
  65935. getClassName(): string;
  65936. /**
  65937. * Gets the world position input component
  65938. */
  65939. get worldPosition(): NodeMaterialConnectionPoint;
  65940. /**
  65941. * Gets the world normal input component
  65942. */
  65943. get worldNormal(): NodeMaterialConnectionPoint;
  65944. /**
  65945. * Gets the perturbed normal input component
  65946. */
  65947. get perturbedNormal(): NodeMaterialConnectionPoint;
  65948. /**
  65949. * Gets the camera position input component
  65950. */
  65951. get cameraPosition(): NodeMaterialConnectionPoint;
  65952. /**
  65953. * Gets the base color input component
  65954. */
  65955. get baseColor(): NodeMaterialConnectionPoint;
  65956. /**
  65957. * Gets the opacity texture input component
  65958. */
  65959. get opacityTexture(): NodeMaterialConnectionPoint;
  65960. /**
  65961. * Gets the ambient color input component
  65962. */
  65963. get ambientColor(): NodeMaterialConnectionPoint;
  65964. /**
  65965. * Gets the reflectivity object parameters
  65966. */
  65967. get reflectivity(): NodeMaterialConnectionPoint;
  65968. /**
  65969. * Gets the ambient occlusion object parameters
  65970. */
  65971. get ambientOcc(): NodeMaterialConnectionPoint;
  65972. /**
  65973. * Gets the reflection object parameters
  65974. */
  65975. get reflection(): NodeMaterialConnectionPoint;
  65976. /**
  65977. * Gets the sheen object parameters
  65978. */
  65979. get sheen(): NodeMaterialConnectionPoint;
  65980. /**
  65981. * Gets the clear coat object parameters
  65982. */
  65983. get clearcoat(): NodeMaterialConnectionPoint;
  65984. /**
  65985. * Gets the sub surface object parameters
  65986. */
  65987. get subsurface(): NodeMaterialConnectionPoint;
  65988. /**
  65989. * Gets the anisotropy object parameters
  65990. */
  65991. get anisotropy(): NodeMaterialConnectionPoint;
  65992. /**
  65993. * Gets the view matrix parameter
  65994. */
  65995. get view(): NodeMaterialConnectionPoint;
  65996. /**
  65997. * Gets the ambient output component
  65998. */
  65999. get ambient(): NodeMaterialConnectionPoint;
  66000. /**
  66001. * Gets the diffuse output component
  66002. */
  66003. get diffuse(): NodeMaterialConnectionPoint;
  66004. /**
  66005. * Gets the specular output component
  66006. */
  66007. get specular(): NodeMaterialConnectionPoint;
  66008. /**
  66009. * Gets the sheen output component
  66010. */
  66011. get sheenDir(): NodeMaterialConnectionPoint;
  66012. /**
  66013. * Gets the clear coat output component
  66014. */
  66015. get clearcoatDir(): NodeMaterialConnectionPoint;
  66016. /**
  66017. * Gets the indirect diffuse output component
  66018. */
  66019. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66020. /**
  66021. * Gets the indirect specular output component
  66022. */
  66023. get specularIndirect(): NodeMaterialConnectionPoint;
  66024. /**
  66025. * Gets the indirect sheen output component
  66026. */
  66027. get sheenIndirect(): NodeMaterialConnectionPoint;
  66028. /**
  66029. * Gets the indirect clear coat output component
  66030. */
  66031. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66032. /**
  66033. * Gets the refraction output component
  66034. */
  66035. get refraction(): NodeMaterialConnectionPoint;
  66036. /**
  66037. * Gets the global lighting output component
  66038. */
  66039. get lighting(): NodeMaterialConnectionPoint;
  66040. /**
  66041. * Gets the shadow output component
  66042. */
  66043. get shadow(): NodeMaterialConnectionPoint;
  66044. /**
  66045. * Gets the alpha output component
  66046. */
  66047. get alpha(): NodeMaterialConnectionPoint;
  66048. autoConfigure(material: NodeMaterial): void;
  66049. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66050. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66051. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66052. private _injectVertexCode;
  66053. /**
  66054. * Gets the code corresponding to the albedo/opacity module
  66055. * @returns the shader code
  66056. */
  66057. getAlbedoOpacityCode(): string;
  66058. protected _buildBlock(state: NodeMaterialBuildState): this;
  66059. protected _dumpPropertiesCode(): string;
  66060. serialize(): any;
  66061. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66062. }
  66063. }
  66064. declare module BABYLON {
  66065. /**
  66066. * Block used to compute value of one parameter modulo another
  66067. */
  66068. export class ModBlock extends NodeMaterialBlock {
  66069. /**
  66070. * Creates a new ModBlock
  66071. * @param name defines the block name
  66072. */
  66073. constructor(name: string);
  66074. /**
  66075. * Gets the current class name
  66076. * @returns the class name
  66077. */
  66078. getClassName(): string;
  66079. /**
  66080. * Gets the left operand input component
  66081. */
  66082. get left(): NodeMaterialConnectionPoint;
  66083. /**
  66084. * Gets the right operand input component
  66085. */
  66086. get right(): NodeMaterialConnectionPoint;
  66087. /**
  66088. * Gets the output component
  66089. */
  66090. get output(): NodeMaterialConnectionPoint;
  66091. protected _buildBlock(state: NodeMaterialBuildState): this;
  66092. }
  66093. }
  66094. declare module BABYLON {
  66095. /**
  66096. * Configuration for Draco compression
  66097. */
  66098. export interface IDracoCompressionConfiguration {
  66099. /**
  66100. * Configuration for the decoder.
  66101. */
  66102. decoder: {
  66103. /**
  66104. * The url to the WebAssembly module.
  66105. */
  66106. wasmUrl?: string;
  66107. /**
  66108. * The url to the WebAssembly binary.
  66109. */
  66110. wasmBinaryUrl?: string;
  66111. /**
  66112. * The url to the fallback JavaScript module.
  66113. */
  66114. fallbackUrl?: string;
  66115. };
  66116. }
  66117. /**
  66118. * Draco compression (https://google.github.io/draco/)
  66119. *
  66120. * This class wraps the Draco module.
  66121. *
  66122. * **Encoder**
  66123. *
  66124. * The encoder is not currently implemented.
  66125. *
  66126. * **Decoder**
  66127. *
  66128. * 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.
  66129. *
  66130. * To update the configuration, use the following code:
  66131. * ```javascript
  66132. * DracoCompression.Configuration = {
  66133. * decoder: {
  66134. * wasmUrl: "<url to the WebAssembly library>",
  66135. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66136. * fallbackUrl: "<url to the fallback JavaScript library>",
  66137. * }
  66138. * };
  66139. * ```
  66140. *
  66141. * 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.
  66142. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66143. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66144. *
  66145. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66146. * ```javascript
  66147. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66148. * ```
  66149. *
  66150. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66151. */
  66152. export class DracoCompression implements IDisposable {
  66153. private _workerPoolPromise?;
  66154. private _decoderModulePromise?;
  66155. /**
  66156. * The configuration. Defaults to the following urls:
  66157. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66158. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66159. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66160. */
  66161. static Configuration: IDracoCompressionConfiguration;
  66162. /**
  66163. * Returns true if the decoder configuration is available.
  66164. */
  66165. static get DecoderAvailable(): boolean;
  66166. /**
  66167. * Default number of workers to create when creating the draco compression object.
  66168. */
  66169. static DefaultNumWorkers: number;
  66170. private static GetDefaultNumWorkers;
  66171. private static _Default;
  66172. /**
  66173. * Default instance for the draco compression object.
  66174. */
  66175. static get Default(): DracoCompression;
  66176. /**
  66177. * Constructor
  66178. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66179. */
  66180. constructor(numWorkers?: number);
  66181. /**
  66182. * Stop all async operations and release resources.
  66183. */
  66184. dispose(): void;
  66185. /**
  66186. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66187. * @returns a promise that resolves when ready
  66188. */
  66189. whenReadyAsync(): Promise<void>;
  66190. /**
  66191. * Decode Draco compressed mesh data to vertex data.
  66192. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66193. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66194. * @returns A promise that resolves with the decoded vertex data
  66195. */
  66196. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66197. [kind: string]: number;
  66198. }): Promise<VertexData>;
  66199. }
  66200. }
  66201. declare module BABYLON {
  66202. /**
  66203. * Class for building Constructive Solid Geometry
  66204. */
  66205. export class CSG {
  66206. private polygons;
  66207. /**
  66208. * The world matrix
  66209. */
  66210. matrix: Matrix;
  66211. /**
  66212. * Stores the position
  66213. */
  66214. position: Vector3;
  66215. /**
  66216. * Stores the rotation
  66217. */
  66218. rotation: Vector3;
  66219. /**
  66220. * Stores the rotation quaternion
  66221. */
  66222. rotationQuaternion: Nullable<Quaternion>;
  66223. /**
  66224. * Stores the scaling vector
  66225. */
  66226. scaling: Vector3;
  66227. /**
  66228. * Convert the Mesh to CSG
  66229. * @param mesh The Mesh to convert to CSG
  66230. * @returns A new CSG from the Mesh
  66231. */
  66232. static FromMesh(mesh: Mesh): CSG;
  66233. /**
  66234. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66235. * @param polygons Polygons used to construct a CSG solid
  66236. */
  66237. private static FromPolygons;
  66238. /**
  66239. * Clones, or makes a deep copy, of the CSG
  66240. * @returns A new CSG
  66241. */
  66242. clone(): CSG;
  66243. /**
  66244. * Unions this CSG with another CSG
  66245. * @param csg The CSG to union against this CSG
  66246. * @returns The unioned CSG
  66247. */
  66248. union(csg: CSG): CSG;
  66249. /**
  66250. * Unions this CSG with another CSG in place
  66251. * @param csg The CSG to union against this CSG
  66252. */
  66253. unionInPlace(csg: CSG): void;
  66254. /**
  66255. * Subtracts this CSG with another CSG
  66256. * @param csg The CSG to subtract against this CSG
  66257. * @returns A new CSG
  66258. */
  66259. subtract(csg: CSG): CSG;
  66260. /**
  66261. * Subtracts this CSG with another CSG in place
  66262. * @param csg The CSG to subtact against this CSG
  66263. */
  66264. subtractInPlace(csg: CSG): void;
  66265. /**
  66266. * Intersect this CSG with another CSG
  66267. * @param csg The CSG to intersect against this CSG
  66268. * @returns A new CSG
  66269. */
  66270. intersect(csg: CSG): CSG;
  66271. /**
  66272. * Intersects this CSG with another CSG in place
  66273. * @param csg The CSG to intersect against this CSG
  66274. */
  66275. intersectInPlace(csg: CSG): void;
  66276. /**
  66277. * Return a new CSG solid with solid and empty space switched. This solid is
  66278. * not modified.
  66279. * @returns A new CSG solid with solid and empty space switched
  66280. */
  66281. inverse(): CSG;
  66282. /**
  66283. * Inverses the CSG in place
  66284. */
  66285. inverseInPlace(): void;
  66286. /**
  66287. * This is used to keep meshes transformations so they can be restored
  66288. * when we build back a Babylon Mesh
  66289. * NB : All CSG operations are performed in world coordinates
  66290. * @param csg The CSG to copy the transform attributes from
  66291. * @returns This CSG
  66292. */
  66293. copyTransformAttributes(csg: CSG): CSG;
  66294. /**
  66295. * Build Raw mesh from CSG
  66296. * Coordinates here are in world space
  66297. * @param name The name of the mesh geometry
  66298. * @param scene The Scene
  66299. * @param keepSubMeshes Specifies if the submeshes should be kept
  66300. * @returns A new Mesh
  66301. */
  66302. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66303. /**
  66304. * Build Mesh from CSG taking material and transforms into account
  66305. * @param name The name of the Mesh
  66306. * @param material The material of the Mesh
  66307. * @param scene The Scene
  66308. * @param keepSubMeshes Specifies if submeshes should be kept
  66309. * @returns The new Mesh
  66310. */
  66311. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66312. }
  66313. }
  66314. declare module BABYLON {
  66315. /**
  66316. * Class used to create a trail following a mesh
  66317. */
  66318. export class TrailMesh extends Mesh {
  66319. private _generator;
  66320. private _autoStart;
  66321. private _running;
  66322. private _diameter;
  66323. private _length;
  66324. private _sectionPolygonPointsCount;
  66325. private _sectionVectors;
  66326. private _sectionNormalVectors;
  66327. private _beforeRenderObserver;
  66328. /**
  66329. * @constructor
  66330. * @param name The value used by scene.getMeshByName() to do a lookup.
  66331. * @param generator The mesh or transform node to generate a trail.
  66332. * @param scene The scene to add this mesh to.
  66333. * @param diameter Diameter of trailing mesh. Default is 1.
  66334. * @param length Length of trailing mesh. Default is 60.
  66335. * @param autoStart Automatically start trailing mesh. Default true.
  66336. */
  66337. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66338. /**
  66339. * "TrailMesh"
  66340. * @returns "TrailMesh"
  66341. */
  66342. getClassName(): string;
  66343. private _createMesh;
  66344. /**
  66345. * Start trailing mesh.
  66346. */
  66347. start(): void;
  66348. /**
  66349. * Stop trailing mesh.
  66350. */
  66351. stop(): void;
  66352. /**
  66353. * Update trailing mesh geometry.
  66354. */
  66355. update(): void;
  66356. /**
  66357. * Returns a new TrailMesh object.
  66358. * @param name is a string, the name given to the new mesh
  66359. * @param newGenerator use new generator object for cloned trail mesh
  66360. * @returns a new mesh
  66361. */
  66362. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66363. /**
  66364. * Serializes this trail mesh
  66365. * @param serializationObject object to write serialization to
  66366. */
  66367. serialize(serializationObject: any): void;
  66368. /**
  66369. * Parses a serialized trail mesh
  66370. * @param parsedMesh the serialized mesh
  66371. * @param scene the scene to create the trail mesh in
  66372. * @returns the created trail mesh
  66373. */
  66374. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66375. }
  66376. }
  66377. declare module BABYLON {
  66378. /**
  66379. * Class containing static functions to help procedurally build meshes
  66380. */
  66381. export class TiledBoxBuilder {
  66382. /**
  66383. * Creates a box mesh
  66384. * 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)
  66385. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66387. * * 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
  66388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66389. * @param name defines the name of the mesh
  66390. * @param options defines the options used to create the mesh
  66391. * @param scene defines the hosting scene
  66392. * @returns the box mesh
  66393. */
  66394. static CreateTiledBox(name: string, options: {
  66395. pattern?: number;
  66396. width?: number;
  66397. height?: number;
  66398. depth?: number;
  66399. tileSize?: number;
  66400. tileWidth?: number;
  66401. tileHeight?: number;
  66402. alignHorizontal?: number;
  66403. alignVertical?: number;
  66404. faceUV?: Vector4[];
  66405. faceColors?: Color4[];
  66406. sideOrientation?: number;
  66407. updatable?: boolean;
  66408. }, scene?: Nullable<Scene>): Mesh;
  66409. }
  66410. }
  66411. declare module BABYLON {
  66412. /**
  66413. * Class containing static functions to help procedurally build meshes
  66414. */
  66415. export class TorusKnotBuilder {
  66416. /**
  66417. * Creates a torus knot mesh
  66418. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66419. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66420. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66421. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66423. * * 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
  66424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66425. * @param name defines the name of the mesh
  66426. * @param options defines the options used to create the mesh
  66427. * @param scene defines the hosting scene
  66428. * @returns the torus knot mesh
  66429. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66430. */
  66431. static CreateTorusKnot(name: string, options: {
  66432. radius?: number;
  66433. tube?: number;
  66434. radialSegments?: number;
  66435. tubularSegments?: number;
  66436. p?: number;
  66437. q?: number;
  66438. updatable?: boolean;
  66439. sideOrientation?: number;
  66440. frontUVs?: Vector4;
  66441. backUVs?: Vector4;
  66442. }, scene: any): Mesh;
  66443. }
  66444. }
  66445. declare module BABYLON {
  66446. /**
  66447. * Polygon
  66448. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66449. */
  66450. export class Polygon {
  66451. /**
  66452. * Creates a rectangle
  66453. * @param xmin bottom X coord
  66454. * @param ymin bottom Y coord
  66455. * @param xmax top X coord
  66456. * @param ymax top Y coord
  66457. * @returns points that make the resulting rectation
  66458. */
  66459. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66460. /**
  66461. * Creates a circle
  66462. * @param radius radius of circle
  66463. * @param cx scale in x
  66464. * @param cy scale in y
  66465. * @param numberOfSides number of sides that make up the circle
  66466. * @returns points that make the resulting circle
  66467. */
  66468. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66469. /**
  66470. * Creates a polygon from input string
  66471. * @param input Input polygon data
  66472. * @returns the parsed points
  66473. */
  66474. static Parse(input: string): Vector2[];
  66475. /**
  66476. * Starts building a polygon from x and y coordinates
  66477. * @param x x coordinate
  66478. * @param y y coordinate
  66479. * @returns the started path2
  66480. */
  66481. static StartingAt(x: number, y: number): Path2;
  66482. }
  66483. /**
  66484. * Builds a polygon
  66485. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66486. */
  66487. export class PolygonMeshBuilder {
  66488. private _points;
  66489. private _outlinepoints;
  66490. private _holes;
  66491. private _name;
  66492. private _scene;
  66493. private _epoints;
  66494. private _eholes;
  66495. private _addToepoint;
  66496. /**
  66497. * Babylon reference to the earcut plugin.
  66498. */
  66499. bjsEarcut: any;
  66500. /**
  66501. * Creates a PolygonMeshBuilder
  66502. * @param name name of the builder
  66503. * @param contours Path of the polygon
  66504. * @param scene scene to add to when creating the mesh
  66505. * @param earcutInjection can be used to inject your own earcut reference
  66506. */
  66507. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66508. /**
  66509. * Adds a whole within the polygon
  66510. * @param hole Array of points defining the hole
  66511. * @returns this
  66512. */
  66513. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66514. /**
  66515. * Creates the polygon
  66516. * @param updatable If the mesh should be updatable
  66517. * @param depth The depth of the mesh created
  66518. * @returns the created mesh
  66519. */
  66520. build(updatable?: boolean, depth?: number): Mesh;
  66521. /**
  66522. * Creates the polygon
  66523. * @param depth The depth of the mesh created
  66524. * @returns the created VertexData
  66525. */
  66526. buildVertexData(depth?: number): VertexData;
  66527. /**
  66528. * Adds a side to the polygon
  66529. * @param positions points that make the polygon
  66530. * @param normals normals of the polygon
  66531. * @param uvs uvs of the polygon
  66532. * @param indices indices of the polygon
  66533. * @param bounds bounds of the polygon
  66534. * @param points points of the polygon
  66535. * @param depth depth of the polygon
  66536. * @param flip flip of the polygon
  66537. */
  66538. private addSide;
  66539. }
  66540. }
  66541. declare module BABYLON {
  66542. /**
  66543. * Class containing static functions to help procedurally build meshes
  66544. */
  66545. export class PolygonBuilder {
  66546. /**
  66547. * Creates a polygon mesh
  66548. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66549. * * 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
  66550. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66552. * * 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)
  66553. * * Remember you can only change the shape positions, not their number when updating a polygon
  66554. * @param name defines the name of the mesh
  66555. * @param options defines the options used to create the mesh
  66556. * @param scene defines the hosting scene
  66557. * @param earcutInjection can be used to inject your own earcut reference
  66558. * @returns the polygon mesh
  66559. */
  66560. static CreatePolygon(name: string, options: {
  66561. shape: Vector3[];
  66562. holes?: Vector3[][];
  66563. depth?: number;
  66564. faceUV?: Vector4[];
  66565. faceColors?: Color4[];
  66566. updatable?: boolean;
  66567. sideOrientation?: number;
  66568. frontUVs?: Vector4;
  66569. backUVs?: Vector4;
  66570. wrap?: boolean;
  66571. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66572. /**
  66573. * Creates an extruded polygon mesh, with depth in the Y direction.
  66574. * * 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)
  66575. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66576. * @param name defines the name of the mesh
  66577. * @param options defines the options used to create the mesh
  66578. * @param scene defines the hosting scene
  66579. * @param earcutInjection can be used to inject your own earcut reference
  66580. * @returns the polygon mesh
  66581. */
  66582. static ExtrudePolygon(name: string, options: {
  66583. shape: Vector3[];
  66584. holes?: Vector3[][];
  66585. depth?: number;
  66586. faceUV?: Vector4[];
  66587. faceColors?: Color4[];
  66588. updatable?: boolean;
  66589. sideOrientation?: number;
  66590. frontUVs?: Vector4;
  66591. backUVs?: Vector4;
  66592. wrap?: boolean;
  66593. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66594. }
  66595. }
  66596. declare module BABYLON {
  66597. /**
  66598. * Class containing static functions to help procedurally build meshes
  66599. */
  66600. export class LatheBuilder {
  66601. /**
  66602. * Creates lathe mesh.
  66603. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66604. * * 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
  66605. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66606. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66607. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66608. * * 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
  66609. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66610. * * 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
  66611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66612. * * 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
  66613. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66615. * @param name defines the name of the mesh
  66616. * @param options defines the options used to create the mesh
  66617. * @param scene defines the hosting scene
  66618. * @returns the lathe mesh
  66619. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66620. */
  66621. static CreateLathe(name: string, options: {
  66622. shape: Vector3[];
  66623. radius?: number;
  66624. tessellation?: number;
  66625. clip?: number;
  66626. arc?: number;
  66627. closed?: boolean;
  66628. updatable?: boolean;
  66629. sideOrientation?: number;
  66630. frontUVs?: Vector4;
  66631. backUVs?: Vector4;
  66632. cap?: number;
  66633. invertUV?: boolean;
  66634. }, scene?: Nullable<Scene>): Mesh;
  66635. }
  66636. }
  66637. declare module BABYLON {
  66638. /**
  66639. * Class containing static functions to help procedurally build meshes
  66640. */
  66641. export class TiledPlaneBuilder {
  66642. /**
  66643. * Creates a tiled plane mesh
  66644. * * The parameter `pattern` will, depending on value, do nothing or
  66645. * * * flip (reflect about central vertical) alternate tiles across and up
  66646. * * * flip every tile on alternate rows
  66647. * * * rotate (180 degs) alternate tiles across and up
  66648. * * * rotate every tile on alternate rows
  66649. * * * flip and rotate alternate tiles across and up
  66650. * * * flip and rotate every tile on alternate rows
  66651. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66652. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66653. * * 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
  66654. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66655. * * 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)
  66656. * * 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)
  66657. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66658. * @param name defines the name of the mesh
  66659. * @param options defines the options used to create the mesh
  66660. * @param scene defines the hosting scene
  66661. * @returns the box mesh
  66662. */
  66663. static CreateTiledPlane(name: string, options: {
  66664. pattern?: number;
  66665. tileSize?: number;
  66666. tileWidth?: number;
  66667. tileHeight?: number;
  66668. size?: number;
  66669. width?: number;
  66670. height?: number;
  66671. alignHorizontal?: number;
  66672. alignVertical?: number;
  66673. sideOrientation?: number;
  66674. frontUVs?: Vector4;
  66675. backUVs?: Vector4;
  66676. updatable?: boolean;
  66677. }, scene?: Nullable<Scene>): Mesh;
  66678. }
  66679. }
  66680. declare module BABYLON {
  66681. /**
  66682. * Class containing static functions to help procedurally build meshes
  66683. */
  66684. export class TubeBuilder {
  66685. /**
  66686. * Creates a tube mesh.
  66687. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66688. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66689. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66690. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66691. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66692. * * 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)
  66693. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66694. * * 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
  66695. * * 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
  66696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66697. * * 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
  66698. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66700. * @param name defines the name of the mesh
  66701. * @param options defines the options used to create the mesh
  66702. * @param scene defines the hosting scene
  66703. * @returns the tube mesh
  66704. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66705. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66706. */
  66707. static CreateTube(name: string, options: {
  66708. path: Vector3[];
  66709. radius?: number;
  66710. tessellation?: number;
  66711. radiusFunction?: {
  66712. (i: number, distance: number): number;
  66713. };
  66714. cap?: number;
  66715. arc?: number;
  66716. updatable?: boolean;
  66717. sideOrientation?: number;
  66718. frontUVs?: Vector4;
  66719. backUVs?: Vector4;
  66720. instance?: Mesh;
  66721. invertUV?: boolean;
  66722. }, scene?: Nullable<Scene>): Mesh;
  66723. }
  66724. }
  66725. declare module BABYLON {
  66726. /**
  66727. * Class containing static functions to help procedurally build meshes
  66728. */
  66729. export class IcoSphereBuilder {
  66730. /**
  66731. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66732. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66733. * * 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`)
  66734. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66735. * * 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
  66736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66737. * * 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
  66738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66739. * @param name defines the name of the mesh
  66740. * @param options defines the options used to create the mesh
  66741. * @param scene defines the hosting scene
  66742. * @returns the icosahedron mesh
  66743. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66744. */
  66745. static CreateIcoSphere(name: string, options: {
  66746. radius?: number;
  66747. radiusX?: number;
  66748. radiusY?: number;
  66749. radiusZ?: number;
  66750. flat?: boolean;
  66751. subdivisions?: number;
  66752. sideOrientation?: number;
  66753. frontUVs?: Vector4;
  66754. backUVs?: Vector4;
  66755. updatable?: boolean;
  66756. }, scene?: Nullable<Scene>): Mesh;
  66757. }
  66758. }
  66759. declare module BABYLON {
  66760. /**
  66761. * Class containing static functions to help procedurally build meshes
  66762. */
  66763. export class DecalBuilder {
  66764. /**
  66765. * Creates a decal mesh.
  66766. * 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
  66767. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66768. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66769. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66770. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66771. * @param name defines the name of the mesh
  66772. * @param sourceMesh defines the mesh where the decal must be applied
  66773. * @param options defines the options used to create the mesh
  66774. * @param scene defines the hosting scene
  66775. * @returns the decal mesh
  66776. * @see https://doc.babylonjs.com/how_to/decals
  66777. */
  66778. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66779. position?: Vector3;
  66780. normal?: Vector3;
  66781. size?: Vector3;
  66782. angle?: number;
  66783. }): Mesh;
  66784. }
  66785. }
  66786. declare module BABYLON {
  66787. /**
  66788. * Class containing static functions to help procedurally build meshes
  66789. */
  66790. export class MeshBuilder {
  66791. /**
  66792. * Creates a box mesh
  66793. * * The parameter `size` sets the size (float) of each box side (default 1)
  66794. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66795. * * 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)
  66796. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66798. * * 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
  66799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66800. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66801. * @param name defines the name of the mesh
  66802. * @param options defines the options used to create the mesh
  66803. * @param scene defines the hosting scene
  66804. * @returns the box mesh
  66805. */
  66806. static CreateBox(name: string, options: {
  66807. size?: number;
  66808. width?: number;
  66809. height?: number;
  66810. depth?: number;
  66811. faceUV?: Vector4[];
  66812. faceColors?: Color4[];
  66813. sideOrientation?: number;
  66814. frontUVs?: Vector4;
  66815. backUVs?: Vector4;
  66816. wrap?: boolean;
  66817. topBaseAt?: number;
  66818. bottomBaseAt?: number;
  66819. updatable?: boolean;
  66820. }, scene?: Nullable<Scene>): Mesh;
  66821. /**
  66822. * Creates a tiled box mesh
  66823. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66825. * @param name defines the name of the mesh
  66826. * @param options defines the options used to create the mesh
  66827. * @param scene defines the hosting scene
  66828. * @returns the tiled box mesh
  66829. */
  66830. static CreateTiledBox(name: string, options: {
  66831. pattern?: number;
  66832. size?: number;
  66833. width?: number;
  66834. height?: number;
  66835. depth: number;
  66836. tileSize?: number;
  66837. tileWidth?: number;
  66838. tileHeight?: number;
  66839. faceUV?: Vector4[];
  66840. faceColors?: Color4[];
  66841. alignHorizontal?: number;
  66842. alignVertical?: number;
  66843. sideOrientation?: number;
  66844. updatable?: boolean;
  66845. }, scene?: Nullable<Scene>): Mesh;
  66846. /**
  66847. * Creates a sphere mesh
  66848. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66849. * * 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`)
  66850. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66851. * * 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
  66852. * * 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)
  66853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66854. * * 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
  66855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66856. * @param name defines the name of the mesh
  66857. * @param options defines the options used to create the mesh
  66858. * @param scene defines the hosting scene
  66859. * @returns the sphere mesh
  66860. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66861. */
  66862. static CreateSphere(name: string, options: {
  66863. segments?: number;
  66864. diameter?: number;
  66865. diameterX?: number;
  66866. diameterY?: number;
  66867. diameterZ?: number;
  66868. arc?: number;
  66869. slice?: number;
  66870. sideOrientation?: number;
  66871. frontUVs?: Vector4;
  66872. backUVs?: Vector4;
  66873. updatable?: boolean;
  66874. }, scene?: Nullable<Scene>): Mesh;
  66875. /**
  66876. * Creates a plane polygonal mesh. By default, this is a disc
  66877. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66878. * * 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
  66879. * * 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
  66880. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66881. * * 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
  66882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66883. * @param name defines the name of the mesh
  66884. * @param options defines the options used to create the mesh
  66885. * @param scene defines the hosting scene
  66886. * @returns the plane polygonal mesh
  66887. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66888. */
  66889. static CreateDisc(name: string, options: {
  66890. radius?: number;
  66891. tessellation?: number;
  66892. arc?: number;
  66893. updatable?: boolean;
  66894. sideOrientation?: number;
  66895. frontUVs?: Vector4;
  66896. backUVs?: Vector4;
  66897. }, scene?: Nullable<Scene>): Mesh;
  66898. /**
  66899. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66900. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66901. * * 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`)
  66902. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66903. * * 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
  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 icosahedron mesh
  66911. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66912. */
  66913. static CreateIcoSphere(name: string, options: {
  66914. radius?: number;
  66915. radiusX?: number;
  66916. radiusY?: number;
  66917. radiusZ?: number;
  66918. flat?: boolean;
  66919. subdivisions?: number;
  66920. sideOrientation?: number;
  66921. frontUVs?: Vector4;
  66922. backUVs?: Vector4;
  66923. updatable?: boolean;
  66924. }, scene?: Nullable<Scene>): Mesh;
  66925. /**
  66926. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66927. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66928. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66929. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66930. * * 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
  66931. * * 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
  66932. * * 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
  66933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66934. * * 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
  66935. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66936. * * 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
  66937. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66938. * * 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
  66939. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66941. * @param name defines the name of the mesh
  66942. * @param options defines the options used to create the mesh
  66943. * @param scene defines the hosting scene
  66944. * @returns the ribbon mesh
  66945. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66946. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66947. */
  66948. static CreateRibbon(name: string, options: {
  66949. pathArray: Vector3[][];
  66950. closeArray?: boolean;
  66951. closePath?: boolean;
  66952. offset?: number;
  66953. updatable?: boolean;
  66954. sideOrientation?: number;
  66955. frontUVs?: Vector4;
  66956. backUVs?: Vector4;
  66957. instance?: Mesh;
  66958. invertUV?: boolean;
  66959. uvs?: Vector2[];
  66960. colors?: Color4[];
  66961. }, scene?: Nullable<Scene>): Mesh;
  66962. /**
  66963. * Creates a cylinder or a cone mesh
  66964. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66965. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66966. * * 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.
  66967. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66968. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66969. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66970. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66971. * * 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).
  66972. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66973. * * 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).
  66974. * * 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
  66975. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66976. * * 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
  66977. * * 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.
  66978. * * If `enclose` is false, a ring surface is one element.
  66979. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66980. * * 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
  66981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66982. * * 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
  66983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66984. * @param name defines the name of the mesh
  66985. * @param options defines the options used to create the mesh
  66986. * @param scene defines the hosting scene
  66987. * @returns the cylinder mesh
  66988. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66989. */
  66990. static CreateCylinder(name: string, options: {
  66991. height?: number;
  66992. diameterTop?: number;
  66993. diameterBottom?: number;
  66994. diameter?: number;
  66995. tessellation?: number;
  66996. subdivisions?: number;
  66997. arc?: number;
  66998. faceColors?: Color4[];
  66999. faceUV?: Vector4[];
  67000. updatable?: boolean;
  67001. hasRings?: boolean;
  67002. enclose?: boolean;
  67003. cap?: number;
  67004. sideOrientation?: number;
  67005. frontUVs?: Vector4;
  67006. backUVs?: Vector4;
  67007. }, scene?: Nullable<Scene>): Mesh;
  67008. /**
  67009. * Creates a torus mesh
  67010. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67011. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67012. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67014. * * 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
  67015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67016. * @param name defines the name of the mesh
  67017. * @param options defines the options used to create the mesh
  67018. * @param scene defines the hosting scene
  67019. * @returns the torus mesh
  67020. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67021. */
  67022. static CreateTorus(name: string, options: {
  67023. diameter?: number;
  67024. thickness?: number;
  67025. tessellation?: number;
  67026. updatable?: boolean;
  67027. sideOrientation?: number;
  67028. frontUVs?: Vector4;
  67029. backUVs?: Vector4;
  67030. }, scene?: Nullable<Scene>): Mesh;
  67031. /**
  67032. * Creates a torus knot mesh
  67033. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67034. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67035. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67036. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67038. * * 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
  67039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67040. * @param name defines the name of the mesh
  67041. * @param options defines the options used to create the mesh
  67042. * @param scene defines the hosting scene
  67043. * @returns the torus knot mesh
  67044. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67045. */
  67046. static CreateTorusKnot(name: string, options: {
  67047. radius?: number;
  67048. tube?: number;
  67049. radialSegments?: number;
  67050. tubularSegments?: number;
  67051. p?: number;
  67052. q?: number;
  67053. updatable?: boolean;
  67054. sideOrientation?: number;
  67055. frontUVs?: Vector4;
  67056. backUVs?: Vector4;
  67057. }, scene?: Nullable<Scene>): Mesh;
  67058. /**
  67059. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67060. * * 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
  67061. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67062. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67063. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67064. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67065. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67066. * * 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
  67067. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67070. * @param name defines the name of the new line system
  67071. * @param options defines the options used to create the line system
  67072. * @param scene defines the hosting scene
  67073. * @returns a new line system mesh
  67074. */
  67075. static CreateLineSystem(name: string, options: {
  67076. lines: Vector3[][];
  67077. updatable?: boolean;
  67078. instance?: Nullable<LinesMesh>;
  67079. colors?: Nullable<Color4[][]>;
  67080. useVertexAlpha?: boolean;
  67081. }, scene: Nullable<Scene>): LinesMesh;
  67082. /**
  67083. * Creates a line mesh
  67084. * 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
  67085. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67086. * * The parameter `points` is an array successive Vector3
  67087. * * 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
  67088. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67089. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67090. * * When updating an instance, remember that only point positions can change, not the number of points
  67091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67092. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67093. * @param name defines the name of the new line system
  67094. * @param options defines the options used to create the line system
  67095. * @param scene defines the hosting scene
  67096. * @returns a new line mesh
  67097. */
  67098. static CreateLines(name: string, options: {
  67099. points: Vector3[];
  67100. updatable?: boolean;
  67101. instance?: Nullable<LinesMesh>;
  67102. colors?: Color4[];
  67103. useVertexAlpha?: boolean;
  67104. }, scene?: Nullable<Scene>): LinesMesh;
  67105. /**
  67106. * Creates a dashed line mesh
  67107. * * 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
  67108. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67109. * * The parameter `points` is an array successive Vector3
  67110. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67111. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67112. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67113. * * 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
  67114. * * When updating an instance, remember that only point positions can change, not the number of points
  67115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67116. * @param name defines the name of the mesh
  67117. * @param options defines the options used to create the mesh
  67118. * @param scene defines the hosting scene
  67119. * @returns the dashed line mesh
  67120. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67121. */
  67122. static CreateDashedLines(name: string, options: {
  67123. points: Vector3[];
  67124. dashSize?: number;
  67125. gapSize?: number;
  67126. dashNb?: number;
  67127. updatable?: boolean;
  67128. instance?: LinesMesh;
  67129. }, scene?: Nullable<Scene>): LinesMesh;
  67130. /**
  67131. * 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.
  67132. * * 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.
  67133. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67134. * * 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.
  67135. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67136. * * 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
  67137. * * 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
  67138. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67140. * * 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
  67141. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  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. * @param name defines the name of the mesh
  67144. * @param options defines the options used to create the mesh
  67145. * @param scene defines the hosting scene
  67146. * @returns the extruded shape mesh
  67147. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67148. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67149. */
  67150. static ExtrudeShape(name: string, options: {
  67151. shape: Vector3[];
  67152. path: Vector3[];
  67153. scale?: number;
  67154. rotation?: number;
  67155. cap?: number;
  67156. updatable?: boolean;
  67157. sideOrientation?: number;
  67158. frontUVs?: Vector4;
  67159. backUVs?: Vector4;
  67160. instance?: Mesh;
  67161. invertUV?: boolean;
  67162. }, scene?: Nullable<Scene>): Mesh;
  67163. /**
  67164. * Creates an custom extruded shape mesh.
  67165. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67166. * * 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.
  67167. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67168. * * 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
  67169. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67170. * * 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
  67171. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67172. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67173. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67174. * * 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
  67175. * * 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
  67176. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67178. * * 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
  67179. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67181. * @param name defines the name of the mesh
  67182. * @param options defines the options used to create the mesh
  67183. * @param scene defines the hosting scene
  67184. * @returns the custom extruded shape mesh
  67185. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67186. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67187. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67188. */
  67189. static ExtrudeShapeCustom(name: string, options: {
  67190. shape: Vector3[];
  67191. path: Vector3[];
  67192. scaleFunction?: any;
  67193. rotationFunction?: any;
  67194. ribbonCloseArray?: boolean;
  67195. ribbonClosePath?: boolean;
  67196. cap?: number;
  67197. updatable?: boolean;
  67198. sideOrientation?: number;
  67199. frontUVs?: Vector4;
  67200. backUVs?: Vector4;
  67201. instance?: Mesh;
  67202. invertUV?: boolean;
  67203. }, scene?: Nullable<Scene>): Mesh;
  67204. /**
  67205. * Creates lathe mesh.
  67206. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67207. * * 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
  67208. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67209. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67210. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67211. * * 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
  67212. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67213. * * 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
  67214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67215. * * 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
  67216. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67218. * @param name defines the name of the mesh
  67219. * @param options defines the options used to create the mesh
  67220. * @param scene defines the hosting scene
  67221. * @returns the lathe mesh
  67222. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67223. */
  67224. static CreateLathe(name: string, options: {
  67225. shape: Vector3[];
  67226. radius?: number;
  67227. tessellation?: number;
  67228. clip?: number;
  67229. arc?: number;
  67230. closed?: boolean;
  67231. updatable?: boolean;
  67232. sideOrientation?: number;
  67233. frontUVs?: Vector4;
  67234. backUVs?: Vector4;
  67235. cap?: number;
  67236. invertUV?: boolean;
  67237. }, scene?: Nullable<Scene>): Mesh;
  67238. /**
  67239. * Creates a tiled plane mesh
  67240. * * You can set a limited pattern arrangement with the tiles
  67241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67242. * * 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
  67243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67244. * @param name defines the name of the mesh
  67245. * @param options defines the options used to create the mesh
  67246. * @param scene defines the hosting scene
  67247. * @returns the plane mesh
  67248. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67249. */
  67250. static CreateTiledPlane(name: string, options: {
  67251. pattern?: number;
  67252. tileSize?: number;
  67253. tileWidth?: number;
  67254. tileHeight?: number;
  67255. size?: number;
  67256. width?: number;
  67257. height?: number;
  67258. alignHorizontal?: number;
  67259. alignVertical?: number;
  67260. sideOrientation?: number;
  67261. frontUVs?: Vector4;
  67262. backUVs?: Vector4;
  67263. updatable?: boolean;
  67264. }, scene?: Nullable<Scene>): Mesh;
  67265. /**
  67266. * Creates a plane mesh
  67267. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67268. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67269. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67271. * * 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
  67272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67273. * @param name defines the name of the mesh
  67274. * @param options defines the options used to create the mesh
  67275. * @param scene defines the hosting scene
  67276. * @returns the plane mesh
  67277. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67278. */
  67279. static CreatePlane(name: string, options: {
  67280. size?: number;
  67281. width?: number;
  67282. height?: number;
  67283. sideOrientation?: number;
  67284. frontUVs?: Vector4;
  67285. backUVs?: Vector4;
  67286. updatable?: boolean;
  67287. sourcePlane?: Plane;
  67288. }, scene?: Nullable<Scene>): Mesh;
  67289. /**
  67290. * Creates a ground mesh
  67291. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67292. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67294. * @param name defines the name of the mesh
  67295. * @param options defines the options used to create the mesh
  67296. * @param scene defines the hosting scene
  67297. * @returns the ground mesh
  67298. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67299. */
  67300. static CreateGround(name: string, options: {
  67301. width?: number;
  67302. height?: number;
  67303. subdivisions?: number;
  67304. subdivisionsX?: number;
  67305. subdivisionsY?: number;
  67306. updatable?: boolean;
  67307. }, scene?: Nullable<Scene>): Mesh;
  67308. /**
  67309. * Creates a tiled ground mesh
  67310. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67311. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67312. * * 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
  67313. * * 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
  67314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67315. * @param name defines the name of the mesh
  67316. * @param options defines the options used to create the mesh
  67317. * @param scene defines the hosting scene
  67318. * @returns the tiled ground mesh
  67319. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67320. */
  67321. static CreateTiledGround(name: string, options: {
  67322. xmin: number;
  67323. zmin: number;
  67324. xmax: number;
  67325. zmax: number;
  67326. subdivisions?: {
  67327. w: number;
  67328. h: number;
  67329. };
  67330. precision?: {
  67331. w: number;
  67332. h: number;
  67333. };
  67334. updatable?: boolean;
  67335. }, scene?: Nullable<Scene>): Mesh;
  67336. /**
  67337. * Creates a ground mesh from a height map
  67338. * * The parameter `url` sets the URL of the height map image resource.
  67339. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67340. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67341. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67342. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67343. * * 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.
  67344. * * 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).
  67345. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67347. * @param name defines the name of the mesh
  67348. * @param url defines the url to the height map
  67349. * @param options defines the options used to create the mesh
  67350. * @param scene defines the hosting scene
  67351. * @returns the ground mesh
  67352. * @see https://doc.babylonjs.com/babylon101/height_map
  67353. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67354. */
  67355. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67356. width?: number;
  67357. height?: number;
  67358. subdivisions?: number;
  67359. minHeight?: number;
  67360. maxHeight?: number;
  67361. colorFilter?: Color3;
  67362. alphaFilter?: number;
  67363. updatable?: boolean;
  67364. onReady?: (mesh: GroundMesh) => void;
  67365. }, scene?: Nullable<Scene>): GroundMesh;
  67366. /**
  67367. * Creates a polygon mesh
  67368. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67369. * * 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
  67370. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67372. * * 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)
  67373. * * Remember you can only change the shape positions, not their number when updating a polygon
  67374. * @param name defines the name of the mesh
  67375. * @param options defines the options used to create the mesh
  67376. * @param scene defines the hosting scene
  67377. * @param earcutInjection can be used to inject your own earcut reference
  67378. * @returns the polygon mesh
  67379. */
  67380. static CreatePolygon(name: string, options: {
  67381. shape: Vector3[];
  67382. holes?: Vector3[][];
  67383. depth?: number;
  67384. faceUV?: Vector4[];
  67385. faceColors?: Color4[];
  67386. updatable?: boolean;
  67387. sideOrientation?: number;
  67388. frontUVs?: Vector4;
  67389. backUVs?: Vector4;
  67390. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67391. /**
  67392. * Creates an extruded polygon mesh, with depth in the Y direction.
  67393. * * 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)
  67394. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67395. * @param name defines the name of the mesh
  67396. * @param options defines the options used to create the mesh
  67397. * @param scene defines the hosting scene
  67398. * @param earcutInjection can be used to inject your own earcut reference
  67399. * @returns the polygon mesh
  67400. */
  67401. static ExtrudePolygon(name: string, options: {
  67402. shape: Vector3[];
  67403. holes?: Vector3[][];
  67404. depth?: number;
  67405. faceUV?: Vector4[];
  67406. faceColors?: Color4[];
  67407. updatable?: boolean;
  67408. sideOrientation?: number;
  67409. frontUVs?: Vector4;
  67410. backUVs?: Vector4;
  67411. wrap?: boolean;
  67412. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67413. /**
  67414. * Creates a tube mesh.
  67415. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67416. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67417. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67418. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67419. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67420. * * 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)
  67421. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67422. * * 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
  67423. * * 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
  67424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67425. * * 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
  67426. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67428. * @param name defines the name of the mesh
  67429. * @param options defines the options used to create the mesh
  67430. * @param scene defines the hosting scene
  67431. * @returns the tube mesh
  67432. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67433. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67434. */
  67435. static CreateTube(name: string, options: {
  67436. path: Vector3[];
  67437. radius?: number;
  67438. tessellation?: number;
  67439. radiusFunction?: {
  67440. (i: number, distance: number): number;
  67441. };
  67442. cap?: number;
  67443. arc?: number;
  67444. updatable?: boolean;
  67445. sideOrientation?: number;
  67446. frontUVs?: Vector4;
  67447. backUVs?: Vector4;
  67448. instance?: Mesh;
  67449. invertUV?: boolean;
  67450. }, scene?: Nullable<Scene>): Mesh;
  67451. /**
  67452. * Creates a polyhedron mesh
  67453. * * 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
  67454. * * The parameter `size` (positive float, default 1) sets the polygon size
  67455. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67456. * * 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`
  67457. * * 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
  67458. * * 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)`)
  67459. * * 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
  67460. * * 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
  67461. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67462. * * 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
  67463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67464. * @param name defines the name of the mesh
  67465. * @param options defines the options used to create the mesh
  67466. * @param scene defines the hosting scene
  67467. * @returns the polyhedron mesh
  67468. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67469. */
  67470. static CreatePolyhedron(name: string, options: {
  67471. type?: number;
  67472. size?: number;
  67473. sizeX?: number;
  67474. sizeY?: number;
  67475. sizeZ?: number;
  67476. custom?: any;
  67477. faceUV?: Vector4[];
  67478. faceColors?: Color4[];
  67479. flat?: boolean;
  67480. updatable?: boolean;
  67481. sideOrientation?: number;
  67482. frontUVs?: Vector4;
  67483. backUVs?: Vector4;
  67484. }, scene?: Nullable<Scene>): Mesh;
  67485. /**
  67486. * Creates a decal mesh.
  67487. * 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
  67488. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67489. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67490. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67491. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67492. * @param name defines the name of the mesh
  67493. * @param sourceMesh defines the mesh where the decal must be applied
  67494. * @param options defines the options used to create the mesh
  67495. * @param scene defines the hosting scene
  67496. * @returns the decal mesh
  67497. * @see https://doc.babylonjs.com/how_to/decals
  67498. */
  67499. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67500. position?: Vector3;
  67501. normal?: Vector3;
  67502. size?: Vector3;
  67503. angle?: number;
  67504. }): Mesh;
  67505. /**
  67506. * Creates a Capsule Mesh
  67507. * @param name defines the name of the mesh.
  67508. * @param options the constructors options used to shape the mesh.
  67509. * @param scene defines the scene the mesh is scoped to.
  67510. * @returns the capsule mesh
  67511. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67512. */
  67513. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67514. }
  67515. }
  67516. declare module BABYLON {
  67517. /**
  67518. * A simplifier interface for future simplification implementations
  67519. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67520. */
  67521. export interface ISimplifier {
  67522. /**
  67523. * Simplification of a given mesh according to the given settings.
  67524. * Since this requires computation, it is assumed that the function runs async.
  67525. * @param settings The settings of the simplification, including quality and distance
  67526. * @param successCallback A callback that will be called after the mesh was simplified.
  67527. * @param errorCallback in case of an error, this callback will be called. optional.
  67528. */
  67529. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67530. }
  67531. /**
  67532. * Expected simplification settings.
  67533. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67534. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67535. */
  67536. export interface ISimplificationSettings {
  67537. /**
  67538. * Gets or sets the expected quality
  67539. */
  67540. quality: number;
  67541. /**
  67542. * Gets or sets the distance when this optimized version should be used
  67543. */
  67544. distance: number;
  67545. /**
  67546. * Gets an already optimized mesh
  67547. */
  67548. optimizeMesh?: boolean;
  67549. }
  67550. /**
  67551. * Class used to specify simplification options
  67552. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67553. */
  67554. export class SimplificationSettings implements ISimplificationSettings {
  67555. /** expected quality */
  67556. quality: number;
  67557. /** distance when this optimized version should be used */
  67558. distance: number;
  67559. /** already optimized mesh */
  67560. optimizeMesh?: boolean | undefined;
  67561. /**
  67562. * Creates a SimplificationSettings
  67563. * @param quality expected quality
  67564. * @param distance distance when this optimized version should be used
  67565. * @param optimizeMesh already optimized mesh
  67566. */
  67567. constructor(
  67568. /** expected quality */
  67569. quality: number,
  67570. /** distance when this optimized version should be used */
  67571. distance: number,
  67572. /** already optimized mesh */
  67573. optimizeMesh?: boolean | undefined);
  67574. }
  67575. /**
  67576. * Interface used to define a simplification task
  67577. */
  67578. export interface ISimplificationTask {
  67579. /**
  67580. * Array of settings
  67581. */
  67582. settings: Array<ISimplificationSettings>;
  67583. /**
  67584. * Simplification type
  67585. */
  67586. simplificationType: SimplificationType;
  67587. /**
  67588. * Mesh to simplify
  67589. */
  67590. mesh: Mesh;
  67591. /**
  67592. * Callback called on success
  67593. */
  67594. successCallback?: () => void;
  67595. /**
  67596. * Defines if parallel processing can be used
  67597. */
  67598. parallelProcessing: boolean;
  67599. }
  67600. /**
  67601. * Queue used to order the simplification tasks
  67602. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67603. */
  67604. export class SimplificationQueue {
  67605. private _simplificationArray;
  67606. /**
  67607. * Gets a boolean indicating that the process is still running
  67608. */
  67609. running: boolean;
  67610. /**
  67611. * Creates a new queue
  67612. */
  67613. constructor();
  67614. /**
  67615. * Adds a new simplification task
  67616. * @param task defines a task to add
  67617. */
  67618. addTask(task: ISimplificationTask): void;
  67619. /**
  67620. * Execute next task
  67621. */
  67622. executeNext(): void;
  67623. /**
  67624. * Execute a simplification task
  67625. * @param task defines the task to run
  67626. */
  67627. runSimplification(task: ISimplificationTask): void;
  67628. private getSimplifier;
  67629. }
  67630. /**
  67631. * The implemented types of simplification
  67632. * At the moment only Quadratic Error Decimation is implemented
  67633. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67634. */
  67635. export enum SimplificationType {
  67636. /** Quadratic error decimation */
  67637. QUADRATIC = 0
  67638. }
  67639. /**
  67640. * An implementation of the Quadratic Error simplification algorithm.
  67641. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67642. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67643. * @author RaananW
  67644. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67645. */
  67646. export class QuadraticErrorSimplification implements ISimplifier {
  67647. private _mesh;
  67648. private triangles;
  67649. private vertices;
  67650. private references;
  67651. private _reconstructedMesh;
  67652. /** Gets or sets the number pf sync interations */
  67653. syncIterations: number;
  67654. /** Gets or sets the aggressiveness of the simplifier */
  67655. aggressiveness: number;
  67656. /** Gets or sets the number of allowed iterations for decimation */
  67657. decimationIterations: number;
  67658. /** Gets or sets the espilon to use for bounding box computation */
  67659. boundingBoxEpsilon: number;
  67660. /**
  67661. * Creates a new QuadraticErrorSimplification
  67662. * @param _mesh defines the target mesh
  67663. */
  67664. constructor(_mesh: Mesh);
  67665. /**
  67666. * Simplification of a given mesh according to the given settings.
  67667. * Since this requires computation, it is assumed that the function runs async.
  67668. * @param settings The settings of the simplification, including quality and distance
  67669. * @param successCallback A callback that will be called after the mesh was simplified.
  67670. */
  67671. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67672. private runDecimation;
  67673. private initWithMesh;
  67674. private init;
  67675. private reconstructMesh;
  67676. private initDecimatedMesh;
  67677. private isFlipped;
  67678. private updateTriangles;
  67679. private identifyBorder;
  67680. private updateMesh;
  67681. private vertexError;
  67682. private calculateError;
  67683. }
  67684. }
  67685. declare module BABYLON {
  67686. interface Scene {
  67687. /** @hidden (Backing field) */
  67688. _simplificationQueue: SimplificationQueue;
  67689. /**
  67690. * Gets or sets the simplification queue attached to the scene
  67691. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67692. */
  67693. simplificationQueue: SimplificationQueue;
  67694. }
  67695. interface Mesh {
  67696. /**
  67697. * Simplify the mesh according to the given array of settings.
  67698. * Function will return immediately and will simplify async
  67699. * @param settings a collection of simplification settings
  67700. * @param parallelProcessing should all levels calculate parallel or one after the other
  67701. * @param simplificationType the type of simplification to run
  67702. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67703. * @returns the current mesh
  67704. */
  67705. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67706. }
  67707. /**
  67708. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67709. * created in a scene
  67710. */
  67711. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67712. /**
  67713. * The component name helpfull to identify the component in the list of scene components.
  67714. */
  67715. readonly name: string;
  67716. /**
  67717. * The scene the component belongs to.
  67718. */
  67719. scene: Scene;
  67720. /**
  67721. * Creates a new instance of the component for the given scene
  67722. * @param scene Defines the scene to register the component in
  67723. */
  67724. constructor(scene: Scene);
  67725. /**
  67726. * Registers the component in a given scene
  67727. */
  67728. register(): void;
  67729. /**
  67730. * Rebuilds the elements related to this component in case of
  67731. * context lost for instance.
  67732. */
  67733. rebuild(): void;
  67734. /**
  67735. * Disposes the component and the associated ressources
  67736. */
  67737. dispose(): void;
  67738. private _beforeCameraUpdate;
  67739. }
  67740. }
  67741. declare module BABYLON {
  67742. interface Mesh {
  67743. /**
  67744. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  67745. */
  67746. thinInstanceEnablePicking: boolean;
  67747. /**
  67748. * Creates a new thin instance
  67749. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  67750. * @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
  67751. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  67752. */
  67753. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  67754. /**
  67755. * Adds the transformation (matrix) of the current mesh as a thin instance
  67756. * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
  67757. * @returns the thin instance index number
  67758. */
  67759. thinInstanceAddSelf(refresh: boolean): number;
  67760. /**
  67761. * Registers a custom attribute to be used with thin instances
  67762. * @param kind name of the attribute
  67763. * @param stride size in floats of the attribute
  67764. */
  67765. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67766. /**
  67767. * Sets the matrix of a thin instance
  67768. * @param index index of the thin instance
  67769. * @param matrix matrix to set
  67770. * @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
  67771. */
  67772. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  67773. /**
  67774. * Sets the value of a custom attribute for a thin instance
  67775. * @param kind name of the attribute
  67776. * @param index index of the thin instance
  67777. * @param value value to set
  67778. * @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
  67779. */
  67780. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  67781. /**
  67782. * 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.
  67783. */
  67784. thinInstanceCount: number;
  67785. /**
  67786. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  67787. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  67788. * @param buffer buffer to set
  67789. * @param stride size in floats of each value of the buffer
  67790. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  67791. */
  67792. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  67793. /**
  67794. * Gets the list of world matrices
  67795. * @return an array containing all the world matrices from the thin instances
  67796. */
  67797. thinInstanceGetWorldMatrices(): Matrix[];
  67798. /**
  67799. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  67800. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67801. */
  67802. thinInstanceBufferUpdated(kind: string): void;
  67803. /**
  67804. * Applies a partial update to a buffer directly on the GPU
  67805. * 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
  67806. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67807. * @param data the data to set in the GPU buffer
  67808. * @param offset the offset in the GPU buffer where to update the data
  67809. */
  67810. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  67811. /**
  67812. * Refreshes the bounding info, taking into account all the thin instances defined
  67813. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  67814. */
  67815. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  67816. /** @hidden */
  67817. _thinInstanceInitializeUserStorage(): void;
  67818. /** @hidden */
  67819. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  67820. /** @hidden */
  67821. _userThinInstanceBuffersStorage: {
  67822. data: {
  67823. [key: string]: Float32Array;
  67824. };
  67825. sizes: {
  67826. [key: string]: number;
  67827. };
  67828. vertexBuffers: {
  67829. [key: string]: Nullable<VertexBuffer>;
  67830. };
  67831. strides: {
  67832. [key: string]: number;
  67833. };
  67834. };
  67835. }
  67836. }
  67837. declare module BABYLON {
  67838. /**
  67839. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67840. */
  67841. export interface INavigationEnginePlugin {
  67842. /**
  67843. * plugin name
  67844. */
  67845. name: string;
  67846. /**
  67847. * Creates a navigation mesh
  67848. * @param meshes array of all the geometry used to compute the navigatio mesh
  67849. * @param parameters bunch of parameters used to filter geometry
  67850. */
  67851. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67852. /**
  67853. * Create a navigation mesh debug mesh
  67854. * @param scene is where the mesh will be added
  67855. * @returns debug display mesh
  67856. */
  67857. createDebugNavMesh(scene: Scene): Mesh;
  67858. /**
  67859. * Get a navigation mesh constrained position, closest to the parameter position
  67860. * @param position world position
  67861. * @returns the closest point to position constrained by the navigation mesh
  67862. */
  67863. getClosestPoint(position: Vector3): Vector3;
  67864. /**
  67865. * Get a navigation mesh constrained position, closest to the parameter position
  67866. * @param position world position
  67867. * @param result output the closest point to position constrained by the navigation mesh
  67868. */
  67869. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67870. /**
  67871. * Get a navigation mesh constrained position, within a particular radius
  67872. * @param position world position
  67873. * @param maxRadius the maximum distance to the constrained world position
  67874. * @returns the closest point to position constrained by the navigation mesh
  67875. */
  67876. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67877. /**
  67878. * Get a navigation mesh constrained position, within a particular radius
  67879. * @param position world position
  67880. * @param maxRadius the maximum distance to the constrained world position
  67881. * @param result output the closest point to position constrained by the navigation mesh
  67882. */
  67883. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67884. /**
  67885. * Compute the final position from a segment made of destination-position
  67886. * @param position world position
  67887. * @param destination world position
  67888. * @returns the resulting point along the navmesh
  67889. */
  67890. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67891. /**
  67892. * Compute the final position from a segment made of destination-position
  67893. * @param position world position
  67894. * @param destination world position
  67895. * @param result output the resulting point along the navmesh
  67896. */
  67897. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67898. /**
  67899. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67900. * @param start world position
  67901. * @param end world position
  67902. * @returns array containing world position composing the path
  67903. */
  67904. computePath(start: Vector3, end: Vector3): Vector3[];
  67905. /**
  67906. * If this plugin is supported
  67907. * @returns true if plugin is supported
  67908. */
  67909. isSupported(): boolean;
  67910. /**
  67911. * Create a new Crowd so you can add agents
  67912. * @param maxAgents the maximum agent count in the crowd
  67913. * @param maxAgentRadius the maximum radius an agent can have
  67914. * @param scene to attach the crowd to
  67915. * @returns the crowd you can add agents to
  67916. */
  67917. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67918. /**
  67919. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67920. * The queries will try to find a solution within those bounds
  67921. * default is (1,1,1)
  67922. * @param extent x,y,z value that define the extent around the queries point of reference
  67923. */
  67924. setDefaultQueryExtent(extent: Vector3): void;
  67925. /**
  67926. * Get the Bounding box extent specified by setDefaultQueryExtent
  67927. * @returns the box extent values
  67928. */
  67929. getDefaultQueryExtent(): Vector3;
  67930. /**
  67931. * build the navmesh from a previously saved state using getNavmeshData
  67932. * @param data the Uint8Array returned by getNavmeshData
  67933. */
  67934. buildFromNavmeshData(data: Uint8Array): void;
  67935. /**
  67936. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67937. * @returns data the Uint8Array that can be saved and reused
  67938. */
  67939. getNavmeshData(): Uint8Array;
  67940. /**
  67941. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67942. * @param result output the box extent values
  67943. */
  67944. getDefaultQueryExtentToRef(result: Vector3): void;
  67945. /**
  67946. * Release all resources
  67947. */
  67948. dispose(): void;
  67949. }
  67950. /**
  67951. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67952. */
  67953. export interface ICrowd {
  67954. /**
  67955. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67956. * You can attach anything to that node. The node position is updated in the scene update tick.
  67957. * @param pos world position that will be constrained by the navigation mesh
  67958. * @param parameters agent parameters
  67959. * @param transform hooked to the agent that will be update by the scene
  67960. * @returns agent index
  67961. */
  67962. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67963. /**
  67964. * Returns the agent position in world space
  67965. * @param index agent index returned by addAgent
  67966. * @returns world space position
  67967. */
  67968. getAgentPosition(index: number): Vector3;
  67969. /**
  67970. * Gets the agent position result in world space
  67971. * @param index agent index returned by addAgent
  67972. * @param result output world space position
  67973. */
  67974. getAgentPositionToRef(index: number, result: Vector3): void;
  67975. /**
  67976. * Gets the agent velocity in world space
  67977. * @param index agent index returned by addAgent
  67978. * @returns world space velocity
  67979. */
  67980. getAgentVelocity(index: number): Vector3;
  67981. /**
  67982. * Gets the agent velocity result in world space
  67983. * @param index agent index returned by addAgent
  67984. * @param result output world space velocity
  67985. */
  67986. getAgentVelocityToRef(index: number, result: Vector3): void;
  67987. /**
  67988. * Gets the agent next target point on the path
  67989. * @param index agent index returned by addAgent
  67990. * @returns world space position
  67991. */
  67992. getAgentNextTargetPath(index: number): Vector3;
  67993. /**
  67994. * Gets the agent next target point on the path
  67995. * @param index agent index returned by addAgent
  67996. * @param result output world space position
  67997. */
  67998. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  67999. /**
  68000. * remove a particular agent previously created
  68001. * @param index agent index returned by addAgent
  68002. */
  68003. removeAgent(index: number): void;
  68004. /**
  68005. * get the list of all agents attached to this crowd
  68006. * @returns list of agent indices
  68007. */
  68008. getAgents(): number[];
  68009. /**
  68010. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68011. * @param deltaTime in seconds
  68012. */
  68013. update(deltaTime: number): void;
  68014. /**
  68015. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68016. * @param index agent index returned by addAgent
  68017. * @param destination targeted world position
  68018. */
  68019. agentGoto(index: number, destination: Vector3): void;
  68020. /**
  68021. * Teleport the agent to a new position
  68022. * @param index agent index returned by addAgent
  68023. * @param destination targeted world position
  68024. */
  68025. agentTeleport(index: number, destination: Vector3): void;
  68026. /**
  68027. * Update agent parameters
  68028. * @param index agent index returned by addAgent
  68029. * @param parameters agent parameters
  68030. */
  68031. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68032. /**
  68033. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68034. * The queries will try to find a solution within those bounds
  68035. * default is (1,1,1)
  68036. * @param extent x,y,z value that define the extent around the queries point of reference
  68037. */
  68038. setDefaultQueryExtent(extent: Vector3): void;
  68039. /**
  68040. * Get the Bounding box extent specified by setDefaultQueryExtent
  68041. * @returns the box extent values
  68042. */
  68043. getDefaultQueryExtent(): Vector3;
  68044. /**
  68045. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68046. * @param result output the box extent values
  68047. */
  68048. getDefaultQueryExtentToRef(result: Vector3): void;
  68049. /**
  68050. * Release all resources
  68051. */
  68052. dispose(): void;
  68053. }
  68054. /**
  68055. * Configures an agent
  68056. */
  68057. export interface IAgentParameters {
  68058. /**
  68059. * Agent radius. [Limit: >= 0]
  68060. */
  68061. radius: number;
  68062. /**
  68063. * Agent height. [Limit: > 0]
  68064. */
  68065. height: number;
  68066. /**
  68067. * Maximum allowed acceleration. [Limit: >= 0]
  68068. */
  68069. maxAcceleration: number;
  68070. /**
  68071. * Maximum allowed speed. [Limit: >= 0]
  68072. */
  68073. maxSpeed: number;
  68074. /**
  68075. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68076. */
  68077. collisionQueryRange: number;
  68078. /**
  68079. * The path visibility optimization range. [Limit: > 0]
  68080. */
  68081. pathOptimizationRange: number;
  68082. /**
  68083. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68084. */
  68085. separationWeight: number;
  68086. }
  68087. /**
  68088. * Configures the navigation mesh creation
  68089. */
  68090. export interface INavMeshParameters {
  68091. /**
  68092. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68093. */
  68094. cs: number;
  68095. /**
  68096. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68097. */
  68098. ch: number;
  68099. /**
  68100. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68101. */
  68102. walkableSlopeAngle: number;
  68103. /**
  68104. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68105. * be considered walkable. [Limit: >= 3] [Units: vx]
  68106. */
  68107. walkableHeight: number;
  68108. /**
  68109. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68110. */
  68111. walkableClimb: number;
  68112. /**
  68113. * The distance to erode/shrink the walkable area of the heightfield away from
  68114. * obstructions. [Limit: >=0] [Units: vx]
  68115. */
  68116. walkableRadius: number;
  68117. /**
  68118. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68119. */
  68120. maxEdgeLen: number;
  68121. /**
  68122. * The maximum distance a simplfied contour's border edges should deviate
  68123. * the original raw contour. [Limit: >=0] [Units: vx]
  68124. */
  68125. maxSimplificationError: number;
  68126. /**
  68127. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68128. */
  68129. minRegionArea: number;
  68130. /**
  68131. * Any regions with a span count smaller than this value will, if possible,
  68132. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68133. */
  68134. mergeRegionArea: number;
  68135. /**
  68136. * The maximum number of vertices allowed for polygons generated during the
  68137. * contour to polygon conversion process. [Limit: >= 3]
  68138. */
  68139. maxVertsPerPoly: number;
  68140. /**
  68141. * Sets the sampling distance to use when generating the detail mesh.
  68142. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68143. */
  68144. detailSampleDist: number;
  68145. /**
  68146. * The maximum distance the detail mesh surface should deviate from heightfield
  68147. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68148. */
  68149. detailSampleMaxError: number;
  68150. }
  68151. }
  68152. declare module BABYLON {
  68153. /**
  68154. * RecastJS navigation plugin
  68155. */
  68156. export class RecastJSPlugin implements INavigationEnginePlugin {
  68157. /**
  68158. * Reference to the Recast library
  68159. */
  68160. bjsRECAST: any;
  68161. /**
  68162. * plugin name
  68163. */
  68164. name: string;
  68165. /**
  68166. * the first navmesh created. We might extend this to support multiple navmeshes
  68167. */
  68168. navMesh: any;
  68169. /**
  68170. * Initializes the recastJS plugin
  68171. * @param recastInjection can be used to inject your own recast reference
  68172. */
  68173. constructor(recastInjection?: any);
  68174. /**
  68175. * Creates a navigation mesh
  68176. * @param meshes array of all the geometry used to compute the navigatio mesh
  68177. * @param parameters bunch of parameters used to filter geometry
  68178. */
  68179. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68180. /**
  68181. * Create a navigation mesh debug mesh
  68182. * @param scene is where the mesh will be added
  68183. * @returns debug display mesh
  68184. */
  68185. createDebugNavMesh(scene: Scene): Mesh;
  68186. /**
  68187. * Get a navigation mesh constrained position, closest to the parameter position
  68188. * @param position world position
  68189. * @returns the closest point to position constrained by the navigation mesh
  68190. */
  68191. getClosestPoint(position: Vector3): Vector3;
  68192. /**
  68193. * Get a navigation mesh constrained position, closest to the parameter position
  68194. * @param position world position
  68195. * @param result output the closest point to position constrained by the navigation mesh
  68196. */
  68197. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68198. /**
  68199. * Get a navigation mesh constrained position, within a particular radius
  68200. * @param position world position
  68201. * @param maxRadius the maximum distance to the constrained world position
  68202. * @returns the closest point to position constrained by the navigation mesh
  68203. */
  68204. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68205. /**
  68206. * Get a navigation mesh constrained position, within a particular radius
  68207. * @param position world position
  68208. * @param maxRadius the maximum distance to the constrained world position
  68209. * @param result output the closest point to position constrained by the navigation mesh
  68210. */
  68211. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68212. /**
  68213. * Compute the final position from a segment made of destination-position
  68214. * @param position world position
  68215. * @param destination world position
  68216. * @returns the resulting point along the navmesh
  68217. */
  68218. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68219. /**
  68220. * Compute the final position from a segment made of destination-position
  68221. * @param position world position
  68222. * @param destination world position
  68223. * @param result output the resulting point along the navmesh
  68224. */
  68225. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68226. /**
  68227. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68228. * @param start world position
  68229. * @param end world position
  68230. * @returns array containing world position composing the path
  68231. */
  68232. computePath(start: Vector3, end: Vector3): Vector3[];
  68233. /**
  68234. * Create a new Crowd so you can add agents
  68235. * @param maxAgents the maximum agent count in the crowd
  68236. * @param maxAgentRadius the maximum radius an agent can have
  68237. * @param scene to attach the crowd to
  68238. * @returns the crowd you can add agents to
  68239. */
  68240. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68241. /**
  68242. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68243. * The queries will try to find a solution within those bounds
  68244. * default is (1,1,1)
  68245. * @param extent x,y,z value that define the extent around the queries point of reference
  68246. */
  68247. setDefaultQueryExtent(extent: Vector3): void;
  68248. /**
  68249. * Get the Bounding box extent specified by setDefaultQueryExtent
  68250. * @returns the box extent values
  68251. */
  68252. getDefaultQueryExtent(): Vector3;
  68253. /**
  68254. * build the navmesh from a previously saved state using getNavmeshData
  68255. * @param data the Uint8Array returned by getNavmeshData
  68256. */
  68257. buildFromNavmeshData(data: Uint8Array): void;
  68258. /**
  68259. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68260. * @returns data the Uint8Array that can be saved and reused
  68261. */
  68262. getNavmeshData(): Uint8Array;
  68263. /**
  68264. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68265. * @param result output the box extent values
  68266. */
  68267. getDefaultQueryExtentToRef(result: Vector3): void;
  68268. /**
  68269. * Disposes
  68270. */
  68271. dispose(): void;
  68272. /**
  68273. * If this plugin is supported
  68274. * @returns true if plugin is supported
  68275. */
  68276. isSupported(): boolean;
  68277. }
  68278. /**
  68279. * Recast detour crowd implementation
  68280. */
  68281. export class RecastJSCrowd implements ICrowd {
  68282. /**
  68283. * Recast/detour plugin
  68284. */
  68285. bjsRECASTPlugin: RecastJSPlugin;
  68286. /**
  68287. * Link to the detour crowd
  68288. */
  68289. recastCrowd: any;
  68290. /**
  68291. * One transform per agent
  68292. */
  68293. transforms: TransformNode[];
  68294. /**
  68295. * All agents created
  68296. */
  68297. agents: number[];
  68298. /**
  68299. * Link to the scene is kept to unregister the crowd from the scene
  68300. */
  68301. private _scene;
  68302. /**
  68303. * Observer for crowd updates
  68304. */
  68305. private _onBeforeAnimationsObserver;
  68306. /**
  68307. * Constructor
  68308. * @param plugin recastJS plugin
  68309. * @param maxAgents the maximum agent count in the crowd
  68310. * @param maxAgentRadius the maximum radius an agent can have
  68311. * @param scene to attach the crowd to
  68312. * @returns the crowd you can add agents to
  68313. */
  68314. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68315. /**
  68316. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68317. * You can attach anything to that node. The node position is updated in the scene update tick.
  68318. * @param pos world position that will be constrained by the navigation mesh
  68319. * @param parameters agent parameters
  68320. * @param transform hooked to the agent that will be update by the scene
  68321. * @returns agent index
  68322. */
  68323. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68324. /**
  68325. * Returns the agent position in world space
  68326. * @param index agent index returned by addAgent
  68327. * @returns world space position
  68328. */
  68329. getAgentPosition(index: number): Vector3;
  68330. /**
  68331. * Returns the agent position result in world space
  68332. * @param index agent index returned by addAgent
  68333. * @param result output world space position
  68334. */
  68335. getAgentPositionToRef(index: number, result: Vector3): void;
  68336. /**
  68337. * Returns the agent velocity in world space
  68338. * @param index agent index returned by addAgent
  68339. * @returns world space velocity
  68340. */
  68341. getAgentVelocity(index: number): Vector3;
  68342. /**
  68343. * Returns the agent velocity result in world space
  68344. * @param index agent index returned by addAgent
  68345. * @param result output world space velocity
  68346. */
  68347. getAgentVelocityToRef(index: number, result: Vector3): void;
  68348. /**
  68349. * Returns the agent next target point on the path
  68350. * @param index agent index returned by addAgent
  68351. * @returns world space position
  68352. */
  68353. getAgentNextTargetPath(index: number): Vector3;
  68354. /**
  68355. * Returns the agent next target point on the path
  68356. * @param index agent index returned by addAgent
  68357. * @param result output world space position
  68358. */
  68359. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68360. /**
  68361. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68362. * @param index agent index returned by addAgent
  68363. * @param destination targeted world position
  68364. */
  68365. agentGoto(index: number, destination: Vector3): void;
  68366. /**
  68367. * Teleport the agent to a new position
  68368. * @param index agent index returned by addAgent
  68369. * @param destination targeted world position
  68370. */
  68371. agentTeleport(index: number, destination: Vector3): void;
  68372. /**
  68373. * Update agent parameters
  68374. * @param index agent index returned by addAgent
  68375. * @param parameters agent parameters
  68376. */
  68377. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68378. /**
  68379. * remove a particular agent previously created
  68380. * @param index agent index returned by addAgent
  68381. */
  68382. removeAgent(index: number): void;
  68383. /**
  68384. * get the list of all agents attached to this crowd
  68385. * @returns list of agent indices
  68386. */
  68387. getAgents(): number[];
  68388. /**
  68389. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68390. * @param deltaTime in seconds
  68391. */
  68392. update(deltaTime: number): void;
  68393. /**
  68394. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68395. * The queries will try to find a solution within those bounds
  68396. * default is (1,1,1)
  68397. * @param extent x,y,z value that define the extent around the queries point of reference
  68398. */
  68399. setDefaultQueryExtent(extent: Vector3): void;
  68400. /**
  68401. * Get the Bounding box extent specified by setDefaultQueryExtent
  68402. * @returns the box extent values
  68403. */
  68404. getDefaultQueryExtent(): Vector3;
  68405. /**
  68406. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68407. * @param result output the box extent values
  68408. */
  68409. getDefaultQueryExtentToRef(result: Vector3): void;
  68410. /**
  68411. * Release all resources
  68412. */
  68413. dispose(): void;
  68414. }
  68415. }
  68416. declare module BABYLON {
  68417. /**
  68418. * Class used to enable access to IndexedDB
  68419. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68420. */
  68421. export class Database implements IOfflineProvider {
  68422. private _callbackManifestChecked;
  68423. private _currentSceneUrl;
  68424. private _db;
  68425. private _enableSceneOffline;
  68426. private _enableTexturesOffline;
  68427. private _manifestVersionFound;
  68428. private _mustUpdateRessources;
  68429. private _hasReachedQuota;
  68430. private _isSupported;
  68431. private _idbFactory;
  68432. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68433. private static IsUASupportingBlobStorage;
  68434. /**
  68435. * Gets a boolean indicating if Database storate is enabled (off by default)
  68436. */
  68437. static IDBStorageEnabled: boolean;
  68438. /**
  68439. * Gets a boolean indicating if scene must be saved in the database
  68440. */
  68441. get enableSceneOffline(): boolean;
  68442. /**
  68443. * Gets a boolean indicating if textures must be saved in the database
  68444. */
  68445. get enableTexturesOffline(): boolean;
  68446. /**
  68447. * Creates a new Database
  68448. * @param urlToScene defines the url to load the scene
  68449. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68450. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68451. */
  68452. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68453. private static _ParseURL;
  68454. private static _ReturnFullUrlLocation;
  68455. private _checkManifestFile;
  68456. /**
  68457. * Open the database and make it available
  68458. * @param successCallback defines the callback to call on success
  68459. * @param errorCallback defines the callback to call on error
  68460. */
  68461. open(successCallback: () => void, errorCallback: () => void): void;
  68462. /**
  68463. * Loads an image from the database
  68464. * @param url defines the url to load from
  68465. * @param image defines the target DOM image
  68466. */
  68467. loadImage(url: string, image: HTMLImageElement): void;
  68468. private _loadImageFromDBAsync;
  68469. private _saveImageIntoDBAsync;
  68470. private _checkVersionFromDB;
  68471. private _loadVersionFromDBAsync;
  68472. private _saveVersionIntoDBAsync;
  68473. /**
  68474. * Loads a file from database
  68475. * @param url defines the URL to load from
  68476. * @param sceneLoaded defines a callback to call on success
  68477. * @param progressCallBack defines a callback to call when progress changed
  68478. * @param errorCallback defines a callback to call on error
  68479. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68480. */
  68481. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68482. private _loadFileAsync;
  68483. private _saveFileAsync;
  68484. /**
  68485. * Validates if xhr data is correct
  68486. * @param xhr defines the request to validate
  68487. * @param dataType defines the expected data type
  68488. * @returns true if data is correct
  68489. */
  68490. private static _ValidateXHRData;
  68491. }
  68492. }
  68493. declare module BABYLON {
  68494. /** @hidden */
  68495. export var gpuUpdateParticlesPixelShader: {
  68496. name: string;
  68497. shader: string;
  68498. };
  68499. }
  68500. declare module BABYLON {
  68501. /** @hidden */
  68502. export var gpuUpdateParticlesVertexShader: {
  68503. name: string;
  68504. shader: string;
  68505. };
  68506. }
  68507. declare module BABYLON {
  68508. /** @hidden */
  68509. export var clipPlaneFragmentDeclaration2: {
  68510. name: string;
  68511. shader: string;
  68512. };
  68513. }
  68514. declare module BABYLON {
  68515. /** @hidden */
  68516. export var gpuRenderParticlesPixelShader: {
  68517. name: string;
  68518. shader: string;
  68519. };
  68520. }
  68521. declare module BABYLON {
  68522. /** @hidden */
  68523. export var clipPlaneVertexDeclaration2: {
  68524. name: string;
  68525. shader: string;
  68526. };
  68527. }
  68528. declare module BABYLON {
  68529. /** @hidden */
  68530. export var gpuRenderParticlesVertexShader: {
  68531. name: string;
  68532. shader: string;
  68533. };
  68534. }
  68535. declare module BABYLON {
  68536. /**
  68537. * This represents a GPU particle system in Babylon
  68538. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68539. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68540. */
  68541. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68542. /**
  68543. * The layer mask we are rendering the particles through.
  68544. */
  68545. layerMask: number;
  68546. private _capacity;
  68547. private _activeCount;
  68548. private _currentActiveCount;
  68549. private _accumulatedCount;
  68550. private _renderEffect;
  68551. private _updateEffect;
  68552. private _buffer0;
  68553. private _buffer1;
  68554. private _spriteBuffer;
  68555. private _updateVAO;
  68556. private _renderVAO;
  68557. private _targetIndex;
  68558. private _sourceBuffer;
  68559. private _targetBuffer;
  68560. private _currentRenderId;
  68561. private _started;
  68562. private _stopped;
  68563. private _timeDelta;
  68564. private _randomTexture;
  68565. private _randomTexture2;
  68566. private _attributesStrideSize;
  68567. private _updateEffectOptions;
  68568. private _randomTextureSize;
  68569. private _actualFrame;
  68570. private _customEffect;
  68571. private readonly _rawTextureWidth;
  68572. /**
  68573. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68574. */
  68575. static get IsSupported(): boolean;
  68576. /**
  68577. * An event triggered when the system is disposed.
  68578. */
  68579. onDisposeObservable: Observable<IParticleSystem>;
  68580. /**
  68581. * An event triggered when the system is stopped
  68582. */
  68583. onStoppedObservable: Observable<IParticleSystem>;
  68584. /**
  68585. * Gets the maximum number of particles active at the same time.
  68586. * @returns The max number of active particles.
  68587. */
  68588. getCapacity(): number;
  68589. /**
  68590. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68591. * to override the particles.
  68592. */
  68593. forceDepthWrite: boolean;
  68594. /**
  68595. * Gets or set the number of active particles
  68596. */
  68597. get activeParticleCount(): number;
  68598. set activeParticleCount(value: number);
  68599. private _preWarmDone;
  68600. /**
  68601. * Specifies if the particles are updated in emitter local space or world space.
  68602. */
  68603. isLocal: boolean;
  68604. /** Gets or sets a matrix to use to compute projection */
  68605. defaultProjectionMatrix: Matrix;
  68606. /**
  68607. * Is this system ready to be used/rendered
  68608. * @return true if the system is ready
  68609. */
  68610. isReady(): boolean;
  68611. /**
  68612. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68613. * @returns True if it has been started, otherwise false.
  68614. */
  68615. isStarted(): boolean;
  68616. /**
  68617. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68618. * @returns True if it has been stopped, otherwise false.
  68619. */
  68620. isStopped(): boolean;
  68621. /**
  68622. * Gets a boolean indicating that the system is stopping
  68623. * @returns true if the system is currently stopping
  68624. */
  68625. isStopping(): boolean;
  68626. /**
  68627. * Gets the number of particles active at the same time.
  68628. * @returns The number of active particles.
  68629. */
  68630. getActiveCount(): number;
  68631. /**
  68632. * Starts the particle system and begins to emit
  68633. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68634. */
  68635. start(delay?: number): void;
  68636. /**
  68637. * Stops the particle system.
  68638. */
  68639. stop(): void;
  68640. /**
  68641. * Remove all active particles
  68642. */
  68643. reset(): void;
  68644. /**
  68645. * Returns the string "GPUParticleSystem"
  68646. * @returns a string containing the class name
  68647. */
  68648. getClassName(): string;
  68649. /**
  68650. * Gets the custom effect used to render the particles
  68651. * @param blendMode Blend mode for which the effect should be retrieved
  68652. * @returns The effect
  68653. */
  68654. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68655. /**
  68656. * Sets the custom effect used to render the particles
  68657. * @param effect The effect to set
  68658. * @param blendMode Blend mode for which the effect should be set
  68659. */
  68660. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  68661. /** @hidden */
  68662. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  68663. /**
  68664. * Observable that will be called just before the particles are drawn
  68665. */
  68666. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  68667. /**
  68668. * Gets the name of the particle vertex shader
  68669. */
  68670. get vertexShaderName(): string;
  68671. private _colorGradientsTexture;
  68672. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68673. /**
  68674. * Adds a new color gradient
  68675. * @param gradient defines the gradient to use (between 0 and 1)
  68676. * @param color1 defines the color to affect to the specified gradient
  68677. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68678. * @returns the current particle system
  68679. */
  68680. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68681. private _refreshColorGradient;
  68682. /** Force the system to rebuild all gradients that need to be resync */
  68683. forceRefreshGradients(): void;
  68684. /**
  68685. * Remove a specific color gradient
  68686. * @param gradient defines the gradient to remove
  68687. * @returns the current particle system
  68688. */
  68689. removeColorGradient(gradient: number): GPUParticleSystem;
  68690. private _angularSpeedGradientsTexture;
  68691. private _sizeGradientsTexture;
  68692. private _velocityGradientsTexture;
  68693. private _limitVelocityGradientsTexture;
  68694. private _dragGradientsTexture;
  68695. private _addFactorGradient;
  68696. /**
  68697. * Adds a new size gradient
  68698. * @param gradient defines the gradient to use (between 0 and 1)
  68699. * @param factor defines the size factor to affect to the specified gradient
  68700. * @returns the current particle system
  68701. */
  68702. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68703. /**
  68704. * Remove a specific size gradient
  68705. * @param gradient defines the gradient to remove
  68706. * @returns the current particle system
  68707. */
  68708. removeSizeGradient(gradient: number): GPUParticleSystem;
  68709. private _refreshFactorGradient;
  68710. /**
  68711. * Adds a new angular speed gradient
  68712. * @param gradient defines the gradient to use (between 0 and 1)
  68713. * @param factor defines the angular speed to affect to the specified gradient
  68714. * @returns the current particle system
  68715. */
  68716. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68717. /**
  68718. * Remove a specific angular speed gradient
  68719. * @param gradient defines the gradient to remove
  68720. * @returns the current particle system
  68721. */
  68722. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68723. /**
  68724. * Adds a new velocity gradient
  68725. * @param gradient defines the gradient to use (between 0 and 1)
  68726. * @param factor defines the velocity to affect to the specified gradient
  68727. * @returns the current particle system
  68728. */
  68729. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68730. /**
  68731. * Remove a specific velocity gradient
  68732. * @param gradient defines the gradient to remove
  68733. * @returns the current particle system
  68734. */
  68735. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68736. /**
  68737. * Adds a new limit velocity gradient
  68738. * @param gradient defines the gradient to use (between 0 and 1)
  68739. * @param factor defines the limit velocity value to affect to the specified gradient
  68740. * @returns the current particle system
  68741. */
  68742. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68743. /**
  68744. * Remove a specific limit velocity gradient
  68745. * @param gradient defines the gradient to remove
  68746. * @returns the current particle system
  68747. */
  68748. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68749. /**
  68750. * Adds a new drag gradient
  68751. * @param gradient defines the gradient to use (between 0 and 1)
  68752. * @param factor defines the drag value to affect to the specified gradient
  68753. * @returns the current particle system
  68754. */
  68755. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68756. /**
  68757. * Remove a specific drag gradient
  68758. * @param gradient defines the gradient to remove
  68759. * @returns the current particle system
  68760. */
  68761. removeDragGradient(gradient: number): GPUParticleSystem;
  68762. /**
  68763. * Not supported by GPUParticleSystem
  68764. * @param gradient defines the gradient to use (between 0 and 1)
  68765. * @param factor defines the emit rate value to affect to the specified gradient
  68766. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68767. * @returns the current particle system
  68768. */
  68769. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68770. /**
  68771. * Not supported by GPUParticleSystem
  68772. * @param gradient defines the gradient to remove
  68773. * @returns the current particle system
  68774. */
  68775. removeEmitRateGradient(gradient: number): IParticleSystem;
  68776. /**
  68777. * Not supported by GPUParticleSystem
  68778. * @param gradient defines the gradient to use (between 0 and 1)
  68779. * @param factor defines the start size value to affect to the specified gradient
  68780. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68781. * @returns the current particle system
  68782. */
  68783. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68784. /**
  68785. * Not supported by GPUParticleSystem
  68786. * @param gradient defines the gradient to remove
  68787. * @returns the current particle system
  68788. */
  68789. removeStartSizeGradient(gradient: number): IParticleSystem;
  68790. /**
  68791. * Not supported by GPUParticleSystem
  68792. * @param gradient defines the gradient to use (between 0 and 1)
  68793. * @param min defines the color remap minimal range
  68794. * @param max defines the color remap maximal range
  68795. * @returns the current particle system
  68796. */
  68797. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68798. /**
  68799. * Not supported by GPUParticleSystem
  68800. * @param gradient defines the gradient to remove
  68801. * @returns the current particle system
  68802. */
  68803. removeColorRemapGradient(): IParticleSystem;
  68804. /**
  68805. * Not supported by GPUParticleSystem
  68806. * @param gradient defines the gradient to use (between 0 and 1)
  68807. * @param min defines the alpha remap minimal range
  68808. * @param max defines the alpha remap maximal range
  68809. * @returns the current particle system
  68810. */
  68811. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68812. /**
  68813. * Not supported by GPUParticleSystem
  68814. * @param gradient defines the gradient to remove
  68815. * @returns the current particle system
  68816. */
  68817. removeAlphaRemapGradient(): IParticleSystem;
  68818. /**
  68819. * Not supported by GPUParticleSystem
  68820. * @param gradient defines the gradient to use (between 0 and 1)
  68821. * @param color defines the color to affect to the specified gradient
  68822. * @returns the current particle system
  68823. */
  68824. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68825. /**
  68826. * Not supported by GPUParticleSystem
  68827. * @param gradient defines the gradient to remove
  68828. * @returns the current particle system
  68829. */
  68830. removeRampGradient(): IParticleSystem;
  68831. /**
  68832. * Not supported by GPUParticleSystem
  68833. * @returns the list of ramp gradients
  68834. */
  68835. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68836. /**
  68837. * Not supported by GPUParticleSystem
  68838. * Gets or sets a boolean indicating that ramp gradients must be used
  68839. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68840. */
  68841. get useRampGradients(): boolean;
  68842. set useRampGradients(value: boolean);
  68843. /**
  68844. * Not supported by GPUParticleSystem
  68845. * @param gradient defines the gradient to use (between 0 and 1)
  68846. * @param factor defines the life time factor to affect to the specified gradient
  68847. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68848. * @returns the current particle system
  68849. */
  68850. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68851. /**
  68852. * Not supported by GPUParticleSystem
  68853. * @param gradient defines the gradient to remove
  68854. * @returns the current particle system
  68855. */
  68856. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68857. /**
  68858. * Instantiates a GPU particle system.
  68859. * 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.
  68860. * @param name The name of the particle system
  68861. * @param options The options used to create the system
  68862. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  68863. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68864. * @param customEffect a custom effect used to change the way particles are rendered by default
  68865. */
  68866. constructor(name: string, options: Partial<{
  68867. capacity: number;
  68868. randomTextureSize: number;
  68869. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  68870. protected _reset(): void;
  68871. private _createUpdateVAO;
  68872. private _createRenderVAO;
  68873. private _initialize;
  68874. /** @hidden */
  68875. _recreateUpdateEffect(): void;
  68876. private _getEffect;
  68877. /**
  68878. * Fill the defines array according to the current settings of the particle system
  68879. * @param defines Array to be updated
  68880. * @param blendMode blend mode to take into account when updating the array
  68881. */
  68882. fillDefines(defines: Array<string>, blendMode?: number): void;
  68883. /**
  68884. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  68885. * @param uniforms Uniforms array to fill
  68886. * @param attributes Attributes array to fill
  68887. * @param samplers Samplers array to fill
  68888. */
  68889. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  68890. /** @hidden */
  68891. _recreateRenderEffect(): Effect;
  68892. /**
  68893. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68894. * @param preWarm defines if we are in the pre-warmimg phase
  68895. */
  68896. animate(preWarm?: boolean): void;
  68897. private _createFactorGradientTexture;
  68898. private _createSizeGradientTexture;
  68899. private _createAngularSpeedGradientTexture;
  68900. private _createVelocityGradientTexture;
  68901. private _createLimitVelocityGradientTexture;
  68902. private _createDragGradientTexture;
  68903. private _createColorGradientTexture;
  68904. /**
  68905. * Renders the particle system in its current state
  68906. * @param preWarm defines if the system should only update the particles but not render them
  68907. * @returns the current number of particles
  68908. */
  68909. render(preWarm?: boolean): number;
  68910. /**
  68911. * Rebuilds the particle system
  68912. */
  68913. rebuild(): void;
  68914. private _releaseBuffers;
  68915. private _releaseVAOs;
  68916. /**
  68917. * Disposes the particle system and free the associated resources
  68918. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68919. */
  68920. dispose(disposeTexture?: boolean): void;
  68921. /**
  68922. * Clones the particle system.
  68923. * @param name The name of the cloned object
  68924. * @param newEmitter The new emitter to use
  68925. * @returns the cloned particle system
  68926. */
  68927. clone(name: string, newEmitter: any): GPUParticleSystem;
  68928. /**
  68929. * Serializes the particle system to a JSON object
  68930. * @param serializeTexture defines if the texture must be serialized as well
  68931. * @returns the JSON object
  68932. */
  68933. serialize(serializeTexture?: boolean): any;
  68934. /**
  68935. * Parses a JSON object to create a GPU particle system.
  68936. * @param parsedParticleSystem The JSON object to parse
  68937. * @param sceneOrEngine The scene or the engine to create the particle system in
  68938. * @param rootUrl The root url to use to load external dependencies like texture
  68939. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68940. * @returns the parsed GPU particle system
  68941. */
  68942. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68943. }
  68944. }
  68945. declare module BABYLON {
  68946. /**
  68947. * Represents a set of particle systems working together to create a specific effect
  68948. */
  68949. export class ParticleSystemSet implements IDisposable {
  68950. /**
  68951. * Gets or sets base Assets URL
  68952. */
  68953. static BaseAssetsUrl: string;
  68954. private _emitterCreationOptions;
  68955. private _emitterNode;
  68956. /**
  68957. * Gets the particle system list
  68958. */
  68959. systems: IParticleSystem[];
  68960. /**
  68961. * Gets the emitter node used with this set
  68962. */
  68963. get emitterNode(): Nullable<TransformNode>;
  68964. /**
  68965. * Creates a new emitter mesh as a sphere
  68966. * @param options defines the options used to create the sphere
  68967. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68968. * @param scene defines the hosting scene
  68969. */
  68970. setEmitterAsSphere(options: {
  68971. diameter: number;
  68972. segments: number;
  68973. color: Color3;
  68974. }, renderingGroupId: number, scene: Scene): void;
  68975. /**
  68976. * Starts all particle systems of the set
  68977. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68978. */
  68979. start(emitter?: AbstractMesh): void;
  68980. /**
  68981. * Release all associated resources
  68982. */
  68983. dispose(): void;
  68984. /**
  68985. * Serialize the set into a JSON compatible object
  68986. * @param serializeTexture defines if the texture must be serialized as well
  68987. * @returns a JSON compatible representation of the set
  68988. */
  68989. serialize(serializeTexture?: boolean): any;
  68990. /**
  68991. * Parse a new ParticleSystemSet from a serialized source
  68992. * @param data defines a JSON compatible representation of the set
  68993. * @param scene defines the hosting scene
  68994. * @param gpu defines if we want GPU particles or CPU particles
  68995. * @returns a new ParticleSystemSet
  68996. */
  68997. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68998. }
  68999. }
  69000. declare module BABYLON {
  69001. /**
  69002. * This class is made for on one-liner static method to help creating particle system set.
  69003. */
  69004. export class ParticleHelper {
  69005. /**
  69006. * Gets or sets base Assets URL
  69007. */
  69008. static BaseAssetsUrl: string;
  69009. /** Define the Url to load snippets */
  69010. static SnippetUrl: string;
  69011. /**
  69012. * Create a default particle system that you can tweak
  69013. * @param emitter defines the emitter to use
  69014. * @param capacity defines the system capacity (default is 500 particles)
  69015. * @param scene defines the hosting scene
  69016. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69017. * @returns the new Particle system
  69018. */
  69019. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69020. /**
  69021. * This is the main static method (one-liner) of this helper to create different particle systems
  69022. * @param type This string represents the type to the particle system to create
  69023. * @param scene The scene where the particle system should live
  69024. * @param gpu If the system will use gpu
  69025. * @returns the ParticleSystemSet created
  69026. */
  69027. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69028. /**
  69029. * Static function used to export a particle system to a ParticleSystemSet variable.
  69030. * Please note that the emitter shape is not exported
  69031. * @param systems defines the particle systems to export
  69032. * @returns the created particle system set
  69033. */
  69034. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69035. /**
  69036. * Creates a particle system from a snippet saved in a remote file
  69037. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69038. * @param url defines the url to load from
  69039. * @param scene defines the hosting scene
  69040. * @param gpu If the system will use gpu
  69041. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69042. * @returns a promise that will resolve to the new particle system
  69043. */
  69044. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69045. /**
  69046. * Creates a particle system from a snippet saved by the particle system editor
  69047. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  69048. * @param scene defines the hosting scene
  69049. * @param gpu If the system will use gpu
  69050. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69051. * @returns a promise that will resolve to the new particle system
  69052. */
  69053. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69054. }
  69055. }
  69056. declare module BABYLON {
  69057. interface Engine {
  69058. /**
  69059. * Create an effect to use with particle systems.
  69060. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69061. * the particle system for which you want to create a custom effect in the last parameter
  69062. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69063. * @param uniformsNames defines a list of attribute names
  69064. * @param samplers defines an array of string used to represent textures
  69065. * @param defines defines the string containing the defines to use to compile the shaders
  69066. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69067. * @param onCompiled defines a function to call when the effect creation is successful
  69068. * @param onError defines a function to call when the effect creation has failed
  69069. * @param particleSystem the particle system you want to create the effect for
  69070. * @returns the new Effect
  69071. */
  69072. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69073. }
  69074. interface Mesh {
  69075. /**
  69076. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69077. * @returns an array of IParticleSystem
  69078. */
  69079. getEmittedParticleSystems(): IParticleSystem[];
  69080. /**
  69081. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69082. * @returns an array of IParticleSystem
  69083. */
  69084. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69085. }
  69086. }
  69087. declare module BABYLON {
  69088. /** Defines the 4 color options */
  69089. export enum PointColor {
  69090. /** color value */
  69091. Color = 2,
  69092. /** uv value */
  69093. UV = 1,
  69094. /** random value */
  69095. Random = 0,
  69096. /** stated value */
  69097. Stated = 3
  69098. }
  69099. /**
  69100. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69101. * 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.
  69102. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69103. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69104. *
  69105. * Full documentation here : TO BE ENTERED
  69106. */
  69107. export class PointsCloudSystem implements IDisposable {
  69108. /**
  69109. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69110. * Example : var p = SPS.particles[i];
  69111. */
  69112. particles: CloudPoint[];
  69113. /**
  69114. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69115. */
  69116. nbParticles: number;
  69117. /**
  69118. * This a counter for your own usage. It's not set by any SPS functions.
  69119. */
  69120. counter: number;
  69121. /**
  69122. * The PCS name. This name is also given to the underlying mesh.
  69123. */
  69124. name: string;
  69125. /**
  69126. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69127. */
  69128. mesh: Mesh;
  69129. /**
  69130. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69131. * Please read :
  69132. */
  69133. vars: any;
  69134. /**
  69135. * @hidden
  69136. */
  69137. _size: number;
  69138. private _scene;
  69139. private _promises;
  69140. private _positions;
  69141. private _indices;
  69142. private _normals;
  69143. private _colors;
  69144. private _uvs;
  69145. private _indices32;
  69146. private _positions32;
  69147. private _colors32;
  69148. private _uvs32;
  69149. private _updatable;
  69150. private _isVisibilityBoxLocked;
  69151. private _alwaysVisible;
  69152. private _groups;
  69153. private _groupCounter;
  69154. private _computeParticleColor;
  69155. private _computeParticleTexture;
  69156. private _computeParticleRotation;
  69157. private _computeBoundingBox;
  69158. private _isReady;
  69159. /**
  69160. * Creates a PCS (Points Cloud System) object
  69161. * @param name (String) is the PCS name, this will be the underlying mesh name
  69162. * @param pointSize (number) is the size for each point
  69163. * @param scene (Scene) is the scene in which the PCS is added
  69164. * @param options defines the options of the PCS e.g.
  69165. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69166. */
  69167. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69168. updatable?: boolean;
  69169. });
  69170. /**
  69171. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69172. * If no points were added to the PCS, the returned mesh is just a single point.
  69173. * @returns a promise for the created mesh
  69174. */
  69175. buildMeshAsync(): Promise<Mesh>;
  69176. /**
  69177. * @hidden
  69178. */
  69179. private _buildMesh;
  69180. private _addParticle;
  69181. private _randomUnitVector;
  69182. private _getColorIndicesForCoord;
  69183. private _setPointsColorOrUV;
  69184. private _colorFromTexture;
  69185. private _calculateDensity;
  69186. /**
  69187. * Adds points to the PCS in random positions within a unit sphere
  69188. * @param nb (positive integer) the number of particles to be created from this model
  69189. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69190. * @returns the number of groups in the system
  69191. */
  69192. addPoints(nb: number, pointFunction?: any): number;
  69193. /**
  69194. * Adds points to the PCS from the surface of the model shape
  69195. * @param mesh is any Mesh object that will be used as a surface model for the points
  69196. * @param nb (positive integer) the number of particles to be created from this model
  69197. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69198. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69199. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69200. * @returns the number of groups in the system
  69201. */
  69202. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69203. /**
  69204. * Adds points to the PCS inside the model shape
  69205. * @param mesh is any Mesh object that will be used as a surface model for the points
  69206. * @param nb (positive integer) the number of particles to be created from this model
  69207. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69208. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69209. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69210. * @returns the number of groups in the system
  69211. */
  69212. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69213. /**
  69214. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69215. * This method calls `updateParticle()` for each particle of the SPS.
  69216. * For an animated SPS, it is usually called within the render loop.
  69217. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69218. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69219. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69220. * @returns the PCS.
  69221. */
  69222. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69223. /**
  69224. * Disposes the PCS.
  69225. */
  69226. dispose(): void;
  69227. /**
  69228. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69229. * doc :
  69230. * @returns the PCS.
  69231. */
  69232. refreshVisibleSize(): PointsCloudSystem;
  69233. /**
  69234. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69235. * @param size the size (float) of the visibility box
  69236. * note : this doesn't lock the PCS mesh bounding box.
  69237. * doc :
  69238. */
  69239. setVisibilityBox(size: number): void;
  69240. /**
  69241. * Gets whether the PCS is always visible or not
  69242. * doc :
  69243. */
  69244. get isAlwaysVisible(): boolean;
  69245. /**
  69246. * Sets the PCS as always visible or not
  69247. * doc :
  69248. */
  69249. set isAlwaysVisible(val: boolean);
  69250. /**
  69251. * Tells to `setParticles()` to compute the particle rotations or not
  69252. * Default value : false. The PCS is faster when it's set to false
  69253. * Note : particle rotations are only applied to parent particles
  69254. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69255. */
  69256. set computeParticleRotation(val: boolean);
  69257. /**
  69258. * Tells to `setParticles()` to compute the particle colors or not.
  69259. * Default value : true. The PCS is faster when it's set to false.
  69260. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69261. */
  69262. set computeParticleColor(val: boolean);
  69263. set computeParticleTexture(val: boolean);
  69264. /**
  69265. * Gets if `setParticles()` computes the particle colors or not.
  69266. * Default value : false. The PCS is faster when it's set to false.
  69267. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69268. */
  69269. get computeParticleColor(): boolean;
  69270. /**
  69271. * Gets if `setParticles()` computes the particle textures or not.
  69272. * Default value : false. The PCS is faster when it's set to false.
  69273. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69274. */
  69275. get computeParticleTexture(): boolean;
  69276. /**
  69277. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69278. */
  69279. set computeBoundingBox(val: boolean);
  69280. /**
  69281. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69282. */
  69283. get computeBoundingBox(): boolean;
  69284. /**
  69285. * This function does nothing. It may be overwritten to set all the particle first values.
  69286. * The PCS doesn't call this function, you may have to call it by your own.
  69287. * doc :
  69288. */
  69289. initParticles(): void;
  69290. /**
  69291. * This function does nothing. It may be overwritten to recycle a particle
  69292. * The PCS doesn't call this function, you can to call it
  69293. * doc :
  69294. * @param particle The particle to recycle
  69295. * @returns the recycled particle
  69296. */
  69297. recycleParticle(particle: CloudPoint): CloudPoint;
  69298. /**
  69299. * Updates a particle : this function should be overwritten by the user.
  69300. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69301. * doc :
  69302. * @example : just set a particle position or velocity and recycle conditions
  69303. * @param particle The particle to update
  69304. * @returns the updated particle
  69305. */
  69306. updateParticle(particle: CloudPoint): CloudPoint;
  69307. /**
  69308. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69309. * This does nothing and may be overwritten by the user.
  69310. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69311. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69312. * @param update the boolean update value actually passed to setParticles()
  69313. */
  69314. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69315. /**
  69316. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69317. * This will be passed three parameters.
  69318. * This does nothing and may be overwritten by the user.
  69319. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69320. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69321. * @param update the boolean update value actually passed to setParticles()
  69322. */
  69323. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69324. }
  69325. }
  69326. declare module BABYLON {
  69327. /**
  69328. * Represents one particle of a points cloud system.
  69329. */
  69330. export class CloudPoint {
  69331. /**
  69332. * particle global index
  69333. */
  69334. idx: number;
  69335. /**
  69336. * The color of the particle
  69337. */
  69338. color: Nullable<Color4>;
  69339. /**
  69340. * The world space position of the particle.
  69341. */
  69342. position: Vector3;
  69343. /**
  69344. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69345. */
  69346. rotation: Vector3;
  69347. /**
  69348. * The world space rotation quaternion of the particle.
  69349. */
  69350. rotationQuaternion: Nullable<Quaternion>;
  69351. /**
  69352. * The uv of the particle.
  69353. */
  69354. uv: Nullable<Vector2>;
  69355. /**
  69356. * The current speed of the particle.
  69357. */
  69358. velocity: Vector3;
  69359. /**
  69360. * The pivot point in the particle local space.
  69361. */
  69362. pivot: Vector3;
  69363. /**
  69364. * Must the particle be translated from its pivot point in its local space ?
  69365. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69366. * Default : false
  69367. */
  69368. translateFromPivot: boolean;
  69369. /**
  69370. * Index of this particle in the global "positions" array (Internal use)
  69371. * @hidden
  69372. */
  69373. _pos: number;
  69374. /**
  69375. * @hidden Index of this particle in the global "indices" array (Internal use)
  69376. */
  69377. _ind: number;
  69378. /**
  69379. * Group this particle belongs to
  69380. */
  69381. _group: PointsGroup;
  69382. /**
  69383. * Group id of this particle
  69384. */
  69385. groupId: number;
  69386. /**
  69387. * Index of the particle in its group id (Internal use)
  69388. */
  69389. idxInGroup: number;
  69390. /**
  69391. * @hidden Particle BoundingInfo object (Internal use)
  69392. */
  69393. _boundingInfo: BoundingInfo;
  69394. /**
  69395. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69396. */
  69397. _pcs: PointsCloudSystem;
  69398. /**
  69399. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69400. */
  69401. _stillInvisible: boolean;
  69402. /**
  69403. * @hidden Last computed particle rotation matrix
  69404. */
  69405. _rotationMatrix: number[];
  69406. /**
  69407. * Parent particle Id, if any.
  69408. * Default null.
  69409. */
  69410. parentId: Nullable<number>;
  69411. /**
  69412. * @hidden Internal global position in the PCS.
  69413. */
  69414. _globalPosition: Vector3;
  69415. /**
  69416. * Creates a Point Cloud object.
  69417. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69418. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69419. * @param group (PointsGroup) is the group the particle belongs to
  69420. * @param groupId (integer) is the group identifier in the PCS.
  69421. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69422. * @param pcs defines the PCS it is associated to
  69423. */
  69424. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69425. /**
  69426. * get point size
  69427. */
  69428. get size(): Vector3;
  69429. /**
  69430. * Set point size
  69431. */
  69432. set size(scale: Vector3);
  69433. /**
  69434. * Legacy support, changed quaternion to rotationQuaternion
  69435. */
  69436. get quaternion(): Nullable<Quaternion>;
  69437. /**
  69438. * Legacy support, changed quaternion to rotationQuaternion
  69439. */
  69440. set quaternion(q: Nullable<Quaternion>);
  69441. /**
  69442. * Returns a boolean. True if the particle intersects a mesh, else false
  69443. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69444. * @param target is the object (point or mesh) what the intersection is computed against
  69445. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69446. * @returns true if it intersects
  69447. */
  69448. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69449. /**
  69450. * get the rotation matrix of the particle
  69451. * @hidden
  69452. */
  69453. getRotationMatrix(m: Matrix): void;
  69454. }
  69455. /**
  69456. * Represents a group of points in a points cloud system
  69457. * * PCS internal tool, don't use it manually.
  69458. */
  69459. export class PointsGroup {
  69460. /**
  69461. * The group id
  69462. * @hidden
  69463. */
  69464. groupID: number;
  69465. /**
  69466. * image data for group (internal use)
  69467. * @hidden
  69468. */
  69469. _groupImageData: Nullable<ArrayBufferView>;
  69470. /**
  69471. * Image Width (internal use)
  69472. * @hidden
  69473. */
  69474. _groupImgWidth: number;
  69475. /**
  69476. * Image Height (internal use)
  69477. * @hidden
  69478. */
  69479. _groupImgHeight: number;
  69480. /**
  69481. * Custom position function (internal use)
  69482. * @hidden
  69483. */
  69484. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69485. /**
  69486. * density per facet for surface points
  69487. * @hidden
  69488. */
  69489. _groupDensity: number[];
  69490. /**
  69491. * Only when points are colored by texture carries pointer to texture list array
  69492. * @hidden
  69493. */
  69494. _textureNb: number;
  69495. /**
  69496. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69497. * PCS internal tool, don't use it manually.
  69498. * @hidden
  69499. */
  69500. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69501. }
  69502. }
  69503. declare module BABYLON {
  69504. interface Scene {
  69505. /** @hidden (Backing field) */
  69506. _physicsEngine: Nullable<IPhysicsEngine>;
  69507. /** @hidden */
  69508. _physicsTimeAccumulator: number;
  69509. /**
  69510. * Gets the current physics engine
  69511. * @returns a IPhysicsEngine or null if none attached
  69512. */
  69513. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69514. /**
  69515. * Enables physics to the current scene
  69516. * @param gravity defines the scene's gravity for the physics engine
  69517. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69518. * @return a boolean indicating if the physics engine was initialized
  69519. */
  69520. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69521. /**
  69522. * Disables and disposes the physics engine associated with the scene
  69523. */
  69524. disablePhysicsEngine(): void;
  69525. /**
  69526. * Gets a boolean indicating if there is an active physics engine
  69527. * @returns a boolean indicating if there is an active physics engine
  69528. */
  69529. isPhysicsEnabled(): boolean;
  69530. /**
  69531. * Deletes a physics compound impostor
  69532. * @param compound defines the compound to delete
  69533. */
  69534. deleteCompoundImpostor(compound: any): void;
  69535. /**
  69536. * An event triggered when physic simulation is about to be run
  69537. */
  69538. onBeforePhysicsObservable: Observable<Scene>;
  69539. /**
  69540. * An event triggered when physic simulation has been done
  69541. */
  69542. onAfterPhysicsObservable: Observable<Scene>;
  69543. }
  69544. interface AbstractMesh {
  69545. /** @hidden */
  69546. _physicsImpostor: Nullable<PhysicsImpostor>;
  69547. /**
  69548. * Gets or sets impostor used for physic simulation
  69549. * @see https://doc.babylonjs.com/features/physics_engine
  69550. */
  69551. physicsImpostor: Nullable<PhysicsImpostor>;
  69552. /**
  69553. * Gets the current physics impostor
  69554. * @see https://doc.babylonjs.com/features/physics_engine
  69555. * @returns a physics impostor or null
  69556. */
  69557. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69558. /** Apply a physic impulse to the mesh
  69559. * @param force defines the force to apply
  69560. * @param contactPoint defines where to apply the force
  69561. * @returns the current mesh
  69562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69563. */
  69564. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69565. /**
  69566. * Creates a physic joint between two meshes
  69567. * @param otherMesh defines the other mesh to use
  69568. * @param pivot1 defines the pivot to use on this mesh
  69569. * @param pivot2 defines the pivot to use on the other mesh
  69570. * @param options defines additional options (can be plugin dependent)
  69571. * @returns the current mesh
  69572. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69573. */
  69574. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69575. /** @hidden */
  69576. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69577. }
  69578. /**
  69579. * Defines the physics engine scene component responsible to manage a physics engine
  69580. */
  69581. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69582. /**
  69583. * The component name helpful to identify the component in the list of scene components.
  69584. */
  69585. readonly name: string;
  69586. /**
  69587. * The scene the component belongs to.
  69588. */
  69589. scene: Scene;
  69590. /**
  69591. * Creates a new instance of the component for the given scene
  69592. * @param scene Defines the scene to register the component in
  69593. */
  69594. constructor(scene: Scene);
  69595. /**
  69596. * Registers the component in a given scene
  69597. */
  69598. register(): void;
  69599. /**
  69600. * Rebuilds the elements related to this component in case of
  69601. * context lost for instance.
  69602. */
  69603. rebuild(): void;
  69604. /**
  69605. * Disposes the component and the associated ressources
  69606. */
  69607. dispose(): void;
  69608. }
  69609. }
  69610. declare module BABYLON {
  69611. /**
  69612. * A helper for physics simulations
  69613. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69614. */
  69615. export class PhysicsHelper {
  69616. private _scene;
  69617. private _physicsEngine;
  69618. /**
  69619. * Initializes the Physics helper
  69620. * @param scene Babylon.js scene
  69621. */
  69622. constructor(scene: Scene);
  69623. /**
  69624. * Applies a radial explosion impulse
  69625. * @param origin the origin of the explosion
  69626. * @param radiusOrEventOptions the radius or the options of radial explosion
  69627. * @param strength the explosion strength
  69628. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69629. * @returns A physics radial explosion event, or null
  69630. */
  69631. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69632. /**
  69633. * Applies a radial explosion force
  69634. * @param origin the origin of the explosion
  69635. * @param radiusOrEventOptions the radius or the options of radial explosion
  69636. * @param strength the explosion strength
  69637. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69638. * @returns A physics radial explosion event, or null
  69639. */
  69640. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69641. /**
  69642. * Creates a gravitational field
  69643. * @param origin the origin of the explosion
  69644. * @param radiusOrEventOptions the radius or the options of radial explosion
  69645. * @param strength the explosion strength
  69646. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69647. * @returns A physics gravitational field event, or null
  69648. */
  69649. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69650. /**
  69651. * Creates a physics updraft event
  69652. * @param origin the origin of the updraft
  69653. * @param radiusOrEventOptions the radius or the options of the updraft
  69654. * @param strength the strength of the updraft
  69655. * @param height the height of the updraft
  69656. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69657. * @returns A physics updraft event, or null
  69658. */
  69659. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69660. /**
  69661. * Creates a physics vortex event
  69662. * @param origin the of the vortex
  69663. * @param radiusOrEventOptions the radius or the options of the vortex
  69664. * @param strength the strength of the vortex
  69665. * @param height the height of the vortex
  69666. * @returns a Physics vortex event, or null
  69667. * A physics vortex event or null
  69668. */
  69669. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69670. }
  69671. /**
  69672. * Represents a physics radial explosion event
  69673. */
  69674. class PhysicsRadialExplosionEvent {
  69675. private _scene;
  69676. private _options;
  69677. private _sphere;
  69678. private _dataFetched;
  69679. /**
  69680. * Initializes a radial explosioin event
  69681. * @param _scene BabylonJS scene
  69682. * @param _options The options for the vortex event
  69683. */
  69684. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69685. /**
  69686. * Returns the data related to the radial explosion event (sphere).
  69687. * @returns The radial explosion event data
  69688. */
  69689. getData(): PhysicsRadialExplosionEventData;
  69690. /**
  69691. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69692. * @param impostor A physics imposter
  69693. * @param origin the origin of the explosion
  69694. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69695. */
  69696. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69697. /**
  69698. * Triggers affecterd impostors callbacks
  69699. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69700. */
  69701. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69702. /**
  69703. * Disposes the sphere.
  69704. * @param force Specifies if the sphere should be disposed by force
  69705. */
  69706. dispose(force?: boolean): void;
  69707. /*** Helpers ***/
  69708. private _prepareSphere;
  69709. private _intersectsWithSphere;
  69710. }
  69711. /**
  69712. * Represents a gravitational field event
  69713. */
  69714. class PhysicsGravitationalFieldEvent {
  69715. private _physicsHelper;
  69716. private _scene;
  69717. private _origin;
  69718. private _options;
  69719. private _tickCallback;
  69720. private _sphere;
  69721. private _dataFetched;
  69722. /**
  69723. * Initializes the physics gravitational field event
  69724. * @param _physicsHelper A physics helper
  69725. * @param _scene BabylonJS scene
  69726. * @param _origin The origin position of the gravitational field event
  69727. * @param _options The options for the vortex event
  69728. */
  69729. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69730. /**
  69731. * Returns the data related to the gravitational field event (sphere).
  69732. * @returns A gravitational field event
  69733. */
  69734. getData(): PhysicsGravitationalFieldEventData;
  69735. /**
  69736. * Enables the gravitational field.
  69737. */
  69738. enable(): void;
  69739. /**
  69740. * Disables the gravitational field.
  69741. */
  69742. disable(): void;
  69743. /**
  69744. * Disposes the sphere.
  69745. * @param force The force to dispose from the gravitational field event
  69746. */
  69747. dispose(force?: boolean): void;
  69748. private _tick;
  69749. }
  69750. /**
  69751. * Represents a physics updraft event
  69752. */
  69753. class PhysicsUpdraftEvent {
  69754. private _scene;
  69755. private _origin;
  69756. private _options;
  69757. private _physicsEngine;
  69758. private _originTop;
  69759. private _originDirection;
  69760. private _tickCallback;
  69761. private _cylinder;
  69762. private _cylinderPosition;
  69763. private _dataFetched;
  69764. /**
  69765. * Initializes the physics updraft event
  69766. * @param _scene BabylonJS scene
  69767. * @param _origin The origin position of the updraft
  69768. * @param _options The options for the updraft event
  69769. */
  69770. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69771. /**
  69772. * Returns the data related to the updraft event (cylinder).
  69773. * @returns A physics updraft event
  69774. */
  69775. getData(): PhysicsUpdraftEventData;
  69776. /**
  69777. * Enables the updraft.
  69778. */
  69779. enable(): void;
  69780. /**
  69781. * Disables the updraft.
  69782. */
  69783. disable(): void;
  69784. /**
  69785. * Disposes the cylinder.
  69786. * @param force Specifies if the updraft should be disposed by force
  69787. */
  69788. dispose(force?: boolean): void;
  69789. private getImpostorHitData;
  69790. private _tick;
  69791. /*** Helpers ***/
  69792. private _prepareCylinder;
  69793. private _intersectsWithCylinder;
  69794. }
  69795. /**
  69796. * Represents a physics vortex event
  69797. */
  69798. class PhysicsVortexEvent {
  69799. private _scene;
  69800. private _origin;
  69801. private _options;
  69802. private _physicsEngine;
  69803. private _originTop;
  69804. private _tickCallback;
  69805. private _cylinder;
  69806. private _cylinderPosition;
  69807. private _dataFetched;
  69808. /**
  69809. * Initializes the physics vortex event
  69810. * @param _scene The BabylonJS scene
  69811. * @param _origin The origin position of the vortex
  69812. * @param _options The options for the vortex event
  69813. */
  69814. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69815. /**
  69816. * Returns the data related to the vortex event (cylinder).
  69817. * @returns The physics vortex event data
  69818. */
  69819. getData(): PhysicsVortexEventData;
  69820. /**
  69821. * Enables the vortex.
  69822. */
  69823. enable(): void;
  69824. /**
  69825. * Disables the cortex.
  69826. */
  69827. disable(): void;
  69828. /**
  69829. * Disposes the sphere.
  69830. * @param force
  69831. */
  69832. dispose(force?: boolean): void;
  69833. private getImpostorHitData;
  69834. private _tick;
  69835. /*** Helpers ***/
  69836. private _prepareCylinder;
  69837. private _intersectsWithCylinder;
  69838. }
  69839. /**
  69840. * Options fot the radial explosion event
  69841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69842. */
  69843. export class PhysicsRadialExplosionEventOptions {
  69844. /**
  69845. * The radius of the sphere for the radial explosion.
  69846. */
  69847. radius: number;
  69848. /**
  69849. * The strenth of the explosion.
  69850. */
  69851. strength: number;
  69852. /**
  69853. * The strenght of the force in correspondence to the distance of the affected object
  69854. */
  69855. falloff: PhysicsRadialImpulseFalloff;
  69856. /**
  69857. * Sphere options for the radial explosion.
  69858. */
  69859. sphere: {
  69860. segments: number;
  69861. diameter: number;
  69862. };
  69863. /**
  69864. * Sphere options for the radial explosion.
  69865. */
  69866. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69867. }
  69868. /**
  69869. * Options fot the updraft event
  69870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69871. */
  69872. export class PhysicsUpdraftEventOptions {
  69873. /**
  69874. * The radius of the cylinder for the vortex
  69875. */
  69876. radius: number;
  69877. /**
  69878. * The strenth of the updraft.
  69879. */
  69880. strength: number;
  69881. /**
  69882. * The height of the cylinder for the updraft.
  69883. */
  69884. height: number;
  69885. /**
  69886. * The mode for the the updraft.
  69887. */
  69888. updraftMode: PhysicsUpdraftMode;
  69889. }
  69890. /**
  69891. * Options fot the vortex event
  69892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69893. */
  69894. export class PhysicsVortexEventOptions {
  69895. /**
  69896. * The radius of the cylinder for the vortex
  69897. */
  69898. radius: number;
  69899. /**
  69900. * The strenth of the vortex.
  69901. */
  69902. strength: number;
  69903. /**
  69904. * The height of the cylinder for the vortex.
  69905. */
  69906. height: number;
  69907. /**
  69908. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69909. */
  69910. centripetalForceThreshold: number;
  69911. /**
  69912. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69913. */
  69914. centripetalForceMultiplier: number;
  69915. /**
  69916. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69917. */
  69918. centrifugalForceMultiplier: number;
  69919. /**
  69920. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69921. */
  69922. updraftForceMultiplier: number;
  69923. }
  69924. /**
  69925. * The strenght of the force in correspondence to the distance of the affected object
  69926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69927. */
  69928. export enum PhysicsRadialImpulseFalloff {
  69929. /** Defines that impulse is constant in strength across it's whole radius */
  69930. Constant = 0,
  69931. /** Defines that impulse gets weaker if it's further from the origin */
  69932. Linear = 1
  69933. }
  69934. /**
  69935. * The strength of the force in correspondence to the distance of the affected object
  69936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69937. */
  69938. export enum PhysicsUpdraftMode {
  69939. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69940. Center = 0,
  69941. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69942. Perpendicular = 1
  69943. }
  69944. /**
  69945. * Interface for a physics hit data
  69946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69947. */
  69948. export interface PhysicsHitData {
  69949. /**
  69950. * The force applied at the contact point
  69951. */
  69952. force: Vector3;
  69953. /**
  69954. * The contact point
  69955. */
  69956. contactPoint: Vector3;
  69957. /**
  69958. * The distance from the origin to the contact point
  69959. */
  69960. distanceFromOrigin: number;
  69961. }
  69962. /**
  69963. * Interface for radial explosion event data
  69964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69965. */
  69966. export interface PhysicsRadialExplosionEventData {
  69967. /**
  69968. * A sphere used for the radial explosion event
  69969. */
  69970. sphere: Mesh;
  69971. }
  69972. /**
  69973. * Interface for gravitational field event data
  69974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69975. */
  69976. export interface PhysicsGravitationalFieldEventData {
  69977. /**
  69978. * A sphere mesh used for the gravitational field event
  69979. */
  69980. sphere: Mesh;
  69981. }
  69982. /**
  69983. * Interface for updraft event data
  69984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69985. */
  69986. export interface PhysicsUpdraftEventData {
  69987. /**
  69988. * A cylinder used for the updraft event
  69989. */
  69990. cylinder: Mesh;
  69991. }
  69992. /**
  69993. * Interface for vortex event data
  69994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69995. */
  69996. export interface PhysicsVortexEventData {
  69997. /**
  69998. * A cylinder used for the vortex event
  69999. */
  70000. cylinder: Mesh;
  70001. }
  70002. /**
  70003. * Interface for an affected physics impostor
  70004. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70005. */
  70006. export interface PhysicsAffectedImpostorWithData {
  70007. /**
  70008. * The impostor affected by the effect
  70009. */
  70010. impostor: PhysicsImpostor;
  70011. /**
  70012. * The data about the hit/horce from the explosion
  70013. */
  70014. hitData: PhysicsHitData;
  70015. }
  70016. }
  70017. declare module BABYLON {
  70018. /** @hidden */
  70019. export var blackAndWhitePixelShader: {
  70020. name: string;
  70021. shader: string;
  70022. };
  70023. }
  70024. declare module BABYLON {
  70025. /**
  70026. * Post process used to render in black and white
  70027. */
  70028. export class BlackAndWhitePostProcess extends PostProcess {
  70029. /**
  70030. * Linear about to convert he result to black and white (default: 1)
  70031. */
  70032. degree: number;
  70033. /**
  70034. * Gets a string identifying the name of the class
  70035. * @returns "BlackAndWhitePostProcess" string
  70036. */
  70037. getClassName(): string;
  70038. /**
  70039. * Creates a black and white post process
  70040. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70041. * @param name The name of the effect.
  70042. * @param options The required width/height ratio to downsize to before computing the render pass.
  70043. * @param camera The camera to apply the render pass to.
  70044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70045. * @param engine The engine which the post process will be applied. (default: current engine)
  70046. * @param reusable If the post process can be reused on the same frame. (default: false)
  70047. */
  70048. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70049. /** @hidden */
  70050. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  70051. }
  70052. }
  70053. declare module BABYLON {
  70054. /**
  70055. * This represents a set of one or more post processes in Babylon.
  70056. * A post process can be used to apply a shader to a texture after it is rendered.
  70057. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70058. */
  70059. export class PostProcessRenderEffect {
  70060. private _postProcesses;
  70061. private _getPostProcesses;
  70062. private _singleInstance;
  70063. private _cameras;
  70064. private _indicesForCamera;
  70065. /**
  70066. * Name of the effect
  70067. * @hidden
  70068. */
  70069. _name: string;
  70070. /**
  70071. * Instantiates a post process render effect.
  70072. * A post process can be used to apply a shader to a texture after it is rendered.
  70073. * @param engine The engine the effect is tied to
  70074. * @param name The name of the effect
  70075. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70076. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70077. */
  70078. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70079. /**
  70080. * Checks if all the post processes in the effect are supported.
  70081. */
  70082. get isSupported(): boolean;
  70083. /**
  70084. * Updates the current state of the effect
  70085. * @hidden
  70086. */
  70087. _update(): void;
  70088. /**
  70089. * Attaches the effect on cameras
  70090. * @param cameras The camera to attach to.
  70091. * @hidden
  70092. */
  70093. _attachCameras(cameras: Camera): void;
  70094. /**
  70095. * Attaches the effect on cameras
  70096. * @param cameras The camera to attach to.
  70097. * @hidden
  70098. */
  70099. _attachCameras(cameras: Camera[]): void;
  70100. /**
  70101. * Detaches the effect on cameras
  70102. * @param cameras The camera to detatch from.
  70103. * @hidden
  70104. */
  70105. _detachCameras(cameras: Camera): void;
  70106. /**
  70107. * Detatches the effect on cameras
  70108. * @param cameras The camera to detatch from.
  70109. * @hidden
  70110. */
  70111. _detachCameras(cameras: Camera[]): void;
  70112. /**
  70113. * Enables the effect on given cameras
  70114. * @param cameras The camera to enable.
  70115. * @hidden
  70116. */
  70117. _enable(cameras: Camera): void;
  70118. /**
  70119. * Enables the effect on given cameras
  70120. * @param cameras The camera to enable.
  70121. * @hidden
  70122. */
  70123. _enable(cameras: Nullable<Camera[]>): void;
  70124. /**
  70125. * Disables the effect on the given cameras
  70126. * @param cameras The camera to disable.
  70127. * @hidden
  70128. */
  70129. _disable(cameras: Camera): void;
  70130. /**
  70131. * Disables the effect on the given cameras
  70132. * @param cameras The camera to disable.
  70133. * @hidden
  70134. */
  70135. _disable(cameras: Nullable<Camera[]>): void;
  70136. /**
  70137. * Gets a list of the post processes contained in the effect.
  70138. * @param camera The camera to get the post processes on.
  70139. * @returns The list of the post processes in the effect.
  70140. */
  70141. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70142. }
  70143. }
  70144. declare module BABYLON {
  70145. /** @hidden */
  70146. export var extractHighlightsPixelShader: {
  70147. name: string;
  70148. shader: string;
  70149. };
  70150. }
  70151. declare module BABYLON {
  70152. /**
  70153. * 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.
  70154. */
  70155. export class ExtractHighlightsPostProcess extends PostProcess {
  70156. /**
  70157. * The luminance threshold, pixels below this value will be set to black.
  70158. */
  70159. threshold: number;
  70160. /** @hidden */
  70161. _exposure: number;
  70162. /**
  70163. * Post process which has the input texture to be used when performing highlight extraction
  70164. * @hidden
  70165. */
  70166. _inputPostProcess: Nullable<PostProcess>;
  70167. /**
  70168. * Gets a string identifying the name of the class
  70169. * @returns "ExtractHighlightsPostProcess" string
  70170. */
  70171. getClassName(): string;
  70172. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70173. }
  70174. }
  70175. declare module BABYLON {
  70176. /** @hidden */
  70177. export var bloomMergePixelShader: {
  70178. name: string;
  70179. shader: string;
  70180. };
  70181. }
  70182. declare module BABYLON {
  70183. /**
  70184. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70185. */
  70186. export class BloomMergePostProcess extends PostProcess {
  70187. /** Weight of the bloom to be added to the original input. */
  70188. weight: number;
  70189. /**
  70190. * Gets a string identifying the name of the class
  70191. * @returns "BloomMergePostProcess" string
  70192. */
  70193. getClassName(): string;
  70194. /**
  70195. * Creates a new instance of @see BloomMergePostProcess
  70196. * @param name The name of the effect.
  70197. * @param originalFromInput Post process which's input will be used for the merge.
  70198. * @param blurred Blurred highlights post process which's output will be used.
  70199. * @param weight Weight of the bloom to be added to the original input.
  70200. * @param options The required width/height ratio to downsize to before computing the render pass.
  70201. * @param camera The camera to apply the render pass to.
  70202. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70203. * @param engine The engine which the post process will be applied. (default: current engine)
  70204. * @param reusable If the post process can be reused on the same frame. (default: false)
  70205. * @param textureType Type of textures used when performing the post process. (default: 0)
  70206. * @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)
  70207. */
  70208. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70209. /** Weight of the bloom to be added to the original input. */
  70210. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70211. }
  70212. }
  70213. declare module BABYLON {
  70214. /**
  70215. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70216. */
  70217. export class BloomEffect extends PostProcessRenderEffect {
  70218. private bloomScale;
  70219. /**
  70220. * @hidden Internal
  70221. */
  70222. _effects: Array<PostProcess>;
  70223. /**
  70224. * @hidden Internal
  70225. */
  70226. _downscale: ExtractHighlightsPostProcess;
  70227. private _blurX;
  70228. private _blurY;
  70229. private _merge;
  70230. /**
  70231. * The luminance threshold to find bright areas of the image to bloom.
  70232. */
  70233. get threshold(): number;
  70234. set threshold(value: number);
  70235. /**
  70236. * The strength of the bloom.
  70237. */
  70238. get weight(): number;
  70239. set weight(value: number);
  70240. /**
  70241. * Specifies the size of the bloom blur kernel, relative to the final output size
  70242. */
  70243. get kernel(): number;
  70244. set kernel(value: number);
  70245. /**
  70246. * Creates a new instance of @see BloomEffect
  70247. * @param scene The scene the effect belongs to.
  70248. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70249. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70250. * @param bloomWeight The the strength of bloom.
  70251. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70252. * @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)
  70253. */
  70254. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70255. /**
  70256. * Disposes each of the internal effects for a given camera.
  70257. * @param camera The camera to dispose the effect on.
  70258. */
  70259. disposeEffects(camera: Camera): void;
  70260. /**
  70261. * @hidden Internal
  70262. */
  70263. _updateEffects(): void;
  70264. /**
  70265. * Internal
  70266. * @returns if all the contained post processes are ready.
  70267. * @hidden
  70268. */
  70269. _isReady(): boolean;
  70270. }
  70271. }
  70272. declare module BABYLON {
  70273. /** @hidden */
  70274. export var chromaticAberrationPixelShader: {
  70275. name: string;
  70276. shader: string;
  70277. };
  70278. }
  70279. declare module BABYLON {
  70280. /**
  70281. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70282. */
  70283. export class ChromaticAberrationPostProcess extends PostProcess {
  70284. /**
  70285. * The amount of seperation of rgb channels (default: 30)
  70286. */
  70287. aberrationAmount: number;
  70288. /**
  70289. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70290. */
  70291. radialIntensity: number;
  70292. /**
  70293. * 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))
  70294. */
  70295. direction: Vector2;
  70296. /**
  70297. * 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))
  70298. */
  70299. centerPosition: Vector2;
  70300. /** The width of the screen to apply the effect on */
  70301. screenWidth: number;
  70302. /** The height of the screen to apply the effect on */
  70303. screenHeight: number;
  70304. /**
  70305. * Gets a string identifying the name of the class
  70306. * @returns "ChromaticAberrationPostProcess" string
  70307. */
  70308. getClassName(): string;
  70309. /**
  70310. * Creates a new instance ChromaticAberrationPostProcess
  70311. * @param name The name of the effect.
  70312. * @param screenWidth The width of the screen to apply the effect on.
  70313. * @param screenHeight The height of the screen to apply the effect on.
  70314. * @param options The required width/height ratio to downsize to before computing the render pass.
  70315. * @param camera The camera to apply the render pass to.
  70316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70317. * @param engine The engine which the post process will be applied. (default: current engine)
  70318. * @param reusable If the post process can be reused on the same frame. (default: false)
  70319. * @param textureType Type of textures used when performing the post process. (default: 0)
  70320. * @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)
  70321. */
  70322. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70323. /** @hidden */
  70324. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70325. }
  70326. }
  70327. declare module BABYLON {
  70328. /** @hidden */
  70329. export var circleOfConfusionPixelShader: {
  70330. name: string;
  70331. shader: string;
  70332. };
  70333. }
  70334. declare module BABYLON {
  70335. /**
  70336. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70337. */
  70338. export class CircleOfConfusionPostProcess extends PostProcess {
  70339. /**
  70340. * 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.
  70341. */
  70342. lensSize: number;
  70343. /**
  70344. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70345. */
  70346. fStop: number;
  70347. /**
  70348. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70349. */
  70350. focusDistance: number;
  70351. /**
  70352. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70353. */
  70354. focalLength: number;
  70355. /**
  70356. * Gets a string identifying the name of the class
  70357. * @returns "CircleOfConfusionPostProcess" string
  70358. */
  70359. getClassName(): string;
  70360. private _depthTexture;
  70361. /**
  70362. * Creates a new instance CircleOfConfusionPostProcess
  70363. * @param name The name of the effect.
  70364. * @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.
  70365. * @param options The required width/height ratio to downsize to before computing the render pass.
  70366. * @param camera The camera to apply the render pass to.
  70367. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70368. * @param engine The engine which the post process will be applied. (default: current engine)
  70369. * @param reusable If the post process can be reused on the same frame. (default: false)
  70370. * @param textureType Type of textures used when performing the post process. (default: 0)
  70371. * @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)
  70372. */
  70373. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70374. /**
  70375. * 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.
  70376. */
  70377. set depthTexture(value: RenderTargetTexture);
  70378. }
  70379. }
  70380. declare module BABYLON {
  70381. /** @hidden */
  70382. export var colorCorrectionPixelShader: {
  70383. name: string;
  70384. shader: string;
  70385. };
  70386. }
  70387. declare module BABYLON {
  70388. /**
  70389. *
  70390. * This post-process allows the modification of rendered colors by using
  70391. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70392. *
  70393. * The object needs to be provided an url to a texture containing the color
  70394. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70395. * Use an image editing software to tweak the LUT to match your needs.
  70396. *
  70397. * For an example of a color LUT, see here:
  70398. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70399. * For explanations on color grading, see here:
  70400. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70401. *
  70402. */
  70403. export class ColorCorrectionPostProcess extends PostProcess {
  70404. private _colorTableTexture;
  70405. /**
  70406. * Gets the color table url used to create the LUT texture
  70407. */
  70408. colorTableUrl: string;
  70409. /**
  70410. * Gets a string identifying the name of the class
  70411. * @returns "ColorCorrectionPostProcess" string
  70412. */
  70413. getClassName(): string;
  70414. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70415. /** @hidden */
  70416. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70417. }
  70418. }
  70419. declare module BABYLON {
  70420. /** @hidden */
  70421. export var convolutionPixelShader: {
  70422. name: string;
  70423. shader: string;
  70424. };
  70425. }
  70426. declare module BABYLON {
  70427. /**
  70428. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70429. * input texture to perform effects such as edge detection or sharpening
  70430. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70431. */
  70432. export class ConvolutionPostProcess extends PostProcess {
  70433. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70434. kernel: number[];
  70435. /**
  70436. * Gets a string identifying the name of the class
  70437. * @returns "ConvolutionPostProcess" string
  70438. */
  70439. getClassName(): string;
  70440. /**
  70441. * Creates a new instance ConvolutionPostProcess
  70442. * @param name The name of the effect.
  70443. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70444. * @param options The required width/height ratio to downsize to before computing the render pass.
  70445. * @param camera The camera to apply the render pass to.
  70446. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70447. * @param engine The engine which the post process will be applied. (default: current engine)
  70448. * @param reusable If the post process can be reused on the same frame. (default: false)
  70449. * @param textureType Type of textures used when performing the post process. (default: 0)
  70450. */
  70451. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70452. /** @hidden */
  70453. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70454. /**
  70455. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70456. */
  70457. static EdgeDetect0Kernel: number[];
  70458. /**
  70459. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70460. */
  70461. static EdgeDetect1Kernel: number[];
  70462. /**
  70463. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70464. */
  70465. static EdgeDetect2Kernel: number[];
  70466. /**
  70467. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70468. */
  70469. static SharpenKernel: number[];
  70470. /**
  70471. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70472. */
  70473. static EmbossKernel: number[];
  70474. /**
  70475. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70476. */
  70477. static GaussianKernel: number[];
  70478. }
  70479. }
  70480. declare module BABYLON {
  70481. /**
  70482. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70483. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70484. * based on samples that have a large difference in distance than the center pixel.
  70485. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70486. */
  70487. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70488. /**
  70489. * The direction the blur should be applied
  70490. */
  70491. direction: Vector2;
  70492. /**
  70493. * Gets a string identifying the name of the class
  70494. * @returns "DepthOfFieldBlurPostProcess" string
  70495. */
  70496. getClassName(): string;
  70497. /**
  70498. * Creates a new instance CircleOfConfusionPostProcess
  70499. * @param name The name of the effect.
  70500. * @param scene The scene the effect belongs to.
  70501. * @param direction The direction the blur should be applied.
  70502. * @param kernel The size of the kernel used to blur.
  70503. * @param options The required width/height ratio to downsize to before computing the render pass.
  70504. * @param camera The camera to apply the render pass to.
  70505. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70506. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70508. * @param engine The engine which the post process will be applied. (default: current engine)
  70509. * @param reusable If the post process can be reused on the same frame. (default: false)
  70510. * @param textureType Type of textures used when performing the post process. (default: 0)
  70511. * @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)
  70512. */
  70513. 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);
  70514. }
  70515. }
  70516. declare module BABYLON {
  70517. /** @hidden */
  70518. export var depthOfFieldMergePixelShader: {
  70519. name: string;
  70520. shader: string;
  70521. };
  70522. }
  70523. declare module BABYLON {
  70524. /**
  70525. * Options to be set when merging outputs from the default pipeline.
  70526. */
  70527. export class DepthOfFieldMergePostProcessOptions {
  70528. /**
  70529. * The original image to merge on top of
  70530. */
  70531. originalFromInput: PostProcess;
  70532. /**
  70533. * Parameters to perform the merge of the depth of field effect
  70534. */
  70535. depthOfField?: {
  70536. circleOfConfusion: PostProcess;
  70537. blurSteps: Array<PostProcess>;
  70538. };
  70539. /**
  70540. * Parameters to perform the merge of bloom effect
  70541. */
  70542. bloom?: {
  70543. blurred: PostProcess;
  70544. weight: number;
  70545. };
  70546. }
  70547. /**
  70548. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70549. */
  70550. export class DepthOfFieldMergePostProcess extends PostProcess {
  70551. private blurSteps;
  70552. /**
  70553. * Gets a string identifying the name of the class
  70554. * @returns "DepthOfFieldMergePostProcess" string
  70555. */
  70556. getClassName(): string;
  70557. /**
  70558. * Creates a new instance of DepthOfFieldMergePostProcess
  70559. * @param name The name of the effect.
  70560. * @param originalFromInput Post process which's input will be used for the merge.
  70561. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70562. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70563. * @param options The required width/height ratio to downsize to before computing the render pass.
  70564. * @param camera The camera to apply the render pass to.
  70565. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70566. * @param engine The engine which the post process will be applied. (default: current engine)
  70567. * @param reusable If the post process can be reused on the same frame. (default: false)
  70568. * @param textureType Type of textures used when performing the post process. (default: 0)
  70569. * @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)
  70570. */
  70571. 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);
  70572. /**
  70573. * Updates the effect with the current post process compile time values and recompiles the shader.
  70574. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70575. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70576. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70577. * @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
  70578. * @param onCompiled Called when the shader has been compiled.
  70579. * @param onError Called if there is an error when compiling a shader.
  70580. */
  70581. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70582. }
  70583. }
  70584. declare module BABYLON {
  70585. /**
  70586. * Specifies the level of max blur that should be applied when using the depth of field effect
  70587. */
  70588. export enum DepthOfFieldEffectBlurLevel {
  70589. /**
  70590. * Subtle blur
  70591. */
  70592. Low = 0,
  70593. /**
  70594. * Medium blur
  70595. */
  70596. Medium = 1,
  70597. /**
  70598. * Large blur
  70599. */
  70600. High = 2
  70601. }
  70602. /**
  70603. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70604. */
  70605. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70606. private _circleOfConfusion;
  70607. /**
  70608. * @hidden Internal, blurs from high to low
  70609. */
  70610. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70611. private _depthOfFieldBlurY;
  70612. private _dofMerge;
  70613. /**
  70614. * @hidden Internal post processes in depth of field effect
  70615. */
  70616. _effects: Array<PostProcess>;
  70617. /**
  70618. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70619. */
  70620. set focalLength(value: number);
  70621. get focalLength(): number;
  70622. /**
  70623. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70624. */
  70625. set fStop(value: number);
  70626. get fStop(): number;
  70627. /**
  70628. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70629. */
  70630. set focusDistance(value: number);
  70631. get focusDistance(): number;
  70632. /**
  70633. * 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.
  70634. */
  70635. set lensSize(value: number);
  70636. get lensSize(): number;
  70637. /**
  70638. * Creates a new instance DepthOfFieldEffect
  70639. * @param scene The scene the effect belongs to.
  70640. * @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.
  70641. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70642. * @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)
  70643. */
  70644. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70645. /**
  70646. * Get the current class name of the current effet
  70647. * @returns "DepthOfFieldEffect"
  70648. */
  70649. getClassName(): string;
  70650. /**
  70651. * 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.
  70652. */
  70653. set depthTexture(value: RenderTargetTexture);
  70654. /**
  70655. * Disposes each of the internal effects for a given camera.
  70656. * @param camera The camera to dispose the effect on.
  70657. */
  70658. disposeEffects(camera: Camera): void;
  70659. /**
  70660. * @hidden Internal
  70661. */
  70662. _updateEffects(): void;
  70663. /**
  70664. * Internal
  70665. * @returns if all the contained post processes are ready.
  70666. * @hidden
  70667. */
  70668. _isReady(): boolean;
  70669. }
  70670. }
  70671. declare module BABYLON {
  70672. /** @hidden */
  70673. export var displayPassPixelShader: {
  70674. name: string;
  70675. shader: string;
  70676. };
  70677. }
  70678. declare module BABYLON {
  70679. /**
  70680. * DisplayPassPostProcess which produces an output the same as it's input
  70681. */
  70682. export class DisplayPassPostProcess extends PostProcess {
  70683. /**
  70684. * Gets a string identifying the name of the class
  70685. * @returns "DisplayPassPostProcess" string
  70686. */
  70687. getClassName(): string;
  70688. /**
  70689. * Creates the DisplayPassPostProcess
  70690. * @param name The name of the effect.
  70691. * @param options The required width/height ratio to downsize to before computing the render pass.
  70692. * @param camera The camera to apply the render pass to.
  70693. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70694. * @param engine The engine which the post process will be applied. (default: current engine)
  70695. * @param reusable If the post process can be reused on the same frame. (default: false)
  70696. */
  70697. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70698. /** @hidden */
  70699. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  70700. }
  70701. }
  70702. declare module BABYLON {
  70703. /** @hidden */
  70704. export var filterPixelShader: {
  70705. name: string;
  70706. shader: string;
  70707. };
  70708. }
  70709. declare module BABYLON {
  70710. /**
  70711. * Applies a kernel filter to the image
  70712. */
  70713. export class FilterPostProcess extends PostProcess {
  70714. /** The matrix to be applied to the image */
  70715. kernelMatrix: Matrix;
  70716. /**
  70717. * Gets a string identifying the name of the class
  70718. * @returns "FilterPostProcess" string
  70719. */
  70720. getClassName(): string;
  70721. /**
  70722. *
  70723. * @param name The name of the effect.
  70724. * @param kernelMatrix The matrix to be applied to the image
  70725. * @param options The required width/height ratio to downsize to before computing the render pass.
  70726. * @param camera The camera to apply the render pass to.
  70727. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70728. * @param engine The engine which the post process will be applied. (default: current engine)
  70729. * @param reusable If the post process can be reused on the same frame. (default: false)
  70730. */
  70731. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70732. /** @hidden */
  70733. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  70734. }
  70735. }
  70736. declare module BABYLON {
  70737. /** @hidden */
  70738. export var fxaaPixelShader: {
  70739. name: string;
  70740. shader: string;
  70741. };
  70742. }
  70743. declare module BABYLON {
  70744. /** @hidden */
  70745. export var fxaaVertexShader: {
  70746. name: string;
  70747. shader: string;
  70748. };
  70749. }
  70750. declare module BABYLON {
  70751. /**
  70752. * Fxaa post process
  70753. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70754. */
  70755. export class FxaaPostProcess extends PostProcess {
  70756. /**
  70757. * Gets a string identifying the name of the class
  70758. * @returns "FxaaPostProcess" string
  70759. */
  70760. getClassName(): string;
  70761. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70762. private _getDefines;
  70763. /** @hidden */
  70764. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  70765. }
  70766. }
  70767. declare module BABYLON {
  70768. /** @hidden */
  70769. export var grainPixelShader: {
  70770. name: string;
  70771. shader: string;
  70772. };
  70773. }
  70774. declare module BABYLON {
  70775. /**
  70776. * The GrainPostProcess adds noise to the image at mid luminance levels
  70777. */
  70778. export class GrainPostProcess extends PostProcess {
  70779. /**
  70780. * The intensity of the grain added (default: 30)
  70781. */
  70782. intensity: number;
  70783. /**
  70784. * If the grain should be randomized on every frame
  70785. */
  70786. animated: boolean;
  70787. /**
  70788. * Gets a string identifying the name of the class
  70789. * @returns "GrainPostProcess" string
  70790. */
  70791. getClassName(): string;
  70792. /**
  70793. * Creates a new instance of @see GrainPostProcess
  70794. * @param name The name of the effect.
  70795. * @param options The required width/height ratio to downsize to before computing the render pass.
  70796. * @param camera The camera to apply the render pass to.
  70797. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70798. * @param engine The engine which the post process will be applied. (default: current engine)
  70799. * @param reusable If the post process can be reused on the same frame. (default: false)
  70800. * @param textureType Type of textures used when performing the post process. (default: 0)
  70801. * @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)
  70802. */
  70803. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70804. /** @hidden */
  70805. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  70806. }
  70807. }
  70808. declare module BABYLON {
  70809. /** @hidden */
  70810. export var highlightsPixelShader: {
  70811. name: string;
  70812. shader: string;
  70813. };
  70814. }
  70815. declare module BABYLON {
  70816. /**
  70817. * Extracts highlights from the image
  70818. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70819. */
  70820. export class HighlightsPostProcess extends PostProcess {
  70821. /**
  70822. * Gets a string identifying the name of the class
  70823. * @returns "HighlightsPostProcess" string
  70824. */
  70825. getClassName(): string;
  70826. /**
  70827. * Extracts highlights from the image
  70828. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70829. * @param name The name of the effect.
  70830. * @param options The required width/height ratio to downsize to before computing the render pass.
  70831. * @param camera The camera to apply the render pass to.
  70832. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70833. * @param engine The engine which the post process will be applied. (default: current engine)
  70834. * @param reusable If the post process can be reused on the same frame. (default: false)
  70835. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70836. */
  70837. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70838. }
  70839. }
  70840. declare module BABYLON {
  70841. /**
  70842. * Contains all parameters needed for the prepass to perform
  70843. * motion blur
  70844. */
  70845. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  70846. /**
  70847. * Is motion blur enabled
  70848. */
  70849. enabled: boolean;
  70850. /**
  70851. * Name of the configuration
  70852. */
  70853. name: string;
  70854. /**
  70855. * Textures that should be present in the MRT for this effect to work
  70856. */
  70857. readonly texturesRequired: number[];
  70858. }
  70859. }
  70860. declare module BABYLON {
  70861. interface Scene {
  70862. /** @hidden (Backing field) */
  70863. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70864. /**
  70865. * Gets or Sets the current geometry buffer associated to the scene.
  70866. */
  70867. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70868. /**
  70869. * Enables a GeometryBufferRender and associates it with the scene
  70870. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70871. * @returns the GeometryBufferRenderer
  70872. */
  70873. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70874. /**
  70875. * Disables the GeometryBufferRender associated with the scene
  70876. */
  70877. disableGeometryBufferRenderer(): void;
  70878. }
  70879. /**
  70880. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70881. * in several rendering techniques.
  70882. */
  70883. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70884. /**
  70885. * The component name helpful to identify the component in the list of scene components.
  70886. */
  70887. readonly name: string;
  70888. /**
  70889. * The scene the component belongs to.
  70890. */
  70891. scene: Scene;
  70892. /**
  70893. * Creates a new instance of the component for the given scene
  70894. * @param scene Defines the scene to register the component in
  70895. */
  70896. constructor(scene: Scene);
  70897. /**
  70898. * Registers the component in a given scene
  70899. */
  70900. register(): void;
  70901. /**
  70902. * Rebuilds the elements related to this component in case of
  70903. * context lost for instance.
  70904. */
  70905. rebuild(): void;
  70906. /**
  70907. * Disposes the component and the associated ressources
  70908. */
  70909. dispose(): void;
  70910. private _gatherRenderTargets;
  70911. }
  70912. }
  70913. declare module BABYLON {
  70914. /** @hidden */
  70915. export var motionBlurPixelShader: {
  70916. name: string;
  70917. shader: string;
  70918. };
  70919. }
  70920. declare module BABYLON {
  70921. /**
  70922. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70923. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70924. * As an example, all you have to do is to create the post-process:
  70925. * var mb = new BABYLON.MotionBlurPostProcess(
  70926. * 'mb', // The name of the effect.
  70927. * scene, // The scene containing the objects to blur according to their velocity.
  70928. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70929. * camera // The camera to apply the render pass to.
  70930. * );
  70931. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70932. */
  70933. export class MotionBlurPostProcess extends PostProcess {
  70934. /**
  70935. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70936. */
  70937. motionStrength: number;
  70938. /**
  70939. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70940. */
  70941. get motionBlurSamples(): number;
  70942. /**
  70943. * Sets the number of iterations to be used for motion blur quality
  70944. */
  70945. set motionBlurSamples(samples: number);
  70946. private _motionBlurSamples;
  70947. private _forceGeometryBuffer;
  70948. private _geometryBufferRenderer;
  70949. private _prePassRenderer;
  70950. /**
  70951. * Gets a string identifying the name of the class
  70952. * @returns "MotionBlurPostProcess" string
  70953. */
  70954. getClassName(): string;
  70955. /**
  70956. * Creates a new instance MotionBlurPostProcess
  70957. * @param name The name of the effect.
  70958. * @param scene The scene containing the objects to blur according to their velocity.
  70959. * @param options The required width/height ratio to downsize to before computing the render pass.
  70960. * @param camera The camera to apply the render pass to.
  70961. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70962. * @param engine The engine which the post process will be applied. (default: current engine)
  70963. * @param reusable If the post process can be reused on the same frame. (default: false)
  70964. * @param textureType Type of textures used when performing the post process. (default: 0)
  70965. * @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)
  70966. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  70967. */
  70968. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  70969. /**
  70970. * Excludes the given skinned mesh from computing bones velocities.
  70971. * 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.
  70972. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70973. */
  70974. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70975. /**
  70976. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70977. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70978. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70979. */
  70980. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70981. /**
  70982. * Disposes the post process.
  70983. * @param camera The camera to dispose the post process on.
  70984. */
  70985. dispose(camera?: Camera): void;
  70986. /** @hidden */
  70987. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70988. }
  70989. }
  70990. declare module BABYLON {
  70991. /** @hidden */
  70992. export var refractionPixelShader: {
  70993. name: string;
  70994. shader: string;
  70995. };
  70996. }
  70997. declare module BABYLON {
  70998. /**
  70999. * Post process which applies a refractin texture
  71000. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71001. */
  71002. export class RefractionPostProcess extends PostProcess {
  71003. private _refTexture;
  71004. private _ownRefractionTexture;
  71005. /** the base color of the refraction (used to taint the rendering) */
  71006. color: Color3;
  71007. /** simulated refraction depth */
  71008. depth: number;
  71009. /** the coefficient of the base color (0 to remove base color tainting) */
  71010. colorLevel: number;
  71011. /** Gets the url used to load the refraction texture */
  71012. refractionTextureUrl: string;
  71013. /**
  71014. * Gets or sets the refraction texture
  71015. * Please note that you are responsible for disposing the texture if you set it manually
  71016. */
  71017. get refractionTexture(): Texture;
  71018. set refractionTexture(value: Texture);
  71019. /**
  71020. * Gets a string identifying the name of the class
  71021. * @returns "RefractionPostProcess" string
  71022. */
  71023. getClassName(): string;
  71024. /**
  71025. * Initializes the RefractionPostProcess
  71026. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71027. * @param name The name of the effect.
  71028. * @param refractionTextureUrl Url of the refraction texture to use
  71029. * @param color the base color of the refraction (used to taint the rendering)
  71030. * @param depth simulated refraction depth
  71031. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71032. * @param camera The camera to apply the render pass to.
  71033. * @param options The required width/height ratio to downsize to before computing the render pass.
  71034. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71035. * @param engine The engine which the post process will be applied. (default: current engine)
  71036. * @param reusable If the post process can be reused on the same frame. (default: false)
  71037. */
  71038. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71039. /**
  71040. * Disposes of the post process
  71041. * @param camera Camera to dispose post process on
  71042. */
  71043. dispose(camera: Camera): void;
  71044. /** @hidden */
  71045. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  71046. }
  71047. }
  71048. declare module BABYLON {
  71049. /** @hidden */
  71050. export var sharpenPixelShader: {
  71051. name: string;
  71052. shader: string;
  71053. };
  71054. }
  71055. declare module BABYLON {
  71056. /**
  71057. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71058. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71059. */
  71060. export class SharpenPostProcess extends PostProcess {
  71061. /**
  71062. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71063. */
  71064. colorAmount: number;
  71065. /**
  71066. * How much sharpness should be applied (default: 0.3)
  71067. */
  71068. edgeAmount: number;
  71069. /**
  71070. * Gets a string identifying the name of the class
  71071. * @returns "SharpenPostProcess" string
  71072. */
  71073. getClassName(): string;
  71074. /**
  71075. * Creates a new instance ConvolutionPostProcess
  71076. * @param name The name of the effect.
  71077. * @param options The required width/height ratio to downsize to before computing the render pass.
  71078. * @param camera The camera to apply the render pass to.
  71079. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71080. * @param engine The engine which the post process will be applied. (default: current engine)
  71081. * @param reusable If the post process can be reused on the same frame. (default: false)
  71082. * @param textureType Type of textures used when performing the post process. (default: 0)
  71083. * @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)
  71084. */
  71085. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71086. /** @hidden */
  71087. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  71088. }
  71089. }
  71090. declare module BABYLON {
  71091. /**
  71092. * PostProcessRenderPipeline
  71093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71094. */
  71095. export class PostProcessRenderPipeline {
  71096. private engine;
  71097. private _renderEffects;
  71098. private _renderEffectsForIsolatedPass;
  71099. /**
  71100. * List of inspectable custom properties (used by the Inspector)
  71101. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71102. */
  71103. inspectableCustomProperties: IInspectable[];
  71104. /**
  71105. * @hidden
  71106. */
  71107. protected _cameras: Camera[];
  71108. /** @hidden */
  71109. _name: string;
  71110. /**
  71111. * Gets pipeline name
  71112. */
  71113. get name(): string;
  71114. /** Gets the list of attached cameras */
  71115. get cameras(): Camera[];
  71116. /**
  71117. * Initializes a PostProcessRenderPipeline
  71118. * @param engine engine to add the pipeline to
  71119. * @param name name of the pipeline
  71120. */
  71121. constructor(engine: Engine, name: string);
  71122. /**
  71123. * Gets the class name
  71124. * @returns "PostProcessRenderPipeline"
  71125. */
  71126. getClassName(): string;
  71127. /**
  71128. * If all the render effects in the pipeline are supported
  71129. */
  71130. get isSupported(): boolean;
  71131. /**
  71132. * Adds an effect to the pipeline
  71133. * @param renderEffect the effect to add
  71134. */
  71135. addEffect(renderEffect: PostProcessRenderEffect): void;
  71136. /** @hidden */
  71137. _rebuild(): void;
  71138. /** @hidden */
  71139. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71140. /** @hidden */
  71141. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71142. /** @hidden */
  71143. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71144. /** @hidden */
  71145. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71146. /** @hidden */
  71147. _attachCameras(cameras: Camera, unique: boolean): void;
  71148. /** @hidden */
  71149. _attachCameras(cameras: Camera[], unique: boolean): void;
  71150. /** @hidden */
  71151. _detachCameras(cameras: Camera): void;
  71152. /** @hidden */
  71153. _detachCameras(cameras: Nullable<Camera[]>): void;
  71154. /** @hidden */
  71155. _update(): void;
  71156. /** @hidden */
  71157. _reset(): void;
  71158. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71159. /**
  71160. * Sets the required values to the prepass renderer.
  71161. * @param prePassRenderer defines the prepass renderer to setup.
  71162. * @returns true if the pre pass is needed.
  71163. */
  71164. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71165. /**
  71166. * Disposes of the pipeline
  71167. */
  71168. dispose(): void;
  71169. }
  71170. }
  71171. declare module BABYLON {
  71172. /**
  71173. * PostProcessRenderPipelineManager class
  71174. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71175. */
  71176. export class PostProcessRenderPipelineManager {
  71177. private _renderPipelines;
  71178. /**
  71179. * Initializes a PostProcessRenderPipelineManager
  71180. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71181. */
  71182. constructor();
  71183. /**
  71184. * Gets the list of supported render pipelines
  71185. */
  71186. get supportedPipelines(): PostProcessRenderPipeline[];
  71187. /**
  71188. * Adds a pipeline to the manager
  71189. * @param renderPipeline The pipeline to add
  71190. */
  71191. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71192. /**
  71193. * Attaches a camera to the pipeline
  71194. * @param renderPipelineName The name of the pipeline to attach to
  71195. * @param cameras the camera to attach
  71196. * @param unique if the camera can be attached multiple times to the pipeline
  71197. */
  71198. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71199. /**
  71200. * Detaches a camera from the pipeline
  71201. * @param renderPipelineName The name of the pipeline to detach from
  71202. * @param cameras the camera to detach
  71203. */
  71204. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71205. /**
  71206. * Enables an effect by name on a pipeline
  71207. * @param renderPipelineName the name of the pipeline to enable the effect in
  71208. * @param renderEffectName the name of the effect to enable
  71209. * @param cameras the cameras that the effect should be enabled on
  71210. */
  71211. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71212. /**
  71213. * Disables an effect by name on a pipeline
  71214. * @param renderPipelineName the name of the pipeline to disable the effect in
  71215. * @param renderEffectName the name of the effect to disable
  71216. * @param cameras the cameras that the effect should be disabled on
  71217. */
  71218. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71219. /**
  71220. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71221. */
  71222. update(): void;
  71223. /** @hidden */
  71224. _rebuild(): void;
  71225. /**
  71226. * Disposes of the manager and pipelines
  71227. */
  71228. dispose(): void;
  71229. }
  71230. }
  71231. declare module BABYLON {
  71232. interface Scene {
  71233. /** @hidden (Backing field) */
  71234. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71235. /**
  71236. * Gets the postprocess render pipeline manager
  71237. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71238. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71239. */
  71240. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71241. }
  71242. /**
  71243. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71244. */
  71245. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71246. /**
  71247. * The component name helpfull to identify the component in the list of scene components.
  71248. */
  71249. readonly name: string;
  71250. /**
  71251. * The scene the component belongs to.
  71252. */
  71253. scene: Scene;
  71254. /**
  71255. * Creates a new instance of the component for the given scene
  71256. * @param scene Defines the scene to register the component in
  71257. */
  71258. constructor(scene: Scene);
  71259. /**
  71260. * Registers the component in a given scene
  71261. */
  71262. register(): void;
  71263. /**
  71264. * Rebuilds the elements related to this component in case of
  71265. * context lost for instance.
  71266. */
  71267. rebuild(): void;
  71268. /**
  71269. * Disposes the component and the associated ressources
  71270. */
  71271. dispose(): void;
  71272. private _gatherRenderTargets;
  71273. }
  71274. }
  71275. declare module BABYLON {
  71276. /**
  71277. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71278. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71279. */
  71280. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71281. private _scene;
  71282. private _camerasToBeAttached;
  71283. /**
  71284. * ID of the sharpen post process,
  71285. */
  71286. private readonly SharpenPostProcessId;
  71287. /**
  71288. * @ignore
  71289. * ID of the image processing post process;
  71290. */
  71291. readonly ImageProcessingPostProcessId: string;
  71292. /**
  71293. * @ignore
  71294. * ID of the Fast Approximate Anti-Aliasing post process;
  71295. */
  71296. readonly FxaaPostProcessId: string;
  71297. /**
  71298. * ID of the chromatic aberration post process,
  71299. */
  71300. private readonly ChromaticAberrationPostProcessId;
  71301. /**
  71302. * ID of the grain post process
  71303. */
  71304. private readonly GrainPostProcessId;
  71305. /**
  71306. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71307. */
  71308. sharpen: SharpenPostProcess;
  71309. private _sharpenEffect;
  71310. private bloom;
  71311. /**
  71312. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71313. */
  71314. depthOfField: DepthOfFieldEffect;
  71315. /**
  71316. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71317. */
  71318. fxaa: FxaaPostProcess;
  71319. /**
  71320. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71321. */
  71322. imageProcessing: ImageProcessingPostProcess;
  71323. /**
  71324. * Chromatic aberration post process which will shift rgb colors in the image
  71325. */
  71326. chromaticAberration: ChromaticAberrationPostProcess;
  71327. private _chromaticAberrationEffect;
  71328. /**
  71329. * Grain post process which add noise to the image
  71330. */
  71331. grain: GrainPostProcess;
  71332. private _grainEffect;
  71333. /**
  71334. * Glow post process which adds a glow to emissive areas of the image
  71335. */
  71336. private _glowLayer;
  71337. /**
  71338. * Animations which can be used to tweak settings over a period of time
  71339. */
  71340. animations: Animation[];
  71341. private _imageProcessingConfigurationObserver;
  71342. private _sharpenEnabled;
  71343. private _bloomEnabled;
  71344. private _depthOfFieldEnabled;
  71345. private _depthOfFieldBlurLevel;
  71346. private _fxaaEnabled;
  71347. private _imageProcessingEnabled;
  71348. private _defaultPipelineTextureType;
  71349. private _bloomScale;
  71350. private _chromaticAberrationEnabled;
  71351. private _grainEnabled;
  71352. private _buildAllowed;
  71353. /**
  71354. * Gets active scene
  71355. */
  71356. get scene(): Scene;
  71357. /**
  71358. * Enable or disable the sharpen process from the pipeline
  71359. */
  71360. set sharpenEnabled(enabled: boolean);
  71361. get sharpenEnabled(): boolean;
  71362. private _resizeObserver;
  71363. private _hardwareScaleLevel;
  71364. private _bloomKernel;
  71365. /**
  71366. * Specifies the size of the bloom blur kernel, relative to the final output size
  71367. */
  71368. get bloomKernel(): number;
  71369. set bloomKernel(value: number);
  71370. /**
  71371. * Specifies the weight of the bloom in the final rendering
  71372. */
  71373. private _bloomWeight;
  71374. /**
  71375. * Specifies the luma threshold for the area that will be blurred by the bloom
  71376. */
  71377. private _bloomThreshold;
  71378. private _hdr;
  71379. /**
  71380. * The strength of the bloom.
  71381. */
  71382. set bloomWeight(value: number);
  71383. get bloomWeight(): number;
  71384. /**
  71385. * The strength of the bloom.
  71386. */
  71387. set bloomThreshold(value: number);
  71388. get bloomThreshold(): number;
  71389. /**
  71390. * The scale of the bloom, lower value will provide better performance.
  71391. */
  71392. set bloomScale(value: number);
  71393. get bloomScale(): number;
  71394. /**
  71395. * Enable or disable the bloom from the pipeline
  71396. */
  71397. set bloomEnabled(enabled: boolean);
  71398. get bloomEnabled(): boolean;
  71399. private _rebuildBloom;
  71400. /**
  71401. * If the depth of field is enabled.
  71402. */
  71403. get depthOfFieldEnabled(): boolean;
  71404. set depthOfFieldEnabled(enabled: boolean);
  71405. /**
  71406. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71407. */
  71408. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71409. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71410. /**
  71411. * If the anti aliasing is enabled.
  71412. */
  71413. set fxaaEnabled(enabled: boolean);
  71414. get fxaaEnabled(): boolean;
  71415. private _samples;
  71416. /**
  71417. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71418. */
  71419. set samples(sampleCount: number);
  71420. get samples(): number;
  71421. /**
  71422. * If image processing is enabled.
  71423. */
  71424. set imageProcessingEnabled(enabled: boolean);
  71425. get imageProcessingEnabled(): boolean;
  71426. /**
  71427. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71428. */
  71429. set glowLayerEnabled(enabled: boolean);
  71430. get glowLayerEnabled(): boolean;
  71431. /**
  71432. * Gets the glow layer (or null if not defined)
  71433. */
  71434. get glowLayer(): Nullable<GlowLayer>;
  71435. /**
  71436. * Enable or disable the chromaticAberration process from the pipeline
  71437. */
  71438. set chromaticAberrationEnabled(enabled: boolean);
  71439. get chromaticAberrationEnabled(): boolean;
  71440. /**
  71441. * Enable or disable the grain process from the pipeline
  71442. */
  71443. set grainEnabled(enabled: boolean);
  71444. get grainEnabled(): boolean;
  71445. /**
  71446. * @constructor
  71447. * @param name - The rendering pipeline name (default: "")
  71448. * @param hdr - If high dynamic range textures should be used (default: true)
  71449. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71450. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71451. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71452. */
  71453. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71454. /**
  71455. * Get the class name
  71456. * @returns "DefaultRenderingPipeline"
  71457. */
  71458. getClassName(): string;
  71459. /**
  71460. * Force the compilation of the entire pipeline.
  71461. */
  71462. prepare(): void;
  71463. private _hasCleared;
  71464. private _prevPostProcess;
  71465. private _prevPrevPostProcess;
  71466. private _setAutoClearAndTextureSharing;
  71467. private _depthOfFieldSceneObserver;
  71468. private _buildPipeline;
  71469. private _disposePostProcesses;
  71470. /**
  71471. * Adds a camera to the pipeline
  71472. * @param camera the camera to be added
  71473. */
  71474. addCamera(camera: Camera): void;
  71475. /**
  71476. * Removes a camera from the pipeline
  71477. * @param camera the camera to remove
  71478. */
  71479. removeCamera(camera: Camera): void;
  71480. /**
  71481. * Dispose of the pipeline and stop all post processes
  71482. */
  71483. dispose(): void;
  71484. /**
  71485. * Serialize the rendering pipeline (Used when exporting)
  71486. * @returns the serialized object
  71487. */
  71488. serialize(): any;
  71489. /**
  71490. * Parse the serialized pipeline
  71491. * @param source Source pipeline.
  71492. * @param scene The scene to load the pipeline to.
  71493. * @param rootUrl The URL of the serialized pipeline.
  71494. * @returns An instantiated pipeline from the serialized object.
  71495. */
  71496. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71497. }
  71498. }
  71499. declare module BABYLON {
  71500. /** @hidden */
  71501. export var lensHighlightsPixelShader: {
  71502. name: string;
  71503. shader: string;
  71504. };
  71505. }
  71506. declare module BABYLON {
  71507. /** @hidden */
  71508. export var depthOfFieldPixelShader: {
  71509. name: string;
  71510. shader: string;
  71511. };
  71512. }
  71513. declare module BABYLON {
  71514. /**
  71515. * BABYLON.JS Chromatic Aberration GLSL Shader
  71516. * Author: Olivier Guyot
  71517. * Separates very slightly R, G and B colors on the edges of the screen
  71518. * Inspired by Francois Tarlier & Martins Upitis
  71519. */
  71520. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71521. /**
  71522. * @ignore
  71523. * The chromatic aberration PostProcess id in the pipeline
  71524. */
  71525. LensChromaticAberrationEffect: string;
  71526. /**
  71527. * @ignore
  71528. * The highlights enhancing PostProcess id in the pipeline
  71529. */
  71530. HighlightsEnhancingEffect: string;
  71531. /**
  71532. * @ignore
  71533. * The depth-of-field PostProcess id in the pipeline
  71534. */
  71535. LensDepthOfFieldEffect: string;
  71536. private _scene;
  71537. private _depthTexture;
  71538. private _grainTexture;
  71539. private _chromaticAberrationPostProcess;
  71540. private _highlightsPostProcess;
  71541. private _depthOfFieldPostProcess;
  71542. private _edgeBlur;
  71543. private _grainAmount;
  71544. private _chromaticAberration;
  71545. private _distortion;
  71546. private _highlightsGain;
  71547. private _highlightsThreshold;
  71548. private _dofDistance;
  71549. private _dofAperture;
  71550. private _dofDarken;
  71551. private _dofPentagon;
  71552. private _blurNoise;
  71553. /**
  71554. * @constructor
  71555. *
  71556. * Effect parameters are as follow:
  71557. * {
  71558. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71559. * edge_blur: number; // from 0 to x (1 for realism)
  71560. * distortion: number; // from 0 to x (1 for realism)
  71561. * grain_amount: number; // from 0 to 1
  71562. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71563. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71564. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71565. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71566. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71567. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71568. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71569. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71570. * }
  71571. * Note: if an effect parameter is unset, effect is disabled
  71572. *
  71573. * @param name The rendering pipeline name
  71574. * @param parameters - An object containing all parameters (see above)
  71575. * @param scene The scene linked to this pipeline
  71576. * @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)
  71577. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71578. */
  71579. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71580. /**
  71581. * Get the class name
  71582. * @returns "LensRenderingPipeline"
  71583. */
  71584. getClassName(): string;
  71585. /**
  71586. * Gets associated scene
  71587. */
  71588. get scene(): Scene;
  71589. /**
  71590. * Gets or sets the edge blur
  71591. */
  71592. get edgeBlur(): number;
  71593. set edgeBlur(value: number);
  71594. /**
  71595. * Gets or sets the grain amount
  71596. */
  71597. get grainAmount(): number;
  71598. set grainAmount(value: number);
  71599. /**
  71600. * Gets or sets the chromatic aberration amount
  71601. */
  71602. get chromaticAberration(): number;
  71603. set chromaticAberration(value: number);
  71604. /**
  71605. * Gets or sets the depth of field aperture
  71606. */
  71607. get dofAperture(): number;
  71608. set dofAperture(value: number);
  71609. /**
  71610. * Gets or sets the edge distortion
  71611. */
  71612. get edgeDistortion(): number;
  71613. set edgeDistortion(value: number);
  71614. /**
  71615. * Gets or sets the depth of field distortion
  71616. */
  71617. get dofDistortion(): number;
  71618. set dofDistortion(value: number);
  71619. /**
  71620. * Gets or sets the darken out of focus amount
  71621. */
  71622. get darkenOutOfFocus(): number;
  71623. set darkenOutOfFocus(value: number);
  71624. /**
  71625. * Gets or sets a boolean indicating if blur noise is enabled
  71626. */
  71627. get blurNoise(): boolean;
  71628. set blurNoise(value: boolean);
  71629. /**
  71630. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71631. */
  71632. get pentagonBokeh(): boolean;
  71633. set pentagonBokeh(value: boolean);
  71634. /**
  71635. * Gets or sets the highlight grain amount
  71636. */
  71637. get highlightsGain(): number;
  71638. set highlightsGain(value: number);
  71639. /**
  71640. * Gets or sets the highlight threshold
  71641. */
  71642. get highlightsThreshold(): number;
  71643. set highlightsThreshold(value: number);
  71644. /**
  71645. * Sets the amount of blur at the edges
  71646. * @param amount blur amount
  71647. */
  71648. setEdgeBlur(amount: number): void;
  71649. /**
  71650. * Sets edge blur to 0
  71651. */
  71652. disableEdgeBlur(): void;
  71653. /**
  71654. * Sets the amout of grain
  71655. * @param amount Amount of grain
  71656. */
  71657. setGrainAmount(amount: number): void;
  71658. /**
  71659. * Set grain amount to 0
  71660. */
  71661. disableGrain(): void;
  71662. /**
  71663. * Sets the chromatic aberration amount
  71664. * @param amount amount of chromatic aberration
  71665. */
  71666. setChromaticAberration(amount: number): void;
  71667. /**
  71668. * Sets chromatic aberration amount to 0
  71669. */
  71670. disableChromaticAberration(): void;
  71671. /**
  71672. * Sets the EdgeDistortion amount
  71673. * @param amount amount of EdgeDistortion
  71674. */
  71675. setEdgeDistortion(amount: number): void;
  71676. /**
  71677. * Sets edge distortion to 0
  71678. */
  71679. disableEdgeDistortion(): void;
  71680. /**
  71681. * Sets the FocusDistance amount
  71682. * @param amount amount of FocusDistance
  71683. */
  71684. setFocusDistance(amount: number): void;
  71685. /**
  71686. * Disables depth of field
  71687. */
  71688. disableDepthOfField(): void;
  71689. /**
  71690. * Sets the Aperture amount
  71691. * @param amount amount of Aperture
  71692. */
  71693. setAperture(amount: number): void;
  71694. /**
  71695. * Sets the DarkenOutOfFocus amount
  71696. * @param amount amount of DarkenOutOfFocus
  71697. */
  71698. setDarkenOutOfFocus(amount: number): void;
  71699. private _pentagonBokehIsEnabled;
  71700. /**
  71701. * Creates a pentagon bokeh effect
  71702. */
  71703. enablePentagonBokeh(): void;
  71704. /**
  71705. * Disables the pentagon bokeh effect
  71706. */
  71707. disablePentagonBokeh(): void;
  71708. /**
  71709. * Enables noise blur
  71710. */
  71711. enableNoiseBlur(): void;
  71712. /**
  71713. * Disables noise blur
  71714. */
  71715. disableNoiseBlur(): void;
  71716. /**
  71717. * Sets the HighlightsGain amount
  71718. * @param amount amount of HighlightsGain
  71719. */
  71720. setHighlightsGain(amount: number): void;
  71721. /**
  71722. * Sets the HighlightsThreshold amount
  71723. * @param amount amount of HighlightsThreshold
  71724. */
  71725. setHighlightsThreshold(amount: number): void;
  71726. /**
  71727. * Disables highlights
  71728. */
  71729. disableHighlights(): void;
  71730. /**
  71731. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71732. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71733. */
  71734. dispose(disableDepthRender?: boolean): void;
  71735. private _createChromaticAberrationPostProcess;
  71736. private _createHighlightsPostProcess;
  71737. private _createDepthOfFieldPostProcess;
  71738. private _createGrainTexture;
  71739. }
  71740. }
  71741. declare module BABYLON {
  71742. /**
  71743. * Contains all parameters needed for the prepass to perform
  71744. * screen space subsurface scattering
  71745. */
  71746. export class SSAO2Configuration implements PrePassEffectConfiguration {
  71747. /**
  71748. * Is subsurface enabled
  71749. */
  71750. enabled: boolean;
  71751. /**
  71752. * Name of the configuration
  71753. */
  71754. name: string;
  71755. /**
  71756. * Textures that should be present in the MRT for this effect to work
  71757. */
  71758. readonly texturesRequired: number[];
  71759. }
  71760. }
  71761. declare module BABYLON {
  71762. /** @hidden */
  71763. export var ssao2PixelShader: {
  71764. name: string;
  71765. shader: string;
  71766. };
  71767. }
  71768. declare module BABYLON {
  71769. /** @hidden */
  71770. export var ssaoCombinePixelShader: {
  71771. name: string;
  71772. shader: string;
  71773. };
  71774. }
  71775. declare module BABYLON {
  71776. /**
  71777. * Render pipeline to produce ssao effect
  71778. */
  71779. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71780. /**
  71781. * @ignore
  71782. * The PassPostProcess id in the pipeline that contains the original scene color
  71783. */
  71784. SSAOOriginalSceneColorEffect: string;
  71785. /**
  71786. * @ignore
  71787. * The SSAO PostProcess id in the pipeline
  71788. */
  71789. SSAORenderEffect: string;
  71790. /**
  71791. * @ignore
  71792. * The horizontal blur PostProcess id in the pipeline
  71793. */
  71794. SSAOBlurHRenderEffect: string;
  71795. /**
  71796. * @ignore
  71797. * The vertical blur PostProcess id in the pipeline
  71798. */
  71799. SSAOBlurVRenderEffect: string;
  71800. /**
  71801. * @ignore
  71802. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71803. */
  71804. SSAOCombineRenderEffect: string;
  71805. /**
  71806. * The output strength of the SSAO post-process. Default value is 1.0.
  71807. */
  71808. totalStrength: number;
  71809. /**
  71810. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71811. */
  71812. maxZ: number;
  71813. /**
  71814. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71815. */
  71816. minZAspect: number;
  71817. private _samples;
  71818. /**
  71819. * Number of samples used for the SSAO calculations. Default value is 8
  71820. */
  71821. set samples(n: number);
  71822. get samples(): number;
  71823. private _textureSamples;
  71824. /**
  71825. * Number of samples to use for antialiasing
  71826. */
  71827. set textureSamples(n: number);
  71828. get textureSamples(): number;
  71829. /**
  71830. * Force rendering the geometry through geometry buffer
  71831. */
  71832. private _forceGeometryBuffer;
  71833. /**
  71834. * Ratio object used for SSAO ratio and blur ratio
  71835. */
  71836. private _ratio;
  71837. /**
  71838. * Dynamically generated sphere sampler.
  71839. */
  71840. private _sampleSphere;
  71841. /**
  71842. * Blur filter offsets
  71843. */
  71844. private _samplerOffsets;
  71845. private _expensiveBlur;
  71846. /**
  71847. * If bilateral blur should be used
  71848. */
  71849. set expensiveBlur(b: boolean);
  71850. get expensiveBlur(): boolean;
  71851. /**
  71852. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71853. */
  71854. radius: number;
  71855. /**
  71856. * The base color of the SSAO post-process
  71857. * The final result is "base + ssao" between [0, 1]
  71858. */
  71859. base: number;
  71860. /**
  71861. * Support test.
  71862. */
  71863. static get IsSupported(): boolean;
  71864. private _scene;
  71865. private _randomTexture;
  71866. private _originalColorPostProcess;
  71867. private _ssaoPostProcess;
  71868. private _blurHPostProcess;
  71869. private _blurVPostProcess;
  71870. private _ssaoCombinePostProcess;
  71871. private _prePassRenderer;
  71872. /**
  71873. * Gets active scene
  71874. */
  71875. get scene(): Scene;
  71876. /**
  71877. * @constructor
  71878. * @param name The rendering pipeline name
  71879. * @param scene The scene linked to this pipeline
  71880. * @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 }
  71881. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71882. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71883. */
  71884. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71885. /**
  71886. * Get the class name
  71887. * @returns "SSAO2RenderingPipeline"
  71888. */
  71889. getClassName(): string;
  71890. /**
  71891. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71892. */
  71893. dispose(disableGeometryBufferRenderer?: boolean): void;
  71894. private _createBlurPostProcess;
  71895. /** @hidden */
  71896. _rebuild(): void;
  71897. private _bits;
  71898. private _radicalInverse_VdC;
  71899. private _hammersley;
  71900. private _hemisphereSample_uniform;
  71901. private _generateHemisphere;
  71902. private _getDefinesForSSAO;
  71903. private _createSSAOPostProcess;
  71904. private _createSSAOCombinePostProcess;
  71905. private _createRandomTexture;
  71906. /**
  71907. * Serialize the rendering pipeline (Used when exporting)
  71908. * @returns the serialized object
  71909. */
  71910. serialize(): any;
  71911. /**
  71912. * Parse the serialized pipeline
  71913. * @param source Source pipeline.
  71914. * @param scene The scene to load the pipeline to.
  71915. * @param rootUrl The URL of the serialized pipeline.
  71916. * @returns An instantiated pipeline from the serialized object.
  71917. */
  71918. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71919. }
  71920. }
  71921. declare module BABYLON {
  71922. /** @hidden */
  71923. export var ssaoPixelShader: {
  71924. name: string;
  71925. shader: string;
  71926. };
  71927. }
  71928. declare module BABYLON {
  71929. /**
  71930. * Render pipeline to produce ssao effect
  71931. */
  71932. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71933. /**
  71934. * @ignore
  71935. * The PassPostProcess id in the pipeline that contains the original scene color
  71936. */
  71937. SSAOOriginalSceneColorEffect: string;
  71938. /**
  71939. * @ignore
  71940. * The SSAO PostProcess id in the pipeline
  71941. */
  71942. SSAORenderEffect: string;
  71943. /**
  71944. * @ignore
  71945. * The horizontal blur PostProcess id in the pipeline
  71946. */
  71947. SSAOBlurHRenderEffect: string;
  71948. /**
  71949. * @ignore
  71950. * The vertical blur PostProcess id in the pipeline
  71951. */
  71952. SSAOBlurVRenderEffect: string;
  71953. /**
  71954. * @ignore
  71955. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71956. */
  71957. SSAOCombineRenderEffect: string;
  71958. /**
  71959. * The output strength of the SSAO post-process. Default value is 1.0.
  71960. */
  71961. totalStrength: number;
  71962. /**
  71963. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71964. */
  71965. radius: number;
  71966. /**
  71967. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71968. * Must not be equal to fallOff and superior to fallOff.
  71969. * Default value is 0.0075
  71970. */
  71971. area: number;
  71972. /**
  71973. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71974. * Must not be equal to area and inferior to area.
  71975. * Default value is 0.000001
  71976. */
  71977. fallOff: number;
  71978. /**
  71979. * The base color of the SSAO post-process
  71980. * The final result is "base + ssao" between [0, 1]
  71981. */
  71982. base: number;
  71983. private _scene;
  71984. private _depthTexture;
  71985. private _randomTexture;
  71986. private _originalColorPostProcess;
  71987. private _ssaoPostProcess;
  71988. private _blurHPostProcess;
  71989. private _blurVPostProcess;
  71990. private _ssaoCombinePostProcess;
  71991. private _firstUpdate;
  71992. /**
  71993. * Gets active scene
  71994. */
  71995. get scene(): Scene;
  71996. /**
  71997. * @constructor
  71998. * @param name - The rendering pipeline name
  71999. * @param scene - The scene linked to this pipeline
  72000. * @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 }
  72001. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72002. */
  72003. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72004. /**
  72005. * Get the class name
  72006. * @returns "SSAORenderingPipeline"
  72007. */
  72008. getClassName(): string;
  72009. /**
  72010. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72011. */
  72012. dispose(disableDepthRender?: boolean): void;
  72013. private _createBlurPostProcess;
  72014. /** @hidden */
  72015. _rebuild(): void;
  72016. private _createSSAOPostProcess;
  72017. private _createSSAOCombinePostProcess;
  72018. private _createRandomTexture;
  72019. }
  72020. }
  72021. declare module BABYLON {
  72022. /**
  72023. * Contains all parameters needed for the prepass to perform
  72024. * screen space reflections
  72025. */
  72026. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  72027. /**
  72028. * Is ssr enabled
  72029. */
  72030. enabled: boolean;
  72031. /**
  72032. * Name of the configuration
  72033. */
  72034. name: string;
  72035. /**
  72036. * Textures that should be present in the MRT for this effect to work
  72037. */
  72038. readonly texturesRequired: number[];
  72039. }
  72040. }
  72041. declare module BABYLON {
  72042. /** @hidden */
  72043. export var screenSpaceReflectionPixelShader: {
  72044. name: string;
  72045. shader: string;
  72046. };
  72047. }
  72048. declare module BABYLON {
  72049. /**
  72050. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72051. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72052. */
  72053. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72054. /**
  72055. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72056. */
  72057. threshold: number;
  72058. /**
  72059. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72060. */
  72061. strength: number;
  72062. /**
  72063. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72064. */
  72065. reflectionSpecularFalloffExponent: number;
  72066. /**
  72067. * 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]
  72068. */
  72069. step: number;
  72070. /**
  72071. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72072. */
  72073. roughnessFactor: number;
  72074. private _forceGeometryBuffer;
  72075. private _geometryBufferRenderer;
  72076. private _prePassRenderer;
  72077. private _enableSmoothReflections;
  72078. private _reflectionSamples;
  72079. private _smoothSteps;
  72080. /**
  72081. * Gets a string identifying the name of the class
  72082. * @returns "ScreenSpaceReflectionPostProcess" string
  72083. */
  72084. getClassName(): string;
  72085. /**
  72086. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72087. * @param name The name of the effect.
  72088. * @param scene The scene containing the objects to calculate reflections.
  72089. * @param options The required width/height ratio to downsize to before computing the render pass.
  72090. * @param camera The camera to apply the render pass to.
  72091. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72092. * @param engine The engine which the post process will be applied. (default: current engine)
  72093. * @param reusable If the post process can be reused on the same frame. (default: false)
  72094. * @param textureType Type of textures used when performing the post process. (default: 0)
  72095. * @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)
  72096. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  72097. */
  72098. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  72099. /**
  72100. * Gets wether or not smoothing reflections is enabled.
  72101. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72102. */
  72103. get enableSmoothReflections(): boolean;
  72104. /**
  72105. * Sets wether or not smoothing reflections is enabled.
  72106. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72107. */
  72108. set enableSmoothReflections(enabled: boolean);
  72109. /**
  72110. * Gets the number of samples taken while computing reflections. More samples count is high,
  72111. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72112. */
  72113. get reflectionSamples(): number;
  72114. /**
  72115. * Sets the number of samples taken while computing reflections. More samples count is high,
  72116. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72117. */
  72118. set reflectionSamples(samples: number);
  72119. /**
  72120. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72121. * more the post-process will require GPU power and can generate a drop in FPS.
  72122. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72123. */
  72124. get smoothSteps(): number;
  72125. set smoothSteps(steps: number);
  72126. private _updateEffectDefines;
  72127. /** @hidden */
  72128. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  72129. }
  72130. }
  72131. declare module BABYLON {
  72132. /** @hidden */
  72133. export var standardPixelShader: {
  72134. name: string;
  72135. shader: string;
  72136. };
  72137. }
  72138. declare module BABYLON {
  72139. /**
  72140. * Standard rendering pipeline
  72141. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72142. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72143. */
  72144. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72145. /**
  72146. * Public members
  72147. */
  72148. /**
  72149. * Post-process which contains the original scene color before the pipeline applies all the effects
  72150. */
  72151. originalPostProcess: Nullable<PostProcess>;
  72152. /**
  72153. * Post-process used to down scale an image x4
  72154. */
  72155. downSampleX4PostProcess: Nullable<PostProcess>;
  72156. /**
  72157. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72158. */
  72159. brightPassPostProcess: Nullable<PostProcess>;
  72160. /**
  72161. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72162. */
  72163. blurHPostProcesses: PostProcess[];
  72164. /**
  72165. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72166. */
  72167. blurVPostProcesses: PostProcess[];
  72168. /**
  72169. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72170. */
  72171. textureAdderPostProcess: Nullable<PostProcess>;
  72172. /**
  72173. * Post-process used to create volumetric lighting effect
  72174. */
  72175. volumetricLightPostProcess: Nullable<PostProcess>;
  72176. /**
  72177. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72178. */
  72179. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72180. /**
  72181. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72182. */
  72183. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72184. /**
  72185. * Post-process used to merge the volumetric light effect and the real scene color
  72186. */
  72187. volumetricLightMergePostProces: Nullable<PostProcess>;
  72188. /**
  72189. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72190. */
  72191. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72192. /**
  72193. * Base post-process used to calculate the average luminance of the final image for HDR
  72194. */
  72195. luminancePostProcess: Nullable<PostProcess>;
  72196. /**
  72197. * Post-processes used to create down sample post-processes in order to get
  72198. * the average luminance of the final image for HDR
  72199. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72200. */
  72201. luminanceDownSamplePostProcesses: PostProcess[];
  72202. /**
  72203. * Post-process used to create a HDR effect (light adaptation)
  72204. */
  72205. hdrPostProcess: Nullable<PostProcess>;
  72206. /**
  72207. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72208. */
  72209. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72210. /**
  72211. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72212. */
  72213. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72214. /**
  72215. * Post-process used to merge the final HDR post-process and the real scene color
  72216. */
  72217. hdrFinalPostProcess: Nullable<PostProcess>;
  72218. /**
  72219. * Post-process used to create a lens flare effect
  72220. */
  72221. lensFlarePostProcess: Nullable<PostProcess>;
  72222. /**
  72223. * Post-process that merges the result of the lens flare post-process and the real scene color
  72224. */
  72225. lensFlareComposePostProcess: Nullable<PostProcess>;
  72226. /**
  72227. * Post-process used to create a motion blur effect
  72228. */
  72229. motionBlurPostProcess: Nullable<PostProcess>;
  72230. /**
  72231. * Post-process used to create a depth of field effect
  72232. */
  72233. depthOfFieldPostProcess: Nullable<PostProcess>;
  72234. /**
  72235. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72236. */
  72237. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72238. /**
  72239. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72240. */
  72241. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72242. /**
  72243. * Represents the brightness threshold in order to configure the illuminated surfaces
  72244. */
  72245. brightThreshold: number;
  72246. /**
  72247. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72248. */
  72249. blurWidth: number;
  72250. /**
  72251. * Sets if the blur for highlighted surfaces must be only horizontal
  72252. */
  72253. horizontalBlur: boolean;
  72254. /**
  72255. * Gets the overall exposure used by the pipeline
  72256. */
  72257. get exposure(): number;
  72258. /**
  72259. * Sets the overall exposure used by the pipeline
  72260. */
  72261. set exposure(value: number);
  72262. /**
  72263. * Texture used typically to simulate "dirty" on camera lens
  72264. */
  72265. lensTexture: Nullable<Texture>;
  72266. /**
  72267. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72268. */
  72269. volumetricLightCoefficient: number;
  72270. /**
  72271. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72272. */
  72273. volumetricLightPower: number;
  72274. /**
  72275. * Used the set the blur intensity to smooth the volumetric lights
  72276. */
  72277. volumetricLightBlurScale: number;
  72278. /**
  72279. * Light (spot or directional) used to generate the volumetric lights rays
  72280. * The source light must have a shadow generate so the pipeline can get its
  72281. * depth map
  72282. */
  72283. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72284. /**
  72285. * For eye adaptation, represents the minimum luminance the eye can see
  72286. */
  72287. hdrMinimumLuminance: number;
  72288. /**
  72289. * For eye adaptation, represents the decrease luminance speed
  72290. */
  72291. hdrDecreaseRate: number;
  72292. /**
  72293. * For eye adaptation, represents the increase luminance speed
  72294. */
  72295. hdrIncreaseRate: number;
  72296. /**
  72297. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72298. */
  72299. get hdrAutoExposure(): boolean;
  72300. /**
  72301. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72302. */
  72303. set hdrAutoExposure(value: boolean);
  72304. /**
  72305. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72306. */
  72307. lensColorTexture: Nullable<Texture>;
  72308. /**
  72309. * The overall strengh for the lens flare effect
  72310. */
  72311. lensFlareStrength: number;
  72312. /**
  72313. * Dispersion coefficient for lens flare ghosts
  72314. */
  72315. lensFlareGhostDispersal: number;
  72316. /**
  72317. * Main lens flare halo width
  72318. */
  72319. lensFlareHaloWidth: number;
  72320. /**
  72321. * Based on the lens distortion effect, defines how much the lens flare result
  72322. * is distorted
  72323. */
  72324. lensFlareDistortionStrength: number;
  72325. /**
  72326. * Configures the blur intensity used for for lens flare (halo)
  72327. */
  72328. lensFlareBlurWidth: number;
  72329. /**
  72330. * Lens star texture must be used to simulate rays on the flares and is available
  72331. * in the documentation
  72332. */
  72333. lensStarTexture: Nullable<Texture>;
  72334. /**
  72335. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72336. * flare effect by taking account of the dirt texture
  72337. */
  72338. lensFlareDirtTexture: Nullable<Texture>;
  72339. /**
  72340. * Represents the focal length for the depth of field effect
  72341. */
  72342. depthOfFieldDistance: number;
  72343. /**
  72344. * Represents the blur intensity for the blurred part of the depth of field effect
  72345. */
  72346. depthOfFieldBlurWidth: number;
  72347. /**
  72348. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72349. */
  72350. get motionStrength(): number;
  72351. /**
  72352. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72353. */
  72354. set motionStrength(strength: number);
  72355. /**
  72356. * Gets wether or not the motion blur post-process is object based or screen based.
  72357. */
  72358. get objectBasedMotionBlur(): boolean;
  72359. /**
  72360. * Sets wether or not the motion blur post-process should be object based or screen based
  72361. */
  72362. set objectBasedMotionBlur(value: boolean);
  72363. /**
  72364. * List of animations for the pipeline (IAnimatable implementation)
  72365. */
  72366. animations: Animation[];
  72367. /**
  72368. * Private members
  72369. */
  72370. private _scene;
  72371. private _currentDepthOfFieldSource;
  72372. private _basePostProcess;
  72373. private _fixedExposure;
  72374. private _currentExposure;
  72375. private _hdrAutoExposure;
  72376. private _hdrCurrentLuminance;
  72377. private _motionStrength;
  72378. private _isObjectBasedMotionBlur;
  72379. private _floatTextureType;
  72380. private _camerasToBeAttached;
  72381. private _ratio;
  72382. private _bloomEnabled;
  72383. private _depthOfFieldEnabled;
  72384. private _vlsEnabled;
  72385. private _lensFlareEnabled;
  72386. private _hdrEnabled;
  72387. private _motionBlurEnabled;
  72388. private _fxaaEnabled;
  72389. private _screenSpaceReflectionsEnabled;
  72390. private _motionBlurSamples;
  72391. private _volumetricLightStepsCount;
  72392. private _samples;
  72393. /**
  72394. * @ignore
  72395. * Specifies if the bloom pipeline is enabled
  72396. */
  72397. get BloomEnabled(): boolean;
  72398. set BloomEnabled(enabled: boolean);
  72399. /**
  72400. * @ignore
  72401. * Specifies if the depth of field pipeline is enabed
  72402. */
  72403. get DepthOfFieldEnabled(): boolean;
  72404. set DepthOfFieldEnabled(enabled: boolean);
  72405. /**
  72406. * @ignore
  72407. * Specifies if the lens flare pipeline is enabed
  72408. */
  72409. get LensFlareEnabled(): boolean;
  72410. set LensFlareEnabled(enabled: boolean);
  72411. /**
  72412. * @ignore
  72413. * Specifies if the HDR pipeline is enabled
  72414. */
  72415. get HDREnabled(): boolean;
  72416. set HDREnabled(enabled: boolean);
  72417. /**
  72418. * @ignore
  72419. * Specifies if the volumetric lights scattering effect is enabled
  72420. */
  72421. get VLSEnabled(): boolean;
  72422. set VLSEnabled(enabled: boolean);
  72423. /**
  72424. * @ignore
  72425. * Specifies if the motion blur effect is enabled
  72426. */
  72427. get MotionBlurEnabled(): boolean;
  72428. set MotionBlurEnabled(enabled: boolean);
  72429. /**
  72430. * Specifies if anti-aliasing is enabled
  72431. */
  72432. get fxaaEnabled(): boolean;
  72433. set fxaaEnabled(enabled: boolean);
  72434. /**
  72435. * Specifies if screen space reflections are enabled.
  72436. */
  72437. get screenSpaceReflectionsEnabled(): boolean;
  72438. set screenSpaceReflectionsEnabled(enabled: boolean);
  72439. /**
  72440. * Specifies the number of steps used to calculate the volumetric lights
  72441. * Typically in interval [50, 200]
  72442. */
  72443. get volumetricLightStepsCount(): number;
  72444. set volumetricLightStepsCount(count: number);
  72445. /**
  72446. * Specifies the number of samples used for the motion blur effect
  72447. * Typically in interval [16, 64]
  72448. */
  72449. get motionBlurSamples(): number;
  72450. set motionBlurSamples(samples: number);
  72451. /**
  72452. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72453. */
  72454. get samples(): number;
  72455. set samples(sampleCount: number);
  72456. /**
  72457. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72458. * @constructor
  72459. * @param name The rendering pipeline name
  72460. * @param scene The scene linked to this pipeline
  72461. * @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)
  72462. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72463. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72464. */
  72465. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72466. private _buildPipeline;
  72467. private _createDownSampleX4PostProcess;
  72468. private _createBrightPassPostProcess;
  72469. private _createBlurPostProcesses;
  72470. private _createTextureAdderPostProcess;
  72471. private _createVolumetricLightPostProcess;
  72472. private _createLuminancePostProcesses;
  72473. private _createHdrPostProcess;
  72474. private _createLensFlarePostProcess;
  72475. private _createDepthOfFieldPostProcess;
  72476. private _createMotionBlurPostProcess;
  72477. private _getDepthTexture;
  72478. private _disposePostProcesses;
  72479. /**
  72480. * Dispose of the pipeline and stop all post processes
  72481. */
  72482. dispose(): void;
  72483. /**
  72484. * Serialize the rendering pipeline (Used when exporting)
  72485. * @returns the serialized object
  72486. */
  72487. serialize(): any;
  72488. /**
  72489. * Parse the serialized pipeline
  72490. * @param source Source pipeline.
  72491. * @param scene The scene to load the pipeline to.
  72492. * @param rootUrl The URL of the serialized pipeline.
  72493. * @returns An instantiated pipeline from the serialized object.
  72494. */
  72495. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72496. /**
  72497. * Luminance steps
  72498. */
  72499. static LuminanceSteps: number;
  72500. }
  72501. }
  72502. declare module BABYLON {
  72503. /** @hidden */
  72504. export var stereoscopicInterlacePixelShader: {
  72505. name: string;
  72506. shader: string;
  72507. };
  72508. }
  72509. declare module BABYLON {
  72510. /**
  72511. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72512. */
  72513. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72514. private _stepSize;
  72515. private _passedProcess;
  72516. /**
  72517. * Gets a string identifying the name of the class
  72518. * @returns "StereoscopicInterlacePostProcessI" string
  72519. */
  72520. getClassName(): string;
  72521. /**
  72522. * Initializes a StereoscopicInterlacePostProcessI
  72523. * @param name The name of the effect.
  72524. * @param rigCameras The rig cameras to be appled to the post process
  72525. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72526. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72527. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72528. * @param engine The engine which the post process will be applied. (default: current engine)
  72529. * @param reusable If the post process can be reused on the same frame. (default: false)
  72530. */
  72531. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72532. }
  72533. /**
  72534. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72535. */
  72536. export class StereoscopicInterlacePostProcess extends PostProcess {
  72537. private _stepSize;
  72538. private _passedProcess;
  72539. /**
  72540. * Gets a string identifying the name of the class
  72541. * @returns "StereoscopicInterlacePostProcess" string
  72542. */
  72543. getClassName(): string;
  72544. /**
  72545. * Initializes a StereoscopicInterlacePostProcess
  72546. * @param name The name of the effect.
  72547. * @param rigCameras The rig cameras to be appled to the post process
  72548. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72549. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72550. * @param engine The engine which the post process will be applied. (default: current engine)
  72551. * @param reusable If the post process can be reused on the same frame. (default: false)
  72552. */
  72553. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72554. }
  72555. }
  72556. declare module BABYLON {
  72557. /** @hidden */
  72558. export var tonemapPixelShader: {
  72559. name: string;
  72560. shader: string;
  72561. };
  72562. }
  72563. declare module BABYLON {
  72564. /** Defines operator used for tonemapping */
  72565. export enum TonemappingOperator {
  72566. /** Hable */
  72567. Hable = 0,
  72568. /** Reinhard */
  72569. Reinhard = 1,
  72570. /** HejiDawson */
  72571. HejiDawson = 2,
  72572. /** Photographic */
  72573. Photographic = 3
  72574. }
  72575. /**
  72576. * Defines a post process to apply tone mapping
  72577. */
  72578. export class TonemapPostProcess extends PostProcess {
  72579. private _operator;
  72580. /** Defines the required exposure adjustement */
  72581. exposureAdjustment: number;
  72582. /**
  72583. * Gets a string identifying the name of the class
  72584. * @returns "TonemapPostProcess" string
  72585. */
  72586. getClassName(): string;
  72587. /**
  72588. * Creates a new TonemapPostProcess
  72589. * @param name defines the name of the postprocess
  72590. * @param _operator defines the operator to use
  72591. * @param exposureAdjustment defines the required exposure adjustement
  72592. * @param camera defines the camera to use (can be null)
  72593. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72594. * @param engine defines the hosting engine (can be ignore if camera is set)
  72595. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72596. */
  72597. constructor(name: string, _operator: TonemappingOperator,
  72598. /** Defines the required exposure adjustement */
  72599. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72600. }
  72601. }
  72602. declare module BABYLON {
  72603. /** @hidden */
  72604. export var volumetricLightScatteringPixelShader: {
  72605. name: string;
  72606. shader: string;
  72607. };
  72608. }
  72609. declare module BABYLON {
  72610. /** @hidden */
  72611. export var volumetricLightScatteringPassVertexShader: {
  72612. name: string;
  72613. shader: string;
  72614. };
  72615. }
  72616. declare module BABYLON {
  72617. /** @hidden */
  72618. export var volumetricLightScatteringPassPixelShader: {
  72619. name: string;
  72620. shader: string;
  72621. };
  72622. }
  72623. declare module BABYLON {
  72624. /**
  72625. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72626. */
  72627. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72628. private _volumetricLightScatteringPass;
  72629. private _volumetricLightScatteringRTT;
  72630. private _viewPort;
  72631. private _screenCoordinates;
  72632. private _cachedDefines;
  72633. /**
  72634. * If not undefined, the mesh position is computed from the attached node position
  72635. */
  72636. attachedNode: {
  72637. position: Vector3;
  72638. };
  72639. /**
  72640. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72641. */
  72642. customMeshPosition: Vector3;
  72643. /**
  72644. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72645. */
  72646. useCustomMeshPosition: boolean;
  72647. /**
  72648. * If the post-process should inverse the light scattering direction
  72649. */
  72650. invert: boolean;
  72651. /**
  72652. * The internal mesh used by the post-process
  72653. */
  72654. mesh: Mesh;
  72655. /**
  72656. * @hidden
  72657. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72658. */
  72659. get useDiffuseColor(): boolean;
  72660. set useDiffuseColor(useDiffuseColor: boolean);
  72661. /**
  72662. * Array containing the excluded meshes not rendered in the internal pass
  72663. */
  72664. excludedMeshes: AbstractMesh[];
  72665. /**
  72666. * Controls the overall intensity of the post-process
  72667. */
  72668. exposure: number;
  72669. /**
  72670. * Dissipates each sample's contribution in range [0, 1]
  72671. */
  72672. decay: number;
  72673. /**
  72674. * Controls the overall intensity of each sample
  72675. */
  72676. weight: number;
  72677. /**
  72678. * Controls the density of each sample
  72679. */
  72680. density: number;
  72681. /**
  72682. * @constructor
  72683. * @param name The post-process name
  72684. * @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)
  72685. * @param camera The camera that the post-process will be attached to
  72686. * @param mesh The mesh used to create the light scattering
  72687. * @param samples The post-process quality, default 100
  72688. * @param samplingModeThe post-process filtering mode
  72689. * @param engine The babylon engine
  72690. * @param reusable If the post-process is reusable
  72691. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72692. */
  72693. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72694. /**
  72695. * Returns the string "VolumetricLightScatteringPostProcess"
  72696. * @returns "VolumetricLightScatteringPostProcess"
  72697. */
  72698. getClassName(): string;
  72699. private _isReady;
  72700. /**
  72701. * Sets the new light position for light scattering effect
  72702. * @param position The new custom light position
  72703. */
  72704. setCustomMeshPosition(position: Vector3): void;
  72705. /**
  72706. * Returns the light position for light scattering effect
  72707. * @return Vector3 The custom light position
  72708. */
  72709. getCustomMeshPosition(): Vector3;
  72710. /**
  72711. * Disposes the internal assets and detaches the post-process from the camera
  72712. */
  72713. dispose(camera: Camera): void;
  72714. /**
  72715. * Returns the render target texture used by the post-process
  72716. * @return the render target texture used by the post-process
  72717. */
  72718. getPass(): RenderTargetTexture;
  72719. private _meshExcluded;
  72720. private _createPass;
  72721. private _updateMeshScreenCoordinates;
  72722. /**
  72723. * Creates a default mesh for the Volumeric Light Scattering post-process
  72724. * @param name The mesh name
  72725. * @param scene The scene where to create the mesh
  72726. * @return the default mesh
  72727. */
  72728. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72729. }
  72730. }
  72731. declare module BABYLON {
  72732. /** @hidden */
  72733. export var screenSpaceCurvaturePixelShader: {
  72734. name: string;
  72735. shader: string;
  72736. };
  72737. }
  72738. declare module BABYLON {
  72739. /**
  72740. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  72741. */
  72742. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  72743. /**
  72744. * Defines how much ridge the curvature effect displays.
  72745. */
  72746. ridge: number;
  72747. /**
  72748. * Defines how much valley the curvature effect displays.
  72749. */
  72750. valley: number;
  72751. private _geometryBufferRenderer;
  72752. /**
  72753. * Gets a string identifying the name of the class
  72754. * @returns "ScreenSpaceCurvaturePostProcess" string
  72755. */
  72756. getClassName(): string;
  72757. /**
  72758. * Creates a new instance ScreenSpaceCurvaturePostProcess
  72759. * @param name The name of the effect.
  72760. * @param scene The scene containing the objects to blur according to their velocity.
  72761. * @param options The required width/height ratio to downsize to before computing the render pass.
  72762. * @param camera The camera to apply the render pass to.
  72763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72764. * @param engine The engine which the post process will be applied. (default: current engine)
  72765. * @param reusable If the post process can be reused on the same frame. (default: false)
  72766. * @param textureType Type of textures used when performing the post process. (default: 0)
  72767. * @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)
  72768. */
  72769. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72770. /**
  72771. * Support test.
  72772. */
  72773. static get IsSupported(): boolean;
  72774. /** @hidden */
  72775. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72776. }
  72777. }
  72778. declare module BABYLON {
  72779. interface Scene {
  72780. /** @hidden (Backing field) */
  72781. _boundingBoxRenderer: BoundingBoxRenderer;
  72782. /** @hidden (Backing field) */
  72783. _forceShowBoundingBoxes: boolean;
  72784. /**
  72785. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72786. */
  72787. forceShowBoundingBoxes: boolean;
  72788. /**
  72789. * Gets the bounding box renderer associated with the scene
  72790. * @returns a BoundingBoxRenderer
  72791. */
  72792. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72793. }
  72794. interface AbstractMesh {
  72795. /** @hidden (Backing field) */
  72796. _showBoundingBox: boolean;
  72797. /**
  72798. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72799. */
  72800. showBoundingBox: boolean;
  72801. }
  72802. /**
  72803. * Component responsible of rendering the bounding box of the meshes in a scene.
  72804. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72805. */
  72806. export class BoundingBoxRenderer implements ISceneComponent {
  72807. /**
  72808. * The component name helpfull to identify the component in the list of scene components.
  72809. */
  72810. readonly name: string;
  72811. /**
  72812. * The scene the component belongs to.
  72813. */
  72814. scene: Scene;
  72815. /**
  72816. * Color of the bounding box lines placed in front of an object
  72817. */
  72818. frontColor: Color3;
  72819. /**
  72820. * Color of the bounding box lines placed behind an object
  72821. */
  72822. backColor: Color3;
  72823. /**
  72824. * Defines if the renderer should show the back lines or not
  72825. */
  72826. showBackLines: boolean;
  72827. /**
  72828. * Observable raised before rendering a bounding box
  72829. */
  72830. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72831. /**
  72832. * Observable raised after rendering a bounding box
  72833. */
  72834. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72835. /**
  72836. * When false, no bounding boxes will be rendered
  72837. */
  72838. enabled: boolean;
  72839. /**
  72840. * @hidden
  72841. */
  72842. renderList: SmartArray<BoundingBox>;
  72843. private _colorShader;
  72844. private _vertexBuffers;
  72845. private _indexBuffer;
  72846. private _fillIndexBuffer;
  72847. private _fillIndexData;
  72848. /**
  72849. * Instantiates a new bounding box renderer in a scene.
  72850. * @param scene the scene the renderer renders in
  72851. */
  72852. constructor(scene: Scene);
  72853. /**
  72854. * Registers the component in a given scene
  72855. */
  72856. register(): void;
  72857. private _evaluateSubMesh;
  72858. private _preActiveMesh;
  72859. private _prepareRessources;
  72860. private _createIndexBuffer;
  72861. /**
  72862. * Rebuilds the elements related to this component in case of
  72863. * context lost for instance.
  72864. */
  72865. rebuild(): void;
  72866. /**
  72867. * @hidden
  72868. */
  72869. reset(): void;
  72870. /**
  72871. * Render the bounding boxes of a specific rendering group
  72872. * @param renderingGroupId defines the rendering group to render
  72873. */
  72874. render(renderingGroupId: number): void;
  72875. /**
  72876. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72877. * @param mesh Define the mesh to render the occlusion bounding box for
  72878. */
  72879. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72880. /**
  72881. * Dispose and release the resources attached to this renderer.
  72882. */
  72883. dispose(): void;
  72884. }
  72885. }
  72886. declare module BABYLON {
  72887. interface Scene {
  72888. /** @hidden (Backing field) */
  72889. _depthRenderer: {
  72890. [id: string]: DepthRenderer;
  72891. };
  72892. /**
  72893. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72894. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72895. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72896. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72897. * @returns the created depth renderer
  72898. */
  72899. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72900. /**
  72901. * Disables a depth renderer for a given camera
  72902. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72903. */
  72904. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72905. }
  72906. /**
  72907. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72908. * in several rendering techniques.
  72909. */
  72910. export class DepthRendererSceneComponent implements ISceneComponent {
  72911. /**
  72912. * The component name helpfull to identify the component in the list of scene components.
  72913. */
  72914. readonly name: string;
  72915. /**
  72916. * The scene the component belongs to.
  72917. */
  72918. scene: Scene;
  72919. /**
  72920. * Creates a new instance of the component for the given scene
  72921. * @param scene Defines the scene to register the component in
  72922. */
  72923. constructor(scene: Scene);
  72924. /**
  72925. * Registers the component in a given scene
  72926. */
  72927. register(): void;
  72928. /**
  72929. * Rebuilds the elements related to this component in case of
  72930. * context lost for instance.
  72931. */
  72932. rebuild(): void;
  72933. /**
  72934. * Disposes the component and the associated ressources
  72935. */
  72936. dispose(): void;
  72937. private _gatherRenderTargets;
  72938. private _gatherActiveCameraRenderTargets;
  72939. }
  72940. }
  72941. declare module BABYLON {
  72942. interface AbstractScene {
  72943. /** @hidden (Backing field) */
  72944. _prePassRenderer: Nullable<PrePassRenderer>;
  72945. /**
  72946. * Gets or Sets the current prepass renderer associated to the scene.
  72947. */
  72948. prePassRenderer: Nullable<PrePassRenderer>;
  72949. /**
  72950. * Enables the prepass and associates it with the scene
  72951. * @returns the PrePassRenderer
  72952. */
  72953. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72954. /**
  72955. * Disables the prepass associated with the scene
  72956. */
  72957. disablePrePassRenderer(): void;
  72958. }
  72959. /**
  72960. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72961. * in several rendering techniques.
  72962. */
  72963. export class PrePassRendererSceneComponent implements ISceneComponent {
  72964. /**
  72965. * The component name helpful to identify the component in the list of scene components.
  72966. */
  72967. readonly name: string;
  72968. /**
  72969. * The scene the component belongs to.
  72970. */
  72971. scene: Scene;
  72972. /**
  72973. * Creates a new instance of the component for the given scene
  72974. * @param scene Defines the scene to register the component in
  72975. */
  72976. constructor(scene: Scene);
  72977. /**
  72978. * Registers the component in a given scene
  72979. */
  72980. register(): void;
  72981. private _beforeCameraDraw;
  72982. private _afterCameraDraw;
  72983. private _beforeClearStage;
  72984. /**
  72985. * Rebuilds the elements related to this component in case of
  72986. * context lost for instance.
  72987. */
  72988. rebuild(): void;
  72989. /**
  72990. * Disposes the component and the associated ressources
  72991. */
  72992. dispose(): void;
  72993. }
  72994. }
  72995. declare module BABYLON {
  72996. /** @hidden */
  72997. export var fibonacci: {
  72998. name: string;
  72999. shader: string;
  73000. };
  73001. }
  73002. declare module BABYLON {
  73003. /** @hidden */
  73004. export var diffusionProfile: {
  73005. name: string;
  73006. shader: string;
  73007. };
  73008. }
  73009. declare module BABYLON {
  73010. /** @hidden */
  73011. export var subSurfaceScatteringPixelShader: {
  73012. name: string;
  73013. shader: string;
  73014. };
  73015. }
  73016. declare module BABYLON {
  73017. /**
  73018. * Sub surface scattering post process
  73019. */
  73020. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73021. /**
  73022. * Gets a string identifying the name of the class
  73023. * @returns "SubSurfaceScatteringPostProcess" string
  73024. */
  73025. getClassName(): string;
  73026. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73027. }
  73028. }
  73029. declare module BABYLON {
  73030. /**
  73031. * Contains all parameters needed for the prepass to perform
  73032. * screen space subsurface scattering
  73033. */
  73034. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73035. /** @hidden */
  73036. static _SceneComponentInitialization: (scene: Scene) => void;
  73037. private _ssDiffusionS;
  73038. private _ssFilterRadii;
  73039. private _ssDiffusionD;
  73040. /**
  73041. * Post process to attach for screen space subsurface scattering
  73042. */
  73043. postProcess: SubSurfaceScatteringPostProcess;
  73044. /**
  73045. * Diffusion profile color for subsurface scattering
  73046. */
  73047. get ssDiffusionS(): number[];
  73048. /**
  73049. * Diffusion profile max color channel value for subsurface scattering
  73050. */
  73051. get ssDiffusionD(): number[];
  73052. /**
  73053. * Diffusion profile filter radius for subsurface scattering
  73054. */
  73055. get ssFilterRadii(): number[];
  73056. /**
  73057. * Is subsurface enabled
  73058. */
  73059. enabled: boolean;
  73060. /**
  73061. * Name of the configuration
  73062. */
  73063. name: string;
  73064. /**
  73065. * Diffusion profile colors for subsurface scattering
  73066. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73067. * See ...
  73068. * Note that you can only store up to 5 of them
  73069. */
  73070. ssDiffusionProfileColors: Color3[];
  73071. /**
  73072. * Defines the ratio real world => scene units.
  73073. * Used for subsurface scattering
  73074. */
  73075. metersPerUnit: number;
  73076. /**
  73077. * Textures that should be present in the MRT for this effect to work
  73078. */
  73079. readonly texturesRequired: number[];
  73080. private _scene;
  73081. /**
  73082. * Builds a subsurface configuration object
  73083. * @param scene The scene
  73084. */
  73085. constructor(scene: Scene);
  73086. /**
  73087. * Adds a new diffusion profile.
  73088. * Useful for more realistic subsurface scattering on diverse materials.
  73089. * @param color The color of the diffusion profile. Should be the average color of the material.
  73090. * @return The index of the diffusion profile for the material subsurface configuration
  73091. */
  73092. addDiffusionProfile(color: Color3): number;
  73093. /**
  73094. * Creates the sss post process
  73095. * @return The created post process
  73096. */
  73097. createPostProcess(): SubSurfaceScatteringPostProcess;
  73098. /**
  73099. * Deletes all diffusion profiles.
  73100. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73101. */
  73102. clearAllDiffusionProfiles(): void;
  73103. /**
  73104. * Disposes this object
  73105. */
  73106. dispose(): void;
  73107. /**
  73108. * @hidden
  73109. * https://zero-radiance.github.io/post/sampling-diffusion/
  73110. *
  73111. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73112. * ------------------------------------------------------------------------------------
  73113. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73114. * PDF[r, phi, s] = r * R[r, phi, s]
  73115. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73116. * ------------------------------------------------------------------------------------
  73117. * We importance sample the color channel with the widest scattering distance.
  73118. */
  73119. getDiffusionProfileParameters(color: Color3): number;
  73120. /**
  73121. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73122. * 'u' is the random number (the value of the CDF): [0, 1).
  73123. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73124. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73125. */
  73126. private _sampleBurleyDiffusionProfile;
  73127. }
  73128. }
  73129. declare module BABYLON {
  73130. interface AbstractScene {
  73131. /** @hidden (Backing field) */
  73132. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73133. /**
  73134. * Gets or Sets the current prepass renderer associated to the scene.
  73135. */
  73136. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73137. /**
  73138. * Enables the subsurface effect for prepass
  73139. * @returns the SubSurfaceConfiguration
  73140. */
  73141. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  73142. /**
  73143. * Disables the subsurface effect for prepass
  73144. */
  73145. disableSubSurfaceForPrePass(): void;
  73146. }
  73147. /**
  73148. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73149. * in several rendering techniques.
  73150. */
  73151. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  73152. /**
  73153. * The component name helpful to identify the component in the list of scene components.
  73154. */
  73155. readonly name: string;
  73156. /**
  73157. * The scene the component belongs to.
  73158. */
  73159. scene: Scene;
  73160. /**
  73161. * Creates a new instance of the component for the given scene
  73162. * @param scene Defines the scene to register the component in
  73163. */
  73164. constructor(scene: Scene);
  73165. /**
  73166. * Registers the component in a given scene
  73167. */
  73168. register(): void;
  73169. /**
  73170. * Serializes the component data to the specified json object
  73171. * @param serializationObject The object to serialize to
  73172. */
  73173. serialize(serializationObject: any): void;
  73174. /**
  73175. * Adds all the elements from the container to the scene
  73176. * @param container the container holding the elements
  73177. */
  73178. addFromContainer(container: AbstractScene): void;
  73179. /**
  73180. * Removes all the elements in the container from the scene
  73181. * @param container contains the elements to remove
  73182. * @param dispose if the removed element should be disposed (default: false)
  73183. */
  73184. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73185. /**
  73186. * Rebuilds the elements related to this component in case of
  73187. * context lost for instance.
  73188. */
  73189. rebuild(): void;
  73190. /**
  73191. * Disposes the component and the associated ressources
  73192. */
  73193. dispose(): void;
  73194. }
  73195. }
  73196. declare module BABYLON {
  73197. /** @hidden */
  73198. export var outlinePixelShader: {
  73199. name: string;
  73200. shader: string;
  73201. };
  73202. }
  73203. declare module BABYLON {
  73204. /** @hidden */
  73205. export var outlineVertexShader: {
  73206. name: string;
  73207. shader: string;
  73208. };
  73209. }
  73210. declare module BABYLON {
  73211. interface Scene {
  73212. /** @hidden */
  73213. _outlineRenderer: OutlineRenderer;
  73214. /**
  73215. * Gets the outline renderer associated with the scene
  73216. * @returns a OutlineRenderer
  73217. */
  73218. getOutlineRenderer(): OutlineRenderer;
  73219. }
  73220. interface AbstractMesh {
  73221. /** @hidden (Backing field) */
  73222. _renderOutline: boolean;
  73223. /**
  73224. * Gets or sets a boolean indicating if the outline must be rendered as well
  73225. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73226. */
  73227. renderOutline: boolean;
  73228. /** @hidden (Backing field) */
  73229. _renderOverlay: boolean;
  73230. /**
  73231. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73232. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73233. */
  73234. renderOverlay: boolean;
  73235. }
  73236. /**
  73237. * This class is responsible to draw bothe outline/overlay of meshes.
  73238. * It should not be used directly but through the available method on mesh.
  73239. */
  73240. export class OutlineRenderer implements ISceneComponent {
  73241. /**
  73242. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73243. */
  73244. private static _StencilReference;
  73245. /**
  73246. * The name of the component. Each component must have a unique name.
  73247. */
  73248. name: string;
  73249. /**
  73250. * The scene the component belongs to.
  73251. */
  73252. scene: Scene;
  73253. /**
  73254. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73255. */
  73256. zOffset: number;
  73257. private _engine;
  73258. private _effect;
  73259. private _cachedDefines;
  73260. private _savedDepthWrite;
  73261. /**
  73262. * Instantiates a new outline renderer. (There could be only one per scene).
  73263. * @param scene Defines the scene it belongs to
  73264. */
  73265. constructor(scene: Scene);
  73266. /**
  73267. * Register the component to one instance of a scene.
  73268. */
  73269. register(): void;
  73270. /**
  73271. * Rebuilds the elements related to this component in case of
  73272. * context lost for instance.
  73273. */
  73274. rebuild(): void;
  73275. /**
  73276. * Disposes the component and the associated ressources.
  73277. */
  73278. dispose(): void;
  73279. /**
  73280. * Renders the outline in the canvas.
  73281. * @param subMesh Defines the sumesh to render
  73282. * @param batch Defines the batch of meshes in case of instances
  73283. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73284. */
  73285. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73286. /**
  73287. * Returns whether or not the outline renderer is ready for a given submesh.
  73288. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73289. * @param subMesh Defines the submesh to check readyness for
  73290. * @param useInstances Defines wheter wee are trying to render instances or not
  73291. * @returns true if ready otherwise false
  73292. */
  73293. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73294. private _beforeRenderingMesh;
  73295. private _afterRenderingMesh;
  73296. }
  73297. }
  73298. declare module BABYLON {
  73299. /**
  73300. * Defines the basic options interface of a Sprite Frame Source Size.
  73301. */
  73302. export interface ISpriteJSONSpriteSourceSize {
  73303. /**
  73304. * number of the original width of the Frame
  73305. */
  73306. w: number;
  73307. /**
  73308. * number of the original height of the Frame
  73309. */
  73310. h: number;
  73311. }
  73312. /**
  73313. * Defines the basic options interface of a Sprite Frame Data.
  73314. */
  73315. export interface ISpriteJSONSpriteFrameData {
  73316. /**
  73317. * number of the x offset of the Frame
  73318. */
  73319. x: number;
  73320. /**
  73321. * number of the y offset of the Frame
  73322. */
  73323. y: number;
  73324. /**
  73325. * number of the width of the Frame
  73326. */
  73327. w: number;
  73328. /**
  73329. * number of the height of the Frame
  73330. */
  73331. h: number;
  73332. }
  73333. /**
  73334. * Defines the basic options interface of a JSON Sprite.
  73335. */
  73336. export interface ISpriteJSONSprite {
  73337. /**
  73338. * string name of the Frame
  73339. */
  73340. filename: string;
  73341. /**
  73342. * ISpriteJSONSpriteFrame basic object of the frame data
  73343. */
  73344. frame: ISpriteJSONSpriteFrameData;
  73345. /**
  73346. * boolean to flag is the frame was rotated.
  73347. */
  73348. rotated: boolean;
  73349. /**
  73350. * boolean to flag is the frame was trimmed.
  73351. */
  73352. trimmed: boolean;
  73353. /**
  73354. * ISpriteJSONSpriteFrame basic object of the source data
  73355. */
  73356. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73357. /**
  73358. * ISpriteJSONSpriteFrame basic object of the source data
  73359. */
  73360. sourceSize: ISpriteJSONSpriteSourceSize;
  73361. }
  73362. /**
  73363. * Defines the basic options interface of a JSON atlas.
  73364. */
  73365. export interface ISpriteJSONAtlas {
  73366. /**
  73367. * Array of objects that contain the frame data.
  73368. */
  73369. frames: Array<ISpriteJSONSprite>;
  73370. /**
  73371. * object basic object containing the sprite meta data.
  73372. */
  73373. meta?: object;
  73374. }
  73375. }
  73376. declare module BABYLON {
  73377. /** @hidden */
  73378. export var spriteMapPixelShader: {
  73379. name: string;
  73380. shader: string;
  73381. };
  73382. }
  73383. declare module BABYLON {
  73384. /** @hidden */
  73385. export var spriteMapVertexShader: {
  73386. name: string;
  73387. shader: string;
  73388. };
  73389. }
  73390. declare module BABYLON {
  73391. /**
  73392. * Defines the basic options interface of a SpriteMap
  73393. */
  73394. export interface ISpriteMapOptions {
  73395. /**
  73396. * Vector2 of the number of cells in the grid.
  73397. */
  73398. stageSize?: Vector2;
  73399. /**
  73400. * Vector2 of the size of the output plane in World Units.
  73401. */
  73402. outputSize?: Vector2;
  73403. /**
  73404. * Vector3 of the position of the output plane in World Units.
  73405. */
  73406. outputPosition?: Vector3;
  73407. /**
  73408. * Vector3 of the rotation of the output plane.
  73409. */
  73410. outputRotation?: Vector3;
  73411. /**
  73412. * number of layers that the system will reserve in resources.
  73413. */
  73414. layerCount?: number;
  73415. /**
  73416. * number of max animation frames a single cell will reserve in resources.
  73417. */
  73418. maxAnimationFrames?: number;
  73419. /**
  73420. * number cell index of the base tile when the system compiles.
  73421. */
  73422. baseTile?: number;
  73423. /**
  73424. * boolean flip the sprite after its been repositioned by the framing data.
  73425. */
  73426. flipU?: boolean;
  73427. /**
  73428. * Vector3 scalar of the global RGB values of the SpriteMap.
  73429. */
  73430. colorMultiply?: Vector3;
  73431. }
  73432. /**
  73433. * Defines the IDisposable interface in order to be cleanable from resources.
  73434. */
  73435. export interface ISpriteMap extends IDisposable {
  73436. /**
  73437. * String name of the SpriteMap.
  73438. */
  73439. name: string;
  73440. /**
  73441. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73442. */
  73443. atlasJSON: ISpriteJSONAtlas;
  73444. /**
  73445. * Texture of the SpriteMap.
  73446. */
  73447. spriteSheet: Texture;
  73448. /**
  73449. * The parameters to initialize the SpriteMap with.
  73450. */
  73451. options: ISpriteMapOptions;
  73452. }
  73453. /**
  73454. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73455. */
  73456. export class SpriteMap implements ISpriteMap {
  73457. /** The Name of the spriteMap */
  73458. name: string;
  73459. /** The JSON file with the frame and meta data */
  73460. atlasJSON: ISpriteJSONAtlas;
  73461. /** The systems Sprite Sheet Texture */
  73462. spriteSheet: Texture;
  73463. /** Arguments passed with the Constructor */
  73464. options: ISpriteMapOptions;
  73465. /** Public Sprite Storage array, parsed from atlasJSON */
  73466. sprites: Array<ISpriteJSONSprite>;
  73467. /** Returns the Number of Sprites in the System */
  73468. get spriteCount(): number;
  73469. /** Returns the Position of Output Plane*/
  73470. get position(): Vector3;
  73471. /** Returns the Position of Output Plane*/
  73472. set position(v: Vector3);
  73473. /** Returns the Rotation of Output Plane*/
  73474. get rotation(): Vector3;
  73475. /** Returns the Rotation of Output Plane*/
  73476. set rotation(v: Vector3);
  73477. /** Sets the AnimationMap*/
  73478. get animationMap(): RawTexture;
  73479. /** Sets the AnimationMap*/
  73480. set animationMap(v: RawTexture);
  73481. /** Scene that the SpriteMap was created in */
  73482. private _scene;
  73483. /** Texture Buffer of Float32 that holds tile frame data*/
  73484. private _frameMap;
  73485. /** Texture Buffers of Float32 that holds tileMap data*/
  73486. private _tileMaps;
  73487. /** Texture Buffer of Float32 that holds Animation Data*/
  73488. private _animationMap;
  73489. /** Custom ShaderMaterial Central to the System*/
  73490. private _material;
  73491. /** Custom ShaderMaterial Central to the System*/
  73492. private _output;
  73493. /** Systems Time Ticker*/
  73494. private _time;
  73495. /**
  73496. * Creates a new SpriteMap
  73497. * @param name defines the SpriteMaps Name
  73498. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73499. * @param spriteSheet is the Texture that the Sprites are on.
  73500. * @param options a basic deployment configuration
  73501. * @param scene The Scene that the map is deployed on
  73502. */
  73503. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73504. /**
  73505. * Returns tileID location
  73506. * @returns Vector2 the cell position ID
  73507. */
  73508. getTileID(): Vector2;
  73509. /**
  73510. * Gets the UV location of the mouse over the SpriteMap.
  73511. * @returns Vector2 the UV position of the mouse interaction
  73512. */
  73513. getMousePosition(): Vector2;
  73514. /**
  73515. * Creates the "frame" texture Buffer
  73516. * -------------------------------------
  73517. * Structure of frames
  73518. * "filename": "Falling-Water-2.png",
  73519. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73520. * "rotated": true,
  73521. * "trimmed": true,
  73522. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73523. * "sourceSize": {"w":32,"h":32}
  73524. * @returns RawTexture of the frameMap
  73525. */
  73526. private _createFrameBuffer;
  73527. /**
  73528. * Creates the tileMap texture Buffer
  73529. * @param buffer normally and array of numbers, or a false to generate from scratch
  73530. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73531. * @returns RawTexture of the tileMap
  73532. */
  73533. private _createTileBuffer;
  73534. /**
  73535. * Modifies the data of the tileMaps
  73536. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73537. * @param pos is the iVector2 Coordinates of the Tile
  73538. * @param tile The SpriteIndex of the new Tile
  73539. */
  73540. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73541. /**
  73542. * Creates the animationMap texture Buffer
  73543. * @param buffer normally and array of numbers, or a false to generate from scratch
  73544. * @returns RawTexture of the animationMap
  73545. */
  73546. private _createTileAnimationBuffer;
  73547. /**
  73548. * Modifies the data of the animationMap
  73549. * @param cellID is the Index of the Sprite
  73550. * @param _frame is the target Animation frame
  73551. * @param toCell is the Target Index of the next frame of the animation
  73552. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73553. * @param speed is a global scalar of the time variable on the map.
  73554. */
  73555. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73556. /**
  73557. * Exports the .tilemaps file
  73558. */
  73559. saveTileMaps(): void;
  73560. /**
  73561. * Imports the .tilemaps file
  73562. * @param url of the .tilemaps file
  73563. */
  73564. loadTileMaps(url: string): void;
  73565. /**
  73566. * Release associated resources
  73567. */
  73568. dispose(): void;
  73569. }
  73570. }
  73571. declare module BABYLON {
  73572. /**
  73573. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73574. * @see https://doc.babylonjs.com/babylon101/sprites
  73575. */
  73576. export class SpritePackedManager extends SpriteManager {
  73577. /** defines the packed manager's name */
  73578. name: string;
  73579. /**
  73580. * Creates a new sprite manager from a packed sprite sheet
  73581. * @param name defines the manager's name
  73582. * @param imgUrl defines the sprite sheet url
  73583. * @param capacity defines the maximum allowed number of sprites
  73584. * @param scene defines the hosting scene
  73585. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73586. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73587. * @param samplingMode defines the smapling mode to use with spritesheet
  73588. * @param fromPacked set to true; do not alter
  73589. */
  73590. constructor(
  73591. /** defines the packed manager's name */
  73592. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73593. }
  73594. }
  73595. declare module BABYLON {
  73596. /**
  73597. * Defines the list of states available for a task inside a AssetsManager
  73598. */
  73599. export enum AssetTaskState {
  73600. /**
  73601. * Initialization
  73602. */
  73603. INIT = 0,
  73604. /**
  73605. * Running
  73606. */
  73607. RUNNING = 1,
  73608. /**
  73609. * Done
  73610. */
  73611. DONE = 2,
  73612. /**
  73613. * Error
  73614. */
  73615. ERROR = 3
  73616. }
  73617. /**
  73618. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73619. */
  73620. export abstract class AbstractAssetTask {
  73621. /**
  73622. * Task name
  73623. */ name: string;
  73624. /**
  73625. * Callback called when the task is successful
  73626. */
  73627. onSuccess: (task: any) => void;
  73628. /**
  73629. * Callback called when the task is not successful
  73630. */
  73631. onError: (task: any, message?: string, exception?: any) => void;
  73632. /**
  73633. * Creates a new AssetsManager
  73634. * @param name defines the name of the task
  73635. */
  73636. constructor(
  73637. /**
  73638. * Task name
  73639. */ name: string);
  73640. private _isCompleted;
  73641. private _taskState;
  73642. private _errorObject;
  73643. /**
  73644. * Get if the task is completed
  73645. */
  73646. get isCompleted(): boolean;
  73647. /**
  73648. * Gets the current state of the task
  73649. */
  73650. get taskState(): AssetTaskState;
  73651. /**
  73652. * Gets the current error object (if task is in error)
  73653. */
  73654. get errorObject(): {
  73655. message?: string;
  73656. exception?: any;
  73657. };
  73658. /**
  73659. * Internal only
  73660. * @hidden
  73661. */
  73662. _setErrorObject(message?: string, exception?: any): void;
  73663. /**
  73664. * Execute the current task
  73665. * @param scene defines the scene where you want your assets to be loaded
  73666. * @param onSuccess is a callback called when the task is successfully executed
  73667. * @param onError is a callback called if an error occurs
  73668. */
  73669. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73670. /**
  73671. * Execute the current task
  73672. * @param scene defines the scene where you want your assets to be loaded
  73673. * @param onSuccess is a callback called when the task is successfully executed
  73674. * @param onError is a callback called if an error occurs
  73675. */
  73676. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73677. /**
  73678. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73679. * This can be used with failed tasks that have the reason for failure fixed.
  73680. */
  73681. reset(): void;
  73682. private onErrorCallback;
  73683. private onDoneCallback;
  73684. }
  73685. /**
  73686. * Define the interface used by progress events raised during assets loading
  73687. */
  73688. export interface IAssetsProgressEvent {
  73689. /**
  73690. * Defines the number of remaining tasks to process
  73691. */
  73692. remainingCount: number;
  73693. /**
  73694. * Defines the total number of tasks
  73695. */
  73696. totalCount: number;
  73697. /**
  73698. * Defines the task that was just processed
  73699. */
  73700. task: AbstractAssetTask;
  73701. }
  73702. /**
  73703. * Class used to share progress information about assets loading
  73704. */
  73705. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73706. /**
  73707. * Defines the number of remaining tasks to process
  73708. */
  73709. remainingCount: number;
  73710. /**
  73711. * Defines the total number of tasks
  73712. */
  73713. totalCount: number;
  73714. /**
  73715. * Defines the task that was just processed
  73716. */
  73717. task: AbstractAssetTask;
  73718. /**
  73719. * Creates a AssetsProgressEvent
  73720. * @param remainingCount defines the number of remaining tasks to process
  73721. * @param totalCount defines the total number of tasks
  73722. * @param task defines the task that was just processed
  73723. */
  73724. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73725. }
  73726. /**
  73727. * Define a task used by AssetsManager to load assets into a container
  73728. */
  73729. export class ContainerAssetTask extends AbstractAssetTask {
  73730. /**
  73731. * Defines the name of the task
  73732. */
  73733. name: string;
  73734. /**
  73735. * Defines the list of mesh's names you want to load
  73736. */
  73737. meshesNames: any;
  73738. /**
  73739. * Defines the root url to use as a base to load your meshes and associated resources
  73740. */
  73741. rootUrl: string;
  73742. /**
  73743. * Defines the filename or File of the scene to load from
  73744. */
  73745. sceneFilename: string | File;
  73746. /**
  73747. * Get the loaded asset container
  73748. */
  73749. loadedContainer: AssetContainer;
  73750. /**
  73751. * Gets the list of loaded meshes
  73752. */
  73753. loadedMeshes: Array<AbstractMesh>;
  73754. /**
  73755. * Gets the list of loaded particle systems
  73756. */
  73757. loadedParticleSystems: Array<IParticleSystem>;
  73758. /**
  73759. * Gets the list of loaded skeletons
  73760. */
  73761. loadedSkeletons: Array<Skeleton>;
  73762. /**
  73763. * Gets the list of loaded animation groups
  73764. */
  73765. loadedAnimationGroups: Array<AnimationGroup>;
  73766. /**
  73767. * Callback called when the task is successful
  73768. */
  73769. onSuccess: (task: ContainerAssetTask) => void;
  73770. /**
  73771. * Callback called when the task is successful
  73772. */
  73773. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73774. /**
  73775. * Creates a new ContainerAssetTask
  73776. * @param name defines the name of the task
  73777. * @param meshesNames defines the list of mesh's names you want to load
  73778. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73779. * @param sceneFilename defines the filename or File of the scene to load from
  73780. */
  73781. constructor(
  73782. /**
  73783. * Defines the name of the task
  73784. */
  73785. name: string,
  73786. /**
  73787. * Defines the list of mesh's names you want to load
  73788. */
  73789. meshesNames: any,
  73790. /**
  73791. * Defines the root url to use as a base to load your meshes and associated resources
  73792. */
  73793. rootUrl: string,
  73794. /**
  73795. * Defines the filename or File of the scene to load from
  73796. */
  73797. sceneFilename: string | File);
  73798. /**
  73799. * Execute the current task
  73800. * @param scene defines the scene where you want your assets to be loaded
  73801. * @param onSuccess is a callback called when the task is successfully executed
  73802. * @param onError is a callback called if an error occurs
  73803. */
  73804. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73805. }
  73806. /**
  73807. * Define a task used by AssetsManager to load meshes
  73808. */
  73809. export class MeshAssetTask extends AbstractAssetTask {
  73810. /**
  73811. * Defines the name of the task
  73812. */
  73813. name: string;
  73814. /**
  73815. * Defines the list of mesh's names you want to load
  73816. */
  73817. meshesNames: any;
  73818. /**
  73819. * Defines the root url to use as a base to load your meshes and associated resources
  73820. */
  73821. rootUrl: string;
  73822. /**
  73823. * Defines the filename or File of the scene to load from
  73824. */
  73825. sceneFilename: string | File;
  73826. /**
  73827. * Gets the list of loaded meshes
  73828. */
  73829. loadedMeshes: Array<AbstractMesh>;
  73830. /**
  73831. * Gets the list of loaded particle systems
  73832. */
  73833. loadedParticleSystems: Array<IParticleSystem>;
  73834. /**
  73835. * Gets the list of loaded skeletons
  73836. */
  73837. loadedSkeletons: Array<Skeleton>;
  73838. /**
  73839. * Gets the list of loaded animation groups
  73840. */
  73841. loadedAnimationGroups: Array<AnimationGroup>;
  73842. /**
  73843. * Callback called when the task is successful
  73844. */
  73845. onSuccess: (task: MeshAssetTask) => void;
  73846. /**
  73847. * Callback called when the task is successful
  73848. */
  73849. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73850. /**
  73851. * Creates a new MeshAssetTask
  73852. * @param name defines the name of the task
  73853. * @param meshesNames defines the list of mesh's names you want to load
  73854. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73855. * @param sceneFilename defines the filename or File of the scene to load from
  73856. */
  73857. constructor(
  73858. /**
  73859. * Defines the name of the task
  73860. */
  73861. name: string,
  73862. /**
  73863. * Defines the list of mesh's names you want to load
  73864. */
  73865. meshesNames: any,
  73866. /**
  73867. * Defines the root url to use as a base to load your meshes and associated resources
  73868. */
  73869. rootUrl: string,
  73870. /**
  73871. * Defines the filename or File of the scene to load from
  73872. */
  73873. sceneFilename: string | File);
  73874. /**
  73875. * Execute the current task
  73876. * @param scene defines the scene where you want your assets to be loaded
  73877. * @param onSuccess is a callback called when the task is successfully executed
  73878. * @param onError is a callback called if an error occurs
  73879. */
  73880. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73881. }
  73882. /**
  73883. * Define a task used by AssetsManager to load text content
  73884. */
  73885. export class TextFileAssetTask extends AbstractAssetTask {
  73886. /**
  73887. * Defines the name of the task
  73888. */
  73889. name: string;
  73890. /**
  73891. * Defines the location of the file to load
  73892. */
  73893. url: string;
  73894. /**
  73895. * Gets the loaded text string
  73896. */
  73897. text: string;
  73898. /**
  73899. * Callback called when the task is successful
  73900. */
  73901. onSuccess: (task: TextFileAssetTask) => void;
  73902. /**
  73903. * Callback called when the task is successful
  73904. */
  73905. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73906. /**
  73907. * Creates a new TextFileAssetTask object
  73908. * @param name defines the name of the task
  73909. * @param url defines the location of the file to load
  73910. */
  73911. constructor(
  73912. /**
  73913. * Defines the name of the task
  73914. */
  73915. name: string,
  73916. /**
  73917. * Defines the location of the file to load
  73918. */
  73919. url: string);
  73920. /**
  73921. * Execute the current task
  73922. * @param scene defines the scene where you want your assets to be loaded
  73923. * @param onSuccess is a callback called when the task is successfully executed
  73924. * @param onError is a callback called if an error occurs
  73925. */
  73926. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73927. }
  73928. /**
  73929. * Define a task used by AssetsManager to load binary data
  73930. */
  73931. export class BinaryFileAssetTask extends AbstractAssetTask {
  73932. /**
  73933. * Defines the name of the task
  73934. */
  73935. name: string;
  73936. /**
  73937. * Defines the location of the file to load
  73938. */
  73939. url: string;
  73940. /**
  73941. * Gets the lodaded data (as an array buffer)
  73942. */
  73943. data: ArrayBuffer;
  73944. /**
  73945. * Callback called when the task is successful
  73946. */
  73947. onSuccess: (task: BinaryFileAssetTask) => void;
  73948. /**
  73949. * Callback called when the task is successful
  73950. */
  73951. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73952. /**
  73953. * Creates a new BinaryFileAssetTask object
  73954. * @param name defines the name of the new task
  73955. * @param url defines the location of the file to load
  73956. */
  73957. constructor(
  73958. /**
  73959. * Defines the name of the task
  73960. */
  73961. name: string,
  73962. /**
  73963. * Defines the location of the file to load
  73964. */
  73965. url: string);
  73966. /**
  73967. * Execute the current task
  73968. * @param scene defines the scene where you want your assets to be loaded
  73969. * @param onSuccess is a callback called when the task is successfully executed
  73970. * @param onError is a callback called if an error occurs
  73971. */
  73972. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73973. }
  73974. /**
  73975. * Define a task used by AssetsManager to load images
  73976. */
  73977. export class ImageAssetTask extends AbstractAssetTask {
  73978. /**
  73979. * Defines the name of the task
  73980. */
  73981. name: string;
  73982. /**
  73983. * Defines the location of the image to load
  73984. */
  73985. url: string;
  73986. /**
  73987. * Gets the loaded images
  73988. */
  73989. image: HTMLImageElement;
  73990. /**
  73991. * Callback called when the task is successful
  73992. */
  73993. onSuccess: (task: ImageAssetTask) => void;
  73994. /**
  73995. * Callback called when the task is successful
  73996. */
  73997. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73998. /**
  73999. * Creates a new ImageAssetTask
  74000. * @param name defines the name of the task
  74001. * @param url defines the location of the image to load
  74002. */
  74003. constructor(
  74004. /**
  74005. * Defines the name of the task
  74006. */
  74007. name: string,
  74008. /**
  74009. * Defines the location of the image to load
  74010. */
  74011. url: string);
  74012. /**
  74013. * Execute the current task
  74014. * @param scene defines the scene where you want your assets to be loaded
  74015. * @param onSuccess is a callback called when the task is successfully executed
  74016. * @param onError is a callback called if an error occurs
  74017. */
  74018. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74019. }
  74020. /**
  74021. * Defines the interface used by texture loading tasks
  74022. */
  74023. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74024. /**
  74025. * Gets the loaded texture
  74026. */
  74027. texture: TEX;
  74028. }
  74029. /**
  74030. * Define a task used by AssetsManager to load 2D textures
  74031. */
  74032. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74033. /**
  74034. * Defines the name of the task
  74035. */
  74036. name: string;
  74037. /**
  74038. * Defines the location of the file to load
  74039. */
  74040. url: string;
  74041. /**
  74042. * Defines if mipmap should not be generated (default is false)
  74043. */
  74044. noMipmap?: boolean | undefined;
  74045. /**
  74046. * Defines if texture must be inverted on Y axis (default is true)
  74047. */
  74048. invertY: boolean;
  74049. /**
  74050. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74051. */
  74052. samplingMode: number;
  74053. /**
  74054. * Gets the loaded texture
  74055. */
  74056. texture: Texture;
  74057. /**
  74058. * Callback called when the task is successful
  74059. */
  74060. onSuccess: (task: TextureAssetTask) => void;
  74061. /**
  74062. * Callback called when the task is successful
  74063. */
  74064. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74065. /**
  74066. * Creates a new TextureAssetTask object
  74067. * @param name defines the name of the task
  74068. * @param url defines the location of the file to load
  74069. * @param noMipmap defines if mipmap should not be generated (default is false)
  74070. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74071. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74072. */
  74073. constructor(
  74074. /**
  74075. * Defines the name of the task
  74076. */
  74077. name: string,
  74078. /**
  74079. * Defines the location of the file to load
  74080. */
  74081. url: string,
  74082. /**
  74083. * Defines if mipmap should not be generated (default is false)
  74084. */
  74085. noMipmap?: boolean | undefined,
  74086. /**
  74087. * Defines if texture must be inverted on Y axis (default is true)
  74088. */
  74089. invertY?: boolean,
  74090. /**
  74091. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74092. */
  74093. samplingMode?: number);
  74094. /**
  74095. * Execute the current task
  74096. * @param scene defines the scene where you want your assets to be loaded
  74097. * @param onSuccess is a callback called when the task is successfully executed
  74098. * @param onError is a callback called if an error occurs
  74099. */
  74100. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74101. }
  74102. /**
  74103. * Define a task used by AssetsManager to load cube textures
  74104. */
  74105. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74106. /**
  74107. * Defines the name of the task
  74108. */
  74109. name: string;
  74110. /**
  74111. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74112. */
  74113. url: string;
  74114. /**
  74115. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74116. */
  74117. extensions?: string[] | undefined;
  74118. /**
  74119. * Defines if mipmaps should not be generated (default is false)
  74120. */
  74121. noMipmap?: boolean | undefined;
  74122. /**
  74123. * Defines the explicit list of files (undefined by default)
  74124. */
  74125. files?: string[] | undefined;
  74126. /**
  74127. * Gets the loaded texture
  74128. */
  74129. texture: CubeTexture;
  74130. /**
  74131. * Callback called when the task is successful
  74132. */
  74133. onSuccess: (task: CubeTextureAssetTask) => void;
  74134. /**
  74135. * Callback called when the task is successful
  74136. */
  74137. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74138. /**
  74139. * Creates a new CubeTextureAssetTask
  74140. * @param name defines the name of the task
  74141. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74142. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74143. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74144. * @param files defines the explicit list of files (undefined by default)
  74145. */
  74146. constructor(
  74147. /**
  74148. * Defines the name of the task
  74149. */
  74150. name: string,
  74151. /**
  74152. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74153. */
  74154. url: string,
  74155. /**
  74156. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74157. */
  74158. extensions?: string[] | undefined,
  74159. /**
  74160. * Defines if mipmaps should not be generated (default is false)
  74161. */
  74162. noMipmap?: boolean | undefined,
  74163. /**
  74164. * Defines the explicit list of files (undefined by default)
  74165. */
  74166. files?: string[] | undefined);
  74167. /**
  74168. * Execute the current task
  74169. * @param scene defines the scene where you want your assets to be loaded
  74170. * @param onSuccess is a callback called when the task is successfully executed
  74171. * @param onError is a callback called if an error occurs
  74172. */
  74173. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74174. }
  74175. /**
  74176. * Define a task used by AssetsManager to load HDR cube textures
  74177. */
  74178. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74179. /**
  74180. * Defines the name of the task
  74181. */
  74182. name: string;
  74183. /**
  74184. * Defines the location of the file to load
  74185. */
  74186. url: string;
  74187. /**
  74188. * Defines the desired size (the more it increases the longer the generation will be)
  74189. */
  74190. size: number;
  74191. /**
  74192. * Defines if mipmaps should not be generated (default is false)
  74193. */
  74194. noMipmap: boolean;
  74195. /**
  74196. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74197. */
  74198. generateHarmonics: boolean;
  74199. /**
  74200. * 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)
  74201. */
  74202. gammaSpace: boolean;
  74203. /**
  74204. * Internal Use Only
  74205. */
  74206. reserved: boolean;
  74207. /**
  74208. * Gets the loaded texture
  74209. */
  74210. texture: HDRCubeTexture;
  74211. /**
  74212. * Callback called when the task is successful
  74213. */
  74214. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74215. /**
  74216. * Callback called when the task is successful
  74217. */
  74218. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74219. /**
  74220. * Creates a new HDRCubeTextureAssetTask object
  74221. * @param name defines the name of the task
  74222. * @param url defines the location of the file to load
  74223. * @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.
  74224. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74225. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74226. * @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)
  74227. * @param reserved Internal use only
  74228. */
  74229. constructor(
  74230. /**
  74231. * Defines the name of the task
  74232. */
  74233. name: string,
  74234. /**
  74235. * Defines the location of the file to load
  74236. */
  74237. url: string,
  74238. /**
  74239. * Defines the desired size (the more it increases the longer the generation will be)
  74240. */
  74241. size: number,
  74242. /**
  74243. * Defines if mipmaps should not be generated (default is false)
  74244. */
  74245. noMipmap?: boolean,
  74246. /**
  74247. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74248. */
  74249. generateHarmonics?: boolean,
  74250. /**
  74251. * 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)
  74252. */
  74253. gammaSpace?: boolean,
  74254. /**
  74255. * Internal Use Only
  74256. */
  74257. reserved?: boolean);
  74258. /**
  74259. * Execute the current task
  74260. * @param scene defines the scene where you want your assets to be loaded
  74261. * @param onSuccess is a callback called when the task is successfully executed
  74262. * @param onError is a callback called if an error occurs
  74263. */
  74264. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74265. }
  74266. /**
  74267. * Define a task used by AssetsManager to load Equirectangular cube textures
  74268. */
  74269. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74270. /**
  74271. * Defines the name of the task
  74272. */
  74273. name: string;
  74274. /**
  74275. * Defines the location of the file to load
  74276. */
  74277. url: string;
  74278. /**
  74279. * Defines the desired size (the more it increases the longer the generation will be)
  74280. */
  74281. size: number;
  74282. /**
  74283. * Defines if mipmaps should not be generated (default is false)
  74284. */
  74285. noMipmap: boolean;
  74286. /**
  74287. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74288. * but the standard material would require them in Gamma space) (default is true)
  74289. */
  74290. gammaSpace: boolean;
  74291. /**
  74292. * Gets the loaded texture
  74293. */
  74294. texture: EquiRectangularCubeTexture;
  74295. /**
  74296. * Callback called when the task is successful
  74297. */
  74298. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74299. /**
  74300. * Callback called when the task is successful
  74301. */
  74302. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74303. /**
  74304. * Creates a new EquiRectangularCubeTextureAssetTask object
  74305. * @param name defines the name of the task
  74306. * @param url defines the location of the file to load
  74307. * @param size defines the desired size (the more it increases the longer the generation will be)
  74308. * If the size is omitted this implies you are using a preprocessed cubemap.
  74309. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74310. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74311. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74312. * (default is true)
  74313. */
  74314. constructor(
  74315. /**
  74316. * Defines the name of the task
  74317. */
  74318. name: string,
  74319. /**
  74320. * Defines the location of the file to load
  74321. */
  74322. url: string,
  74323. /**
  74324. * Defines the desired size (the more it increases the longer the generation will be)
  74325. */
  74326. size: number,
  74327. /**
  74328. * Defines if mipmaps should not be generated (default is false)
  74329. */
  74330. noMipmap?: boolean,
  74331. /**
  74332. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74333. * but the standard material would require them in Gamma space) (default is true)
  74334. */
  74335. gammaSpace?: boolean);
  74336. /**
  74337. * Execute the current task
  74338. * @param scene defines the scene where you want your assets to be loaded
  74339. * @param onSuccess is a callback called when the task is successfully executed
  74340. * @param onError is a callback called if an error occurs
  74341. */
  74342. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74343. }
  74344. /**
  74345. * This class can be used to easily import assets into a scene
  74346. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74347. */
  74348. export class AssetsManager {
  74349. private _scene;
  74350. private _isLoading;
  74351. protected _tasks: AbstractAssetTask[];
  74352. protected _waitingTasksCount: number;
  74353. protected _totalTasksCount: number;
  74354. /**
  74355. * Callback called when all tasks are processed
  74356. */
  74357. onFinish: (tasks: AbstractAssetTask[]) => void;
  74358. /**
  74359. * Callback called when a task is successful
  74360. */
  74361. onTaskSuccess: (task: AbstractAssetTask) => void;
  74362. /**
  74363. * Callback called when a task had an error
  74364. */
  74365. onTaskError: (task: AbstractAssetTask) => void;
  74366. /**
  74367. * Callback called when a task is done (whatever the result is)
  74368. */
  74369. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74370. /**
  74371. * Observable called when all tasks are processed
  74372. */
  74373. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74374. /**
  74375. * Observable called when a task had an error
  74376. */
  74377. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74378. /**
  74379. * Observable called when all tasks were executed
  74380. */
  74381. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74382. /**
  74383. * Observable called when a task is done (whatever the result is)
  74384. */
  74385. onProgressObservable: Observable<IAssetsProgressEvent>;
  74386. /**
  74387. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74388. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74389. */
  74390. useDefaultLoadingScreen: boolean;
  74391. /**
  74392. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74393. * when all assets have been downloaded.
  74394. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74395. */
  74396. autoHideLoadingUI: boolean;
  74397. /**
  74398. * Creates a new AssetsManager
  74399. * @param scene defines the scene to work on
  74400. */
  74401. constructor(scene: Scene);
  74402. /**
  74403. * Add a ContainerAssetTask to the list of active tasks
  74404. * @param taskName defines the name of the new task
  74405. * @param meshesNames defines the name of meshes to load
  74406. * @param rootUrl defines the root url to use to locate files
  74407. * @param sceneFilename defines the filename of the scene file
  74408. * @returns a new ContainerAssetTask object
  74409. */
  74410. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74411. /**
  74412. * Add a MeshAssetTask to the list of active tasks
  74413. * @param taskName defines the name of the new task
  74414. * @param meshesNames defines the name of meshes to load
  74415. * @param rootUrl defines the root url to use to locate files
  74416. * @param sceneFilename defines the filename of the scene file
  74417. * @returns a new MeshAssetTask object
  74418. */
  74419. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74420. /**
  74421. * Add a TextFileAssetTask to the list of active tasks
  74422. * @param taskName defines the name of the new task
  74423. * @param url defines the url of the file to load
  74424. * @returns a new TextFileAssetTask object
  74425. */
  74426. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74427. /**
  74428. * Add a BinaryFileAssetTask to the list of active tasks
  74429. * @param taskName defines the name of the new task
  74430. * @param url defines the url of the file to load
  74431. * @returns a new BinaryFileAssetTask object
  74432. */
  74433. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74434. /**
  74435. * Add a ImageAssetTask to the list of active tasks
  74436. * @param taskName defines the name of the new task
  74437. * @param url defines the url of the file to load
  74438. * @returns a new ImageAssetTask object
  74439. */
  74440. addImageTask(taskName: string, url: string): ImageAssetTask;
  74441. /**
  74442. * Add a TextureAssetTask to the list of active tasks
  74443. * @param taskName defines the name of the new task
  74444. * @param url defines the url of the file to load
  74445. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74446. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74447. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74448. * @returns a new TextureAssetTask object
  74449. */
  74450. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74451. /**
  74452. * Add a CubeTextureAssetTask to the list of active tasks
  74453. * @param taskName defines the name of the new task
  74454. * @param url defines the url of the file to load
  74455. * @param extensions defines the extension to use to load the cube map (can be null)
  74456. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74457. * @param files defines the list of files to load (can be null)
  74458. * @returns a new CubeTextureAssetTask object
  74459. */
  74460. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74461. /**
  74462. *
  74463. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74464. * @param taskName defines the name of the new task
  74465. * @param url defines the url of the file to load
  74466. * @param size defines the size you want for the cubemap (can be null)
  74467. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74468. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74469. * @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)
  74470. * @param reserved Internal use only
  74471. * @returns a new HDRCubeTextureAssetTask object
  74472. */
  74473. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74474. /**
  74475. *
  74476. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74477. * @param taskName defines the name of the new task
  74478. * @param url defines the url of the file to load
  74479. * @param size defines the size you want for the cubemap (can be null)
  74480. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74481. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74482. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74483. * @returns a new EquiRectangularCubeTextureAssetTask object
  74484. */
  74485. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74486. /**
  74487. * Remove a task from the assets manager.
  74488. * @param task the task to remove
  74489. */
  74490. removeTask(task: AbstractAssetTask): void;
  74491. private _decreaseWaitingTasksCount;
  74492. private _runTask;
  74493. /**
  74494. * Reset the AssetsManager and remove all tasks
  74495. * @return the current instance of the AssetsManager
  74496. */
  74497. reset(): AssetsManager;
  74498. /**
  74499. * Start the loading process
  74500. * @return the current instance of the AssetsManager
  74501. */
  74502. load(): AssetsManager;
  74503. /**
  74504. * Start the loading process as an async operation
  74505. * @return a promise returning the list of failed tasks
  74506. */
  74507. loadAsync(): Promise<void>;
  74508. }
  74509. }
  74510. declare module BABYLON {
  74511. /**
  74512. * Wrapper class for promise with external resolve and reject.
  74513. */
  74514. export class Deferred<T> {
  74515. /**
  74516. * The promise associated with this deferred object.
  74517. */
  74518. readonly promise: Promise<T>;
  74519. private _resolve;
  74520. private _reject;
  74521. /**
  74522. * The resolve method of the promise associated with this deferred object.
  74523. */
  74524. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74525. /**
  74526. * The reject method of the promise associated with this deferred object.
  74527. */
  74528. get reject(): (reason?: any) => void;
  74529. /**
  74530. * Constructor for this deferred object.
  74531. */
  74532. constructor();
  74533. }
  74534. }
  74535. declare module BABYLON {
  74536. /**
  74537. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74538. */
  74539. export class MeshExploder {
  74540. private _centerMesh;
  74541. private _meshes;
  74542. private _meshesOrigins;
  74543. private _toCenterVectors;
  74544. private _scaledDirection;
  74545. private _newPosition;
  74546. private _centerPosition;
  74547. /**
  74548. * Explodes meshes from a center mesh.
  74549. * @param meshes The meshes to explode.
  74550. * @param centerMesh The mesh to be center of explosion.
  74551. */
  74552. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74553. private _setCenterMesh;
  74554. /**
  74555. * Get class name
  74556. * @returns "MeshExploder"
  74557. */
  74558. getClassName(): string;
  74559. /**
  74560. * "Exploded meshes"
  74561. * @returns Array of meshes with the centerMesh at index 0.
  74562. */
  74563. getMeshes(): Array<Mesh>;
  74564. /**
  74565. * Explodes meshes giving a specific direction
  74566. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74567. */
  74568. explode(direction?: number): void;
  74569. }
  74570. }
  74571. declare module BABYLON {
  74572. /**
  74573. * Class used to help managing file picking and drag'n'drop
  74574. */
  74575. export class FilesInput {
  74576. /**
  74577. * List of files ready to be loaded
  74578. */
  74579. static get FilesToLoad(): {
  74580. [key: string]: File;
  74581. };
  74582. /**
  74583. * Callback called when a file is processed
  74584. */
  74585. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74586. private _engine;
  74587. private _currentScene;
  74588. private _sceneLoadedCallback;
  74589. private _progressCallback;
  74590. private _additionalRenderLoopLogicCallback;
  74591. private _textureLoadingCallback;
  74592. private _startingProcessingFilesCallback;
  74593. private _onReloadCallback;
  74594. private _errorCallback;
  74595. private _elementToMonitor;
  74596. private _sceneFileToLoad;
  74597. private _filesToLoad;
  74598. /**
  74599. * Creates a new FilesInput
  74600. * @param engine defines the rendering engine
  74601. * @param scene defines the hosting scene
  74602. * @param sceneLoadedCallback callback called when scene is loaded
  74603. * @param progressCallback callback called to track progress
  74604. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74605. * @param textureLoadingCallback callback called when a texture is loading
  74606. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74607. * @param onReloadCallback callback called when a reload is requested
  74608. * @param errorCallback callback call if an error occurs
  74609. */
  74610. 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>);
  74611. private _dragEnterHandler;
  74612. private _dragOverHandler;
  74613. private _dropHandler;
  74614. /**
  74615. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74616. * @param elementToMonitor defines the DOM element to track
  74617. */
  74618. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74619. /** Gets the current list of files to load */
  74620. get filesToLoad(): File[];
  74621. /**
  74622. * Release all associated resources
  74623. */
  74624. dispose(): void;
  74625. private renderFunction;
  74626. private drag;
  74627. private drop;
  74628. private _traverseFolder;
  74629. private _processFiles;
  74630. /**
  74631. * Load files from a drop event
  74632. * @param event defines the drop event to use as source
  74633. */
  74634. loadFiles(event: any): void;
  74635. private _processReload;
  74636. /**
  74637. * Reload the current scene from the loaded files
  74638. */
  74639. reload(): void;
  74640. }
  74641. }
  74642. declare module BABYLON {
  74643. /**
  74644. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74645. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74646. */
  74647. export class SceneOptimization {
  74648. /**
  74649. * Defines the priority of this optimization (0 by default which means first in the list)
  74650. */
  74651. priority: number;
  74652. /**
  74653. * Gets a string describing the action executed by the current optimization
  74654. * @returns description string
  74655. */
  74656. getDescription(): string;
  74657. /**
  74658. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74659. * @param scene defines the current scene where to apply this optimization
  74660. * @param optimizer defines the current optimizer
  74661. * @returns true if everything that can be done was applied
  74662. */
  74663. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74664. /**
  74665. * Creates the SceneOptimization object
  74666. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74667. * @param desc defines the description associated with the optimization
  74668. */
  74669. constructor(
  74670. /**
  74671. * Defines the priority of this optimization (0 by default which means first in the list)
  74672. */
  74673. priority?: number);
  74674. }
  74675. /**
  74676. * Defines an optimization used to reduce the size of render target textures
  74677. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74678. */
  74679. export class TextureOptimization extends SceneOptimization {
  74680. /**
  74681. * Defines the priority of this optimization (0 by default which means first in the list)
  74682. */
  74683. priority: number;
  74684. /**
  74685. * 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
  74686. */
  74687. maximumSize: number;
  74688. /**
  74689. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74690. */
  74691. step: number;
  74692. /**
  74693. * Gets a string describing the action executed by the current optimization
  74694. * @returns description string
  74695. */
  74696. getDescription(): string;
  74697. /**
  74698. * Creates the TextureOptimization object
  74699. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74700. * @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
  74701. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74702. */
  74703. constructor(
  74704. /**
  74705. * Defines the priority of this optimization (0 by default which means first in the list)
  74706. */
  74707. priority?: number,
  74708. /**
  74709. * 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
  74710. */
  74711. maximumSize?: number,
  74712. /**
  74713. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74714. */
  74715. step?: number);
  74716. /**
  74717. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74718. * @param scene defines the current scene where to apply this optimization
  74719. * @param optimizer defines the current optimizer
  74720. * @returns true if everything that can be done was applied
  74721. */
  74722. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74723. }
  74724. /**
  74725. * Defines an optimization used to increase or decrease the rendering resolution
  74726. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74727. */
  74728. export class HardwareScalingOptimization extends SceneOptimization {
  74729. /**
  74730. * Defines the priority of this optimization (0 by default which means first in the list)
  74731. */
  74732. priority: number;
  74733. /**
  74734. * Defines the maximum scale to use (2 by default)
  74735. */
  74736. maximumScale: number;
  74737. /**
  74738. * Defines the step to use between two passes (0.5 by default)
  74739. */
  74740. step: number;
  74741. private _currentScale;
  74742. private _directionOffset;
  74743. /**
  74744. * Gets a string describing the action executed by the current optimization
  74745. * @return description string
  74746. */
  74747. getDescription(): string;
  74748. /**
  74749. * Creates the HardwareScalingOptimization object
  74750. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74751. * @param maximumScale defines the maximum scale to use (2 by default)
  74752. * @param step defines the step to use between two passes (0.5 by default)
  74753. */
  74754. constructor(
  74755. /**
  74756. * Defines the priority of this optimization (0 by default which means first in the list)
  74757. */
  74758. priority?: number,
  74759. /**
  74760. * Defines the maximum scale to use (2 by default)
  74761. */
  74762. maximumScale?: number,
  74763. /**
  74764. * Defines the step to use between two passes (0.5 by default)
  74765. */
  74766. step?: number);
  74767. /**
  74768. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74769. * @param scene defines the current scene where to apply this optimization
  74770. * @param optimizer defines the current optimizer
  74771. * @returns true if everything that can be done was applied
  74772. */
  74773. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74774. }
  74775. /**
  74776. * Defines an optimization used to remove shadows
  74777. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74778. */
  74779. export class ShadowsOptimization extends SceneOptimization {
  74780. /**
  74781. * Gets a string describing the action executed by the current optimization
  74782. * @return description string
  74783. */
  74784. getDescription(): string;
  74785. /**
  74786. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74787. * @param scene defines the current scene where to apply this optimization
  74788. * @param optimizer defines the current optimizer
  74789. * @returns true if everything that can be done was applied
  74790. */
  74791. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74792. }
  74793. /**
  74794. * Defines an optimization used to turn post-processes off
  74795. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74796. */
  74797. export class PostProcessesOptimization extends SceneOptimization {
  74798. /**
  74799. * Gets a string describing the action executed by the current optimization
  74800. * @return description string
  74801. */
  74802. getDescription(): string;
  74803. /**
  74804. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74805. * @param scene defines the current scene where to apply this optimization
  74806. * @param optimizer defines the current optimizer
  74807. * @returns true if everything that can be done was applied
  74808. */
  74809. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74810. }
  74811. /**
  74812. * Defines an optimization used to turn lens flares off
  74813. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74814. */
  74815. export class LensFlaresOptimization extends SceneOptimization {
  74816. /**
  74817. * Gets a string describing the action executed by the current optimization
  74818. * @return description string
  74819. */
  74820. getDescription(): string;
  74821. /**
  74822. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74823. * @param scene defines the current scene where to apply this optimization
  74824. * @param optimizer defines the current optimizer
  74825. * @returns true if everything that can be done was applied
  74826. */
  74827. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74828. }
  74829. /**
  74830. * Defines an optimization based on user defined callback.
  74831. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74832. */
  74833. export class CustomOptimization extends SceneOptimization {
  74834. /**
  74835. * Callback called to apply the custom optimization.
  74836. */
  74837. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74838. /**
  74839. * Callback called to get custom description
  74840. */
  74841. onGetDescription: () => string;
  74842. /**
  74843. * Gets a string describing the action executed by the current optimization
  74844. * @returns description string
  74845. */
  74846. getDescription(): string;
  74847. /**
  74848. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74849. * @param scene defines the current scene where to apply this optimization
  74850. * @param optimizer defines the current optimizer
  74851. * @returns true if everything that can be done was applied
  74852. */
  74853. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74854. }
  74855. /**
  74856. * Defines an optimization used to turn particles off
  74857. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74858. */
  74859. export class ParticlesOptimization extends SceneOptimization {
  74860. /**
  74861. * Gets a string describing the action executed by the current optimization
  74862. * @return description string
  74863. */
  74864. getDescription(): string;
  74865. /**
  74866. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74867. * @param scene defines the current scene where to apply this optimization
  74868. * @param optimizer defines the current optimizer
  74869. * @returns true if everything that can be done was applied
  74870. */
  74871. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74872. }
  74873. /**
  74874. * Defines an optimization used to turn render targets off
  74875. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74876. */
  74877. export class RenderTargetsOptimization extends SceneOptimization {
  74878. /**
  74879. * Gets a string describing the action executed by the current optimization
  74880. * @return description string
  74881. */
  74882. getDescription(): string;
  74883. /**
  74884. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74885. * @param scene defines the current scene where to apply this optimization
  74886. * @param optimizer defines the current optimizer
  74887. * @returns true if everything that can be done was applied
  74888. */
  74889. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74890. }
  74891. /**
  74892. * Defines an optimization used to merge meshes with compatible materials
  74893. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74894. */
  74895. export class MergeMeshesOptimization extends SceneOptimization {
  74896. private static _UpdateSelectionTree;
  74897. /**
  74898. * Gets or sets a boolean which defines if optimization octree has to be updated
  74899. */
  74900. static get UpdateSelectionTree(): boolean;
  74901. /**
  74902. * Gets or sets a boolean which defines if optimization octree has to be updated
  74903. */
  74904. static set UpdateSelectionTree(value: boolean);
  74905. /**
  74906. * Gets a string describing the action executed by the current optimization
  74907. * @return description string
  74908. */
  74909. getDescription(): string;
  74910. private _canBeMerged;
  74911. /**
  74912. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74913. * @param scene defines the current scene where to apply this optimization
  74914. * @param optimizer defines the current optimizer
  74915. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74916. * @returns true if everything that can be done was applied
  74917. */
  74918. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74919. }
  74920. /**
  74921. * Defines a list of options used by SceneOptimizer
  74922. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74923. */
  74924. export class SceneOptimizerOptions {
  74925. /**
  74926. * Defines the target frame rate to reach (60 by default)
  74927. */
  74928. targetFrameRate: number;
  74929. /**
  74930. * Defines the interval between two checkes (2000ms by default)
  74931. */
  74932. trackerDuration: number;
  74933. /**
  74934. * Gets the list of optimizations to apply
  74935. */
  74936. optimizations: SceneOptimization[];
  74937. /**
  74938. * Creates a new list of options used by SceneOptimizer
  74939. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74940. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74941. */
  74942. constructor(
  74943. /**
  74944. * Defines the target frame rate to reach (60 by default)
  74945. */
  74946. targetFrameRate?: number,
  74947. /**
  74948. * Defines the interval between two checkes (2000ms by default)
  74949. */
  74950. trackerDuration?: number);
  74951. /**
  74952. * Add a new optimization
  74953. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74954. * @returns the current SceneOptimizerOptions
  74955. */
  74956. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74957. /**
  74958. * Add a new custom optimization
  74959. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74960. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74961. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74962. * @returns the current SceneOptimizerOptions
  74963. */
  74964. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74965. /**
  74966. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74967. * @param targetFrameRate defines the target frame rate (60 by default)
  74968. * @returns a SceneOptimizerOptions object
  74969. */
  74970. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74971. /**
  74972. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74973. * @param targetFrameRate defines the target frame rate (60 by default)
  74974. * @returns a SceneOptimizerOptions object
  74975. */
  74976. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74977. /**
  74978. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74979. * @param targetFrameRate defines the target frame rate (60 by default)
  74980. * @returns a SceneOptimizerOptions object
  74981. */
  74982. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74983. }
  74984. /**
  74985. * Class used to run optimizations in order to reach a target frame rate
  74986. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74987. */
  74988. export class SceneOptimizer implements IDisposable {
  74989. private _isRunning;
  74990. private _options;
  74991. private _scene;
  74992. private _currentPriorityLevel;
  74993. private _targetFrameRate;
  74994. private _trackerDuration;
  74995. private _currentFrameRate;
  74996. private _sceneDisposeObserver;
  74997. private _improvementMode;
  74998. /**
  74999. * Defines an observable called when the optimizer reaches the target frame rate
  75000. */
  75001. onSuccessObservable: Observable<SceneOptimizer>;
  75002. /**
  75003. * Defines an observable called when the optimizer enables an optimization
  75004. */
  75005. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75006. /**
  75007. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75008. */
  75009. onFailureObservable: Observable<SceneOptimizer>;
  75010. /**
  75011. * Gets a boolean indicating if the optimizer is in improvement mode
  75012. */
  75013. get isInImprovementMode(): boolean;
  75014. /**
  75015. * Gets the current priority level (0 at start)
  75016. */
  75017. get currentPriorityLevel(): number;
  75018. /**
  75019. * Gets the current frame rate checked by the SceneOptimizer
  75020. */
  75021. get currentFrameRate(): number;
  75022. /**
  75023. * Gets or sets the current target frame rate (60 by default)
  75024. */
  75025. get targetFrameRate(): number;
  75026. /**
  75027. * Gets or sets the current target frame rate (60 by default)
  75028. */
  75029. set targetFrameRate(value: number);
  75030. /**
  75031. * Gets or sets the current interval between two checks (every 2000ms by default)
  75032. */
  75033. get trackerDuration(): number;
  75034. /**
  75035. * Gets or sets the current interval between two checks (every 2000ms by default)
  75036. */
  75037. set trackerDuration(value: number);
  75038. /**
  75039. * Gets the list of active optimizations
  75040. */
  75041. get optimizations(): SceneOptimization[];
  75042. /**
  75043. * Creates a new SceneOptimizer
  75044. * @param scene defines the scene to work on
  75045. * @param options defines the options to use with the SceneOptimizer
  75046. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75047. * @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)
  75048. */
  75049. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75050. /**
  75051. * Stops the current optimizer
  75052. */
  75053. stop(): void;
  75054. /**
  75055. * Reset the optimizer to initial step (current priority level = 0)
  75056. */
  75057. reset(): void;
  75058. /**
  75059. * Start the optimizer. By default it will try to reach a specific framerate
  75060. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75061. */
  75062. start(): void;
  75063. private _checkCurrentState;
  75064. /**
  75065. * Release all resources
  75066. */
  75067. dispose(): void;
  75068. /**
  75069. * Helper function to create a SceneOptimizer with one single line of code
  75070. * @param scene defines the scene to work on
  75071. * @param options defines the options to use with the SceneOptimizer
  75072. * @param onSuccess defines a callback to call on success
  75073. * @param onFailure defines a callback to call on failure
  75074. * @returns the new SceneOptimizer object
  75075. */
  75076. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75077. }
  75078. }
  75079. declare module BABYLON {
  75080. /**
  75081. * Class used to serialize a scene into a string
  75082. */
  75083. export class SceneSerializer {
  75084. /**
  75085. * Clear cache used by a previous serialization
  75086. */
  75087. static ClearCache(): void;
  75088. /**
  75089. * Serialize a scene into a JSON compatible object
  75090. * @param scene defines the scene to serialize
  75091. * @returns a JSON compatible object
  75092. */
  75093. static Serialize(scene: Scene): any;
  75094. /**
  75095. * Serialize a mesh into a JSON compatible object
  75096. * @param toSerialize defines the mesh to serialize
  75097. * @param withParents defines if parents must be serialized as well
  75098. * @param withChildren defines if children must be serialized as well
  75099. * @returns a JSON compatible object
  75100. */
  75101. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75102. }
  75103. }
  75104. declare module BABYLON {
  75105. /**
  75106. * Class used to host texture specific utilities
  75107. */
  75108. export class TextureTools {
  75109. /**
  75110. * Uses the GPU to create a copy texture rescaled at a given size
  75111. * @param texture Texture to copy from
  75112. * @param width defines the desired width
  75113. * @param height defines the desired height
  75114. * @param useBilinearMode defines if bilinear mode has to be used
  75115. * @return the generated texture
  75116. */
  75117. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75118. }
  75119. }
  75120. declare module BABYLON {
  75121. /**
  75122. * This represents the different options available for the video capture.
  75123. */
  75124. export interface VideoRecorderOptions {
  75125. /** Defines the mime type of the video. */
  75126. mimeType: string;
  75127. /** Defines the FPS the video should be recorded at. */
  75128. fps: number;
  75129. /** Defines the chunk size for the recording data. */
  75130. recordChunckSize: number;
  75131. /** The audio tracks to attach to the recording. */
  75132. audioTracks?: MediaStreamTrack[];
  75133. }
  75134. /**
  75135. * This can help with recording videos from BabylonJS.
  75136. * This is based on the available WebRTC functionalities of the browser.
  75137. *
  75138. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  75139. */
  75140. export class VideoRecorder {
  75141. private static readonly _defaultOptions;
  75142. /**
  75143. * Returns whether or not the VideoRecorder is available in your browser.
  75144. * @param engine Defines the Babylon Engine.
  75145. * @returns true if supported otherwise false.
  75146. */
  75147. static IsSupported(engine: Engine): boolean;
  75148. private readonly _options;
  75149. private _canvas;
  75150. private _mediaRecorder;
  75151. private _recordedChunks;
  75152. private _fileName;
  75153. private _resolve;
  75154. private _reject;
  75155. /**
  75156. * True when a recording is already in progress.
  75157. */
  75158. get isRecording(): boolean;
  75159. /**
  75160. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75161. * @param engine Defines the BabylonJS Engine you wish to record.
  75162. * @param options Defines options that can be used to customize the capture.
  75163. */
  75164. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75165. /**
  75166. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75167. */
  75168. stopRecording(): void;
  75169. /**
  75170. * Starts recording the canvas for a max duration specified in parameters.
  75171. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75172. * If null no automatic download will start and you can rely on the promise to get the data back.
  75173. * @param maxDuration Defines the maximum recording time in seconds.
  75174. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75175. * @return A promise callback at the end of the recording with the video data in Blob.
  75176. */
  75177. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75178. /**
  75179. * Releases internal resources used during the recording.
  75180. */
  75181. dispose(): void;
  75182. private _handleDataAvailable;
  75183. private _handleError;
  75184. private _handleStop;
  75185. }
  75186. }
  75187. declare module BABYLON {
  75188. /**
  75189. * Class containing a set of static utilities functions for screenshots
  75190. */
  75191. export class ScreenshotTools {
  75192. /**
  75193. * Captures a screenshot of the current rendering
  75194. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75195. * @param engine defines the rendering engine
  75196. * @param camera defines the source camera
  75197. * @param size This parameter can be set to a single number or to an object with the
  75198. * following (optional) properties: precision, width, height. If a single number is passed,
  75199. * it will be used for both width and height. If an object is passed, the screenshot size
  75200. * will be derived from the parameters. The precision property is a multiplier allowing
  75201. * rendering at a higher or lower resolution
  75202. * @param successCallback defines the callback receives a single parameter which contains the
  75203. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75204. * src parameter of an <img> to display it
  75205. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75206. * Check your browser for supported MIME types
  75207. */
  75208. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75209. /**
  75210. * Captures a screenshot of the current rendering
  75211. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75212. * @param engine defines the rendering engine
  75213. * @param camera defines the source camera
  75214. * @param size This parameter can be set to a single number or to an object with the
  75215. * following (optional) properties: precision, width, height. If a single number is passed,
  75216. * it will be used for both width and height. If an object is passed, the screenshot size
  75217. * will be derived from the parameters. The precision property is a multiplier allowing
  75218. * rendering at a higher or lower resolution
  75219. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75220. * Check your browser for supported MIME types
  75221. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75222. * to the src parameter of an <img> to display it
  75223. */
  75224. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75225. /**
  75226. * Generates an image screenshot from the specified camera.
  75227. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75228. * @param engine The engine to use for rendering
  75229. * @param camera The camera to use for rendering
  75230. * @param size This parameter can be set to a single number or to an object with the
  75231. * following (optional) properties: precision, width, height. If a single number is passed,
  75232. * it will be used for both width and height. If an object is passed, the screenshot size
  75233. * will be derived from the parameters. The precision property is a multiplier allowing
  75234. * rendering at a higher or lower resolution
  75235. * @param successCallback The callback receives a single parameter which contains the
  75236. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75237. * src parameter of an <img> to display it
  75238. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75239. * Check your browser for supported MIME types
  75240. * @param samples Texture samples (default: 1)
  75241. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75242. * @param fileName A name for for the downloaded file.
  75243. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75244. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  75245. */
  75246. 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;
  75247. /**
  75248. * Generates an image screenshot from the specified camera.
  75249. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75250. * @param engine The engine to use for rendering
  75251. * @param camera The camera to use for rendering
  75252. * @param size This parameter can be set to a single number or to an object with the
  75253. * following (optional) properties: precision, width, height. If a single number is passed,
  75254. * it will be used for both width and height. If an object is passed, the screenshot size
  75255. * will be derived from the parameters. The precision property is a multiplier allowing
  75256. * rendering at a higher or lower resolution
  75257. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75258. * Check your browser for supported MIME types
  75259. * @param samples Texture samples (default: 1)
  75260. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75261. * @param fileName A name for for the downloaded file.
  75262. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75263. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75264. * to the src parameter of an <img> to display it
  75265. */
  75266. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75267. /**
  75268. * Gets height and width for screenshot size
  75269. * @private
  75270. */
  75271. private static _getScreenshotSize;
  75272. }
  75273. }
  75274. declare module BABYLON {
  75275. /**
  75276. * Interface for a data buffer
  75277. */
  75278. export interface IDataBuffer {
  75279. /**
  75280. * Reads bytes from the data buffer.
  75281. * @param byteOffset The byte offset to read
  75282. * @param byteLength The byte length to read
  75283. * @returns A promise that resolves when the bytes are read
  75284. */
  75285. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75286. /**
  75287. * The byte length of the buffer.
  75288. */
  75289. readonly byteLength: number;
  75290. }
  75291. /**
  75292. * Utility class for reading from a data buffer
  75293. */
  75294. export class DataReader {
  75295. /**
  75296. * The data buffer associated with this data reader.
  75297. */
  75298. readonly buffer: IDataBuffer;
  75299. /**
  75300. * The current byte offset from the beginning of the data buffer.
  75301. */
  75302. byteOffset: number;
  75303. private _dataView;
  75304. private _dataByteOffset;
  75305. /**
  75306. * Constructor
  75307. * @param buffer The buffer to read
  75308. */
  75309. constructor(buffer: IDataBuffer);
  75310. /**
  75311. * Loads the given byte length.
  75312. * @param byteLength The byte length to load
  75313. * @returns A promise that resolves when the load is complete
  75314. */
  75315. loadAsync(byteLength: number): Promise<void>;
  75316. /**
  75317. * Read a unsigned 32-bit integer from the currently loaded data range.
  75318. * @returns The 32-bit integer read
  75319. */
  75320. readUint32(): number;
  75321. /**
  75322. * Read a byte array from the currently loaded data range.
  75323. * @param byteLength The byte length to read
  75324. * @returns The byte array read
  75325. */
  75326. readUint8Array(byteLength: number): Uint8Array;
  75327. /**
  75328. * Read a string from the currently loaded data range.
  75329. * @param byteLength The byte length to read
  75330. * @returns The string read
  75331. */
  75332. readString(byteLength: number): string;
  75333. /**
  75334. * Skips the given byte length the currently loaded data range.
  75335. * @param byteLength The byte length to skip
  75336. */
  75337. skipBytes(byteLength: number): void;
  75338. }
  75339. }
  75340. declare module BABYLON {
  75341. /**
  75342. * Class for storing data to local storage if available or in-memory storage otherwise
  75343. */
  75344. export class DataStorage {
  75345. private static _Storage;
  75346. private static _GetStorage;
  75347. /**
  75348. * Reads a string from the data storage
  75349. * @param key The key to read
  75350. * @param defaultValue The value if the key doesn't exist
  75351. * @returns The string value
  75352. */
  75353. static ReadString(key: string, defaultValue: string): string;
  75354. /**
  75355. * Writes a string to the data storage
  75356. * @param key The key to write
  75357. * @param value The value to write
  75358. */
  75359. static WriteString(key: string, value: string): void;
  75360. /**
  75361. * Reads a boolean from the data storage
  75362. * @param key The key to read
  75363. * @param defaultValue The value if the key doesn't exist
  75364. * @returns The boolean value
  75365. */
  75366. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75367. /**
  75368. * Writes a boolean to the data storage
  75369. * @param key The key to write
  75370. * @param value The value to write
  75371. */
  75372. static WriteBoolean(key: string, value: boolean): void;
  75373. /**
  75374. * Reads a number from the data storage
  75375. * @param key The key to read
  75376. * @param defaultValue The value if the key doesn't exist
  75377. * @returns The number value
  75378. */
  75379. static ReadNumber(key: string, defaultValue: number): number;
  75380. /**
  75381. * Writes a number to the data storage
  75382. * @param key The key to write
  75383. * @param value The value to write
  75384. */
  75385. static WriteNumber(key: string, value: number): void;
  75386. }
  75387. }
  75388. declare module BABYLON {
  75389. /**
  75390. * Class used to record delta files between 2 scene states
  75391. */
  75392. export class SceneRecorder {
  75393. private _trackedScene;
  75394. private _savedJSON;
  75395. /**
  75396. * Track a given scene. This means the current scene state will be considered the original state
  75397. * @param scene defines the scene to track
  75398. */
  75399. track(scene: Scene): void;
  75400. /**
  75401. * Get the delta between current state and original state
  75402. * @returns a string containing the delta
  75403. */
  75404. getDelta(): any;
  75405. private _compareArray;
  75406. private _compareObjects;
  75407. private _compareCollections;
  75408. private static GetShadowGeneratorById;
  75409. /**
  75410. * Apply a given delta to a given scene
  75411. * @param deltaJSON defines the JSON containing the delta
  75412. * @param scene defines the scene to apply the delta to
  75413. */
  75414. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75415. private static _ApplyPropertiesToEntity;
  75416. private static _ApplyDeltaForEntity;
  75417. }
  75418. }
  75419. declare module BABYLON {
  75420. /**
  75421. * A 3D trajectory consisting of an order list of vectors describing a
  75422. * path of motion through 3D space.
  75423. */
  75424. export class Trajectory {
  75425. private _points;
  75426. private readonly _segmentLength;
  75427. /**
  75428. * Serialize to JSON.
  75429. * @returns serialized JSON string
  75430. */
  75431. serialize(): string;
  75432. /**
  75433. * Deserialize from JSON.
  75434. * @param json serialized JSON string
  75435. * @returns deserialized Trajectory
  75436. */
  75437. static Deserialize(json: string): Trajectory;
  75438. /**
  75439. * Create a new empty Trajectory.
  75440. * @param segmentLength radius of discretization for Trajectory points
  75441. */
  75442. constructor(segmentLength?: number);
  75443. /**
  75444. * Get the length of the Trajectory.
  75445. * @returns length of the Trajectory
  75446. */
  75447. getLength(): number;
  75448. /**
  75449. * Append a new point to the Trajectory.
  75450. * NOTE: This implementation has many allocations.
  75451. * @param point point to append to the Trajectory
  75452. */
  75453. add(point: DeepImmutable<Vector3>): void;
  75454. /**
  75455. * Create a new Trajectory with a segment length chosen to make it
  75456. * probable that the new Trajectory will have a specified number of
  75457. * segments. This operation is imprecise.
  75458. * @param targetResolution number of segments desired
  75459. * @returns new Trajectory with approximately the requested number of segments
  75460. */
  75461. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75462. /**
  75463. * Convert Trajectory segments into tokenized representation. This
  75464. * representation is an array of numbers where each nth number is the
  75465. * index of the token which is most similar to the nth segment of the
  75466. * Trajectory.
  75467. * @param tokens list of vectors which serve as discrete tokens
  75468. * @returns list of indices of most similar token per segment
  75469. */
  75470. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75471. private static _forwardDir;
  75472. private static _inverseFromVec;
  75473. private static _upDir;
  75474. private static _fromToVec;
  75475. private static _lookMatrix;
  75476. /**
  75477. * Transform the rotation (i.e., direction) of a segment to isolate
  75478. * the relative transformation represented by the segment. This operation
  75479. * may or may not succeed due to singularities in the equations that define
  75480. * motion relativity in this context.
  75481. * @param priorVec the origin of the prior segment
  75482. * @param fromVec the origin of the current segment
  75483. * @param toVec the destination of the current segment
  75484. * @param result reference to output variable
  75485. * @returns whether or not transformation was successful
  75486. */
  75487. private static _transformSegmentDirToRef;
  75488. private static _bestMatch;
  75489. private static _score;
  75490. private static _bestScore;
  75491. /**
  75492. * Determine which token vector is most similar to the
  75493. * segment vector.
  75494. * @param segment segment vector
  75495. * @param tokens token vector list
  75496. * @returns index of the most similar token to the segment
  75497. */
  75498. private static _tokenizeSegment;
  75499. }
  75500. /**
  75501. * Class representing a set of known, named trajectories to which Trajectories can be
  75502. * added and using which Trajectories can be recognized.
  75503. */
  75504. export class TrajectoryClassifier {
  75505. private _maximumAllowableMatchCost;
  75506. private _vector3Alphabet;
  75507. private _levenshteinAlphabet;
  75508. private _nameToDescribedTrajectory;
  75509. /**
  75510. * Serialize to JSON.
  75511. * @returns JSON serialization
  75512. */
  75513. serialize(): string;
  75514. /**
  75515. * Deserialize from JSON.
  75516. * @param json JSON serialization
  75517. * @returns deserialized TrajectorySet
  75518. */
  75519. static Deserialize(json: string): TrajectoryClassifier;
  75520. /**
  75521. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75522. * VERY naive, need to be generating these things from known
  75523. * sets. Better version later, probably eliminating this one.
  75524. * @returns auto-generated TrajectorySet
  75525. */
  75526. static Generate(): TrajectoryClassifier;
  75527. private constructor();
  75528. /**
  75529. * Add a new Trajectory to the set with a given name.
  75530. * @param trajectory new Trajectory to be added
  75531. * @param classification name to which to add the Trajectory
  75532. */
  75533. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75534. /**
  75535. * Remove a known named trajectory and all Trajectories associated with it.
  75536. * @param classification name to remove
  75537. * @returns whether anything was removed
  75538. */
  75539. deleteClassification(classification: string): boolean;
  75540. /**
  75541. * Attempt to recognize a Trajectory from among all the classifications
  75542. * already known to the classifier.
  75543. * @param trajectory Trajectory to be recognized
  75544. * @returns classification of Trajectory if recognized, null otherwise
  75545. */
  75546. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75547. }
  75548. }
  75549. declare module BABYLON {
  75550. /**
  75551. * An interface for all Hit test features
  75552. */
  75553. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75554. /**
  75555. * Triggered when new babylon (transformed) hit test results are available
  75556. */
  75557. onHitTestResultObservable: Observable<T[]>;
  75558. }
  75559. /**
  75560. * Options used for hit testing
  75561. */
  75562. export interface IWebXRLegacyHitTestOptions {
  75563. /**
  75564. * Only test when user interacted with the scene. Default - hit test every frame
  75565. */
  75566. testOnPointerDownOnly?: boolean;
  75567. /**
  75568. * The node to use to transform the local results to world coordinates
  75569. */
  75570. worldParentNode?: TransformNode;
  75571. }
  75572. /**
  75573. * Interface defining the babylon result of raycasting/hit-test
  75574. */
  75575. export interface IWebXRLegacyHitResult {
  75576. /**
  75577. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75578. */
  75579. transformationMatrix: Matrix;
  75580. /**
  75581. * The native hit test result
  75582. */
  75583. xrHitResult: XRHitResult | XRHitTestResult;
  75584. }
  75585. /**
  75586. * The currently-working hit-test module.
  75587. * Hit test (or Ray-casting) is used to interact with the real world.
  75588. * For further information read here - https://github.com/immersive-web/hit-test
  75589. */
  75590. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75591. /**
  75592. * options to use when constructing this feature
  75593. */
  75594. readonly options: IWebXRLegacyHitTestOptions;
  75595. private _direction;
  75596. private _mat;
  75597. private _onSelectEnabled;
  75598. private _origin;
  75599. /**
  75600. * The module's name
  75601. */
  75602. static readonly Name: string;
  75603. /**
  75604. * The (Babylon) version of this module.
  75605. * This is an integer representing the implementation version.
  75606. * This number does not correspond to the WebXR specs version
  75607. */
  75608. static readonly Version: number;
  75609. /**
  75610. * Populated with the last native XR Hit Results
  75611. */
  75612. lastNativeXRHitResults: XRHitResult[];
  75613. /**
  75614. * Triggered when new babylon (transformed) hit test results are available
  75615. */
  75616. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75617. /**
  75618. * Creates a new instance of the (legacy version) hit test feature
  75619. * @param _xrSessionManager an instance of WebXRSessionManager
  75620. * @param options options to use when constructing this feature
  75621. */
  75622. constructor(_xrSessionManager: WebXRSessionManager,
  75623. /**
  75624. * options to use when constructing this feature
  75625. */
  75626. options?: IWebXRLegacyHitTestOptions);
  75627. /**
  75628. * execute a hit test with an XR Ray
  75629. *
  75630. * @param xrSession a native xrSession that will execute this hit test
  75631. * @param xrRay the ray (position and direction) to use for ray-casting
  75632. * @param referenceSpace native XR reference space to use for the hit-test
  75633. * @param filter filter function that will filter the results
  75634. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75635. */
  75636. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75637. /**
  75638. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75639. * @param event the (select) event to use to select with
  75640. * @param referenceSpace the reference space to use for this hit test
  75641. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75642. */
  75643. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75644. /**
  75645. * attach this feature
  75646. * Will usually be called by the features manager
  75647. *
  75648. * @returns true if successful.
  75649. */
  75650. attach(): boolean;
  75651. /**
  75652. * detach this feature.
  75653. * Will usually be called by the features manager
  75654. *
  75655. * @returns true if successful.
  75656. */
  75657. detach(): boolean;
  75658. /**
  75659. * Dispose this feature and all of the resources attached
  75660. */
  75661. dispose(): void;
  75662. protected _onXRFrame(frame: XRFrame): void;
  75663. private _onHitTestResults;
  75664. private _onSelect;
  75665. }
  75666. }
  75667. declare module BABYLON {
  75668. /**
  75669. * Options used for hit testing (version 2)
  75670. */
  75671. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75672. /**
  75673. * Do not create a permanent hit test. Will usually be used when only
  75674. * transient inputs are needed.
  75675. */
  75676. disablePermanentHitTest?: boolean;
  75677. /**
  75678. * Enable transient (for example touch-based) hit test inspections
  75679. */
  75680. enableTransientHitTest?: boolean;
  75681. /**
  75682. * Offset ray for the permanent hit test
  75683. */
  75684. offsetRay?: Vector3;
  75685. /**
  75686. * Offset ray for the transient hit test
  75687. */
  75688. transientOffsetRay?: Vector3;
  75689. /**
  75690. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75691. */
  75692. useReferenceSpace?: boolean;
  75693. /**
  75694. * Override the default entity type(s) of the hit-test result
  75695. */
  75696. entityTypes?: XRHitTestTrackableType[];
  75697. }
  75698. /**
  75699. * Interface defining the babylon result of hit-test
  75700. */
  75701. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75702. /**
  75703. * The input source that generated this hit test (if transient)
  75704. */
  75705. inputSource?: XRInputSource;
  75706. /**
  75707. * Is this a transient hit test
  75708. */
  75709. isTransient?: boolean;
  75710. /**
  75711. * Position of the hit test result
  75712. */
  75713. position: Vector3;
  75714. /**
  75715. * Rotation of the hit test result
  75716. */
  75717. rotationQuaternion: Quaternion;
  75718. /**
  75719. * The native hit test result
  75720. */
  75721. xrHitResult: XRHitTestResult;
  75722. }
  75723. /**
  75724. * The currently-working hit-test module.
  75725. * Hit test (or Ray-casting) is used to interact with the real world.
  75726. * For further information read here - https://github.com/immersive-web/hit-test
  75727. *
  75728. * Tested on chrome (mobile) 80.
  75729. */
  75730. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75731. /**
  75732. * options to use when constructing this feature
  75733. */
  75734. readonly options: IWebXRHitTestOptions;
  75735. private _tmpMat;
  75736. private _tmpPos;
  75737. private _tmpQuat;
  75738. private _transientXrHitTestSource;
  75739. private _xrHitTestSource;
  75740. private initHitTestSource;
  75741. /**
  75742. * The module's name
  75743. */
  75744. static readonly Name: string;
  75745. /**
  75746. * The (Babylon) version of this module.
  75747. * This is an integer representing the implementation version.
  75748. * This number does not correspond to the WebXR specs version
  75749. */
  75750. static readonly Version: number;
  75751. /**
  75752. * When set to true, each hit test will have its own position/rotation objects
  75753. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75754. * the developers will clone them or copy them as they see fit.
  75755. */
  75756. autoCloneTransformation: boolean;
  75757. /**
  75758. * Triggered when new babylon (transformed) hit test results are available
  75759. * Note - this will be called when results come back from the device. It can be an empty array!!
  75760. */
  75761. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75762. /**
  75763. * Use this to temporarily pause hit test checks.
  75764. */
  75765. paused: boolean;
  75766. /**
  75767. * Creates a new instance of the hit test feature
  75768. * @param _xrSessionManager an instance of WebXRSessionManager
  75769. * @param options options to use when constructing this feature
  75770. */
  75771. constructor(_xrSessionManager: WebXRSessionManager,
  75772. /**
  75773. * options to use when constructing this feature
  75774. */
  75775. options?: IWebXRHitTestOptions);
  75776. /**
  75777. * attach this feature
  75778. * Will usually be called by the features manager
  75779. *
  75780. * @returns true if successful.
  75781. */
  75782. attach(): boolean;
  75783. /**
  75784. * detach this feature.
  75785. * Will usually be called by the features manager
  75786. *
  75787. * @returns true if successful.
  75788. */
  75789. detach(): boolean;
  75790. /**
  75791. * Dispose this feature and all of the resources attached
  75792. */
  75793. dispose(): void;
  75794. protected _onXRFrame(frame: XRFrame): void;
  75795. private _processWebXRHitTestResult;
  75796. }
  75797. }
  75798. declare module BABYLON {
  75799. /**
  75800. * Configuration options of the anchor system
  75801. */
  75802. export interface IWebXRAnchorSystemOptions {
  75803. /**
  75804. * a node that will be used to convert local to world coordinates
  75805. */
  75806. worldParentNode?: TransformNode;
  75807. /**
  75808. * If set to true a reference of the created anchors will be kept until the next session starts
  75809. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75810. */
  75811. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75812. }
  75813. /**
  75814. * A babylon container for an XR Anchor
  75815. */
  75816. export interface IWebXRAnchor {
  75817. /**
  75818. * A babylon-assigned ID for this anchor
  75819. */
  75820. id: number;
  75821. /**
  75822. * Transformation matrix to apply to an object attached to this anchor
  75823. */
  75824. transformationMatrix: Matrix;
  75825. /**
  75826. * The native anchor object
  75827. */
  75828. xrAnchor: XRAnchor;
  75829. /**
  75830. * if defined, this object will be constantly updated by the anchor's position and rotation
  75831. */
  75832. attachedNode?: TransformNode;
  75833. }
  75834. /**
  75835. * An implementation of the anchor system for WebXR.
  75836. * For further information see https://github.com/immersive-web/anchors/
  75837. */
  75838. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75839. private _options;
  75840. private _lastFrameDetected;
  75841. private _trackedAnchors;
  75842. private _referenceSpaceForFrameAnchors;
  75843. private _futureAnchors;
  75844. /**
  75845. * The module's name
  75846. */
  75847. static readonly Name: string;
  75848. /**
  75849. * The (Babylon) version of this module.
  75850. * This is an integer representing the implementation version.
  75851. * This number does not correspond to the WebXR specs version
  75852. */
  75853. static readonly Version: number;
  75854. /**
  75855. * Observers registered here will be executed when a new anchor was added to the session
  75856. */
  75857. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75858. /**
  75859. * Observers registered here will be executed when an anchor was removed from the session
  75860. */
  75861. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75862. /**
  75863. * Observers registered here will be executed when an existing anchor updates
  75864. * This can execute N times every frame
  75865. */
  75866. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75867. /**
  75868. * Set the reference space to use for anchor creation, when not using a hit test.
  75869. * Will default to the session's reference space if not defined
  75870. */
  75871. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75872. /**
  75873. * constructs a new anchor system
  75874. * @param _xrSessionManager an instance of WebXRSessionManager
  75875. * @param _options configuration object for this feature
  75876. */
  75877. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75878. private _tmpVector;
  75879. private _tmpQuaternion;
  75880. private _populateTmpTransformation;
  75881. /**
  75882. * Create a new anchor point using a hit test result at a specific point in the scene
  75883. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75884. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75885. *
  75886. * @param hitTestResult The hit test result to use for this anchor creation
  75887. * @param position an optional position offset for this anchor
  75888. * @param rotationQuaternion an optional rotation offset for this anchor
  75889. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75890. */
  75891. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75892. /**
  75893. * Add a new anchor at a specific position and rotation
  75894. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75895. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75896. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75897. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75898. *
  75899. * @param position the position in which to add an anchor
  75900. * @param rotationQuaternion an optional rotation for the anchor transformation
  75901. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75902. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75903. */
  75904. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75905. /**
  75906. * detach this feature.
  75907. * Will usually be called by the features manager
  75908. *
  75909. * @returns true if successful.
  75910. */
  75911. detach(): boolean;
  75912. /**
  75913. * Dispose this feature and all of the resources attached
  75914. */
  75915. dispose(): void;
  75916. protected _onXRFrame(frame: XRFrame): void;
  75917. /**
  75918. * avoiding using Array.find for global support.
  75919. * @param xrAnchor the plane to find in the array
  75920. */
  75921. private _findIndexInAnchorArray;
  75922. private _updateAnchorWithXRFrame;
  75923. private _createAnchorAtTransformation;
  75924. }
  75925. }
  75926. declare module BABYLON {
  75927. /**
  75928. * Options used in the plane detector module
  75929. */
  75930. export interface IWebXRPlaneDetectorOptions {
  75931. /**
  75932. * The node to use to transform the local results to world coordinates
  75933. */
  75934. worldParentNode?: TransformNode;
  75935. /**
  75936. * If set to true a reference of the created planes will be kept until the next session starts
  75937. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  75938. */
  75939. doNotRemovePlanesOnSessionEnded?: boolean;
  75940. }
  75941. /**
  75942. * A babylon interface for a WebXR plane.
  75943. * A Plane is actually a polygon, built from N points in space
  75944. *
  75945. * Supported in chrome 79, not supported in canary 81 ATM
  75946. */
  75947. export interface IWebXRPlane {
  75948. /**
  75949. * a babylon-assigned ID for this polygon
  75950. */
  75951. id: number;
  75952. /**
  75953. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75954. */
  75955. polygonDefinition: Array<Vector3>;
  75956. /**
  75957. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75958. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75959. */
  75960. transformationMatrix: Matrix;
  75961. /**
  75962. * the native xr-plane object
  75963. */
  75964. xrPlane: XRPlane;
  75965. }
  75966. /**
  75967. * The plane detector is used to detect planes in the real world when in AR
  75968. * For more information see https://github.com/immersive-web/real-world-geometry/
  75969. */
  75970. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75971. private _options;
  75972. private _detectedPlanes;
  75973. private _enabled;
  75974. private _lastFrameDetected;
  75975. /**
  75976. * The module's name
  75977. */
  75978. static readonly Name: string;
  75979. /**
  75980. * The (Babylon) version of this module.
  75981. * This is an integer representing the implementation version.
  75982. * This number does not correspond to the WebXR specs version
  75983. */
  75984. static readonly Version: number;
  75985. /**
  75986. * Observers registered here will be executed when a new plane was added to the session
  75987. */
  75988. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75989. /**
  75990. * Observers registered here will be executed when a plane is no longer detected in the session
  75991. */
  75992. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  75993. /**
  75994. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  75995. * This can execute N times every frame
  75996. */
  75997. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  75998. /**
  75999. * construct a new Plane Detector
  76000. * @param _xrSessionManager an instance of xr Session manager
  76001. * @param _options configuration to use when constructing this feature
  76002. */
  76003. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76004. /**
  76005. * detach this feature.
  76006. * Will usually be called by the features manager
  76007. *
  76008. * @returns true if successful.
  76009. */
  76010. detach(): boolean;
  76011. /**
  76012. * Dispose this feature and all of the resources attached
  76013. */
  76014. dispose(): void;
  76015. protected _onXRFrame(frame: XRFrame): void;
  76016. private _init;
  76017. private _updatePlaneWithXRPlane;
  76018. /**
  76019. * avoiding using Array.find for global support.
  76020. * @param xrPlane the plane to find in the array
  76021. */
  76022. private findIndexInPlaneArray;
  76023. }
  76024. }
  76025. declare module BABYLON {
  76026. /**
  76027. * Options interface for the background remover plugin
  76028. */
  76029. export interface IWebXRBackgroundRemoverOptions {
  76030. /**
  76031. * Further background meshes to disable when entering AR
  76032. */
  76033. backgroundMeshes?: AbstractMesh[];
  76034. /**
  76035. * flags to configure the removal of the environment helper.
  76036. * If not set, the entire background will be removed. If set, flags should be set as well.
  76037. */
  76038. environmentHelperRemovalFlags?: {
  76039. /**
  76040. * Should the skybox be removed (default false)
  76041. */
  76042. skyBox?: boolean;
  76043. /**
  76044. * Should the ground be removed (default false)
  76045. */
  76046. ground?: boolean;
  76047. };
  76048. /**
  76049. * don't disable the environment helper
  76050. */
  76051. ignoreEnvironmentHelper?: boolean;
  76052. }
  76053. /**
  76054. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76055. */
  76056. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76057. /**
  76058. * read-only options to be used in this module
  76059. */
  76060. readonly options: IWebXRBackgroundRemoverOptions;
  76061. /**
  76062. * The module's name
  76063. */
  76064. static readonly Name: string;
  76065. /**
  76066. * The (Babylon) version of this module.
  76067. * This is an integer representing the implementation version.
  76068. * This number does not correspond to the WebXR specs version
  76069. */
  76070. static readonly Version: number;
  76071. /**
  76072. * registered observers will be triggered when the background state changes
  76073. */
  76074. onBackgroundStateChangedObservable: Observable<boolean>;
  76075. /**
  76076. * constructs a new background remover module
  76077. * @param _xrSessionManager the session manager for this module
  76078. * @param options read-only options to be used in this module
  76079. */
  76080. constructor(_xrSessionManager: WebXRSessionManager,
  76081. /**
  76082. * read-only options to be used in this module
  76083. */
  76084. options?: IWebXRBackgroundRemoverOptions);
  76085. /**
  76086. * attach this feature
  76087. * Will usually be called by the features manager
  76088. *
  76089. * @returns true if successful.
  76090. */
  76091. attach(): boolean;
  76092. /**
  76093. * detach this feature.
  76094. * Will usually be called by the features manager
  76095. *
  76096. * @returns true if successful.
  76097. */
  76098. detach(): boolean;
  76099. /**
  76100. * Dispose this feature and all of the resources attached
  76101. */
  76102. dispose(): void;
  76103. protected _onXRFrame(_xrFrame: XRFrame): void;
  76104. private _setBackgroundState;
  76105. }
  76106. }
  76107. declare module BABYLON {
  76108. /**
  76109. * Options for the controller physics feature
  76110. */
  76111. export class IWebXRControllerPhysicsOptions {
  76112. /**
  76113. * Should the headset get its own impostor
  76114. */
  76115. enableHeadsetImpostor?: boolean;
  76116. /**
  76117. * Optional parameters for the headset impostor
  76118. */
  76119. headsetImpostorParams?: {
  76120. /**
  76121. * The type of impostor to create. Default is sphere
  76122. */
  76123. impostorType: number;
  76124. /**
  76125. * the size of the impostor. Defaults to 10cm
  76126. */
  76127. impostorSize?: number | {
  76128. width: number;
  76129. height: number;
  76130. depth: number;
  76131. };
  76132. /**
  76133. * Friction definitions
  76134. */
  76135. friction?: number;
  76136. /**
  76137. * Restitution
  76138. */
  76139. restitution?: number;
  76140. };
  76141. /**
  76142. * The physics properties of the future impostors
  76143. */
  76144. physicsProperties?: {
  76145. /**
  76146. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76147. * Note that this requires a physics engine that supports mesh impostors!
  76148. */
  76149. useControllerMesh?: boolean;
  76150. /**
  76151. * The type of impostor to create. Default is sphere
  76152. */
  76153. impostorType?: number;
  76154. /**
  76155. * the size of the impostor. Defaults to 10cm
  76156. */
  76157. impostorSize?: number | {
  76158. width: number;
  76159. height: number;
  76160. depth: number;
  76161. };
  76162. /**
  76163. * Friction definitions
  76164. */
  76165. friction?: number;
  76166. /**
  76167. * Restitution
  76168. */
  76169. restitution?: number;
  76170. };
  76171. /**
  76172. * the xr input to use with this pointer selection
  76173. */
  76174. xrInput: WebXRInput;
  76175. }
  76176. /**
  76177. * Add physics impostor to your webxr controllers,
  76178. * including naive calculation of their linear and angular velocity
  76179. */
  76180. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76181. private readonly _options;
  76182. private _attachController;
  76183. private _controllers;
  76184. private _debugMode;
  76185. private _delta;
  76186. private _headsetImpostor?;
  76187. private _headsetMesh?;
  76188. private _lastTimestamp;
  76189. private _tmpQuaternion;
  76190. private _tmpVector;
  76191. /**
  76192. * The module's name
  76193. */
  76194. static readonly Name: string;
  76195. /**
  76196. * The (Babylon) version of this module.
  76197. * This is an integer representing the implementation version.
  76198. * This number does not correspond to the webxr specs version
  76199. */
  76200. static readonly Version: number;
  76201. /**
  76202. * Construct a new Controller Physics Feature
  76203. * @param _xrSessionManager the corresponding xr session manager
  76204. * @param _options options to create this feature with
  76205. */
  76206. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76207. /**
  76208. * @hidden
  76209. * enable debugging - will show console outputs and the impostor mesh
  76210. */
  76211. _enablePhysicsDebug(): void;
  76212. /**
  76213. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76214. * @param xrController the controller to add
  76215. */
  76216. addController(xrController: WebXRInputSource): void;
  76217. /**
  76218. * attach this feature
  76219. * Will usually be called by the features manager
  76220. *
  76221. * @returns true if successful.
  76222. */
  76223. attach(): boolean;
  76224. /**
  76225. * detach this feature.
  76226. * Will usually be called by the features manager
  76227. *
  76228. * @returns true if successful.
  76229. */
  76230. detach(): boolean;
  76231. /**
  76232. * Get the headset impostor, if enabled
  76233. * @returns the impostor
  76234. */
  76235. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76236. /**
  76237. * Get the physics impostor of a specific controller.
  76238. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76239. * @param controller the controller or the controller id of which to get the impostor
  76240. * @returns the impostor or null
  76241. */
  76242. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76243. /**
  76244. * Update the physics properties provided in the constructor
  76245. * @param newProperties the new properties object
  76246. */
  76247. setPhysicsProperties(newProperties: {
  76248. impostorType?: number;
  76249. impostorSize?: number | {
  76250. width: number;
  76251. height: number;
  76252. depth: number;
  76253. };
  76254. friction?: number;
  76255. restitution?: number;
  76256. }): void;
  76257. protected _onXRFrame(_xrFrame: any): void;
  76258. private _detachController;
  76259. }
  76260. }
  76261. declare module BABYLON {
  76262. /**
  76263. * A babylon interface for a "WebXR" feature point.
  76264. * Represents the position and confidence value of a given feature point.
  76265. */
  76266. export interface IWebXRFeaturePoint {
  76267. /**
  76268. * Represents the position of the feature point in world space.
  76269. */
  76270. position: Vector3;
  76271. /**
  76272. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  76273. */
  76274. confidenceValue: number;
  76275. }
  76276. /**
  76277. * The feature point system is used to detect feature points from real world geometry.
  76278. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  76279. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  76280. */
  76281. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  76282. private _enabled;
  76283. private _featurePointCloud;
  76284. /**
  76285. * The module's name
  76286. */
  76287. static readonly Name: string;
  76288. /**
  76289. * The (Babylon) version of this module.
  76290. * This is an integer representing the implementation version.
  76291. * This number does not correspond to the WebXR specs version
  76292. */
  76293. static readonly Version: number;
  76294. /**
  76295. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76296. * Will notify the observers about which feature points have been added.
  76297. */
  76298. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76299. /**
  76300. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76301. * Will notify the observers about which feature points have been updated.
  76302. */
  76303. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76304. /**
  76305. * The current feature point cloud maintained across frames.
  76306. */
  76307. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76308. /**
  76309. * construct the feature point system
  76310. * @param _xrSessionManager an instance of xr Session manager
  76311. */
  76312. constructor(_xrSessionManager: WebXRSessionManager);
  76313. /**
  76314. * Detach this feature.
  76315. * Will usually be called by the features manager
  76316. *
  76317. * @returns true if successful.
  76318. */
  76319. detach(): boolean;
  76320. /**
  76321. * Dispose this feature and all of the resources attached
  76322. */
  76323. dispose(): void;
  76324. /**
  76325. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76326. */
  76327. protected _onXRFrame(frame: XRFrame): void;
  76328. /**
  76329. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76330. */
  76331. private _init;
  76332. }
  76333. }
  76334. declare module BABYLON {
  76335. /**
  76336. * Configuration interface for the hand tracking feature
  76337. */
  76338. export interface IWebXRHandTrackingOptions {
  76339. /**
  76340. * The xrInput that will be used as source for new hands
  76341. */
  76342. xrInput: WebXRInput;
  76343. /**
  76344. * Configuration object for the joint meshes
  76345. */
  76346. jointMeshes?: {
  76347. /**
  76348. * Should the meshes created be invisible (defaults to false)
  76349. */
  76350. invisible?: boolean;
  76351. /**
  76352. * A source mesh to be used to create instances. Defaults to a sphere.
  76353. * This mesh will be the source for all other (25) meshes.
  76354. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76355. */
  76356. sourceMesh?: Mesh;
  76357. /**
  76358. * This function will be called after a mesh was created for a specific joint.
  76359. * Using this function you can either manipulate the instance or return a new mesh.
  76360. * When returning a new mesh the instance created before will be disposed
  76361. */
  76362. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76363. /**
  76364. * Should the source mesh stay visible. Defaults to false
  76365. */
  76366. keepOriginalVisible?: boolean;
  76367. /**
  76368. * Scale factor for all instances (defaults to 2)
  76369. */
  76370. scaleFactor?: number;
  76371. /**
  76372. * Should each instance have its own physics impostor
  76373. */
  76374. enablePhysics?: boolean;
  76375. /**
  76376. * If enabled, override default physics properties
  76377. */
  76378. physicsProps?: {
  76379. friction?: number;
  76380. restitution?: number;
  76381. impostorType?: number;
  76382. };
  76383. /**
  76384. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  76385. */
  76386. handMesh?: AbstractMesh;
  76387. };
  76388. }
  76389. /**
  76390. * Parts of the hands divided to writs and finger names
  76391. */
  76392. export const enum HandPart {
  76393. /**
  76394. * HandPart - Wrist
  76395. */
  76396. WRIST = "wrist",
  76397. /**
  76398. * HandPart - The THumb
  76399. */
  76400. THUMB = "thumb",
  76401. /**
  76402. * HandPart - Index finger
  76403. */
  76404. INDEX = "index",
  76405. /**
  76406. * HandPart - Middle finger
  76407. */
  76408. MIDDLE = "middle",
  76409. /**
  76410. * HandPart - Ring finger
  76411. */
  76412. RING = "ring",
  76413. /**
  76414. * HandPart - Little finger
  76415. */
  76416. LITTLE = "little"
  76417. }
  76418. /**
  76419. * Representing a single hand (with its corresponding native XRHand object)
  76420. */
  76421. export class WebXRHand implements IDisposable {
  76422. /** the controller to which the hand correlates */
  76423. readonly xrController: WebXRInputSource;
  76424. /** the meshes to be used to track the hand joints */
  76425. readonly trackedMeshes: AbstractMesh[];
  76426. /**
  76427. * Hand-parts definition (key is HandPart)
  76428. */
  76429. handPartsDefinition: {
  76430. [key: string]: number[];
  76431. };
  76432. /**
  76433. * Populate the HandPartsDefinition object.
  76434. * This is called as a side effect since certain browsers don't have XRHand defined.
  76435. */
  76436. private generateHandPartsDefinition;
  76437. /**
  76438. * Construct a new hand object
  76439. * @param xrController the controller to which the hand correlates
  76440. * @param trackedMeshes the meshes to be used to track the hand joints
  76441. */
  76442. constructor(
  76443. /** the controller to which the hand correlates */
  76444. xrController: WebXRInputSource,
  76445. /** the meshes to be used to track the hand joints */
  76446. trackedMeshes: AbstractMesh[]);
  76447. /**
  76448. * Update this hand from the latest xr frame
  76449. * @param xrFrame xrFrame to update from
  76450. * @param referenceSpace The current viewer reference space
  76451. * @param scaleFactor optional scale factor for the meshes
  76452. */
  76453. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76454. /**
  76455. * Get meshes of part of the hand
  76456. * @param part the part of hand to get
  76457. * @returns An array of meshes that correlate to the hand part requested
  76458. */
  76459. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76460. /**
  76461. * Dispose this Hand object
  76462. */
  76463. dispose(): void;
  76464. }
  76465. /**
  76466. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76467. */
  76468. export class WebXRHandTracking extends WebXRAbstractFeature {
  76469. /**
  76470. * options to use when constructing this feature
  76471. */
  76472. readonly options: IWebXRHandTrackingOptions;
  76473. private static _idCounter;
  76474. /**
  76475. * The module's name
  76476. */
  76477. static readonly Name: string;
  76478. /**
  76479. * The (Babylon) version of this module.
  76480. * This is an integer representing the implementation version.
  76481. * This number does not correspond to the WebXR specs version
  76482. */
  76483. static readonly Version: number;
  76484. /**
  76485. * This observable will notify registered observers when a new hand object was added and initialized
  76486. */
  76487. onHandAddedObservable: Observable<WebXRHand>;
  76488. /**
  76489. * This observable will notify its observers right before the hand object is disposed
  76490. */
  76491. onHandRemovedObservable: Observable<WebXRHand>;
  76492. private _hands;
  76493. /**
  76494. * Creates a new instance of the hit test feature
  76495. * @param _xrSessionManager an instance of WebXRSessionManager
  76496. * @param options options to use when constructing this feature
  76497. */
  76498. constructor(_xrSessionManager: WebXRSessionManager,
  76499. /**
  76500. * options to use when constructing this feature
  76501. */
  76502. options: IWebXRHandTrackingOptions);
  76503. /**
  76504. * Check if the needed objects are defined.
  76505. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76506. */
  76507. isCompatible(): boolean;
  76508. /**
  76509. * attach this feature
  76510. * Will usually be called by the features manager
  76511. *
  76512. * @returns true if successful.
  76513. */
  76514. attach(): boolean;
  76515. /**
  76516. * detach this feature.
  76517. * Will usually be called by the features manager
  76518. *
  76519. * @returns true if successful.
  76520. */
  76521. detach(): boolean;
  76522. /**
  76523. * Dispose this feature and all of the resources attached
  76524. */
  76525. dispose(): void;
  76526. /**
  76527. * Get the hand object according to the controller id
  76528. * @param controllerId the controller id to which we want to get the hand
  76529. * @returns null if not found or the WebXRHand object if found
  76530. */
  76531. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76532. /**
  76533. * Get a hand object according to the requested handedness
  76534. * @param handedness the handedness to request
  76535. * @returns null if not found or the WebXRHand object if found
  76536. */
  76537. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76538. protected _onXRFrame(_xrFrame: XRFrame): void;
  76539. private _attachHand;
  76540. private _detachHand;
  76541. }
  76542. }
  76543. declare module BABYLON {
  76544. /**
  76545. * The motion controller class for all microsoft mixed reality controllers
  76546. */
  76547. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76548. protected readonly _mapping: {
  76549. defaultButton: {
  76550. valueNodeName: string;
  76551. unpressedNodeName: string;
  76552. pressedNodeName: string;
  76553. };
  76554. defaultAxis: {
  76555. valueNodeName: string;
  76556. minNodeName: string;
  76557. maxNodeName: string;
  76558. };
  76559. buttons: {
  76560. "xr-standard-trigger": {
  76561. rootNodeName: string;
  76562. componentProperty: string;
  76563. states: string[];
  76564. };
  76565. "xr-standard-squeeze": {
  76566. rootNodeName: string;
  76567. componentProperty: string;
  76568. states: string[];
  76569. };
  76570. "xr-standard-touchpad": {
  76571. rootNodeName: string;
  76572. labelAnchorNodeName: string;
  76573. touchPointNodeName: string;
  76574. };
  76575. "xr-standard-thumbstick": {
  76576. rootNodeName: string;
  76577. componentProperty: string;
  76578. states: string[];
  76579. };
  76580. };
  76581. axes: {
  76582. "xr-standard-touchpad": {
  76583. "x-axis": {
  76584. rootNodeName: string;
  76585. };
  76586. "y-axis": {
  76587. rootNodeName: string;
  76588. };
  76589. };
  76590. "xr-standard-thumbstick": {
  76591. "x-axis": {
  76592. rootNodeName: string;
  76593. };
  76594. "y-axis": {
  76595. rootNodeName: string;
  76596. };
  76597. };
  76598. };
  76599. };
  76600. /**
  76601. * The base url used to load the left and right controller models
  76602. */
  76603. static MODEL_BASE_URL: string;
  76604. /**
  76605. * The name of the left controller model file
  76606. */
  76607. static MODEL_LEFT_FILENAME: string;
  76608. /**
  76609. * The name of the right controller model file
  76610. */
  76611. static MODEL_RIGHT_FILENAME: string;
  76612. profileId: string;
  76613. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76614. protected _getFilenameAndPath(): {
  76615. filename: string;
  76616. path: string;
  76617. };
  76618. protected _getModelLoadingConstraints(): boolean;
  76619. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76620. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76621. protected _updateModel(): void;
  76622. }
  76623. }
  76624. declare module BABYLON {
  76625. /**
  76626. * The motion controller class for oculus touch (quest, rift).
  76627. * This class supports legacy mapping as well the standard xr mapping
  76628. */
  76629. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76630. private _forceLegacyControllers;
  76631. private _modelRootNode;
  76632. /**
  76633. * The base url used to load the left and right controller models
  76634. */
  76635. static MODEL_BASE_URL: string;
  76636. /**
  76637. * The name of the left controller model file
  76638. */
  76639. static MODEL_LEFT_FILENAME: string;
  76640. /**
  76641. * The name of the right controller model file
  76642. */
  76643. static MODEL_RIGHT_FILENAME: string;
  76644. /**
  76645. * Base Url for the Quest controller model.
  76646. */
  76647. static QUEST_MODEL_BASE_URL: string;
  76648. profileId: string;
  76649. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76650. protected _getFilenameAndPath(): {
  76651. filename: string;
  76652. path: string;
  76653. };
  76654. protected _getModelLoadingConstraints(): boolean;
  76655. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76656. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76657. protected _updateModel(): void;
  76658. /**
  76659. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76660. * between the touch and touch 2.
  76661. */
  76662. private _isQuest;
  76663. }
  76664. }
  76665. declare module BABYLON {
  76666. /**
  76667. * The motion controller class for the standard HTC-Vive controllers
  76668. */
  76669. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76670. private _modelRootNode;
  76671. /**
  76672. * The base url used to load the left and right controller models
  76673. */
  76674. static MODEL_BASE_URL: string;
  76675. /**
  76676. * File name for the controller model.
  76677. */
  76678. static MODEL_FILENAME: string;
  76679. profileId: string;
  76680. /**
  76681. * Create a new Vive motion controller object
  76682. * @param scene the scene to use to create this controller
  76683. * @param gamepadObject the corresponding gamepad object
  76684. * @param handedness the handedness of the controller
  76685. */
  76686. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76687. protected _getFilenameAndPath(): {
  76688. filename: string;
  76689. path: string;
  76690. };
  76691. protected _getModelLoadingConstraints(): boolean;
  76692. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76693. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76694. protected _updateModel(): void;
  76695. }
  76696. }
  76697. declare module BABYLON {
  76698. /**
  76699. * A cursor which tracks a point on a path
  76700. */
  76701. export class PathCursor {
  76702. private path;
  76703. /**
  76704. * Stores path cursor callbacks for when an onchange event is triggered
  76705. */
  76706. private _onchange;
  76707. /**
  76708. * The value of the path cursor
  76709. */
  76710. value: number;
  76711. /**
  76712. * The animation array of the path cursor
  76713. */
  76714. animations: Animation[];
  76715. /**
  76716. * Initializes the path cursor
  76717. * @param path The path to track
  76718. */
  76719. constructor(path: Path2);
  76720. /**
  76721. * Gets the cursor point on the path
  76722. * @returns A point on the path cursor at the cursor location
  76723. */
  76724. getPoint(): Vector3;
  76725. /**
  76726. * Moves the cursor ahead by the step amount
  76727. * @param step The amount to move the cursor forward
  76728. * @returns This path cursor
  76729. */
  76730. moveAhead(step?: number): PathCursor;
  76731. /**
  76732. * Moves the cursor behind by the step amount
  76733. * @param step The amount to move the cursor back
  76734. * @returns This path cursor
  76735. */
  76736. moveBack(step?: number): PathCursor;
  76737. /**
  76738. * Moves the cursor by the step amount
  76739. * If the step amount is greater than one, an exception is thrown
  76740. * @param step The amount to move the cursor
  76741. * @returns This path cursor
  76742. */
  76743. move(step: number): PathCursor;
  76744. /**
  76745. * Ensures that the value is limited between zero and one
  76746. * @returns This path cursor
  76747. */
  76748. private ensureLimits;
  76749. /**
  76750. * Runs onchange callbacks on change (used by the animation engine)
  76751. * @returns This path cursor
  76752. */
  76753. private raiseOnChange;
  76754. /**
  76755. * Executes a function on change
  76756. * @param f A path cursor onchange callback
  76757. * @returns This path cursor
  76758. */
  76759. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76760. }
  76761. }
  76762. declare module BABYLON {
  76763. /** @hidden */
  76764. export var blurPixelShader: {
  76765. name: string;
  76766. shader: string;
  76767. };
  76768. }
  76769. declare module BABYLON {
  76770. /** @hidden */
  76771. export var pointCloudVertexDeclaration: {
  76772. name: string;
  76773. shader: string;
  76774. };
  76775. }
  76776. // Mixins
  76777. interface Window {
  76778. mozIndexedDB: IDBFactory;
  76779. webkitIndexedDB: IDBFactory;
  76780. msIndexedDB: IDBFactory;
  76781. webkitURL: typeof URL;
  76782. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  76783. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  76784. WebGLRenderingContext: WebGLRenderingContext;
  76785. MSGesture: MSGesture;
  76786. CANNON: any;
  76787. AudioContext: AudioContext;
  76788. webkitAudioContext: AudioContext;
  76789. PointerEvent: any;
  76790. Math: Math;
  76791. Uint8Array: Uint8ArrayConstructor;
  76792. Float32Array: Float32ArrayConstructor;
  76793. mozURL: typeof URL;
  76794. msURL: typeof URL;
  76795. VRFrameData: any; // WebVR, from specs 1.1
  76796. DracoDecoderModule: any;
  76797. setImmediate(handler: (...args: any[]) => void): number;
  76798. }
  76799. interface HTMLCanvasElement {
  76800. requestPointerLock(): void;
  76801. msRequestPointerLock?(): void;
  76802. mozRequestPointerLock?(): void;
  76803. webkitRequestPointerLock?(): void;
  76804. /** Track wether a record is in progress */
  76805. isRecording: boolean;
  76806. /** Capture Stream method defined by some browsers */
  76807. captureStream(fps?: number): MediaStream;
  76808. }
  76809. interface CanvasRenderingContext2D {
  76810. msImageSmoothingEnabled: boolean;
  76811. }
  76812. interface MouseEvent {
  76813. mozMovementX: number;
  76814. mozMovementY: number;
  76815. webkitMovementX: number;
  76816. webkitMovementY: number;
  76817. msMovementX: number;
  76818. msMovementY: number;
  76819. }
  76820. interface Navigator {
  76821. mozGetVRDevices: (any: any) => any;
  76822. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76823. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76824. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76825. webkitGetGamepads(): Gamepad[];
  76826. msGetGamepads(): Gamepad[];
  76827. webkitGamepads(): Gamepad[];
  76828. }
  76829. interface HTMLVideoElement {
  76830. mozSrcObject: any;
  76831. }
  76832. interface Math {
  76833. fround(x: number): number;
  76834. imul(a: number, b: number): number;
  76835. }
  76836. interface WebGLRenderingContext {
  76837. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76838. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76839. vertexAttribDivisor(index: number, divisor: number): void;
  76840. createVertexArray(): any;
  76841. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76842. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76843. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76844. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76845. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76846. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76847. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76848. // Queries
  76849. createQuery(): WebGLQuery;
  76850. deleteQuery(query: WebGLQuery): void;
  76851. beginQuery(target: number, query: WebGLQuery): void;
  76852. endQuery(target: number): void;
  76853. getQueryParameter(query: WebGLQuery, pname: number): any;
  76854. getQuery(target: number, pname: number): any;
  76855. MAX_SAMPLES: number;
  76856. RGBA8: number;
  76857. READ_FRAMEBUFFER: number;
  76858. DRAW_FRAMEBUFFER: number;
  76859. UNIFORM_BUFFER: number;
  76860. HALF_FLOAT_OES: number;
  76861. RGBA16F: number;
  76862. RGBA32F: number;
  76863. R32F: number;
  76864. RG32F: number;
  76865. RGB32F: number;
  76866. R16F: number;
  76867. RG16F: number;
  76868. RGB16F: number;
  76869. RED: number;
  76870. RG: number;
  76871. R8: number;
  76872. RG8: number;
  76873. UNSIGNED_INT_24_8: number;
  76874. DEPTH24_STENCIL8: number;
  76875. MIN: number;
  76876. MAX: number;
  76877. /* Multiple Render Targets */
  76878. drawBuffers(buffers: number[]): void;
  76879. readBuffer(src: number): void;
  76880. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76881. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76882. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76883. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76884. // Occlusion Query
  76885. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76886. ANY_SAMPLES_PASSED: number;
  76887. QUERY_RESULT_AVAILABLE: number;
  76888. QUERY_RESULT: number;
  76889. }
  76890. interface WebGLProgram {
  76891. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76892. }
  76893. interface EXT_disjoint_timer_query {
  76894. QUERY_COUNTER_BITS_EXT: number;
  76895. TIME_ELAPSED_EXT: number;
  76896. TIMESTAMP_EXT: number;
  76897. GPU_DISJOINT_EXT: number;
  76898. QUERY_RESULT_EXT: number;
  76899. QUERY_RESULT_AVAILABLE_EXT: number;
  76900. queryCounterEXT(query: WebGLQuery, target: number): void;
  76901. createQueryEXT(): WebGLQuery;
  76902. beginQueryEXT(target: number, query: WebGLQuery): void;
  76903. endQueryEXT(target: number): void;
  76904. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76905. deleteQueryEXT(query: WebGLQuery): void;
  76906. }
  76907. interface WebGLUniformLocation {
  76908. _currentState: any;
  76909. }
  76910. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76911. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76912. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76913. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76914. interface WebGLRenderingContext {
  76915. readonly RASTERIZER_DISCARD: number;
  76916. readonly DEPTH_COMPONENT24: number;
  76917. readonly TEXTURE_3D: number;
  76918. readonly TEXTURE_2D_ARRAY: number;
  76919. readonly TEXTURE_COMPARE_FUNC: number;
  76920. readonly TEXTURE_COMPARE_MODE: number;
  76921. readonly COMPARE_REF_TO_TEXTURE: number;
  76922. readonly TEXTURE_WRAP_R: number;
  76923. readonly HALF_FLOAT: number;
  76924. readonly RGB8: number;
  76925. readonly RED_INTEGER: number;
  76926. readonly RG_INTEGER: number;
  76927. readonly RGB_INTEGER: number;
  76928. readonly RGBA_INTEGER: number;
  76929. readonly R8_SNORM: number;
  76930. readonly RG8_SNORM: number;
  76931. readonly RGB8_SNORM: number;
  76932. readonly RGBA8_SNORM: number;
  76933. readonly R8I: number;
  76934. readonly RG8I: number;
  76935. readonly RGB8I: number;
  76936. readonly RGBA8I: number;
  76937. readonly R8UI: number;
  76938. readonly RG8UI: number;
  76939. readonly RGB8UI: number;
  76940. readonly RGBA8UI: number;
  76941. readonly R16I: number;
  76942. readonly RG16I: number;
  76943. readonly RGB16I: number;
  76944. readonly RGBA16I: number;
  76945. readonly R16UI: number;
  76946. readonly RG16UI: number;
  76947. readonly RGB16UI: number;
  76948. readonly RGBA16UI: number;
  76949. readonly R32I: number;
  76950. readonly RG32I: number;
  76951. readonly RGB32I: number;
  76952. readonly RGBA32I: number;
  76953. readonly R32UI: number;
  76954. readonly RG32UI: number;
  76955. readonly RGB32UI: number;
  76956. readonly RGBA32UI: number;
  76957. readonly RGB10_A2UI: number;
  76958. readonly R11F_G11F_B10F: number;
  76959. readonly RGB9_E5: number;
  76960. readonly RGB10_A2: number;
  76961. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  76962. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  76963. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  76964. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76965. readonly DEPTH_COMPONENT32F: number;
  76966. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  76967. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  76968. 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;
  76969. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  76970. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  76971. readonly TRANSFORM_FEEDBACK: number;
  76972. readonly INTERLEAVED_ATTRIBS: number;
  76973. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  76974. createTransformFeedback(): WebGLTransformFeedback;
  76975. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  76976. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  76977. beginTransformFeedback(primitiveMode: number): void;
  76978. endTransformFeedback(): void;
  76979. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  76980. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76981. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76982. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76983. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  76984. }
  76985. interface ImageBitmap {
  76986. readonly width: number;
  76987. readonly height: number;
  76988. close(): void;
  76989. }
  76990. interface WebGLQuery extends WebGLObject {
  76991. }
  76992. declare var WebGLQuery: {
  76993. prototype: WebGLQuery;
  76994. new(): WebGLQuery;
  76995. };
  76996. interface WebGLSampler extends WebGLObject {
  76997. }
  76998. declare var WebGLSampler: {
  76999. prototype: WebGLSampler;
  77000. new(): WebGLSampler;
  77001. };
  77002. interface WebGLSync extends WebGLObject {
  77003. }
  77004. declare var WebGLSync: {
  77005. prototype: WebGLSync;
  77006. new(): WebGLSync;
  77007. };
  77008. interface WebGLTransformFeedback extends WebGLObject {
  77009. }
  77010. declare var WebGLTransformFeedback: {
  77011. prototype: WebGLTransformFeedback;
  77012. new(): WebGLTransformFeedback;
  77013. };
  77014. interface WebGLVertexArrayObject extends WebGLObject {
  77015. }
  77016. declare var WebGLVertexArrayObject: {
  77017. prototype: WebGLVertexArrayObject;
  77018. new(): WebGLVertexArrayObject;
  77019. };
  77020. // Type definitions for WebVR API
  77021. // Project: https://w3c.github.io/webvr/
  77022. // Definitions by: six a <https://github.com/lostfictions>
  77023. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77024. interface VRDisplay extends EventTarget {
  77025. /**
  77026. * Dictionary of capabilities describing the VRDisplay.
  77027. */
  77028. readonly capabilities: VRDisplayCapabilities;
  77029. /**
  77030. * z-depth defining the far plane of the eye view frustum
  77031. * enables mapping of values in the render target depth
  77032. * attachment to scene coordinates. Initially set to 10000.0.
  77033. */
  77034. depthFar: number;
  77035. /**
  77036. * z-depth defining the near plane of the eye view frustum
  77037. * enables mapping of values in the render target depth
  77038. * attachment to scene coordinates. Initially set to 0.01.
  77039. */
  77040. depthNear: number;
  77041. /**
  77042. * An identifier for this distinct VRDisplay. Used as an
  77043. * association point in the Gamepad API.
  77044. */
  77045. readonly displayId: number;
  77046. /**
  77047. * A display name, a user-readable name identifying it.
  77048. */
  77049. readonly displayName: string;
  77050. readonly isConnected: boolean;
  77051. readonly isPresenting: boolean;
  77052. /**
  77053. * If this VRDisplay supports room-scale experiences, the optional
  77054. * stage attribute contains details on the room-scale parameters.
  77055. */
  77056. readonly stageParameters: VRStageParameters | null;
  77057. /**
  77058. * Passing the value returned by `requestAnimationFrame` to
  77059. * `cancelAnimationFrame` will unregister the callback.
  77060. * @param handle Define the hanle of the request to cancel
  77061. */
  77062. cancelAnimationFrame(handle: number): void;
  77063. /**
  77064. * Stops presenting to the VRDisplay.
  77065. * @returns a promise to know when it stopped
  77066. */
  77067. exitPresent(): Promise<void>;
  77068. /**
  77069. * Return the current VREyeParameters for the given eye.
  77070. * @param whichEye Define the eye we want the parameter for
  77071. * @returns the eye parameters
  77072. */
  77073. getEyeParameters(whichEye: string): VREyeParameters;
  77074. /**
  77075. * Populates the passed VRFrameData with the information required to render
  77076. * the current frame.
  77077. * @param frameData Define the data structure to populate
  77078. * @returns true if ok otherwise false
  77079. */
  77080. getFrameData(frameData: VRFrameData): boolean;
  77081. /**
  77082. * Get the layers currently being presented.
  77083. * @returns the list of VR layers
  77084. */
  77085. getLayers(): VRLayer[];
  77086. /**
  77087. * Return a VRPose containing the future predicted pose of the VRDisplay
  77088. * when the current frame will be presented. The value returned will not
  77089. * change until JavaScript has returned control to the browser.
  77090. *
  77091. * The VRPose will contain the position, orientation, velocity,
  77092. * and acceleration of each of these properties.
  77093. * @returns the pose object
  77094. */
  77095. getPose(): VRPose;
  77096. /**
  77097. * Return the current instantaneous pose of the VRDisplay, with no
  77098. * prediction applied.
  77099. * @returns the current instantaneous pose
  77100. */
  77101. getImmediatePose(): VRPose;
  77102. /**
  77103. * The callback passed to `requestAnimationFrame` will be called
  77104. * any time a new frame should be rendered. When the VRDisplay is
  77105. * presenting the callback will be called at the native refresh
  77106. * rate of the HMD. When not presenting this function acts
  77107. * identically to how window.requestAnimationFrame acts. Content should
  77108. * make no assumptions of frame rate or vsync behavior as the HMD runs
  77109. * asynchronously from other displays and at differing refresh rates.
  77110. * @param callback Define the eaction to run next frame
  77111. * @returns the request handle it
  77112. */
  77113. requestAnimationFrame(callback: FrameRequestCallback): number;
  77114. /**
  77115. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  77116. * Repeat calls while already presenting will update the VRLayers being displayed.
  77117. * @param layers Define the list of layer to present
  77118. * @returns a promise to know when the request has been fulfilled
  77119. */
  77120. requestPresent(layers: VRLayer[]): Promise<void>;
  77121. /**
  77122. * Reset the pose for this display, treating its current position and
  77123. * orientation as the "origin/zero" values. VRPose.position,
  77124. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  77125. * updated when calling resetPose(). This should be called in only
  77126. * sitting-space experiences.
  77127. */
  77128. resetPose(): void;
  77129. /**
  77130. * The VRLayer provided to the VRDisplay will be captured and presented
  77131. * in the HMD. Calling this function has the same effect on the source
  77132. * canvas as any other operation that uses its source image, and canvases
  77133. * created without preserveDrawingBuffer set to true will be cleared.
  77134. * @param pose Define the pose to submit
  77135. */
  77136. submitFrame(pose?: VRPose): void;
  77137. }
  77138. declare var VRDisplay: {
  77139. prototype: VRDisplay;
  77140. new(): VRDisplay;
  77141. };
  77142. interface VRLayer {
  77143. leftBounds?: number[] | Float32Array | null;
  77144. rightBounds?: number[] | Float32Array | null;
  77145. source?: HTMLCanvasElement | null;
  77146. }
  77147. interface VRDisplayCapabilities {
  77148. readonly canPresent: boolean;
  77149. readonly hasExternalDisplay: boolean;
  77150. readonly hasOrientation: boolean;
  77151. readonly hasPosition: boolean;
  77152. readonly maxLayers: number;
  77153. }
  77154. interface VREyeParameters {
  77155. /** @deprecated */
  77156. readonly fieldOfView: VRFieldOfView;
  77157. readonly offset: Float32Array;
  77158. readonly renderHeight: number;
  77159. readonly renderWidth: number;
  77160. }
  77161. interface VRFieldOfView {
  77162. readonly downDegrees: number;
  77163. readonly leftDegrees: number;
  77164. readonly rightDegrees: number;
  77165. readonly upDegrees: number;
  77166. }
  77167. interface VRFrameData {
  77168. readonly leftProjectionMatrix: Float32Array;
  77169. readonly leftViewMatrix: Float32Array;
  77170. readonly pose: VRPose;
  77171. readonly rightProjectionMatrix: Float32Array;
  77172. readonly rightViewMatrix: Float32Array;
  77173. readonly timestamp: number;
  77174. }
  77175. interface VRPose {
  77176. readonly angularAcceleration: Float32Array | null;
  77177. readonly angularVelocity: Float32Array | null;
  77178. readonly linearAcceleration: Float32Array | null;
  77179. readonly linearVelocity: Float32Array | null;
  77180. readonly orientation: Float32Array | null;
  77181. readonly position: Float32Array | null;
  77182. readonly timestamp: number;
  77183. }
  77184. interface VRStageParameters {
  77185. sittingToStandingTransform?: Float32Array;
  77186. sizeX?: number;
  77187. sizeY?: number;
  77188. }
  77189. interface Navigator {
  77190. getVRDisplays(): Promise<VRDisplay[]>;
  77191. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  77192. }
  77193. interface Window {
  77194. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  77195. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  77196. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  77197. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77198. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77199. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  77200. }
  77201. interface Gamepad {
  77202. readonly displayId: number;
  77203. }
  77204. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  77205. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  77206. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  77207. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  77208. type XRHandedness = "none" | "left" | "right";
  77209. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  77210. type XREye = "none" | "left" | "right";
  77211. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  77212. interface XRSpace extends EventTarget {}
  77213. interface XRRenderState {
  77214. depthNear?: number;
  77215. depthFar?: number;
  77216. inlineVerticalFieldOfView?: number;
  77217. baseLayer?: XRWebGLLayer;
  77218. }
  77219. interface XRInputSource {
  77220. handedness: XRHandedness;
  77221. targetRayMode: XRTargetRayMode;
  77222. targetRaySpace: XRSpace;
  77223. gripSpace: XRSpace | undefined;
  77224. gamepad: Gamepad | undefined;
  77225. profiles: Array<string>;
  77226. hand: XRHand | undefined;
  77227. }
  77228. interface XRSessionInit {
  77229. optionalFeatures?: string[];
  77230. requiredFeatures?: string[];
  77231. }
  77232. interface XRSession {
  77233. addEventListener: Function;
  77234. removeEventListener: Function;
  77235. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  77236. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  77237. requestAnimationFrame: Function;
  77238. end(): Promise<void>;
  77239. renderState: XRRenderState;
  77240. inputSources: Array<XRInputSource>;
  77241. // hit test
  77242. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  77243. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  77244. // legacy AR hit test
  77245. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77246. // legacy plane detection
  77247. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  77248. }
  77249. interface XRReferenceSpace extends XRSpace {
  77250. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  77251. onreset: any;
  77252. }
  77253. type XRPlaneSet = Set<XRPlane>;
  77254. type XRAnchorSet = Set<XRAnchor>;
  77255. interface XRFrame {
  77256. session: XRSession;
  77257. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  77258. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  77259. // AR
  77260. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  77261. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  77262. // Anchors
  77263. trackedAnchors?: XRAnchorSet;
  77264. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  77265. // Planes
  77266. worldInformation: {
  77267. detectedPlanes?: XRPlaneSet;
  77268. };
  77269. // Hand tracking
  77270. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  77271. }
  77272. interface XRViewerPose extends XRPose {
  77273. views: Array<XRView>;
  77274. }
  77275. interface XRPose {
  77276. transform: XRRigidTransform;
  77277. emulatedPosition: boolean;
  77278. }
  77279. interface XRWebGLLayerOptions {
  77280. antialias?: boolean;
  77281. depth?: boolean;
  77282. stencil?: boolean;
  77283. alpha?: boolean;
  77284. multiview?: boolean;
  77285. framebufferScaleFactor?: number;
  77286. }
  77287. declare var XRWebGLLayer: {
  77288. prototype: XRWebGLLayer;
  77289. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  77290. };
  77291. interface XRWebGLLayer {
  77292. framebuffer: WebGLFramebuffer;
  77293. framebufferWidth: number;
  77294. framebufferHeight: number;
  77295. getViewport: Function;
  77296. }
  77297. declare class XRRigidTransform {
  77298. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  77299. position: DOMPointReadOnly;
  77300. orientation: DOMPointReadOnly;
  77301. matrix: Float32Array;
  77302. inverse: XRRigidTransform;
  77303. }
  77304. interface XRView {
  77305. eye: XREye;
  77306. projectionMatrix: Float32Array;
  77307. transform: XRRigidTransform;
  77308. }
  77309. interface XRInputSourceChangeEvent {
  77310. session: XRSession;
  77311. removed: Array<XRInputSource>;
  77312. added: Array<XRInputSource>;
  77313. }
  77314. interface XRInputSourceEvent extends Event {
  77315. readonly frame: XRFrame;
  77316. readonly inputSource: XRInputSource;
  77317. }
  77318. // Experimental(er) features
  77319. declare class XRRay {
  77320. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77321. origin: DOMPointReadOnly;
  77322. direction: DOMPointReadOnly;
  77323. matrix: Float32Array;
  77324. }
  77325. declare enum XRHitTestTrackableType {
  77326. "point",
  77327. "plane",
  77328. "mesh",
  77329. }
  77330. interface XRHitResult {
  77331. hitMatrix: Float32Array;
  77332. }
  77333. interface XRTransientInputHitTestResult {
  77334. readonly inputSource: XRInputSource;
  77335. readonly results: Array<XRHitTestResult>;
  77336. }
  77337. interface XRHitTestResult {
  77338. getPose(baseSpace: XRSpace): XRPose | undefined;
  77339. // When anchor system is enabled
  77340. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77341. }
  77342. interface XRHitTestSource {
  77343. cancel(): void;
  77344. }
  77345. interface XRTransientInputHitTestSource {
  77346. cancel(): void;
  77347. }
  77348. interface XRHitTestOptionsInit {
  77349. space: XRSpace;
  77350. entityTypes?: Array<XRHitTestTrackableType>;
  77351. offsetRay?: XRRay;
  77352. }
  77353. interface XRTransientInputHitTestOptionsInit {
  77354. profile: string;
  77355. entityTypes?: Array<XRHitTestTrackableType>;
  77356. offsetRay?: XRRay;
  77357. }
  77358. interface XRAnchor {
  77359. anchorSpace: XRSpace;
  77360. delete(): void;
  77361. }
  77362. interface XRPlane {
  77363. orientation: "Horizontal" | "Vertical";
  77364. planeSpace: XRSpace;
  77365. polygon: Array<DOMPointReadOnly>;
  77366. lastChangedTime: number;
  77367. }
  77368. interface XRJointSpace extends XRSpace {}
  77369. interface XRJointPose extends XRPose {
  77370. radius: number | undefined;
  77371. }
  77372. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  77373. readonly length: number;
  77374. [index: number]: XRJointSpace;
  77375. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  77376. readonly WRIST: number;
  77377. readonly THUMB_METACARPAL: number;
  77378. readonly THUMB_PHALANX_PROXIMAL: number;
  77379. readonly THUMB_PHALANX_DISTAL: number;
  77380. readonly THUMB_PHALANX_TIP: number;
  77381. readonly INDEX_METACARPAL: number;
  77382. readonly INDEX_PHALANX_PROXIMAL: number;
  77383. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77384. readonly INDEX_PHALANX_DISTAL: number;
  77385. readonly INDEX_PHALANX_TIP: number;
  77386. readonly MIDDLE_METACARPAL: number;
  77387. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77388. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77389. readonly MIDDLE_PHALANX_DISTAL: number;
  77390. readonly MIDDLE_PHALANX_TIP: number;
  77391. readonly RING_METACARPAL: number;
  77392. readonly RING_PHALANX_PROXIMAL: number;
  77393. readonly RING_PHALANX_INTERMEDIATE: number;
  77394. readonly RING_PHALANX_DISTAL: number;
  77395. readonly RING_PHALANX_TIP: number;
  77396. readonly LITTLE_METACARPAL: number;
  77397. readonly LITTLE_PHALANX_PROXIMAL: number;
  77398. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  77399. readonly LITTLE_PHALANX_DISTAL: number;
  77400. readonly LITTLE_PHALANX_TIP: number;
  77401. }
  77402. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  77403. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  77404. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  77405. interface XRSession {
  77406. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  77407. }
  77408. interface XRFrame {
  77409. featurePointCloud? : Array<number>;
  77410. }
  77411. /**
  77412. * @ignore
  77413. */
  77414. declare module BABYLON.GLTF2.Exporter {
  77415. }
  77416. /**
  77417. * @ignore
  77418. */
  77419. declare module BABYLON.GLTF1 {
  77420. }
  77421. declare module BABYLON.GUI {
  77422. /**
  77423. * Class used to specific a value and its associated unit
  77424. */
  77425. export class ValueAndUnit {
  77426. /** defines the unit to store */
  77427. unit: number;
  77428. /** defines a boolean indicating if the value can be negative */
  77429. negativeValueAllowed: boolean;
  77430. private _value;
  77431. private _originalUnit;
  77432. /**
  77433. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77434. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77435. */
  77436. ignoreAdaptiveScaling: boolean;
  77437. /**
  77438. * Creates a new ValueAndUnit
  77439. * @param value defines the value to store
  77440. * @param unit defines the unit to store
  77441. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77442. */
  77443. constructor(value: number,
  77444. /** defines the unit to store */
  77445. unit?: number,
  77446. /** defines a boolean indicating if the value can be negative */
  77447. negativeValueAllowed?: boolean);
  77448. /** Gets a boolean indicating if the value is a percentage */
  77449. get isPercentage(): boolean;
  77450. /** Gets a boolean indicating if the value is store as pixel */
  77451. get isPixel(): boolean;
  77452. /** Gets direct internal value */
  77453. get internalValue(): number;
  77454. /**
  77455. * Gets value as pixel
  77456. * @param host defines the root host
  77457. * @param refValue defines the reference value for percentages
  77458. * @returns the value as pixel
  77459. */
  77460. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  77461. /**
  77462. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  77463. * @param value defines the value to store
  77464. * @param unit defines the unit to store
  77465. * @returns the current ValueAndUnit
  77466. */
  77467. updateInPlace(value: number, unit?: number): ValueAndUnit;
  77468. /**
  77469. * Gets the value accordingly to its unit
  77470. * @param host defines the root host
  77471. * @returns the value
  77472. */
  77473. getValue(host: AdvancedDynamicTexture): number;
  77474. /**
  77475. * Gets a string representation of the value
  77476. * @param host defines the root host
  77477. * @param decimals defines an optional number of decimals to display
  77478. * @returns a string
  77479. */
  77480. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77481. /**
  77482. * Store a value parsed from a string
  77483. * @param source defines the source string
  77484. * @returns true if the value was successfully parsed
  77485. */
  77486. fromString(source: string | number): boolean;
  77487. private static _Regex;
  77488. private static _UNITMODE_PERCENTAGE;
  77489. private static _UNITMODE_PIXEL;
  77490. /** UNITMODE_PERCENTAGE */
  77491. static get UNITMODE_PERCENTAGE(): number;
  77492. /** UNITMODE_PIXEL */
  77493. static get UNITMODE_PIXEL(): number;
  77494. }
  77495. }
  77496. declare module BABYLON.GUI {
  77497. /**
  77498. * Define a style used by control to automatically setup properties based on a template.
  77499. * Only support font related properties so far
  77500. */
  77501. export class Style implements BABYLON.IDisposable {
  77502. private _fontFamily;
  77503. private _fontStyle;
  77504. private _fontWeight;
  77505. /** @hidden */
  77506. _host: AdvancedDynamicTexture;
  77507. /** @hidden */
  77508. _fontSize: ValueAndUnit;
  77509. /**
  77510. * BABYLON.Observable raised when the style values are changed
  77511. */
  77512. onChangedObservable: BABYLON.Observable<Style>;
  77513. /**
  77514. * Creates a new style object
  77515. * @param host defines the AdvancedDynamicTexture which hosts this style
  77516. */
  77517. constructor(host: AdvancedDynamicTexture);
  77518. /**
  77519. * Gets or sets the font size
  77520. */
  77521. get fontSize(): string | number;
  77522. set fontSize(value: string | number);
  77523. /**
  77524. * Gets or sets the font family
  77525. */
  77526. get fontFamily(): string;
  77527. set fontFamily(value: string);
  77528. /**
  77529. * Gets or sets the font style
  77530. */
  77531. get fontStyle(): string;
  77532. set fontStyle(value: string);
  77533. /** Gets or sets font weight */
  77534. get fontWeight(): string;
  77535. set fontWeight(value: string);
  77536. /** Dispose all associated resources */
  77537. dispose(): void;
  77538. }
  77539. }
  77540. declare module BABYLON.GUI {
  77541. /**
  77542. * Class used to transport BABYLON.Vector2 information for pointer events
  77543. */
  77544. export class Vector2WithInfo extends BABYLON.Vector2 {
  77545. /** defines the current mouse button index */
  77546. buttonIndex: number;
  77547. /**
  77548. * Creates a new Vector2WithInfo
  77549. * @param source defines the vector2 data to transport
  77550. * @param buttonIndex defines the current mouse button index
  77551. */
  77552. constructor(source: BABYLON.Vector2,
  77553. /** defines the current mouse button index */
  77554. buttonIndex?: number);
  77555. }
  77556. /** Class used to provide 2D matrix features */
  77557. export class Matrix2D {
  77558. /** Gets the internal array of 6 floats used to store matrix data */
  77559. m: Float32Array;
  77560. /**
  77561. * Creates a new matrix
  77562. * @param m00 defines value for (0, 0)
  77563. * @param m01 defines value for (0, 1)
  77564. * @param m10 defines value for (1, 0)
  77565. * @param m11 defines value for (1, 1)
  77566. * @param m20 defines value for (2, 0)
  77567. * @param m21 defines value for (2, 1)
  77568. */
  77569. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  77570. /**
  77571. * Fills the matrix from direct values
  77572. * @param m00 defines value for (0, 0)
  77573. * @param m01 defines value for (0, 1)
  77574. * @param m10 defines value for (1, 0)
  77575. * @param m11 defines value for (1, 1)
  77576. * @param m20 defines value for (2, 0)
  77577. * @param m21 defines value for (2, 1)
  77578. * @returns the current modified matrix
  77579. */
  77580. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  77581. /**
  77582. * Gets matrix determinant
  77583. * @returns the determinant
  77584. */
  77585. determinant(): number;
  77586. /**
  77587. * Inverses the matrix and stores it in a target matrix
  77588. * @param result defines the target matrix
  77589. * @returns the current matrix
  77590. */
  77591. invertToRef(result: Matrix2D): Matrix2D;
  77592. /**
  77593. * Multiplies the current matrix with another one
  77594. * @param other defines the second operand
  77595. * @param result defines the target matrix
  77596. * @returns the current matrix
  77597. */
  77598. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  77599. /**
  77600. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  77601. * @param x defines the x coordinate to transform
  77602. * @param y defines the x coordinate to transform
  77603. * @param result defines the target vector2
  77604. * @returns the current matrix
  77605. */
  77606. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  77607. /**
  77608. * Creates an identity matrix
  77609. * @returns a new matrix
  77610. */
  77611. static Identity(): Matrix2D;
  77612. /**
  77613. * Creates a translation matrix and stores it in a target matrix
  77614. * @param x defines the x coordinate of the translation
  77615. * @param y defines the y coordinate of the translation
  77616. * @param result defines the target matrix
  77617. */
  77618. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  77619. /**
  77620. * Creates a scaling matrix and stores it in a target matrix
  77621. * @param x defines the x coordinate of the scaling
  77622. * @param y defines the y coordinate of the scaling
  77623. * @param result defines the target matrix
  77624. */
  77625. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  77626. /**
  77627. * Creates a rotation matrix and stores it in a target matrix
  77628. * @param angle defines the rotation angle
  77629. * @param result defines the target matrix
  77630. */
  77631. static RotationToRef(angle: number, result: Matrix2D): void;
  77632. private static _TempPreTranslationMatrix;
  77633. private static _TempPostTranslationMatrix;
  77634. private static _TempRotationMatrix;
  77635. private static _TempScalingMatrix;
  77636. private static _TempCompose0;
  77637. private static _TempCompose1;
  77638. private static _TempCompose2;
  77639. /**
  77640. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  77641. * @param tx defines the x coordinate of the translation
  77642. * @param ty defines the y coordinate of the translation
  77643. * @param angle defines the rotation angle
  77644. * @param scaleX defines the x coordinate of the scaling
  77645. * @param scaleY defines the y coordinate of the scaling
  77646. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  77647. * @param result defines the target matrix
  77648. */
  77649. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  77650. }
  77651. }
  77652. declare module BABYLON.GUI {
  77653. /**
  77654. * Class used to store 2D control sizes
  77655. */
  77656. export class Measure {
  77657. /** defines left coordinate */
  77658. left: number;
  77659. /** defines top coordinate */
  77660. top: number;
  77661. /** defines width dimension */
  77662. width: number;
  77663. /** defines height dimension */
  77664. height: number;
  77665. /**
  77666. * Creates a new measure
  77667. * @param left defines left coordinate
  77668. * @param top defines top coordinate
  77669. * @param width defines width dimension
  77670. * @param height defines height dimension
  77671. */
  77672. constructor(
  77673. /** defines left coordinate */
  77674. left: number,
  77675. /** defines top coordinate */
  77676. top: number,
  77677. /** defines width dimension */
  77678. width: number,
  77679. /** defines height dimension */
  77680. height: number);
  77681. /**
  77682. * Copy from another measure
  77683. * @param other defines the other measure to copy from
  77684. */
  77685. copyFrom(other: Measure): void;
  77686. /**
  77687. * Copy from a group of 4 floats
  77688. * @param left defines left coordinate
  77689. * @param top defines top coordinate
  77690. * @param width defines width dimension
  77691. * @param height defines height dimension
  77692. */
  77693. copyFromFloats(left: number, top: number, width: number, height: number): void;
  77694. /**
  77695. * Computes the axis aligned bounding box measure for two given measures
  77696. * @param a Input measure
  77697. * @param b Input measure
  77698. * @param result the resulting bounding measure
  77699. */
  77700. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  77701. /**
  77702. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77703. * @param transform the matrix to transform the measure before computing the AABB
  77704. * @param addX number to add to left
  77705. * @param addY number to add to top
  77706. * @param addWidth number to add to width
  77707. * @param addHeight number to add to height
  77708. * @param result the resulting AABB
  77709. */
  77710. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  77711. /**
  77712. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77713. * @param transform the matrix to transform the measure before computing the AABB
  77714. * @param result the resulting AABB
  77715. */
  77716. transformToRef(transform: Matrix2D, result: Measure): void;
  77717. /**
  77718. * Check equality between this measure and another one
  77719. * @param other defines the other measures
  77720. * @returns true if both measures are equals
  77721. */
  77722. isEqualsTo(other: Measure): boolean;
  77723. /**
  77724. * Creates an empty measure
  77725. * @returns a new measure
  77726. */
  77727. static Empty(): Measure;
  77728. }
  77729. }
  77730. declare module BABYLON.GUI {
  77731. /**
  77732. * Interface used to define a control that can receive focus
  77733. */
  77734. export interface IFocusableControl {
  77735. /**
  77736. * Function called when the control receives the focus
  77737. */
  77738. onFocus(): void;
  77739. /**
  77740. * Function called when the control loses the focus
  77741. */
  77742. onBlur(): void;
  77743. /**
  77744. * Function called to let the control handle keyboard events
  77745. * @param evt defines the current keyboard event
  77746. */
  77747. processKeyboard(evt: KeyboardEvent): void;
  77748. /**
  77749. * Function called to get the list of controls that should not steal the focus from this control
  77750. * @returns an array of controls
  77751. */
  77752. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77753. }
  77754. /**
  77755. * Class used to create texture to support 2D GUI elements
  77756. * @see https://doc.babylonjs.com/how_to/gui
  77757. */
  77758. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  77759. private _isDirty;
  77760. private _renderObserver;
  77761. private _resizeObserver;
  77762. private _preKeyboardObserver;
  77763. private _pointerMoveObserver;
  77764. private _pointerObserver;
  77765. private _canvasPointerOutObserver;
  77766. private _canvasBlurObserver;
  77767. private _background;
  77768. /** @hidden */
  77769. _rootContainer: Container;
  77770. /** @hidden */
  77771. _lastPickedControl: Control;
  77772. /** @hidden */
  77773. _lastControlOver: {
  77774. [pointerId: number]: Control;
  77775. };
  77776. /** @hidden */
  77777. _lastControlDown: {
  77778. [pointerId: number]: Control;
  77779. };
  77780. /** @hidden */
  77781. _capturingControl: {
  77782. [pointerId: number]: Control;
  77783. };
  77784. /** @hidden */
  77785. _shouldBlockPointer: boolean;
  77786. /** @hidden */
  77787. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  77788. /** @hidden */
  77789. _linkedControls: Control[];
  77790. private _isFullscreen;
  77791. private _fullscreenViewport;
  77792. private _idealWidth;
  77793. private _idealHeight;
  77794. private _useSmallestIdeal;
  77795. private _renderAtIdealSize;
  77796. private _focusedControl;
  77797. private _blockNextFocusCheck;
  77798. private _renderScale;
  77799. private _rootElement;
  77800. private _cursorChanged;
  77801. private _defaultMousePointerId;
  77802. /** @hidden */
  77803. _numLayoutCalls: number;
  77804. /** Gets the number of layout calls made the last time the ADT has been rendered */
  77805. get numLayoutCalls(): number;
  77806. /** @hidden */
  77807. _numRenderCalls: number;
  77808. /** Gets the number of render calls made the last time the ADT has been rendered */
  77809. get numRenderCalls(): number;
  77810. /**
  77811. * Define type to string to ensure compatibility across browsers
  77812. * Safari doesn't support DataTransfer constructor
  77813. */
  77814. private _clipboardData;
  77815. /**
  77816. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77817. */
  77818. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77819. /**
  77820. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77821. */
  77822. onControlPickedObservable: BABYLON.Observable<Control>;
  77823. /**
  77824. * BABYLON.Observable event triggered before layout is evaluated
  77825. */
  77826. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77827. /**
  77828. * BABYLON.Observable event triggered after the layout was evaluated
  77829. */
  77830. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77831. /**
  77832. * BABYLON.Observable event triggered before the texture is rendered
  77833. */
  77834. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77835. /**
  77836. * BABYLON.Observable event triggered after the texture was rendered
  77837. */
  77838. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77839. /**
  77840. * Gets or sets a boolean defining if alpha is stored as premultiplied
  77841. */
  77842. premulAlpha: boolean;
  77843. /**
  77844. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  77845. * Useful when you want more antialiasing
  77846. */
  77847. get renderScale(): number;
  77848. set renderScale(value: number);
  77849. /** Gets or sets the background color */
  77850. get background(): string;
  77851. set background(value: string);
  77852. /**
  77853. * Gets or sets the ideal width used to design controls.
  77854. * The GUI will then rescale everything accordingly
  77855. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77856. */
  77857. get idealWidth(): number;
  77858. set idealWidth(value: number);
  77859. /**
  77860. * Gets or sets the ideal height used to design controls.
  77861. * The GUI will then rescale everything accordingly
  77862. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77863. */
  77864. get idealHeight(): number;
  77865. set idealHeight(value: number);
  77866. /**
  77867. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  77868. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77869. */
  77870. get useSmallestIdeal(): boolean;
  77871. set useSmallestIdeal(value: boolean);
  77872. /**
  77873. * Gets or sets a boolean indicating if adaptive scaling must be used
  77874. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77875. */
  77876. get renderAtIdealSize(): boolean;
  77877. set renderAtIdealSize(value: boolean);
  77878. /**
  77879. * Gets the ratio used when in "ideal mode"
  77880. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77881. * */
  77882. get idealRatio(): number;
  77883. /**
  77884. * Gets the underlying layer used to render the texture when in fullscreen mode
  77885. */
  77886. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  77887. /**
  77888. * Gets the root container control
  77889. */
  77890. get rootContainer(): Container;
  77891. /**
  77892. * Returns an array containing the root container.
  77893. * This is mostly used to let the Inspector introspects the ADT
  77894. * @returns an array containing the rootContainer
  77895. */
  77896. getChildren(): Array<Container>;
  77897. /**
  77898. * Will return all controls that are inside this texture
  77899. * @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
  77900. * @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
  77901. * @return all child controls
  77902. */
  77903. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77904. /**
  77905. * Gets or sets the current focused control
  77906. */
  77907. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  77908. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  77909. /**
  77910. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  77911. */
  77912. get isForeground(): boolean;
  77913. set isForeground(value: boolean);
  77914. /**
  77915. * Gets or set information about clipboardData
  77916. */
  77917. get clipboardData(): string;
  77918. set clipboardData(value: string);
  77919. /**
  77920. * Creates a new AdvancedDynamicTexture
  77921. * @param name defines the name of the texture
  77922. * @param width defines the width of the texture
  77923. * @param height defines the height of the texture
  77924. * @param scene defines the hosting scene
  77925. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  77926. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77927. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77928. */
  77929. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  77930. /**
  77931. * Get the current class name of the texture useful for serialization or dynamic coding.
  77932. * @returns "AdvancedDynamicTexture"
  77933. */
  77934. getClassName(): string;
  77935. /**
  77936. * Function used to execute a function on all controls
  77937. * @param func defines the function to execute
  77938. * @param container defines the container where controls belong. If null the root container will be used
  77939. */
  77940. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  77941. private _useInvalidateRectOptimization;
  77942. /**
  77943. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  77944. */
  77945. get useInvalidateRectOptimization(): boolean;
  77946. set useInvalidateRectOptimization(value: boolean);
  77947. private _invalidatedRectangle;
  77948. /**
  77949. * Invalidates a rectangle area on the gui texture
  77950. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  77951. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  77952. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  77953. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  77954. */
  77955. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  77956. /**
  77957. * Marks the texture as dirty forcing a complete update
  77958. */
  77959. markAsDirty(): void;
  77960. /**
  77961. * Helper function used to create a new style
  77962. * @returns a new style
  77963. * @see https://doc.babylonjs.com/how_to/gui#styles
  77964. */
  77965. createStyle(): Style;
  77966. /**
  77967. * Adds a new control to the root container
  77968. * @param control defines the control to add
  77969. * @returns the current texture
  77970. */
  77971. addControl(control: Control): AdvancedDynamicTexture;
  77972. /**
  77973. * Removes a control from the root container
  77974. * @param control defines the control to remove
  77975. * @returns the current texture
  77976. */
  77977. removeControl(control: Control): AdvancedDynamicTexture;
  77978. /**
  77979. * Release all resources
  77980. */
  77981. dispose(): void;
  77982. private _onResize;
  77983. /** @hidden */
  77984. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  77985. /**
  77986. * Get screen coordinates for a vector3
  77987. * @param position defines the position to project
  77988. * @param worldMatrix defines the world matrix to use
  77989. * @returns the projected position
  77990. */
  77991. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  77992. private _checkUpdate;
  77993. private _clearMeasure;
  77994. private _render;
  77995. /** @hidden */
  77996. _changeCursor(cursor: string): void;
  77997. /** @hidden */
  77998. _registerLastControlDown(control: Control, pointerId: number): void;
  77999. private _doPicking;
  78000. /** @hidden */
  78001. _cleanControlAfterRemovalFromList(list: {
  78002. [pointerId: number]: Control;
  78003. }, control: Control): void;
  78004. /** @hidden */
  78005. _cleanControlAfterRemoval(control: Control): void;
  78006. /** Attach to all scene events required to support pointer events */
  78007. attach(): void;
  78008. /** @hidden */
  78009. private onClipboardCopy;
  78010. /** @hidden */
  78011. private onClipboardCut;
  78012. /** @hidden */
  78013. private onClipboardPaste;
  78014. /**
  78015. * Register the clipboard Events onto the canvas
  78016. */
  78017. registerClipboardEvents(): void;
  78018. /**
  78019. * Unregister the clipboard Events from the canvas
  78020. */
  78021. unRegisterClipboardEvents(): void;
  78022. /**
  78023. * Connect the texture to a hosting mesh to enable interactions
  78024. * @param mesh defines the mesh to attach to
  78025. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  78026. */
  78027. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  78028. /**
  78029. * Move the focus to a specific control
  78030. * @param control defines the control which will receive the focus
  78031. */
  78032. moveFocusToControl(control: IFocusableControl): void;
  78033. private _manageFocus;
  78034. private _attachToOnPointerOut;
  78035. private _attachToOnBlur;
  78036. /**
  78037. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  78038. * @param mesh defines the mesh which will receive the texture
  78039. * @param width defines the texture width (1024 by default)
  78040. * @param height defines the texture height (1024 by default)
  78041. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78042. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  78043. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78044. * @returns a new AdvancedDynamicTexture
  78045. */
  78046. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78047. /**
  78048. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  78049. * In this mode the texture will rely on a layer for its rendering.
  78050. * This allows it to be treated like any other layer.
  78051. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  78052. * LayerMask is set through advancedTexture.layer.layerMask
  78053. * @param name defines name for the texture
  78054. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  78055. * @param scene defines the hsoting scene
  78056. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  78057. * @returns a new AdvancedDynamicTexture
  78058. */
  78059. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  78060. }
  78061. }
  78062. declare module BABYLON.GUI {
  78063. /**
  78064. * Root class used for all 2D controls
  78065. * @see https://doc.babylonjs.com/how_to/gui#controls
  78066. */
  78067. export class Control {
  78068. /** defines the name of the control */
  78069. name?: string | undefined;
  78070. /**
  78071. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  78072. */
  78073. static AllowAlphaInheritance: boolean;
  78074. private _alpha;
  78075. private _alphaSet;
  78076. private _zIndex;
  78077. /** @hidden */
  78078. _host: AdvancedDynamicTexture;
  78079. /** Gets or sets the control parent */
  78080. parent: BABYLON.Nullable<Container>;
  78081. /** @hidden */
  78082. _currentMeasure: Measure;
  78083. private _fontFamily;
  78084. private _fontStyle;
  78085. private _fontWeight;
  78086. private _fontSize;
  78087. private _font;
  78088. /** @hidden */
  78089. _width: ValueAndUnit;
  78090. /** @hidden */
  78091. _height: ValueAndUnit;
  78092. /** @hidden */
  78093. protected _fontOffset: {
  78094. ascent: number;
  78095. height: number;
  78096. descent: number;
  78097. };
  78098. private _color;
  78099. private _style;
  78100. private _styleObserver;
  78101. /** @hidden */
  78102. protected _horizontalAlignment: number;
  78103. /** @hidden */
  78104. protected _verticalAlignment: number;
  78105. /** @hidden */
  78106. protected _isDirty: boolean;
  78107. /** @hidden */
  78108. protected _wasDirty: boolean;
  78109. /** @hidden */
  78110. _tempParentMeasure: Measure;
  78111. /** @hidden */
  78112. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  78113. /** @hidden */
  78114. protected _cachedParentMeasure: Measure;
  78115. private _paddingLeft;
  78116. private _paddingRight;
  78117. private _paddingTop;
  78118. private _paddingBottom;
  78119. /** @hidden */
  78120. _left: ValueAndUnit;
  78121. /** @hidden */
  78122. _top: ValueAndUnit;
  78123. private _scaleX;
  78124. private _scaleY;
  78125. private _rotation;
  78126. private _transformCenterX;
  78127. private _transformCenterY;
  78128. /** @hidden */
  78129. _transformMatrix: Matrix2D;
  78130. /** @hidden */
  78131. protected _invertTransformMatrix: Matrix2D;
  78132. /** @hidden */
  78133. protected _transformedPosition: BABYLON.Vector2;
  78134. private _isMatrixDirty;
  78135. private _cachedOffsetX;
  78136. private _cachedOffsetY;
  78137. private _isVisible;
  78138. private _isHighlighted;
  78139. /** @hidden */
  78140. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  78141. private _fontSet;
  78142. private _dummyVector2;
  78143. private _downCount;
  78144. private _enterCount;
  78145. private _doNotRender;
  78146. private _downPointerIds;
  78147. protected _isEnabled: boolean;
  78148. protected _disabledColor: string;
  78149. protected _disabledColorItem: string;
  78150. /** @hidden */
  78151. protected _rebuildLayout: boolean;
  78152. /** @hidden */
  78153. _customData: any;
  78154. /** @hidden */
  78155. _isClipped: boolean;
  78156. /** @hidden */
  78157. _automaticSize: boolean;
  78158. /** @hidden */
  78159. _tag: any;
  78160. /**
  78161. * 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
  78162. */
  78163. uniqueId: number;
  78164. /**
  78165. * Gets or sets an object used to store user defined information for the node
  78166. */
  78167. metadata: any;
  78168. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  78169. isHitTestVisible: boolean;
  78170. /** Gets or sets a boolean indicating if the control can block pointer events */
  78171. isPointerBlocker: boolean;
  78172. /** Gets or sets a boolean indicating if the control can be focusable */
  78173. isFocusInvisible: boolean;
  78174. /**
  78175. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  78176. * 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
  78177. */
  78178. clipChildren: boolean;
  78179. /**
  78180. * Gets or sets a boolean indicating that control content must be clipped
  78181. * 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
  78182. */
  78183. clipContent: boolean;
  78184. /**
  78185. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  78186. */
  78187. useBitmapCache: boolean;
  78188. private _cacheData;
  78189. private _shadowOffsetX;
  78190. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  78191. get shadowOffsetX(): number;
  78192. set shadowOffsetX(value: number);
  78193. private _shadowOffsetY;
  78194. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  78195. get shadowOffsetY(): number;
  78196. set shadowOffsetY(value: number);
  78197. private _shadowBlur;
  78198. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  78199. get shadowBlur(): number;
  78200. set shadowBlur(value: number);
  78201. private _shadowColor;
  78202. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  78203. get shadowColor(): string;
  78204. set shadowColor(value: string);
  78205. /** Gets or sets the cursor to use when the control is hovered */
  78206. hoverCursor: string;
  78207. /** @hidden */
  78208. protected _linkOffsetX: ValueAndUnit;
  78209. /** @hidden */
  78210. protected _linkOffsetY: ValueAndUnit;
  78211. /** Gets the control type name */
  78212. get typeName(): string;
  78213. /**
  78214. * Get the current class name of the control.
  78215. * @returns current class name
  78216. */
  78217. getClassName(): string;
  78218. /**
  78219. * An event triggered when pointer wheel is scrolled
  78220. */
  78221. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  78222. /**
  78223. * An event triggered when the pointer move over the control.
  78224. */
  78225. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  78226. /**
  78227. * An event triggered when the pointer move out of the control.
  78228. */
  78229. onPointerOutObservable: BABYLON.Observable<Control>;
  78230. /**
  78231. * An event triggered when the pointer taps the control
  78232. */
  78233. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  78234. /**
  78235. * An event triggered when pointer up
  78236. */
  78237. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  78238. /**
  78239. * An event triggered when a control is clicked on
  78240. */
  78241. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  78242. /**
  78243. * An event triggered when pointer enters the control
  78244. */
  78245. onPointerEnterObservable: BABYLON.Observable<Control>;
  78246. /**
  78247. * An event triggered when the control is marked as dirty
  78248. */
  78249. onDirtyObservable: BABYLON.Observable<Control>;
  78250. /**
  78251. * An event triggered before drawing the control
  78252. */
  78253. onBeforeDrawObservable: BABYLON.Observable<Control>;
  78254. /**
  78255. * An event triggered after the control was drawn
  78256. */
  78257. onAfterDrawObservable: BABYLON.Observable<Control>;
  78258. /**
  78259. * An event triggered when the control has been disposed
  78260. */
  78261. onDisposeObservable: BABYLON.Observable<Control>;
  78262. /**
  78263. * Get the hosting AdvancedDynamicTexture
  78264. */
  78265. get host(): AdvancedDynamicTexture;
  78266. /** Gets or set information about font offsets (used to render and align text) */
  78267. get fontOffset(): {
  78268. ascent: number;
  78269. height: number;
  78270. descent: number;
  78271. };
  78272. set fontOffset(offset: {
  78273. ascent: number;
  78274. height: number;
  78275. descent: number;
  78276. });
  78277. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  78278. get alpha(): number;
  78279. set alpha(value: number);
  78280. /**
  78281. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  78282. */
  78283. get isHighlighted(): boolean;
  78284. set isHighlighted(value: boolean);
  78285. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  78286. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78287. */
  78288. get scaleX(): number;
  78289. set scaleX(value: number);
  78290. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  78291. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78292. */
  78293. get scaleY(): number;
  78294. set scaleY(value: number);
  78295. /** Gets or sets the rotation angle (0 by default)
  78296. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78297. */
  78298. get rotation(): number;
  78299. set rotation(value: number);
  78300. /** Gets or sets the transformation center on Y axis (0 by default)
  78301. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78302. */
  78303. get transformCenterY(): number;
  78304. set transformCenterY(value: number);
  78305. /** Gets or sets the transformation center on X axis (0 by default)
  78306. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78307. */
  78308. get transformCenterX(): number;
  78309. set transformCenterX(value: number);
  78310. /**
  78311. * Gets or sets the horizontal alignment
  78312. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78313. */
  78314. get horizontalAlignment(): number;
  78315. set horizontalAlignment(value: number);
  78316. /**
  78317. * Gets or sets the vertical alignment
  78318. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78319. */
  78320. get verticalAlignment(): number;
  78321. set verticalAlignment(value: number);
  78322. /**
  78323. * Gets or sets a fixed ratio for this control.
  78324. * When different from 0, the ratio is used to compute the "second" dimension.
  78325. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78326. * second dimension is computed as first dimension * fixedRatio
  78327. */
  78328. fixedRatio: number;
  78329. private _fixedRatioMasterIsWidth;
  78330. /**
  78331. * Gets or sets control width
  78332. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78333. */
  78334. get width(): string | number;
  78335. set width(value: string | number);
  78336. /**
  78337. * Gets or sets the control width in pixel
  78338. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78339. */
  78340. get widthInPixels(): number;
  78341. set widthInPixels(value: number);
  78342. /**
  78343. * Gets or sets control height
  78344. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78345. */
  78346. get height(): string | number;
  78347. set height(value: string | number);
  78348. /**
  78349. * Gets or sets control height in pixel
  78350. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78351. */
  78352. get heightInPixels(): number;
  78353. set heightInPixels(value: number);
  78354. /** Gets or set font family */
  78355. get fontFamily(): string;
  78356. set fontFamily(value: string);
  78357. /** Gets or sets font style */
  78358. get fontStyle(): string;
  78359. set fontStyle(value: string);
  78360. /** Gets or sets font weight */
  78361. get fontWeight(): string;
  78362. set fontWeight(value: string);
  78363. /**
  78364. * Gets or sets style
  78365. * @see https://doc.babylonjs.com/how_to/gui#styles
  78366. */
  78367. get style(): BABYLON.Nullable<Style>;
  78368. set style(value: BABYLON.Nullable<Style>);
  78369. /** @hidden */
  78370. get _isFontSizeInPercentage(): boolean;
  78371. /** Gets or sets font size in pixels */
  78372. get fontSizeInPixels(): number;
  78373. set fontSizeInPixels(value: number);
  78374. /** Gets or sets font size */
  78375. get fontSize(): string | number;
  78376. set fontSize(value: string | number);
  78377. /** Gets or sets foreground color */
  78378. get color(): string;
  78379. set color(value: string);
  78380. /** Gets or sets z index which is used to reorder controls on the z axis */
  78381. get zIndex(): number;
  78382. set zIndex(value: number);
  78383. /** Gets or sets a boolean indicating if the control can be rendered */
  78384. get notRenderable(): boolean;
  78385. set notRenderable(value: boolean);
  78386. /** Gets or sets a boolean indicating if the control is visible */
  78387. get isVisible(): boolean;
  78388. set isVisible(value: boolean);
  78389. /** Gets a boolean indicating that the control needs to update its rendering */
  78390. get isDirty(): boolean;
  78391. /**
  78392. * Gets the current linked mesh (or null if none)
  78393. */
  78394. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  78395. /**
  78396. * Gets or sets a value indicating the padding to use on the left of the control
  78397. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78398. */
  78399. get paddingLeft(): string | number;
  78400. set paddingLeft(value: string | number);
  78401. /**
  78402. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  78403. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78404. */
  78405. get paddingLeftInPixels(): number;
  78406. set paddingLeftInPixels(value: number);
  78407. /**
  78408. * Gets or sets a value indicating the padding to use on the right of the control
  78409. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78410. */
  78411. get paddingRight(): string | number;
  78412. set paddingRight(value: string | number);
  78413. /**
  78414. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  78415. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78416. */
  78417. get paddingRightInPixels(): number;
  78418. set paddingRightInPixels(value: number);
  78419. /**
  78420. * Gets or sets a value indicating the padding to use on the top of the control
  78421. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78422. */
  78423. get paddingTop(): string | number;
  78424. set paddingTop(value: string | number);
  78425. /**
  78426. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  78427. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78428. */
  78429. get paddingTopInPixels(): number;
  78430. set paddingTopInPixels(value: number);
  78431. /**
  78432. * Gets or sets a value indicating the padding to use on the bottom of the control
  78433. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78434. */
  78435. get paddingBottom(): string | number;
  78436. set paddingBottom(value: string | number);
  78437. /**
  78438. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  78439. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78440. */
  78441. get paddingBottomInPixels(): number;
  78442. set paddingBottomInPixels(value: number);
  78443. /**
  78444. * Gets or sets a value indicating the left coordinate of the control
  78445. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78446. */
  78447. get left(): string | number;
  78448. set left(value: string | number);
  78449. /**
  78450. * Gets or sets a value indicating the left coordinate in pixels of the control
  78451. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78452. */
  78453. get leftInPixels(): number;
  78454. set leftInPixels(value: number);
  78455. /**
  78456. * Gets or sets a value indicating the top coordinate of the control
  78457. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78458. */
  78459. get top(): string | number;
  78460. set top(value: string | number);
  78461. /**
  78462. * Gets or sets a value indicating the top coordinate in pixels of the control
  78463. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78464. */
  78465. get topInPixels(): number;
  78466. set topInPixels(value: number);
  78467. /**
  78468. * Gets or sets a value indicating the offset on X axis to the linked mesh
  78469. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78470. */
  78471. get linkOffsetX(): string | number;
  78472. set linkOffsetX(value: string | number);
  78473. /**
  78474. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  78475. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78476. */
  78477. get linkOffsetXInPixels(): number;
  78478. set linkOffsetXInPixels(value: number);
  78479. /**
  78480. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  78481. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78482. */
  78483. get linkOffsetY(): string | number;
  78484. set linkOffsetY(value: string | number);
  78485. /**
  78486. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  78487. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78488. */
  78489. get linkOffsetYInPixels(): number;
  78490. set linkOffsetYInPixels(value: number);
  78491. /** Gets the center coordinate on X axis */
  78492. get centerX(): number;
  78493. /** Gets the center coordinate on Y axis */
  78494. get centerY(): number;
  78495. /** Gets or sets if control is Enabled*/
  78496. get isEnabled(): boolean;
  78497. set isEnabled(value: boolean);
  78498. /** Gets or sets background color of control if it's disabled*/
  78499. get disabledColor(): string;
  78500. set disabledColor(value: string);
  78501. /** Gets or sets front color of control if it's disabled*/
  78502. get disabledColorItem(): string;
  78503. set disabledColorItem(value: string);
  78504. /**
  78505. * Creates a new control
  78506. * @param name defines the name of the control
  78507. */
  78508. constructor(
  78509. /** defines the name of the control */
  78510. name?: string | undefined);
  78511. /** @hidden */
  78512. protected _getTypeName(): string;
  78513. /**
  78514. * Gets the first ascendant in the hierarchy of the given type
  78515. * @param className defines the required type
  78516. * @returns the ascendant or null if not found
  78517. */
  78518. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78519. /** @hidden */
  78520. _resetFontCache(): void;
  78521. /**
  78522. * Determines if a container is an ascendant of the current control
  78523. * @param container defines the container to look for
  78524. * @returns true if the container is one of the ascendant of the control
  78525. */
  78526. isAscendant(container: Control): boolean;
  78527. /**
  78528. * Gets coordinates in local control space
  78529. * @param globalCoordinates defines the coordinates to transform
  78530. * @returns the new coordinates in local space
  78531. */
  78532. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78533. /**
  78534. * Gets coordinates in local control space
  78535. * @param globalCoordinates defines the coordinates to transform
  78536. * @param result defines the target vector2 where to store the result
  78537. * @returns the current control
  78538. */
  78539. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  78540. /**
  78541. * Gets coordinates in parent local control space
  78542. * @param globalCoordinates defines the coordinates to transform
  78543. * @returns the new coordinates in parent local space
  78544. */
  78545. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78546. /**
  78547. * Move the current control to a vector3 position projected onto the screen.
  78548. * @param position defines the target position
  78549. * @param scene defines the hosting scene
  78550. */
  78551. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  78552. /**
  78553. * Will store all controls that have this control as ascendant in a given array
  78554. * @param results defines the array where to store the descendants
  78555. * @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
  78556. * @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
  78557. */
  78558. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78559. /**
  78560. * Will return all controls that have this control as ascendant
  78561. * @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
  78562. * @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
  78563. * @return all child controls
  78564. */
  78565. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78566. /**
  78567. * Link current control with a target mesh
  78568. * @param mesh defines the mesh to link with
  78569. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78570. */
  78571. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  78572. /** @hidden */
  78573. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  78574. /** @hidden */
  78575. _offsetLeft(offset: number): void;
  78576. /** @hidden */
  78577. _offsetTop(offset: number): void;
  78578. /** @hidden */
  78579. _markMatrixAsDirty(): void;
  78580. /** @hidden */
  78581. _flagDescendantsAsMatrixDirty(): void;
  78582. /** @hidden */
  78583. _intersectsRect(rect: Measure): boolean;
  78584. /** @hidden */
  78585. protected invalidateRect(): void;
  78586. /** @hidden */
  78587. _markAsDirty(force?: boolean): void;
  78588. /** @hidden */
  78589. _markAllAsDirty(): void;
  78590. /** @hidden */
  78591. _link(host: AdvancedDynamicTexture): void;
  78592. /** @hidden */
  78593. protected _transform(context?: CanvasRenderingContext2D): void;
  78594. /** @hidden */
  78595. _renderHighlight(context: CanvasRenderingContext2D): void;
  78596. /** @hidden */
  78597. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78598. /** @hidden */
  78599. protected _applyStates(context: CanvasRenderingContext2D): void;
  78600. /** @hidden */
  78601. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78602. /** @hidden */
  78603. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78604. protected _evaluateClippingState(parentMeasure: Measure): void;
  78605. /** @hidden */
  78606. _measure(): void;
  78607. /** @hidden */
  78608. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78609. /** @hidden */
  78610. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78611. /** @hidden */
  78612. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78613. /** @hidden */
  78614. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78615. private static _ClipMeasure;
  78616. private _tmpMeasureA;
  78617. private _clip;
  78618. /** @hidden */
  78619. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  78620. /** @hidden */
  78621. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78622. /**
  78623. * Tests if a given coordinates belong to the current control
  78624. * @param x defines x coordinate to test
  78625. * @param y defines y coordinate to test
  78626. * @returns true if the coordinates are inside the control
  78627. */
  78628. contains(x: number, y: number): boolean;
  78629. /** @hidden */
  78630. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78631. /** @hidden */
  78632. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  78633. /** @hidden */
  78634. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78635. /** @hidden */
  78636. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  78637. /** @hidden */
  78638. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78639. /** @hidden */
  78640. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  78641. /** @hidden */
  78642. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78643. /** @hidden */
  78644. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  78645. /** @hidden */
  78646. _onCanvasBlur(): void;
  78647. /** @hidden */
  78648. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78649. private _prepareFont;
  78650. /** Releases associated resources */
  78651. dispose(): void;
  78652. private static _HORIZONTAL_ALIGNMENT_LEFT;
  78653. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  78654. private static _HORIZONTAL_ALIGNMENT_CENTER;
  78655. private static _VERTICAL_ALIGNMENT_TOP;
  78656. private static _VERTICAL_ALIGNMENT_BOTTOM;
  78657. private static _VERTICAL_ALIGNMENT_CENTER;
  78658. /** HORIZONTAL_ALIGNMENT_LEFT */
  78659. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  78660. /** HORIZONTAL_ALIGNMENT_RIGHT */
  78661. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  78662. /** HORIZONTAL_ALIGNMENT_CENTER */
  78663. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  78664. /** VERTICAL_ALIGNMENT_TOP */
  78665. static get VERTICAL_ALIGNMENT_TOP(): number;
  78666. /** VERTICAL_ALIGNMENT_BOTTOM */
  78667. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  78668. /** VERTICAL_ALIGNMENT_CENTER */
  78669. static get VERTICAL_ALIGNMENT_CENTER(): number;
  78670. private static _FontHeightSizes;
  78671. /** @hidden */
  78672. static _GetFontOffset(font: string): {
  78673. ascent: number;
  78674. height: number;
  78675. descent: number;
  78676. };
  78677. /**
  78678. * Creates a stack panel that can be used to render headers
  78679. * @param control defines the control to associate with the header
  78680. * @param text defines the text of the header
  78681. * @param size defines the size of the header
  78682. * @param options defines options used to configure the header
  78683. * @returns a new StackPanel
  78684. * @ignore
  78685. * @hidden
  78686. */
  78687. static AddHeader: (control: Control, text: string, size: string | number, options: {
  78688. isHorizontal: boolean;
  78689. controlFirst: boolean;
  78690. }) => any;
  78691. /** @hidden */
  78692. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  78693. }
  78694. }
  78695. declare module BABYLON.GUI {
  78696. /**
  78697. * Root class for 2D containers
  78698. * @see https://doc.babylonjs.com/how_to/gui#containers
  78699. */
  78700. export class Container extends Control {
  78701. name?: string | undefined;
  78702. /** @hidden */
  78703. _children: Control[];
  78704. /** @hidden */
  78705. protected _measureForChildren: Measure;
  78706. /** @hidden */
  78707. protected _background: string;
  78708. /** @hidden */
  78709. protected _adaptWidthToChildren: boolean;
  78710. /** @hidden */
  78711. protected _adaptHeightToChildren: boolean;
  78712. /**
  78713. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  78714. */
  78715. logLayoutCycleErrors: boolean;
  78716. /**
  78717. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  78718. */
  78719. maxLayoutCycle: number;
  78720. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  78721. get adaptHeightToChildren(): boolean;
  78722. set adaptHeightToChildren(value: boolean);
  78723. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  78724. get adaptWidthToChildren(): boolean;
  78725. set adaptWidthToChildren(value: boolean);
  78726. /** Gets or sets background color */
  78727. get background(): string;
  78728. set background(value: string);
  78729. /** Gets the list of children */
  78730. get children(): Control[];
  78731. /**
  78732. * Creates a new Container
  78733. * @param name defines the name of the container
  78734. */
  78735. constructor(name?: string | undefined);
  78736. protected _getTypeName(): string;
  78737. _flagDescendantsAsMatrixDirty(): void;
  78738. /**
  78739. * Gets a child using its name
  78740. * @param name defines the child name to look for
  78741. * @returns the child control if found
  78742. */
  78743. getChildByName(name: string): BABYLON.Nullable<Control>;
  78744. /**
  78745. * Gets a child using its type and its name
  78746. * @param name defines the child name to look for
  78747. * @param type defines the child type to look for
  78748. * @returns the child control if found
  78749. */
  78750. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  78751. /**
  78752. * Search for a specific control in children
  78753. * @param control defines the control to look for
  78754. * @returns true if the control is in child list
  78755. */
  78756. containsControl(control: Control): boolean;
  78757. /**
  78758. * Adds a new control to the current container
  78759. * @param control defines the control to add
  78760. * @returns the current container
  78761. */
  78762. addControl(control: BABYLON.Nullable<Control>): Container;
  78763. /**
  78764. * Removes all controls from the current container
  78765. * @returns the current container
  78766. */
  78767. clearControls(): Container;
  78768. /**
  78769. * Removes a control from the current container
  78770. * @param control defines the control to remove
  78771. * @returns the current container
  78772. */
  78773. removeControl(control: Control): Container;
  78774. /** @hidden */
  78775. _reOrderControl(control: Control): void;
  78776. /** @hidden */
  78777. _offsetLeft(offset: number): void;
  78778. /** @hidden */
  78779. _offsetTop(offset: number): void;
  78780. /** @hidden */
  78781. _markAllAsDirty(): void;
  78782. /** @hidden */
  78783. protected _localDraw(context: CanvasRenderingContext2D): void;
  78784. /** @hidden */
  78785. _link(host: AdvancedDynamicTexture): void;
  78786. /** @hidden */
  78787. protected _beforeLayout(): void;
  78788. /** @hidden */
  78789. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78790. /** @hidden */
  78791. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78792. protected _postMeasure(): void;
  78793. /** @hidden */
  78794. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78795. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78796. /** @hidden */
  78797. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78798. /** @hidden */
  78799. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78800. /** Releases associated resources */
  78801. dispose(): void;
  78802. }
  78803. }
  78804. declare module BABYLON.GUI {
  78805. /** Class used to create rectangle container */
  78806. export class Rectangle extends Container {
  78807. name?: string | undefined;
  78808. private _thickness;
  78809. private _cornerRadius;
  78810. /** Gets or sets border thickness */
  78811. get thickness(): number;
  78812. set thickness(value: number);
  78813. /** Gets or sets the corner radius angle */
  78814. get cornerRadius(): number;
  78815. set cornerRadius(value: number);
  78816. /**
  78817. * Creates a new Rectangle
  78818. * @param name defines the control name
  78819. */
  78820. constructor(name?: string | undefined);
  78821. protected _getTypeName(): string;
  78822. protected _localDraw(context: CanvasRenderingContext2D): void;
  78823. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78824. private _drawRoundedRect;
  78825. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78826. }
  78827. }
  78828. declare module BABYLON.GUI {
  78829. /**
  78830. * Enum that determines the text-wrapping mode to use.
  78831. */
  78832. export enum TextWrapping {
  78833. /**
  78834. * Clip the text when it's larger than Control.width; this is the default mode.
  78835. */
  78836. Clip = 0,
  78837. /**
  78838. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  78839. */
  78840. WordWrap = 1,
  78841. /**
  78842. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  78843. */
  78844. Ellipsis = 2
  78845. }
  78846. /**
  78847. * Class used to create text block control
  78848. */
  78849. export class TextBlock extends Control {
  78850. /**
  78851. * Defines the name of the control
  78852. */
  78853. name?: string | undefined;
  78854. private _text;
  78855. private _textWrapping;
  78856. private _textHorizontalAlignment;
  78857. private _textVerticalAlignment;
  78858. private _lines;
  78859. private _resizeToFit;
  78860. private _lineSpacing;
  78861. private _outlineWidth;
  78862. private _outlineColor;
  78863. private _underline;
  78864. private _lineThrough;
  78865. /**
  78866. * An event triggered after the text is changed
  78867. */
  78868. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  78869. /**
  78870. * An event triggered after the text was broken up into lines
  78871. */
  78872. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  78873. /**
  78874. * Function used to split a string into words. By default, a string is split at each space character found
  78875. */
  78876. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  78877. /**
  78878. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  78879. */
  78880. get lines(): any[];
  78881. /**
  78882. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78883. */
  78884. get resizeToFit(): boolean;
  78885. /**
  78886. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78887. */
  78888. set resizeToFit(value: boolean);
  78889. /**
  78890. * Gets or sets a boolean indicating if text must be wrapped
  78891. */
  78892. get textWrapping(): TextWrapping | boolean;
  78893. /**
  78894. * Gets or sets a boolean indicating if text must be wrapped
  78895. */
  78896. set textWrapping(value: TextWrapping | boolean);
  78897. /**
  78898. * Gets or sets text to display
  78899. */
  78900. get text(): string;
  78901. /**
  78902. * Gets or sets text to display
  78903. */
  78904. set text(value: string);
  78905. /**
  78906. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78907. */
  78908. get textHorizontalAlignment(): number;
  78909. /**
  78910. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78911. */
  78912. set textHorizontalAlignment(value: number);
  78913. /**
  78914. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78915. */
  78916. get textVerticalAlignment(): number;
  78917. /**
  78918. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78919. */
  78920. set textVerticalAlignment(value: number);
  78921. /**
  78922. * Gets or sets line spacing value
  78923. */
  78924. set lineSpacing(value: string | number);
  78925. /**
  78926. * Gets or sets line spacing value
  78927. */
  78928. get lineSpacing(): string | number;
  78929. /**
  78930. * Gets or sets outlineWidth of the text to display
  78931. */
  78932. get outlineWidth(): number;
  78933. /**
  78934. * Gets or sets outlineWidth of the text to display
  78935. */
  78936. set outlineWidth(value: number);
  78937. /**
  78938. * Gets or sets a boolean indicating that text must have underline
  78939. */
  78940. get underline(): boolean;
  78941. /**
  78942. * Gets or sets a boolean indicating that text must have underline
  78943. */
  78944. set underline(value: boolean);
  78945. /**
  78946. * Gets or sets an boolean indicating that text must be crossed out
  78947. */
  78948. get lineThrough(): boolean;
  78949. /**
  78950. * Gets or sets an boolean indicating that text must be crossed out
  78951. */
  78952. set lineThrough(value: boolean);
  78953. /**
  78954. * Gets or sets outlineColor of the text to display
  78955. */
  78956. get outlineColor(): string;
  78957. /**
  78958. * Gets or sets outlineColor of the text to display
  78959. */
  78960. set outlineColor(value: string);
  78961. /**
  78962. * Creates a new TextBlock object
  78963. * @param name defines the name of the control
  78964. * @param text defines the text to display (emptry string by default)
  78965. */
  78966. constructor(
  78967. /**
  78968. * Defines the name of the control
  78969. */
  78970. name?: string | undefined, text?: string);
  78971. protected _getTypeName(): string;
  78972. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78973. private _drawText;
  78974. /** @hidden */
  78975. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78976. protected _applyStates(context: CanvasRenderingContext2D): void;
  78977. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  78978. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  78979. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  78980. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  78981. protected _renderLines(context: CanvasRenderingContext2D): void;
  78982. /**
  78983. * Given a width constraint applied on the text block, find the expected height
  78984. * @returns expected height
  78985. */
  78986. computeExpectedHeight(): number;
  78987. dispose(): void;
  78988. }
  78989. }
  78990. declare module BABYLON.GUI {
  78991. /**
  78992. * Class used to create 2D images
  78993. */
  78994. export class Image extends Control {
  78995. name?: string | undefined;
  78996. private _workingCanvas;
  78997. private _domImage;
  78998. private _imageWidth;
  78999. private _imageHeight;
  79000. private _loaded;
  79001. private _stretch;
  79002. private _source;
  79003. private _autoScale;
  79004. private _sourceLeft;
  79005. private _sourceTop;
  79006. private _sourceWidth;
  79007. private _sourceHeight;
  79008. private _svgAttributesComputationCompleted;
  79009. private _isSVG;
  79010. private _cellWidth;
  79011. private _cellHeight;
  79012. private _cellId;
  79013. private _populateNinePatchSlicesFromImage;
  79014. private _sliceLeft;
  79015. private _sliceRight;
  79016. private _sliceTop;
  79017. private _sliceBottom;
  79018. private _detectPointerOnOpaqueOnly;
  79019. private _imageDataCache;
  79020. /**
  79021. * BABYLON.Observable notified when the content is loaded
  79022. */
  79023. onImageLoadedObservable: BABYLON.Observable<Image>;
  79024. /**
  79025. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  79026. */
  79027. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  79028. /**
  79029. * Gets a boolean indicating that the content is loaded
  79030. */
  79031. get isLoaded(): boolean;
  79032. /**
  79033. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  79034. */
  79035. get populateNinePatchSlicesFromImage(): boolean;
  79036. set populateNinePatchSlicesFromImage(value: boolean);
  79037. /**
  79038. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  79039. * Beware using this as this will comsume more memory as the image has to be stored twice
  79040. */
  79041. get detectPointerOnOpaqueOnly(): boolean;
  79042. set detectPointerOnOpaqueOnly(value: boolean);
  79043. /**
  79044. * Gets or sets the left value for slicing (9-patch)
  79045. */
  79046. get sliceLeft(): number;
  79047. set sliceLeft(value: number);
  79048. /**
  79049. * Gets or sets the right value for slicing (9-patch)
  79050. */
  79051. get sliceRight(): number;
  79052. set sliceRight(value: number);
  79053. /**
  79054. * Gets or sets the top value for slicing (9-patch)
  79055. */
  79056. get sliceTop(): number;
  79057. set sliceTop(value: number);
  79058. /**
  79059. * Gets or sets the bottom value for slicing (9-patch)
  79060. */
  79061. get sliceBottom(): number;
  79062. set sliceBottom(value: number);
  79063. /**
  79064. * Gets or sets the left coordinate in the source image
  79065. */
  79066. get sourceLeft(): number;
  79067. set sourceLeft(value: number);
  79068. /**
  79069. * Gets or sets the top coordinate in the source image
  79070. */
  79071. get sourceTop(): number;
  79072. set sourceTop(value: number);
  79073. /**
  79074. * Gets or sets the width to capture in the source image
  79075. */
  79076. get sourceWidth(): number;
  79077. set sourceWidth(value: number);
  79078. /**
  79079. * Gets or sets the height to capture in the source image
  79080. */
  79081. get sourceHeight(): number;
  79082. set sourceHeight(value: number);
  79083. /** Indicates if the format of the image is SVG */
  79084. get isSVG(): boolean;
  79085. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  79086. get svgAttributesComputationCompleted(): boolean;
  79087. /**
  79088. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  79089. * @see https://doc.babylonjs.com/how_to/gui#image
  79090. */
  79091. get autoScale(): boolean;
  79092. set autoScale(value: boolean);
  79093. /** Gets or sets the streching mode used by the image */
  79094. get stretch(): number;
  79095. set stretch(value: number);
  79096. /** @hidden */
  79097. _rotate90(n: number, preserveProperties?: boolean): Image;
  79098. private _handleRotationForSVGImage;
  79099. private _rotate90SourceProperties;
  79100. /**
  79101. * Gets or sets the internal DOM image used to render the control
  79102. */
  79103. set domImage(value: HTMLImageElement);
  79104. get domImage(): HTMLImageElement;
  79105. private _onImageLoaded;
  79106. private _extractNinePatchSliceDataFromImage;
  79107. /**
  79108. * Gets or sets image source url
  79109. */
  79110. set source(value: BABYLON.Nullable<string>);
  79111. /**
  79112. * Checks for svg document with icon id present
  79113. */
  79114. private _svgCheck;
  79115. /**
  79116. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  79117. * given external svg file and icon id
  79118. */
  79119. private _getSVGAttribs;
  79120. /**
  79121. * Gets or sets the cell width to use when animation sheet is enabled
  79122. * @see https://doc.babylonjs.com/how_to/gui#image
  79123. */
  79124. get cellWidth(): number;
  79125. set cellWidth(value: number);
  79126. /**
  79127. * Gets or sets the cell height to use when animation sheet is enabled
  79128. * @see https://doc.babylonjs.com/how_to/gui#image
  79129. */
  79130. get cellHeight(): number;
  79131. set cellHeight(value: number);
  79132. /**
  79133. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  79134. * @see https://doc.babylonjs.com/how_to/gui#image
  79135. */
  79136. get cellId(): number;
  79137. set cellId(value: number);
  79138. /**
  79139. * Creates a new Image
  79140. * @param name defines the control name
  79141. * @param url defines the image url
  79142. */
  79143. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  79144. /**
  79145. * Tests if a given coordinates belong to the current control
  79146. * @param x defines x coordinate to test
  79147. * @param y defines y coordinate to test
  79148. * @returns true if the coordinates are inside the control
  79149. */
  79150. contains(x: number, y: number): boolean;
  79151. protected _getTypeName(): string;
  79152. /** Force the control to synchronize with its content */
  79153. synchronizeSizeWithContent(): void;
  79154. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79155. private _prepareWorkingCanvasForOpaqueDetection;
  79156. private _drawImage;
  79157. _draw(context: CanvasRenderingContext2D): void;
  79158. private _renderCornerPatch;
  79159. private _renderNinePatch;
  79160. dispose(): void;
  79161. /** STRETCH_NONE */
  79162. static readonly STRETCH_NONE: number;
  79163. /** STRETCH_FILL */
  79164. static readonly STRETCH_FILL: number;
  79165. /** STRETCH_UNIFORM */
  79166. static readonly STRETCH_UNIFORM: number;
  79167. /** STRETCH_EXTEND */
  79168. static readonly STRETCH_EXTEND: number;
  79169. /** NINE_PATCH */
  79170. static readonly STRETCH_NINE_PATCH: number;
  79171. }
  79172. }
  79173. declare module BABYLON.GUI {
  79174. /**
  79175. * Class used to create 2D buttons
  79176. */
  79177. export class Button extends Rectangle {
  79178. name?: string | undefined;
  79179. /**
  79180. * Function called to generate a pointer enter animation
  79181. */
  79182. pointerEnterAnimation: () => void;
  79183. /**
  79184. * Function called to generate a pointer out animation
  79185. */
  79186. pointerOutAnimation: () => void;
  79187. /**
  79188. * Function called to generate a pointer down animation
  79189. */
  79190. pointerDownAnimation: () => void;
  79191. /**
  79192. * Function called to generate a pointer up animation
  79193. */
  79194. pointerUpAnimation: () => void;
  79195. /**
  79196. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  79197. */
  79198. delegatePickingToChildren: boolean;
  79199. private _image;
  79200. /**
  79201. * Returns the image part of the button (if any)
  79202. */
  79203. get image(): BABYLON.Nullable<Image>;
  79204. private _textBlock;
  79205. /**
  79206. * Returns the image part of the button (if any)
  79207. */
  79208. get textBlock(): BABYLON.Nullable<TextBlock>;
  79209. /**
  79210. * Creates a new Button
  79211. * @param name defines the name of the button
  79212. */
  79213. constructor(name?: string | undefined);
  79214. protected _getTypeName(): string;
  79215. /** @hidden */
  79216. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79217. /** @hidden */
  79218. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79219. /** @hidden */
  79220. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  79221. /** @hidden */
  79222. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79223. /** @hidden */
  79224. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79225. /**
  79226. * Creates a new button made with an image and a text
  79227. * @param name defines the name of the button
  79228. * @param text defines the text of the button
  79229. * @param imageUrl defines the url of the image
  79230. * @returns a new Button
  79231. */
  79232. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  79233. /**
  79234. * Creates a new button made with an image
  79235. * @param name defines the name of the button
  79236. * @param imageUrl defines the url of the image
  79237. * @returns a new Button
  79238. */
  79239. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  79240. /**
  79241. * Creates a new button made with a text
  79242. * @param name defines the name of the button
  79243. * @param text defines the text of the button
  79244. * @returns a new Button
  79245. */
  79246. static CreateSimpleButton(name: string, text: string): Button;
  79247. /**
  79248. * Creates a new button made with an image and a centered text
  79249. * @param name defines the name of the button
  79250. * @param text defines the text of the button
  79251. * @param imageUrl defines the url of the image
  79252. * @returns a new Button
  79253. */
  79254. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  79255. }
  79256. }
  79257. declare module BABYLON.GUI {
  79258. /**
  79259. * Class used to create a 2D stack panel container
  79260. */
  79261. export class StackPanel extends Container {
  79262. name?: string | undefined;
  79263. private _isVertical;
  79264. private _manualWidth;
  79265. private _manualHeight;
  79266. private _doNotTrackManualChanges;
  79267. /**
  79268. * Gets or sets a boolean indicating that layou warnings should be ignored
  79269. */
  79270. ignoreLayoutWarnings: boolean;
  79271. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  79272. get isVertical(): boolean;
  79273. set isVertical(value: boolean);
  79274. /**
  79275. * Gets or sets panel width.
  79276. * This value should not be set when in horizontal mode as it will be computed automatically
  79277. */
  79278. set width(value: string | number);
  79279. get width(): string | number;
  79280. /**
  79281. * Gets or sets panel height.
  79282. * This value should not be set when in vertical mode as it will be computed automatically
  79283. */
  79284. set height(value: string | number);
  79285. get height(): string | number;
  79286. /**
  79287. * Creates a new StackPanel
  79288. * @param name defines control name
  79289. */
  79290. constructor(name?: string | undefined);
  79291. protected _getTypeName(): string;
  79292. /** @hidden */
  79293. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79294. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79295. protected _postMeasure(): void;
  79296. }
  79297. }
  79298. declare module BABYLON.GUI {
  79299. /**
  79300. * Class used to represent a 2D checkbox
  79301. */
  79302. export class Checkbox extends Control {
  79303. name?: string | undefined;
  79304. private _isChecked;
  79305. private _background;
  79306. private _checkSizeRatio;
  79307. private _thickness;
  79308. /** Gets or sets border thickness */
  79309. get thickness(): number;
  79310. set thickness(value: number);
  79311. /**
  79312. * BABYLON.Observable raised when isChecked property changes
  79313. */
  79314. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79315. /** Gets or sets a value indicating the ratio between overall size and check size */
  79316. get checkSizeRatio(): number;
  79317. set checkSizeRatio(value: number);
  79318. /** Gets or sets background color */
  79319. get background(): string;
  79320. set background(value: string);
  79321. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79322. get isChecked(): boolean;
  79323. set isChecked(value: boolean);
  79324. /**
  79325. * Creates a new CheckBox
  79326. * @param name defines the control name
  79327. */
  79328. constructor(name?: string | undefined);
  79329. protected _getTypeName(): string;
  79330. /** @hidden */
  79331. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79332. /** @hidden */
  79333. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79334. /**
  79335. * Utility function to easily create a checkbox with a header
  79336. * @param title defines the label to use for the header
  79337. * @param onValueChanged defines the callback to call when value changes
  79338. * @returns a StackPanel containing the checkbox and a textBlock
  79339. */
  79340. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  79341. }
  79342. }
  79343. declare module BABYLON.GUI {
  79344. /**
  79345. * Class used to store key control properties
  79346. */
  79347. export class KeyPropertySet {
  79348. /** Width */
  79349. width?: string;
  79350. /** Height */
  79351. height?: string;
  79352. /** Left padding */
  79353. paddingLeft?: string;
  79354. /** Right padding */
  79355. paddingRight?: string;
  79356. /** Top padding */
  79357. paddingTop?: string;
  79358. /** Bottom padding */
  79359. paddingBottom?: string;
  79360. /** Foreground color */
  79361. color?: string;
  79362. /** Background color */
  79363. background?: string;
  79364. }
  79365. /**
  79366. * Class used to create virtual keyboard
  79367. */
  79368. export class VirtualKeyboard extends StackPanel {
  79369. /** BABYLON.Observable raised when a key is pressed */
  79370. onKeyPressObservable: BABYLON.Observable<string>;
  79371. /** Gets or sets default key button width */
  79372. defaultButtonWidth: string;
  79373. /** Gets or sets default key button height */
  79374. defaultButtonHeight: string;
  79375. /** Gets or sets default key button left padding */
  79376. defaultButtonPaddingLeft: string;
  79377. /** Gets or sets default key button right padding */
  79378. defaultButtonPaddingRight: string;
  79379. /** Gets or sets default key button top padding */
  79380. defaultButtonPaddingTop: string;
  79381. /** Gets or sets default key button bottom padding */
  79382. defaultButtonPaddingBottom: string;
  79383. /** Gets or sets default key button foreground color */
  79384. defaultButtonColor: string;
  79385. /** Gets or sets default key button background color */
  79386. defaultButtonBackground: string;
  79387. /** Gets or sets shift button foreground color */
  79388. shiftButtonColor: string;
  79389. /** Gets or sets shift button thickness*/
  79390. selectedShiftThickness: number;
  79391. /** Gets shift key state */
  79392. shiftState: number;
  79393. protected _getTypeName(): string;
  79394. private _createKey;
  79395. /**
  79396. * Adds a new row of keys
  79397. * @param keys defines the list of keys to add
  79398. * @param propertySets defines the associated property sets
  79399. */
  79400. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  79401. /**
  79402. * Set the shift key to a specific state
  79403. * @param shiftState defines the new shift state
  79404. */
  79405. applyShiftState(shiftState: number): void;
  79406. private _currentlyConnectedInputText;
  79407. private _connectedInputTexts;
  79408. private _onKeyPressObserver;
  79409. /** Gets the input text control currently attached to the keyboard */
  79410. get connectedInputText(): BABYLON.Nullable<InputText>;
  79411. /**
  79412. * Connects the keyboard with an input text control
  79413. *
  79414. * @param input defines the target control
  79415. */
  79416. connect(input: InputText): void;
  79417. /**
  79418. * Disconnects the keyboard from connected InputText controls
  79419. *
  79420. * @param input optionally defines a target control, otherwise all are disconnected
  79421. */
  79422. disconnect(input?: InputText): void;
  79423. private _removeConnectedInputObservables;
  79424. /**
  79425. * Release all resources
  79426. */
  79427. dispose(): void;
  79428. /**
  79429. * Creates a new keyboard using a default layout
  79430. *
  79431. * @param name defines control name
  79432. * @returns a new VirtualKeyboard
  79433. */
  79434. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  79435. }
  79436. }
  79437. declare module BABYLON.GUI {
  79438. /**
  79439. * Class used to create input text control
  79440. */
  79441. export class InputText extends Control implements IFocusableControl {
  79442. name?: string | undefined;
  79443. private _text;
  79444. private _placeholderText;
  79445. private _background;
  79446. private _focusedBackground;
  79447. private _focusedColor;
  79448. private _placeholderColor;
  79449. private _thickness;
  79450. private _margin;
  79451. private _autoStretchWidth;
  79452. private _maxWidth;
  79453. private _isFocused;
  79454. private _blinkTimeout;
  79455. private _blinkIsEven;
  79456. private _cursorOffset;
  79457. private _scrollLeft;
  79458. private _textWidth;
  79459. private _clickedCoordinate;
  79460. private _deadKey;
  79461. private _addKey;
  79462. private _currentKey;
  79463. private _isTextHighlightOn;
  79464. private _textHighlightColor;
  79465. private _highligherOpacity;
  79466. private _highlightedText;
  79467. private _startHighlightIndex;
  79468. private _endHighlightIndex;
  79469. private _cursorIndex;
  79470. private _onFocusSelectAll;
  79471. private _isPointerDown;
  79472. private _onClipboardObserver;
  79473. private _onPointerDblTapObserver;
  79474. /** @hidden */
  79475. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  79476. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  79477. promptMessage: string;
  79478. /** Force disable prompt on mobile device */
  79479. disableMobilePrompt: boolean;
  79480. /** BABYLON.Observable raised when the text changes */
  79481. onTextChangedObservable: BABYLON.Observable<InputText>;
  79482. /** BABYLON.Observable raised just before an entered character is to be added */
  79483. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  79484. /** BABYLON.Observable raised when the control gets the focus */
  79485. onFocusObservable: BABYLON.Observable<InputText>;
  79486. /** BABYLON.Observable raised when the control loses the focus */
  79487. onBlurObservable: BABYLON.Observable<InputText>;
  79488. /**Observable raised when the text is highlighted */
  79489. onTextHighlightObservable: BABYLON.Observable<InputText>;
  79490. /**Observable raised when copy event is triggered */
  79491. onTextCopyObservable: BABYLON.Observable<InputText>;
  79492. /** BABYLON.Observable raised when cut event is triggered */
  79493. onTextCutObservable: BABYLON.Observable<InputText>;
  79494. /** BABYLON.Observable raised when paste event is triggered */
  79495. onTextPasteObservable: BABYLON.Observable<InputText>;
  79496. /** BABYLON.Observable raised when a key event was processed */
  79497. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  79498. /** Gets or sets the maximum width allowed by the control */
  79499. get maxWidth(): string | number;
  79500. /** Gets the maximum width allowed by the control in pixels */
  79501. get maxWidthInPixels(): number;
  79502. set maxWidth(value: string | number);
  79503. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79504. get highligherOpacity(): number;
  79505. set highligherOpacity(value: number);
  79506. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79507. get onFocusSelectAll(): boolean;
  79508. set onFocusSelectAll(value: boolean);
  79509. /** Gets or sets the text hightlight color */
  79510. get textHighlightColor(): string;
  79511. set textHighlightColor(value: string);
  79512. /** Gets or sets control margin */
  79513. get margin(): string;
  79514. /** Gets control margin in pixels */
  79515. get marginInPixels(): number;
  79516. set margin(value: string);
  79517. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  79518. get autoStretchWidth(): boolean;
  79519. set autoStretchWidth(value: boolean);
  79520. /** Gets or sets border thickness */
  79521. get thickness(): number;
  79522. set thickness(value: number);
  79523. /** Gets or sets the background color when focused */
  79524. get focusedBackground(): string;
  79525. set focusedBackground(value: string);
  79526. /** Gets or sets the background color when focused */
  79527. get focusedColor(): string;
  79528. set focusedColor(value: string);
  79529. /** Gets or sets the background color */
  79530. get background(): string;
  79531. set background(value: string);
  79532. /** Gets or sets the placeholder color */
  79533. get placeholderColor(): string;
  79534. set placeholderColor(value: string);
  79535. /** Gets or sets the text displayed when the control is empty */
  79536. get placeholderText(): string;
  79537. set placeholderText(value: string);
  79538. /** Gets or sets the dead key flag */
  79539. get deadKey(): boolean;
  79540. set deadKey(flag: boolean);
  79541. /** Gets or sets the highlight text */
  79542. get highlightedText(): string;
  79543. set highlightedText(text: string);
  79544. /** Gets or sets if the current key should be added */
  79545. get addKey(): boolean;
  79546. set addKey(flag: boolean);
  79547. /** Gets or sets the value of the current key being entered */
  79548. get currentKey(): string;
  79549. set currentKey(key: string);
  79550. /** Gets or sets the text displayed in the control */
  79551. get text(): string;
  79552. set text(value: string);
  79553. /** Gets or sets control width */
  79554. get width(): string | number;
  79555. set width(value: string | number);
  79556. /**
  79557. * Creates a new InputText
  79558. * @param name defines the control name
  79559. * @param text defines the text of the control
  79560. */
  79561. constructor(name?: string | undefined, text?: string);
  79562. /** @hidden */
  79563. onBlur(): void;
  79564. /** @hidden */
  79565. onFocus(): void;
  79566. protected _getTypeName(): string;
  79567. /**
  79568. * Function called to get the list of controls that should not steal the focus from this control
  79569. * @returns an array of controls
  79570. */
  79571. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  79572. /** @hidden */
  79573. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  79574. /** @hidden */
  79575. private _updateValueFromCursorIndex;
  79576. /** @hidden */
  79577. private _processDblClick;
  79578. /** @hidden */
  79579. private _selectAllText;
  79580. /**
  79581. * Handles the keyboard event
  79582. * @param evt Defines the KeyboardEvent
  79583. */
  79584. processKeyboard(evt: KeyboardEvent): void;
  79585. /** @hidden */
  79586. private _onCopyText;
  79587. /** @hidden */
  79588. private _onCutText;
  79589. /** @hidden */
  79590. private _onPasteText;
  79591. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79592. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79593. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79594. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79595. protected _beforeRenderText(text: string): string;
  79596. dispose(): void;
  79597. }
  79598. }
  79599. declare module BABYLON.GUI {
  79600. /**
  79601. * Class used to create a 2D grid container
  79602. */
  79603. export class Grid extends Container {
  79604. name?: string | undefined;
  79605. private _rowDefinitions;
  79606. private _columnDefinitions;
  79607. private _cells;
  79608. private _childControls;
  79609. /**
  79610. * Gets the number of columns
  79611. */
  79612. get columnCount(): number;
  79613. /**
  79614. * Gets the number of rows
  79615. */
  79616. get rowCount(): number;
  79617. /** Gets the list of children */
  79618. get children(): Control[];
  79619. /** Gets the list of cells (e.g. the containers) */
  79620. get cells(): {
  79621. [key: string]: Container;
  79622. };
  79623. /**
  79624. * Gets the definition of a specific row
  79625. * @param index defines the index of the row
  79626. * @returns the row definition
  79627. */
  79628. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79629. /**
  79630. * Gets the definition of a specific column
  79631. * @param index defines the index of the column
  79632. * @returns the column definition
  79633. */
  79634. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79635. /**
  79636. * Adds a new row to the grid
  79637. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79638. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  79639. * @returns the current grid
  79640. */
  79641. addRowDefinition(height: number, isPixel?: boolean): Grid;
  79642. /**
  79643. * Adds a new column to the grid
  79644. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79645. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79646. * @returns the current grid
  79647. */
  79648. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  79649. /**
  79650. * Update a row definition
  79651. * @param index defines the index of the row to update
  79652. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79653. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  79654. * @returns the current grid
  79655. */
  79656. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  79657. /**
  79658. * Update a column definition
  79659. * @param index defines the index of the column to update
  79660. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79661. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79662. * @returns the current grid
  79663. */
  79664. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  79665. /**
  79666. * Gets the list of children stored in a specific cell
  79667. * @param row defines the row to check
  79668. * @param column defines the column to check
  79669. * @returns the list of controls
  79670. */
  79671. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  79672. /**
  79673. * Gets a string representing the child cell info (row x column)
  79674. * @param child defines the control to get info from
  79675. * @returns a string containing the child cell info (row x column)
  79676. */
  79677. getChildCellInfo(child: Control): string;
  79678. private _removeCell;
  79679. private _offsetCell;
  79680. /**
  79681. * Remove a column definition at specified index
  79682. * @param index defines the index of the column to remove
  79683. * @returns the current grid
  79684. */
  79685. removeColumnDefinition(index: number): Grid;
  79686. /**
  79687. * Remove a row definition at specified index
  79688. * @param index defines the index of the row to remove
  79689. * @returns the current grid
  79690. */
  79691. removeRowDefinition(index: number): Grid;
  79692. /**
  79693. * Adds a new control to the current grid
  79694. * @param control defines the control to add
  79695. * @param row defines the row where to add the control (0 by default)
  79696. * @param column defines the column where to add the control (0 by default)
  79697. * @returns the current grid
  79698. */
  79699. addControl(control: Control, row?: number, column?: number): Grid;
  79700. /**
  79701. * Removes a control from the current container
  79702. * @param control defines the control to remove
  79703. * @returns the current container
  79704. */
  79705. removeControl(control: Control): Container;
  79706. /**
  79707. * Creates a new Grid
  79708. * @param name defines control name
  79709. */
  79710. constructor(name?: string | undefined);
  79711. protected _getTypeName(): string;
  79712. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  79713. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79714. _flagDescendantsAsMatrixDirty(): void;
  79715. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79716. /** Releases associated resources */
  79717. dispose(): void;
  79718. }
  79719. }
  79720. declare module BABYLON.GUI {
  79721. /** Class used to create color pickers */
  79722. export class ColorPicker extends Control {
  79723. name?: string | undefined;
  79724. private static _Epsilon;
  79725. private _colorWheelCanvas;
  79726. private _value;
  79727. private _tmpColor;
  79728. private _pointerStartedOnSquare;
  79729. private _pointerStartedOnWheel;
  79730. private _squareLeft;
  79731. private _squareTop;
  79732. private _squareSize;
  79733. private _h;
  79734. private _s;
  79735. private _v;
  79736. private _lastPointerDownID;
  79737. /**
  79738. * BABYLON.Observable raised when the value changes
  79739. */
  79740. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  79741. /** Gets or sets the color of the color picker */
  79742. get value(): BABYLON.Color3;
  79743. set value(value: BABYLON.Color3);
  79744. /**
  79745. * Gets or sets control width
  79746. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79747. */
  79748. get width(): string | number;
  79749. set width(value: string | number);
  79750. /**
  79751. * Gets or sets control height
  79752. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79753. */
  79754. get height(): string | number;
  79755. /** Gets or sets control height */
  79756. set height(value: string | number);
  79757. /** Gets or sets control size */
  79758. get size(): string | number;
  79759. set size(value: string | number);
  79760. /**
  79761. * Creates a new ColorPicker
  79762. * @param name defines the control name
  79763. */
  79764. constructor(name?: string | undefined);
  79765. protected _getTypeName(): string;
  79766. /** @hidden */
  79767. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79768. private _updateSquareProps;
  79769. private _drawGradientSquare;
  79770. private _drawCircle;
  79771. private _createColorWheelCanvas;
  79772. /** @hidden */
  79773. _draw(context: CanvasRenderingContext2D): void;
  79774. private _pointerIsDown;
  79775. private _updateValueFromPointer;
  79776. private _isPointOnSquare;
  79777. private _isPointOnWheel;
  79778. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79779. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79780. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79781. _onCanvasBlur(): void;
  79782. /**
  79783. * This function expands the color picker by creating a color picker dialog with manual
  79784. * color value input and the ability to save colors into an array to be used later in
  79785. * subsequent launches of the dialogue.
  79786. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  79787. * @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.
  79788. * @returns picked color as a hex string and the saved colors array as hex strings.
  79789. */
  79790. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  79791. pickerWidth?: string;
  79792. pickerHeight?: string;
  79793. headerHeight?: string;
  79794. lastColor?: string;
  79795. swatchLimit?: number;
  79796. numSwatchesPerLine?: number;
  79797. savedColors?: Array<string>;
  79798. }): Promise<{
  79799. savedColors?: string[];
  79800. pickedColor: string;
  79801. }>;
  79802. }
  79803. }
  79804. declare module BABYLON.GUI {
  79805. /** Class used to create 2D ellipse containers */
  79806. export class Ellipse extends Container {
  79807. name?: string | undefined;
  79808. private _thickness;
  79809. /** Gets or sets border thickness */
  79810. get thickness(): number;
  79811. set thickness(value: number);
  79812. /**
  79813. * Creates a new Ellipse
  79814. * @param name defines the control name
  79815. */
  79816. constructor(name?: string | undefined);
  79817. protected _getTypeName(): string;
  79818. protected _localDraw(context: CanvasRenderingContext2D): void;
  79819. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79820. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79821. }
  79822. }
  79823. declare module BABYLON.GUI {
  79824. /**
  79825. * Class used to create a password control
  79826. */
  79827. export class InputPassword extends InputText {
  79828. protected _beforeRenderText(text: string): string;
  79829. }
  79830. }
  79831. declare module BABYLON.GUI {
  79832. /** Class used to render 2D lines */
  79833. export class Line extends Control {
  79834. name?: string | undefined;
  79835. private _lineWidth;
  79836. private _x1;
  79837. private _y1;
  79838. private _x2;
  79839. private _y2;
  79840. private _dash;
  79841. private _connectedControl;
  79842. private _connectedControlDirtyObserver;
  79843. /** Gets or sets the dash pattern */
  79844. get dash(): Array<number>;
  79845. set dash(value: Array<number>);
  79846. /** Gets or sets the control connected with the line end */
  79847. get connectedControl(): Control;
  79848. set connectedControl(value: Control);
  79849. /** Gets or sets start coordinates on X axis */
  79850. get x1(): string | number;
  79851. set x1(value: string | number);
  79852. /** Gets or sets start coordinates on Y axis */
  79853. get y1(): string | number;
  79854. set y1(value: string | number);
  79855. /** Gets or sets end coordinates on X axis */
  79856. get x2(): string | number;
  79857. set x2(value: string | number);
  79858. /** Gets or sets end coordinates on Y axis */
  79859. get y2(): string | number;
  79860. set y2(value: string | number);
  79861. /** Gets or sets line width */
  79862. get lineWidth(): number;
  79863. set lineWidth(value: number);
  79864. /** Gets or sets horizontal alignment */
  79865. set horizontalAlignment(value: number);
  79866. /** Gets or sets vertical alignment */
  79867. set verticalAlignment(value: number);
  79868. private get _effectiveX2();
  79869. private get _effectiveY2();
  79870. /**
  79871. * Creates a new Line
  79872. * @param name defines the control name
  79873. */
  79874. constructor(name?: string | undefined);
  79875. protected _getTypeName(): string;
  79876. _draw(context: CanvasRenderingContext2D): void;
  79877. _measure(): void;
  79878. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79879. /**
  79880. * Move one end of the line given 3D cartesian coordinates.
  79881. * @param position Targeted world position
  79882. * @param scene BABYLON.Scene
  79883. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79884. */
  79885. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  79886. /**
  79887. * Move one end of the line to a position in screen absolute space.
  79888. * @param projectedPosition Position in screen absolute space (X, Y)
  79889. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79890. */
  79891. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  79892. }
  79893. }
  79894. declare module BABYLON.GUI {
  79895. /**
  79896. * Class used to store a point for a MultiLine object.
  79897. * The point can be pure 2D coordinates, a mesh or a control
  79898. */
  79899. export class MultiLinePoint {
  79900. private _multiLine;
  79901. private _x;
  79902. private _y;
  79903. private _control;
  79904. private _mesh;
  79905. private _controlObserver;
  79906. private _meshObserver;
  79907. /** @hidden */
  79908. _point: BABYLON.Vector2;
  79909. /**
  79910. * Creates a new MultiLinePoint
  79911. * @param multiLine defines the source MultiLine object
  79912. */
  79913. constructor(multiLine: MultiLine);
  79914. /** Gets or sets x coordinate */
  79915. get x(): string | number;
  79916. set x(value: string | number);
  79917. /** Gets or sets y coordinate */
  79918. get y(): string | number;
  79919. set y(value: string | number);
  79920. /** Gets or sets the control associated with this point */
  79921. get control(): BABYLON.Nullable<Control>;
  79922. set control(value: BABYLON.Nullable<Control>);
  79923. /** Gets or sets the mesh associated with this point */
  79924. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79925. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  79926. /** Resets links */
  79927. resetLinks(): void;
  79928. /**
  79929. * Gets a translation vector
  79930. * @returns the translation vector
  79931. */
  79932. translate(): BABYLON.Vector2;
  79933. private _translatePoint;
  79934. /** Release associated resources */
  79935. dispose(): void;
  79936. }
  79937. }
  79938. declare module BABYLON.GUI {
  79939. /**
  79940. * Class used to create multi line control
  79941. */
  79942. export class MultiLine extends Control {
  79943. name?: string | undefined;
  79944. private _lineWidth;
  79945. private _dash;
  79946. private _points;
  79947. private _minX;
  79948. private _minY;
  79949. private _maxX;
  79950. private _maxY;
  79951. /**
  79952. * Creates a new MultiLine
  79953. * @param name defines the control name
  79954. */
  79955. constructor(name?: string | undefined);
  79956. /** Gets or sets dash pattern */
  79957. get dash(): Array<number>;
  79958. set dash(value: Array<number>);
  79959. /**
  79960. * Gets point stored at specified index
  79961. * @param index defines the index to look for
  79962. * @returns the requested point if found
  79963. */
  79964. getAt(index: number): MultiLinePoint;
  79965. /** Function called when a point is updated */
  79966. onPointUpdate: () => void;
  79967. /**
  79968. * Adds new points to the point collection
  79969. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  79970. * @returns the list of created MultiLinePoint
  79971. */
  79972. add(...items: (AbstractMesh | Control | {
  79973. x: string | number;
  79974. y: string | number;
  79975. })[]): MultiLinePoint[];
  79976. /**
  79977. * Adds a new point to the point collection
  79978. * @param item defines the item (mesh, control or 2d coordiantes) to add
  79979. * @returns the created MultiLinePoint
  79980. */
  79981. push(item?: (AbstractMesh | Control | {
  79982. x: string | number;
  79983. y: string | number;
  79984. })): MultiLinePoint;
  79985. /**
  79986. * Remove a specific value or point from the active point collection
  79987. * @param value defines the value or point to remove
  79988. */
  79989. remove(value: number | MultiLinePoint): void;
  79990. /**
  79991. * Resets this object to initial state (no point)
  79992. */
  79993. reset(): void;
  79994. /**
  79995. * Resets all links
  79996. */
  79997. resetLinks(): void;
  79998. /** Gets or sets line width */
  79999. get lineWidth(): number;
  80000. set lineWidth(value: number);
  80001. set horizontalAlignment(value: number);
  80002. set verticalAlignment(value: number);
  80003. protected _getTypeName(): string;
  80004. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80005. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80006. _measure(): void;
  80007. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80008. dispose(): void;
  80009. }
  80010. }
  80011. declare module BABYLON.GUI {
  80012. /**
  80013. * Class used to create radio button controls
  80014. */
  80015. export class RadioButton extends Control {
  80016. name?: string | undefined;
  80017. private _isChecked;
  80018. private _background;
  80019. private _checkSizeRatio;
  80020. private _thickness;
  80021. /** Gets or sets border thickness */
  80022. get thickness(): number;
  80023. set thickness(value: number);
  80024. /** Gets or sets group name */
  80025. group: string;
  80026. /** BABYLON.Observable raised when isChecked is changed */
  80027. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  80028. /** Gets or sets a value indicating the ratio between overall size and check size */
  80029. get checkSizeRatio(): number;
  80030. set checkSizeRatio(value: number);
  80031. /** Gets or sets background color */
  80032. get background(): string;
  80033. set background(value: string);
  80034. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  80035. get isChecked(): boolean;
  80036. set isChecked(value: boolean);
  80037. /**
  80038. * Creates a new RadioButton
  80039. * @param name defines the control name
  80040. */
  80041. constructor(name?: string | undefined);
  80042. protected _getTypeName(): string;
  80043. _draw(context: CanvasRenderingContext2D): void;
  80044. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80045. /**
  80046. * Utility function to easily create a radio button with a header
  80047. * @param title defines the label to use for the header
  80048. * @param group defines the group to use for the radio button
  80049. * @param isChecked defines the initial state of the radio button
  80050. * @param onValueChanged defines the callback to call when value changes
  80051. * @returns a StackPanel containing the radio button and a textBlock
  80052. */
  80053. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  80054. }
  80055. }
  80056. declare module BABYLON.GUI {
  80057. /**
  80058. * Class used to create slider controls
  80059. */
  80060. export class BaseSlider extends Control {
  80061. name?: string | undefined;
  80062. protected _thumbWidth: ValueAndUnit;
  80063. private _minimum;
  80064. private _maximum;
  80065. private _value;
  80066. private _isVertical;
  80067. protected _barOffset: ValueAndUnit;
  80068. private _isThumbClamped;
  80069. protected _displayThumb: boolean;
  80070. private _step;
  80071. private _lastPointerDownID;
  80072. protected _effectiveBarOffset: number;
  80073. protected _renderLeft: number;
  80074. protected _renderTop: number;
  80075. protected _renderWidth: number;
  80076. protected _renderHeight: number;
  80077. protected _backgroundBoxLength: number;
  80078. protected _backgroundBoxThickness: number;
  80079. protected _effectiveThumbThickness: number;
  80080. /** BABYLON.Observable raised when the sldier value changes */
  80081. onValueChangedObservable: BABYLON.Observable<number>;
  80082. /** Gets or sets a boolean indicating if the thumb must be rendered */
  80083. get displayThumb(): boolean;
  80084. set displayThumb(value: boolean);
  80085. /** Gets or sets a step to apply to values (0 by default) */
  80086. get step(): number;
  80087. set step(value: number);
  80088. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  80089. get barOffset(): string | number;
  80090. /** Gets main bar offset in pixels*/
  80091. get barOffsetInPixels(): number;
  80092. set barOffset(value: string | number);
  80093. /** Gets or sets thumb width */
  80094. get thumbWidth(): string | number;
  80095. /** Gets thumb width in pixels */
  80096. get thumbWidthInPixels(): number;
  80097. set thumbWidth(value: string | number);
  80098. /** Gets or sets minimum value */
  80099. get minimum(): number;
  80100. set minimum(value: number);
  80101. /** Gets or sets maximum value */
  80102. get maximum(): number;
  80103. set maximum(value: number);
  80104. /** Gets or sets current value */
  80105. get value(): number;
  80106. set value(value: number);
  80107. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  80108. get isVertical(): boolean;
  80109. set isVertical(value: boolean);
  80110. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  80111. get isThumbClamped(): boolean;
  80112. set isThumbClamped(value: boolean);
  80113. /**
  80114. * Creates a new BaseSlider
  80115. * @param name defines the control name
  80116. */
  80117. constructor(name?: string | undefined);
  80118. protected _getTypeName(): string;
  80119. protected _getThumbPosition(): number;
  80120. protected _getThumbThickness(type: string): number;
  80121. protected _prepareRenderingData(type: string): void;
  80122. private _pointerIsDown;
  80123. /** @hidden */
  80124. protected _updateValueFromPointer(x: number, y: number): void;
  80125. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80126. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80127. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80128. _onCanvasBlur(): void;
  80129. }
  80130. }
  80131. declare module BABYLON.GUI {
  80132. /**
  80133. * Class used to create slider controls
  80134. */
  80135. export class Slider extends BaseSlider {
  80136. name?: string | undefined;
  80137. private _background;
  80138. private _borderColor;
  80139. private _thumbColor;
  80140. private _isThumbCircle;
  80141. protected _displayValueBar: boolean;
  80142. /** Gets or sets a boolean indicating if the value bar must be rendered */
  80143. get displayValueBar(): boolean;
  80144. set displayValueBar(value: boolean);
  80145. /** Gets or sets border color */
  80146. get borderColor(): string;
  80147. set borderColor(value: string);
  80148. /** Gets or sets background color */
  80149. get background(): string;
  80150. set background(value: string);
  80151. /** Gets or sets thumb's color */
  80152. get thumbColor(): string;
  80153. set thumbColor(value: string);
  80154. /** Gets or sets a boolean indicating if the thumb should be round or square */
  80155. get isThumbCircle(): boolean;
  80156. set isThumbCircle(value: boolean);
  80157. /**
  80158. * Creates a new Slider
  80159. * @param name defines the control name
  80160. */
  80161. constructor(name?: string | undefined);
  80162. protected _getTypeName(): string;
  80163. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80164. }
  80165. }
  80166. declare module BABYLON.GUI {
  80167. /** Class used to create a RadioGroup
  80168. * which contains groups of radio buttons
  80169. */
  80170. export class SelectorGroup {
  80171. /** name of SelectorGroup */
  80172. name: string;
  80173. private _groupPanel;
  80174. private _selectors;
  80175. private _groupHeader;
  80176. /**
  80177. * Creates a new SelectorGroup
  80178. * @param name of group, used as a group heading
  80179. */
  80180. constructor(
  80181. /** name of SelectorGroup */
  80182. name: string);
  80183. /** Gets the groupPanel of the SelectorGroup */
  80184. get groupPanel(): StackPanel;
  80185. /** Gets the selectors array */
  80186. get selectors(): StackPanel[];
  80187. /** Gets and sets the group header */
  80188. get header(): string;
  80189. set header(label: string);
  80190. /** @hidden */
  80191. private _addGroupHeader;
  80192. /** @hidden*/
  80193. _getSelector(selectorNb: number): StackPanel | undefined;
  80194. /** Removes the selector at the given position
  80195. * @param selectorNb the position of the selector within the group
  80196. */
  80197. removeSelector(selectorNb: number): void;
  80198. }
  80199. /** Class used to create a CheckboxGroup
  80200. * which contains groups of checkbox buttons
  80201. */
  80202. export class CheckboxGroup extends SelectorGroup {
  80203. /** Adds a checkbox as a control
  80204. * @param text is the label for the selector
  80205. * @param func is the function called when the Selector is checked
  80206. * @param checked is true when Selector is checked
  80207. */
  80208. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  80209. /** @hidden */
  80210. _setSelectorLabel(selectorNb: number, label: string): void;
  80211. /** @hidden */
  80212. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80213. /** @hidden */
  80214. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80215. /** @hidden */
  80216. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80217. }
  80218. /** Class used to create a RadioGroup
  80219. * which contains groups of radio buttons
  80220. */
  80221. export class RadioGroup extends SelectorGroup {
  80222. private _selectNb;
  80223. /** Adds a radio button as a control
  80224. * @param label is the label for the selector
  80225. * @param func is the function called when the Selector is checked
  80226. * @param checked is true when Selector is checked
  80227. */
  80228. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  80229. /** @hidden */
  80230. _setSelectorLabel(selectorNb: number, label: string): void;
  80231. /** @hidden */
  80232. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80233. /** @hidden */
  80234. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80235. /** @hidden */
  80236. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80237. }
  80238. /** Class used to create a SliderGroup
  80239. * which contains groups of slider buttons
  80240. */
  80241. export class SliderGroup extends SelectorGroup {
  80242. /**
  80243. * Adds a slider to the SelectorGroup
  80244. * @param label is the label for the SliderBar
  80245. * @param func is the function called when the Slider moves
  80246. * @param unit is a string describing the units used, eg degrees or metres
  80247. * @param min is the minimum value for the Slider
  80248. * @param max is the maximum value for the Slider
  80249. * @param value is the start value for the Slider between min and max
  80250. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  80251. */
  80252. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  80253. /** @hidden */
  80254. _setSelectorLabel(selectorNb: number, label: string): void;
  80255. /** @hidden */
  80256. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80257. /** @hidden */
  80258. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80259. /** @hidden */
  80260. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80261. }
  80262. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  80263. * @see https://doc.babylonjs.com/how_to/selector
  80264. */
  80265. export class SelectionPanel extends Rectangle {
  80266. /** name of SelectionPanel */
  80267. name: string;
  80268. /** an array of SelectionGroups */
  80269. groups: SelectorGroup[];
  80270. private _panel;
  80271. private _buttonColor;
  80272. private _buttonBackground;
  80273. private _headerColor;
  80274. private _barColor;
  80275. private _barHeight;
  80276. private _spacerHeight;
  80277. private _labelColor;
  80278. private _groups;
  80279. private _bars;
  80280. /**
  80281. * Creates a new SelectionPanel
  80282. * @param name of SelectionPanel
  80283. * @param groups is an array of SelectionGroups
  80284. */
  80285. constructor(
  80286. /** name of SelectionPanel */
  80287. name: string,
  80288. /** an array of SelectionGroups */
  80289. groups?: SelectorGroup[]);
  80290. protected _getTypeName(): string;
  80291. /** Gets the (stack) panel of the SelectionPanel */
  80292. get panel(): StackPanel;
  80293. /** Gets or sets the headerColor */
  80294. get headerColor(): string;
  80295. set headerColor(color: string);
  80296. private _setHeaderColor;
  80297. /** Gets or sets the button color */
  80298. get buttonColor(): string;
  80299. set buttonColor(color: string);
  80300. private _setbuttonColor;
  80301. /** Gets or sets the label color */
  80302. get labelColor(): string;
  80303. set labelColor(color: string);
  80304. private _setLabelColor;
  80305. /** Gets or sets the button background */
  80306. get buttonBackground(): string;
  80307. set buttonBackground(color: string);
  80308. private _setButtonBackground;
  80309. /** Gets or sets the color of separator bar */
  80310. get barColor(): string;
  80311. set barColor(color: string);
  80312. private _setBarColor;
  80313. /** Gets or sets the height of separator bar */
  80314. get barHeight(): string;
  80315. set barHeight(value: string);
  80316. private _setBarHeight;
  80317. /** Gets or sets the height of spacers*/
  80318. get spacerHeight(): string;
  80319. set spacerHeight(value: string);
  80320. private _setSpacerHeight;
  80321. /** Adds a bar between groups */
  80322. private _addSpacer;
  80323. /** Add a group to the selection panel
  80324. * @param group is the selector group to add
  80325. */
  80326. addGroup(group: SelectorGroup): void;
  80327. /** Remove the group from the given position
  80328. * @param groupNb is the position of the group in the list
  80329. */
  80330. removeGroup(groupNb: number): void;
  80331. /** Change a group header label
  80332. * @param label is the new group header label
  80333. * @param groupNb is the number of the group to relabel
  80334. * */
  80335. setHeaderName(label: string, groupNb: number): void;
  80336. /** Change selector label to the one given
  80337. * @param label is the new selector label
  80338. * @param groupNb is the number of the groupcontaining the selector
  80339. * @param selectorNb is the number of the selector within a group to relabel
  80340. * */
  80341. relabel(label: string, groupNb: number, selectorNb: number): void;
  80342. /** For a given group position remove the selector at the given position
  80343. * @param groupNb is the number of the group to remove the selector from
  80344. * @param selectorNb is the number of the selector within the group
  80345. */
  80346. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  80347. /** For a given group position of correct type add a checkbox button
  80348. * @param groupNb is the number of the group to remove the selector from
  80349. * @param label is the label for the selector
  80350. * @param func is the function called when the Selector is checked
  80351. * @param checked is true when Selector is checked
  80352. */
  80353. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80354. /** For a given group position of correct type add a radio button
  80355. * @param groupNb is the number of the group to remove the selector from
  80356. * @param label is the label for the selector
  80357. * @param func is the function called when the Selector is checked
  80358. * @param checked is true when Selector is checked
  80359. */
  80360. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80361. /**
  80362. * For a given slider group add a slider
  80363. * @param groupNb is the number of the group to add the slider to
  80364. * @param label is the label for the Slider
  80365. * @param func is the function called when the Slider moves
  80366. * @param unit is a string describing the units used, eg degrees or metres
  80367. * @param min is the minimum value for the Slider
  80368. * @param max is the maximum value for the Slider
  80369. * @param value is the start value for the Slider between min and max
  80370. * @param onVal is the function used to format the value displayed, eg radians to degrees
  80371. */
  80372. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  80373. }
  80374. }
  80375. declare module BABYLON.GUI {
  80376. /**
  80377. * Class used to hold a the container for ScrollViewer
  80378. * @hidden
  80379. */
  80380. export class _ScrollViewerWindow extends Container {
  80381. parentClientWidth: number;
  80382. parentClientHeight: number;
  80383. private _freezeControls;
  80384. private _parentMeasure;
  80385. private _oldLeft;
  80386. private _oldTop;
  80387. get freezeControls(): boolean;
  80388. set freezeControls(value: boolean);
  80389. private _bucketWidth;
  80390. private _bucketHeight;
  80391. private _buckets;
  80392. private _bucketLen;
  80393. get bucketWidth(): number;
  80394. get bucketHeight(): number;
  80395. setBucketSizes(width: number, height: number): void;
  80396. private _useBuckets;
  80397. private _makeBuckets;
  80398. private _dispatchInBuckets;
  80399. private _updateMeasures;
  80400. private _updateChildrenMeasures;
  80401. private _restoreMeasures;
  80402. /**
  80403. * Creates a new ScrollViewerWindow
  80404. * @param name of ScrollViewerWindow
  80405. */
  80406. constructor(name?: string);
  80407. protected _getTypeName(): string;
  80408. /** @hidden */
  80409. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80410. /** @hidden */
  80411. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  80412. private _scrollChildren;
  80413. private _scrollChildrenWithBuckets;
  80414. /** @hidden */
  80415. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  80416. protected _postMeasure(): void;
  80417. }
  80418. }
  80419. declare module BABYLON.GUI {
  80420. /**
  80421. * Class used to create slider controls
  80422. */
  80423. export class ScrollBar extends BaseSlider {
  80424. name?: string | undefined;
  80425. private _background;
  80426. private _borderColor;
  80427. private _tempMeasure;
  80428. /** Gets or sets border color */
  80429. get borderColor(): string;
  80430. set borderColor(value: string);
  80431. /** Gets or sets background color */
  80432. get background(): string;
  80433. set background(value: string);
  80434. /**
  80435. * Creates a new Slider
  80436. * @param name defines the control name
  80437. */
  80438. constructor(name?: string | undefined);
  80439. protected _getTypeName(): string;
  80440. protected _getThumbThickness(): number;
  80441. _draw(context: CanvasRenderingContext2D): void;
  80442. private _first;
  80443. private _originX;
  80444. private _originY;
  80445. /** @hidden */
  80446. protected _updateValueFromPointer(x: number, y: number): void;
  80447. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80448. }
  80449. }
  80450. declare module BABYLON.GUI {
  80451. /**
  80452. * Class used to create slider controls
  80453. */
  80454. export class ImageScrollBar extends BaseSlider {
  80455. name?: string | undefined;
  80456. private _backgroundBaseImage;
  80457. private _backgroundImage;
  80458. private _thumbImage;
  80459. private _thumbBaseImage;
  80460. private _thumbLength;
  80461. private _thumbHeight;
  80462. private _barImageHeight;
  80463. private _tempMeasure;
  80464. /** Number of 90° rotation to apply on the images when in vertical mode */
  80465. num90RotationInVerticalMode: number;
  80466. /**
  80467. * Gets or sets the image used to render the background for horizontal bar
  80468. */
  80469. get backgroundImage(): Image;
  80470. set backgroundImage(value: Image);
  80471. /**
  80472. * Gets or sets the image used to render the thumb
  80473. */
  80474. get thumbImage(): Image;
  80475. set thumbImage(value: Image);
  80476. /**
  80477. * Gets or sets the length of the thumb
  80478. */
  80479. get thumbLength(): number;
  80480. set thumbLength(value: number);
  80481. /**
  80482. * Gets or sets the height of the thumb
  80483. */
  80484. get thumbHeight(): number;
  80485. set thumbHeight(value: number);
  80486. /**
  80487. * Gets or sets the height of the bar image
  80488. */
  80489. get barImageHeight(): number;
  80490. set barImageHeight(value: number);
  80491. /**
  80492. * Creates a new ImageScrollBar
  80493. * @param name defines the control name
  80494. */
  80495. constructor(name?: string | undefined);
  80496. protected _getTypeName(): string;
  80497. protected _getThumbThickness(): number;
  80498. _draw(context: CanvasRenderingContext2D): void;
  80499. private _first;
  80500. private _originX;
  80501. private _originY;
  80502. /** @hidden */
  80503. protected _updateValueFromPointer(x: number, y: number): void;
  80504. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80505. }
  80506. }
  80507. declare module BABYLON.GUI {
  80508. /**
  80509. * Class used to hold a viewer window and sliders in a grid
  80510. */
  80511. export class ScrollViewer extends Rectangle {
  80512. private _grid;
  80513. private _horizontalBarSpace;
  80514. private _verticalBarSpace;
  80515. private _dragSpace;
  80516. private _horizontalBar;
  80517. private _verticalBar;
  80518. private _barColor;
  80519. private _barBackground;
  80520. private _barImage;
  80521. private _horizontalBarImage;
  80522. private _verticalBarImage;
  80523. private _barBackgroundImage;
  80524. private _horizontalBarBackgroundImage;
  80525. private _verticalBarBackgroundImage;
  80526. private _barSize;
  80527. private _window;
  80528. private _pointerIsOver;
  80529. private _wheelPrecision;
  80530. private _onWheelObserver;
  80531. private _clientWidth;
  80532. private _clientHeight;
  80533. private _useImageBar;
  80534. private _thumbLength;
  80535. private _thumbHeight;
  80536. private _barImageHeight;
  80537. private _horizontalBarImageHeight;
  80538. private _verticalBarImageHeight;
  80539. private _oldWindowContentsWidth;
  80540. private _oldWindowContentsHeight;
  80541. /**
  80542. * Gets the horizontal scrollbar
  80543. */
  80544. get horizontalBar(): ScrollBar | ImageScrollBar;
  80545. /**
  80546. * Gets the vertical scrollbar
  80547. */
  80548. get verticalBar(): ScrollBar | ImageScrollBar;
  80549. /**
  80550. * Adds a new control to the current container
  80551. * @param control defines the control to add
  80552. * @returns the current container
  80553. */
  80554. addControl(control: BABYLON.Nullable<Control>): Container;
  80555. /**
  80556. * Removes a control from the current container
  80557. * @param control defines the control to remove
  80558. * @returns the current container
  80559. */
  80560. removeControl(control: Control): Container;
  80561. /** Gets the list of children */
  80562. get children(): Control[];
  80563. _flagDescendantsAsMatrixDirty(): void;
  80564. /**
  80565. * Freezes or unfreezes the controls in the window.
  80566. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  80567. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  80568. */
  80569. get freezeControls(): boolean;
  80570. set freezeControls(value: boolean);
  80571. /** Gets the bucket width */
  80572. get bucketWidth(): number;
  80573. /** Gets the bucket height */
  80574. get bucketHeight(): number;
  80575. /**
  80576. * Sets the bucket sizes.
  80577. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  80578. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  80579. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  80580. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  80581. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  80582. * used), that's why it is not enabled by default.
  80583. * @param width width of the bucket
  80584. * @param height height of the bucket
  80585. */
  80586. setBucketSizes(width: number, height: number): void;
  80587. private _forceHorizontalBar;
  80588. private _forceVerticalBar;
  80589. /**
  80590. * Forces the horizontal scroll bar to be displayed
  80591. */
  80592. get forceHorizontalBar(): boolean;
  80593. set forceHorizontalBar(value: boolean);
  80594. /**
  80595. * Forces the vertical scroll bar to be displayed
  80596. */
  80597. get forceVerticalBar(): boolean;
  80598. set forceVerticalBar(value: boolean);
  80599. /**
  80600. * Creates a new ScrollViewer
  80601. * @param name of ScrollViewer
  80602. */
  80603. constructor(name?: string, isImageBased?: boolean);
  80604. /** Reset the scroll viewer window to initial size */
  80605. resetWindow(): void;
  80606. protected _getTypeName(): string;
  80607. private _buildClientSizes;
  80608. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80609. protected _postMeasure(): void;
  80610. /**
  80611. * Gets or sets the mouse wheel precision
  80612. * from 0 to 1 with a default value of 0.05
  80613. * */
  80614. get wheelPrecision(): number;
  80615. set wheelPrecision(value: number);
  80616. /** Gets or sets the scroll bar container background color */
  80617. get scrollBackground(): string;
  80618. set scrollBackground(color: string);
  80619. /** Gets or sets the bar color */
  80620. get barColor(): string;
  80621. set barColor(color: string);
  80622. /** Gets or sets the bar image */
  80623. get thumbImage(): Image;
  80624. set thumbImage(value: Image);
  80625. /** Gets or sets the horizontal bar image */
  80626. get horizontalThumbImage(): Image;
  80627. set horizontalThumbImage(value: Image);
  80628. /** Gets or sets the vertical bar image */
  80629. get verticalThumbImage(): Image;
  80630. set verticalThumbImage(value: Image);
  80631. /** Gets or sets the size of the bar */
  80632. get barSize(): number;
  80633. set barSize(value: number);
  80634. /** Gets or sets the length of the thumb */
  80635. get thumbLength(): number;
  80636. set thumbLength(value: number);
  80637. /** Gets or sets the height of the thumb */
  80638. get thumbHeight(): number;
  80639. set thumbHeight(value: number);
  80640. /** Gets or sets the height of the bar image */
  80641. get barImageHeight(): number;
  80642. set barImageHeight(value: number);
  80643. /** Gets or sets the height of the horizontal bar image */
  80644. get horizontalBarImageHeight(): number;
  80645. set horizontalBarImageHeight(value: number);
  80646. /** Gets or sets the height of the vertical bar image */
  80647. get verticalBarImageHeight(): number;
  80648. set verticalBarImageHeight(value: number);
  80649. /** Gets or sets the bar background */
  80650. get barBackground(): string;
  80651. set barBackground(color: string);
  80652. /** Gets or sets the bar background image */
  80653. get barImage(): Image;
  80654. set barImage(value: Image);
  80655. /** Gets or sets the horizontal bar background image */
  80656. get horizontalBarImage(): Image;
  80657. set horizontalBarImage(value: Image);
  80658. /** Gets or sets the vertical bar background image */
  80659. get verticalBarImage(): Image;
  80660. set verticalBarImage(value: Image);
  80661. private _setWindowPosition;
  80662. /** @hidden */
  80663. private _updateScroller;
  80664. _link(host: AdvancedDynamicTexture): void;
  80665. /** @hidden */
  80666. private _addBar;
  80667. /** @hidden */
  80668. private _attachWheel;
  80669. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80670. /** Releases associated resources */
  80671. dispose(): void;
  80672. }
  80673. }
  80674. declare module BABYLON.GUI {
  80675. /** Class used to render a grid */
  80676. export class DisplayGrid extends Control {
  80677. name?: string | undefined;
  80678. private _cellWidth;
  80679. private _cellHeight;
  80680. private _minorLineTickness;
  80681. private _minorLineColor;
  80682. private _majorLineTickness;
  80683. private _majorLineColor;
  80684. private _majorLineFrequency;
  80685. private _background;
  80686. private _displayMajorLines;
  80687. private _displayMinorLines;
  80688. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  80689. get displayMinorLines(): boolean;
  80690. set displayMinorLines(value: boolean);
  80691. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  80692. get displayMajorLines(): boolean;
  80693. set displayMajorLines(value: boolean);
  80694. /** Gets or sets background color (Black by default) */
  80695. get background(): string;
  80696. set background(value: string);
  80697. /** Gets or sets the width of each cell (20 by default) */
  80698. get cellWidth(): number;
  80699. set cellWidth(value: number);
  80700. /** Gets or sets the height of each cell (20 by default) */
  80701. get cellHeight(): number;
  80702. set cellHeight(value: number);
  80703. /** Gets or sets the tickness of minor lines (1 by default) */
  80704. get minorLineTickness(): number;
  80705. set minorLineTickness(value: number);
  80706. /** Gets or sets the color of minor lines (DarkGray by default) */
  80707. get minorLineColor(): string;
  80708. set minorLineColor(value: string);
  80709. /** Gets or sets the tickness of major lines (2 by default) */
  80710. get majorLineTickness(): number;
  80711. set majorLineTickness(value: number);
  80712. /** Gets or sets the color of major lines (White by default) */
  80713. get majorLineColor(): string;
  80714. set majorLineColor(value: string);
  80715. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  80716. get majorLineFrequency(): number;
  80717. set majorLineFrequency(value: number);
  80718. /**
  80719. * Creates a new GridDisplayRectangle
  80720. * @param name defines the control name
  80721. */
  80722. constructor(name?: string | undefined);
  80723. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80724. protected _getTypeName(): string;
  80725. }
  80726. }
  80727. declare module BABYLON.GUI {
  80728. /**
  80729. * Class used to create slider controls based on images
  80730. */
  80731. export class ImageBasedSlider extends BaseSlider {
  80732. name?: string | undefined;
  80733. private _backgroundImage;
  80734. private _thumbImage;
  80735. private _valueBarImage;
  80736. private _tempMeasure;
  80737. get displayThumb(): boolean;
  80738. set displayThumb(value: boolean);
  80739. /**
  80740. * Gets or sets the image used to render the background
  80741. */
  80742. get backgroundImage(): Image;
  80743. set backgroundImage(value: Image);
  80744. /**
  80745. * Gets or sets the image used to render the value bar
  80746. */
  80747. get valueBarImage(): Image;
  80748. set valueBarImage(value: Image);
  80749. /**
  80750. * Gets or sets the image used to render the thumb
  80751. */
  80752. get thumbImage(): Image;
  80753. set thumbImage(value: Image);
  80754. /**
  80755. * Creates a new ImageBasedSlider
  80756. * @param name defines the control name
  80757. */
  80758. constructor(name?: string | undefined);
  80759. protected _getTypeName(): string;
  80760. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80761. }
  80762. }
  80763. declare module BABYLON.GUI {
  80764. /**
  80765. * Forcing an export so that this code will execute
  80766. * @hidden
  80767. */
  80768. const name = "Statics";
  80769. }
  80770. declare module BABYLON.GUI {
  80771. /**
  80772. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  80773. */
  80774. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  80775. /**
  80776. * Define the instrumented AdvancedDynamicTexture.
  80777. */
  80778. texture: AdvancedDynamicTexture;
  80779. private _captureRenderTime;
  80780. private _renderTime;
  80781. private _captureLayoutTime;
  80782. private _layoutTime;
  80783. private _onBeginRenderObserver;
  80784. private _onEndRenderObserver;
  80785. private _onBeginLayoutObserver;
  80786. private _onEndLayoutObserver;
  80787. /**
  80788. * Gets the perf counter used to capture render time
  80789. */
  80790. get renderTimeCounter(): BABYLON.PerfCounter;
  80791. /**
  80792. * Gets the perf counter used to capture layout time
  80793. */
  80794. get layoutTimeCounter(): BABYLON.PerfCounter;
  80795. /**
  80796. * Enable or disable the render time capture
  80797. */
  80798. get captureRenderTime(): boolean;
  80799. set captureRenderTime(value: boolean);
  80800. /**
  80801. * Enable or disable the layout time capture
  80802. */
  80803. get captureLayoutTime(): boolean;
  80804. set captureLayoutTime(value: boolean);
  80805. /**
  80806. * Instantiates a new advanced dynamic texture instrumentation.
  80807. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  80808. * @param texture Defines the AdvancedDynamicTexture to instrument
  80809. */
  80810. constructor(
  80811. /**
  80812. * Define the instrumented AdvancedDynamicTexture.
  80813. */
  80814. texture: AdvancedDynamicTexture);
  80815. /**
  80816. * Dispose and release associated resources.
  80817. */
  80818. dispose(): void;
  80819. }
  80820. }
  80821. declare module BABYLON.GUI {
  80822. /**
  80823. * Class used to load GUI via XML.
  80824. */
  80825. export class XmlLoader {
  80826. private _nodes;
  80827. private _nodeTypes;
  80828. private _isLoaded;
  80829. private _objectAttributes;
  80830. private _parentClass;
  80831. /**
  80832. * Create a new xml loader
  80833. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  80834. */
  80835. constructor(parentClass?: null);
  80836. private _getChainElement;
  80837. private _getClassAttribute;
  80838. private _createGuiElement;
  80839. private _parseGrid;
  80840. private _parseElement;
  80841. private _prepareSourceElement;
  80842. private _parseElementsFromSource;
  80843. private _parseXml;
  80844. /**
  80845. * Gets if the loading has finished.
  80846. * @returns whether the loading has finished or not
  80847. */
  80848. isLoaded(): boolean;
  80849. /**
  80850. * Gets a loaded node / control by id.
  80851. * @param id the Controls id set in the xml
  80852. * @returns element of type Control
  80853. */
  80854. getNodeById(id: string): any;
  80855. /**
  80856. * Gets all loaded nodes / controls
  80857. * @returns Array of controls
  80858. */
  80859. getNodes(): any;
  80860. /**
  80861. * Initiates the xml layout loading
  80862. * @param xmlFile defines the xml layout to load
  80863. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  80864. * @param callback defines the callback called on layout load.
  80865. */
  80866. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  80867. }
  80868. }
  80869. declare module BABYLON.GUI {
  80870. /**
  80871. * Class used to create containers for controls
  80872. */
  80873. export class Container3D extends Control3D {
  80874. private _blockLayout;
  80875. /**
  80876. * Gets the list of child controls
  80877. */
  80878. protected _children: Control3D[];
  80879. /**
  80880. * Gets the list of child controls
  80881. */
  80882. get children(): Array<Control3D>;
  80883. /**
  80884. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  80885. * This is helpful to optimize layout operation when adding multiple children in a row
  80886. */
  80887. get blockLayout(): boolean;
  80888. set blockLayout(value: boolean);
  80889. /**
  80890. * Creates a new container
  80891. * @param name defines the container name
  80892. */
  80893. constructor(name?: string);
  80894. /**
  80895. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  80896. * @returns the current container
  80897. */
  80898. updateLayout(): Container3D;
  80899. /**
  80900. * Gets a boolean indicating if the given control is in the children of this control
  80901. * @param control defines the control to check
  80902. * @returns true if the control is in the child list
  80903. */
  80904. containsControl(control: Control3D): boolean;
  80905. /**
  80906. * Adds a control to the children of this control
  80907. * @param control defines the control to add
  80908. * @returns the current container
  80909. */
  80910. addControl(control: Control3D): Container3D;
  80911. /**
  80912. * This function will be called everytime a new control is added
  80913. */
  80914. protected _arrangeChildren(): void;
  80915. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80916. /**
  80917. * Removes a control from the children of this control
  80918. * @param control defines the control to remove
  80919. * @returns the current container
  80920. */
  80921. removeControl(control: Control3D): Container3D;
  80922. protected _getTypeName(): string;
  80923. /**
  80924. * Releases all associated resources
  80925. */
  80926. dispose(): void;
  80927. /** Control rotation will remain unchanged */
  80928. static readonly UNSET_ORIENTATION: number;
  80929. /** Control will rotate to make it look at sphere central axis */
  80930. static readonly FACEORIGIN_ORIENTATION: number;
  80931. /** Control will rotate to make it look back at sphere central axis */
  80932. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  80933. /** Control will rotate to look at z axis (0, 0, 1) */
  80934. static readonly FACEFORWARD_ORIENTATION: number;
  80935. /** Control will rotate to look at negative z axis (0, 0, -1) */
  80936. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  80937. }
  80938. }
  80939. declare module BABYLON.GUI {
  80940. /**
  80941. * Class used to manage 3D user interface
  80942. * @see https://doc.babylonjs.com/how_to/gui3d
  80943. */
  80944. export class GUI3DManager implements BABYLON.IDisposable {
  80945. private _scene;
  80946. private _sceneDisposeObserver;
  80947. private _utilityLayer;
  80948. private _rootContainer;
  80949. private _pointerObserver;
  80950. private _pointerOutObserver;
  80951. /** @hidden */
  80952. _lastPickedControl: Control3D;
  80953. /** @hidden */
  80954. _lastControlOver: {
  80955. [pointerId: number]: Control3D;
  80956. };
  80957. /** @hidden */
  80958. _lastControlDown: {
  80959. [pointerId: number]: Control3D;
  80960. };
  80961. /**
  80962. * BABYLON.Observable raised when the point picked by the pointer events changed
  80963. */
  80964. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  80965. /** @hidden */
  80966. _sharedMaterials: {
  80967. [key: string]: BABYLON.Material;
  80968. };
  80969. /** Gets the hosting scene */
  80970. get scene(): BABYLON.Scene;
  80971. /** Gets associated utility layer */
  80972. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  80973. /**
  80974. * Creates a new GUI3DManager
  80975. * @param scene
  80976. */
  80977. constructor(scene?: BABYLON.Scene);
  80978. private _handlePointerOut;
  80979. private _doPicking;
  80980. /**
  80981. * Gets the root container
  80982. */
  80983. get rootContainer(): Container3D;
  80984. /**
  80985. * Gets a boolean indicating if the given control is in the root child list
  80986. * @param control defines the control to check
  80987. * @returns true if the control is in the root child list
  80988. */
  80989. containsControl(control: Control3D): boolean;
  80990. /**
  80991. * Adds a control to the root child list
  80992. * @param control defines the control to add
  80993. * @returns the current manager
  80994. */
  80995. addControl(control: Control3D): GUI3DManager;
  80996. /**
  80997. * Removes a control from the root child list
  80998. * @param control defines the control to remove
  80999. * @returns the current container
  81000. */
  81001. removeControl(control: Control3D): GUI3DManager;
  81002. /**
  81003. * Releases all associated resources
  81004. */
  81005. dispose(): void;
  81006. }
  81007. }
  81008. declare module BABYLON.GUI {
  81009. /**
  81010. * Class used to transport BABYLON.Vector3 information for pointer events
  81011. */
  81012. export class Vector3WithInfo extends BABYLON.Vector3 {
  81013. /** defines the current mouse button index */
  81014. buttonIndex: number;
  81015. /**
  81016. * Creates a new Vector3WithInfo
  81017. * @param source defines the vector3 data to transport
  81018. * @param buttonIndex defines the current mouse button index
  81019. */
  81020. constructor(source: BABYLON.Vector3,
  81021. /** defines the current mouse button index */
  81022. buttonIndex?: number);
  81023. }
  81024. }
  81025. declare module BABYLON.GUI {
  81026. /**
  81027. * Class used as base class for controls
  81028. */
  81029. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  81030. /** Defines the control name */
  81031. name?: string | undefined;
  81032. /** @hidden */
  81033. _host: GUI3DManager;
  81034. private _node;
  81035. private _downCount;
  81036. private _enterCount;
  81037. private _downPointerIds;
  81038. private _isVisible;
  81039. /** Gets or sets the control position in world space */
  81040. get position(): BABYLON.Vector3;
  81041. set position(value: BABYLON.Vector3);
  81042. /** Gets or sets the control scaling in world space */
  81043. get scaling(): BABYLON.Vector3;
  81044. set scaling(value: BABYLON.Vector3);
  81045. /** Callback used to start pointer enter animation */
  81046. pointerEnterAnimation: () => void;
  81047. /** Callback used to start pointer out animation */
  81048. pointerOutAnimation: () => void;
  81049. /** Callback used to start pointer down animation */
  81050. pointerDownAnimation: () => void;
  81051. /** Callback used to start pointer up animation */
  81052. pointerUpAnimation: () => void;
  81053. /**
  81054. * An event triggered when the pointer move over the control
  81055. */
  81056. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  81057. /**
  81058. * An event triggered when the pointer move out of the control
  81059. */
  81060. onPointerOutObservable: BABYLON.Observable<Control3D>;
  81061. /**
  81062. * An event triggered when the pointer taps the control
  81063. */
  81064. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  81065. /**
  81066. * An event triggered when pointer is up
  81067. */
  81068. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  81069. /**
  81070. * An event triggered when a control is clicked on (with a mouse)
  81071. */
  81072. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  81073. /**
  81074. * An event triggered when pointer enters the control
  81075. */
  81076. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  81077. /**
  81078. * Gets or sets the parent container
  81079. */
  81080. parent: BABYLON.Nullable<Container3D>;
  81081. private _behaviors;
  81082. /**
  81083. * Gets the list of attached behaviors
  81084. * @see https://doc.babylonjs.com/features/behaviour
  81085. */
  81086. get behaviors(): BABYLON.Behavior<Control3D>[];
  81087. /**
  81088. * Attach a behavior to the control
  81089. * @see https://doc.babylonjs.com/features/behaviour
  81090. * @param behavior defines the behavior to attach
  81091. * @returns the current control
  81092. */
  81093. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81094. /**
  81095. * Remove an attached behavior
  81096. * @see https://doc.babylonjs.com/features/behaviour
  81097. * @param behavior defines the behavior to attach
  81098. * @returns the current control
  81099. */
  81100. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81101. /**
  81102. * Gets an attached behavior by name
  81103. * @param name defines the name of the behavior to look for
  81104. * @see https://doc.babylonjs.com/features/behaviour
  81105. * @returns null if behavior was not found else the requested behavior
  81106. */
  81107. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  81108. /** Gets or sets a boolean indicating if the control is visible */
  81109. get isVisible(): boolean;
  81110. set isVisible(value: boolean);
  81111. /**
  81112. * Creates a new control
  81113. * @param name defines the control name
  81114. */
  81115. constructor(
  81116. /** Defines the control name */
  81117. name?: string | undefined);
  81118. /**
  81119. * Gets a string representing the class name
  81120. */
  81121. get typeName(): string;
  81122. /**
  81123. * Get the current class name of the control.
  81124. * @returns current class name
  81125. */
  81126. getClassName(): string;
  81127. protected _getTypeName(): string;
  81128. /**
  81129. * Gets the transform node used by this control
  81130. */
  81131. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  81132. /**
  81133. * Gets the mesh used to render this control
  81134. */
  81135. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  81136. /**
  81137. * Link the control as child of the given node
  81138. * @param node defines the node to link to. Use null to unlink the control
  81139. * @returns the current control
  81140. */
  81141. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  81142. /** @hidden **/
  81143. _prepareNode(scene: BABYLON.Scene): void;
  81144. /**
  81145. * Node creation.
  81146. * Can be overriden by children
  81147. * @param scene defines the scene where the node must be attached
  81148. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  81149. */
  81150. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81151. /**
  81152. * Affect a material to the given mesh
  81153. * @param mesh defines the mesh which will represent the control
  81154. */
  81155. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81156. /** @hidden */
  81157. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  81158. /** @hidden */
  81159. _onPointerEnter(target: Control3D): boolean;
  81160. /** @hidden */
  81161. _onPointerOut(target: Control3D): void;
  81162. /** @hidden */
  81163. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81164. /** @hidden */
  81165. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  81166. /** @hidden */
  81167. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  81168. /** @hidden */
  81169. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81170. /** @hidden */
  81171. _disposeNode(): void;
  81172. /**
  81173. * Releases all associated resources
  81174. */
  81175. dispose(): void;
  81176. }
  81177. }
  81178. declare module BABYLON.GUI {
  81179. /**
  81180. * Class used as a root to all buttons
  81181. */
  81182. export class AbstractButton3D extends Control3D {
  81183. /**
  81184. * Creates a new button
  81185. * @param name defines the control name
  81186. */
  81187. constructor(name?: string);
  81188. protected _getTypeName(): string;
  81189. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81190. }
  81191. }
  81192. declare module BABYLON.GUI {
  81193. /**
  81194. * Class used to create a button in 3D
  81195. */
  81196. export class Button3D extends AbstractButton3D {
  81197. /** @hidden */
  81198. protected _currentMaterial: BABYLON.Material;
  81199. private _facadeTexture;
  81200. private _content;
  81201. private _contentResolution;
  81202. private _contentScaleRatio;
  81203. /**
  81204. * Gets or sets the texture resolution used to render content (512 by default)
  81205. */
  81206. get contentResolution(): BABYLON.int;
  81207. set contentResolution(value: BABYLON.int);
  81208. /**
  81209. * Gets or sets the texture scale ratio used to render content (2 by default)
  81210. */
  81211. get contentScaleRatio(): number;
  81212. set contentScaleRatio(value: number);
  81213. protected _disposeFacadeTexture(): void;
  81214. protected _resetContent(): void;
  81215. /**
  81216. * Creates a new button
  81217. * @param name defines the control name
  81218. */
  81219. constructor(name?: string);
  81220. /**
  81221. * Gets or sets the GUI 2D content used to display the button's facade
  81222. */
  81223. get content(): Control;
  81224. set content(value: Control);
  81225. /**
  81226. * Apply the facade texture (created from the content property).
  81227. * This function can be overloaded by child classes
  81228. * @param facadeTexture defines the AdvancedDynamicTexture to use
  81229. */
  81230. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81231. protected _getTypeName(): string;
  81232. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81233. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81234. /**
  81235. * Releases all associated resources
  81236. */
  81237. dispose(): void;
  81238. }
  81239. }
  81240. declare module BABYLON.GUI {
  81241. /**
  81242. * Abstract class used to create a container panel deployed on the surface of a volume
  81243. */
  81244. export abstract class VolumeBasedPanel extends Container3D {
  81245. private _columns;
  81246. private _rows;
  81247. private _rowThenColum;
  81248. private _orientation;
  81249. protected _cellWidth: number;
  81250. protected _cellHeight: number;
  81251. /**
  81252. * Gets or sets the distance between elements
  81253. */
  81254. margin: number;
  81255. /**
  81256. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  81257. * | Value | Type | Description |
  81258. * | ----- | ----------------------------------- | ----------- |
  81259. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  81260. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  81261. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  81262. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  81263. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  81264. */
  81265. get orientation(): number;
  81266. set orientation(value: number);
  81267. /**
  81268. * Gets or sets the number of columns requested (10 by default).
  81269. * The panel will automatically compute the number of rows based on number of child controls.
  81270. */
  81271. get columns(): BABYLON.int;
  81272. set columns(value: BABYLON.int);
  81273. /**
  81274. * Gets or sets a the number of rows requested.
  81275. * The panel will automatically compute the number of columns based on number of child controls.
  81276. */
  81277. get rows(): BABYLON.int;
  81278. set rows(value: BABYLON.int);
  81279. /**
  81280. * Creates new VolumeBasedPanel
  81281. */
  81282. constructor();
  81283. protected _arrangeChildren(): void;
  81284. /** Child classes must implement this function to provide correct control positioning */
  81285. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81286. /** Child classes can implement this function to provide additional processing */
  81287. protected _finalProcessing(): void;
  81288. }
  81289. }
  81290. declare module BABYLON.GUI {
  81291. /**
  81292. * Class used to create a container panel deployed on the surface of a cylinder
  81293. */
  81294. export class CylinderPanel extends VolumeBasedPanel {
  81295. private _radius;
  81296. /**
  81297. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  81298. */
  81299. get radius(): BABYLON.float;
  81300. set radius(value: BABYLON.float);
  81301. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81302. private _cylindricalMapping;
  81303. }
  81304. }
  81305. declare module BABYLON.GUI {
  81306. /** @hidden */
  81307. export var fluentVertexShader: {
  81308. name: string;
  81309. shader: string;
  81310. };
  81311. }
  81312. declare module BABYLON.GUI {
  81313. /** @hidden */
  81314. export var fluentPixelShader: {
  81315. name: string;
  81316. shader: string;
  81317. };
  81318. }
  81319. declare module BABYLON.GUI {
  81320. /** @hidden */
  81321. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  81322. INNERGLOW: boolean;
  81323. BORDER: boolean;
  81324. HOVERLIGHT: boolean;
  81325. TEXTURE: boolean;
  81326. constructor();
  81327. }
  81328. /**
  81329. * Class used to render controls with fluent desgin
  81330. */
  81331. export class FluentMaterial extends BABYLON.PushMaterial {
  81332. /**
  81333. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  81334. */
  81335. innerGlowColorIntensity: number;
  81336. /**
  81337. * Gets or sets the inner glow color (white by default)
  81338. */
  81339. innerGlowColor: BABYLON.Color3;
  81340. /**
  81341. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  81342. */
  81343. albedoColor: BABYLON.Color3;
  81344. /**
  81345. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  81346. */
  81347. renderBorders: boolean;
  81348. /**
  81349. * Gets or sets border width (default is 0.5)
  81350. */
  81351. borderWidth: number;
  81352. /**
  81353. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  81354. */
  81355. edgeSmoothingValue: number;
  81356. /**
  81357. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  81358. */
  81359. borderMinValue: number;
  81360. /**
  81361. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  81362. */
  81363. renderHoverLight: boolean;
  81364. /**
  81365. * Gets or sets the radius used to render the hover light (default is 1.0)
  81366. */
  81367. hoverRadius: number;
  81368. /**
  81369. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  81370. */
  81371. hoverColor: BABYLON.Color4;
  81372. /**
  81373. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  81374. */
  81375. hoverPosition: BABYLON.Vector3;
  81376. private _albedoTexture;
  81377. /** Gets or sets the texture to use for albedo color */
  81378. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81379. /**
  81380. * Creates a new Fluent material
  81381. * @param name defines the name of the material
  81382. * @param scene defines the hosting scene
  81383. */
  81384. constructor(name: string, scene: BABYLON.Scene);
  81385. needAlphaBlending(): boolean;
  81386. needAlphaTesting(): boolean;
  81387. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81388. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81389. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81390. getActiveTextures(): BABYLON.BaseTexture[];
  81391. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81392. dispose(forceDisposeEffect?: boolean): void;
  81393. clone(name: string): FluentMaterial;
  81394. serialize(): any;
  81395. getClassName(): string;
  81396. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  81397. }
  81398. }
  81399. declare module BABYLON.GUI {
  81400. /**
  81401. * Class used to create a holographic button in 3D
  81402. */
  81403. export class HolographicButton extends Button3D {
  81404. private _backPlate;
  81405. private _textPlate;
  81406. private _frontPlate;
  81407. private _text;
  81408. private _imageUrl;
  81409. private _shareMaterials;
  81410. private _frontMaterial;
  81411. private _backMaterial;
  81412. private _plateMaterial;
  81413. private _pickedPointObserver;
  81414. private _tooltipFade;
  81415. private _tooltipTextBlock;
  81416. private _tooltipTexture;
  81417. private _tooltipMesh;
  81418. private _tooltipHoverObserver;
  81419. private _tooltipOutObserver;
  81420. private _disposeTooltip;
  81421. /**
  81422. * Rendering ground id of all the mesh in the button
  81423. */
  81424. set renderingGroupId(id: number);
  81425. get renderingGroupId(): number;
  81426. /**
  81427. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  81428. */
  81429. set tooltipText(text: BABYLON.Nullable<string>);
  81430. get tooltipText(): BABYLON.Nullable<string>;
  81431. /**
  81432. * Gets or sets text for the button
  81433. */
  81434. get text(): string;
  81435. set text(value: string);
  81436. /**
  81437. * Gets or sets the image url for the button
  81438. */
  81439. get imageUrl(): string;
  81440. set imageUrl(value: string);
  81441. /**
  81442. * Gets the back material used by this button
  81443. */
  81444. get backMaterial(): FluentMaterial;
  81445. /**
  81446. * Gets the front material used by this button
  81447. */
  81448. get frontMaterial(): FluentMaterial;
  81449. /**
  81450. * Gets the plate material used by this button
  81451. */
  81452. get plateMaterial(): BABYLON.StandardMaterial;
  81453. /**
  81454. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  81455. */
  81456. get shareMaterials(): boolean;
  81457. /**
  81458. * Creates a new button
  81459. * @param name defines the control name
  81460. */
  81461. constructor(name?: string, shareMaterials?: boolean);
  81462. protected _getTypeName(): string;
  81463. private _rebuildContent;
  81464. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81465. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81466. private _createBackMaterial;
  81467. private _createFrontMaterial;
  81468. private _createPlateMaterial;
  81469. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  81470. /**
  81471. * Releases all associated resources
  81472. */
  81473. dispose(): void;
  81474. }
  81475. }
  81476. declare module BABYLON.GUI {
  81477. /**
  81478. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  81479. */
  81480. export class MeshButton3D extends Button3D {
  81481. /** @hidden */
  81482. protected _currentMesh: BABYLON.Mesh;
  81483. /**
  81484. * Creates a new 3D button based on a mesh
  81485. * @param mesh mesh to become a 3D button
  81486. * @param name defines the control name
  81487. */
  81488. constructor(mesh: BABYLON.Mesh, name?: string);
  81489. protected _getTypeName(): string;
  81490. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81491. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81492. }
  81493. }
  81494. declare module BABYLON.GUI {
  81495. /**
  81496. * Class used to create a container panel deployed on the surface of a plane
  81497. */
  81498. export class PlanePanel extends VolumeBasedPanel {
  81499. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81500. }
  81501. }
  81502. declare module BABYLON.GUI {
  81503. /**
  81504. * Class used to create a container panel where items get randomized planar mapping
  81505. */
  81506. export class ScatterPanel extends VolumeBasedPanel {
  81507. private _iteration;
  81508. /**
  81509. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  81510. */
  81511. get iteration(): BABYLON.float;
  81512. set iteration(value: BABYLON.float);
  81513. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81514. private _scatterMapping;
  81515. protected _finalProcessing(): void;
  81516. }
  81517. }
  81518. declare module BABYLON.GUI {
  81519. /**
  81520. * Class used to create a container panel deployed on the surface of a sphere
  81521. */
  81522. export class SpherePanel extends VolumeBasedPanel {
  81523. private _radius;
  81524. /**
  81525. * Gets or sets the radius of the sphere where to project controls (5 by default)
  81526. */
  81527. get radius(): BABYLON.float;
  81528. set radius(value: BABYLON.float);
  81529. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81530. private _sphericalMapping;
  81531. }
  81532. }
  81533. declare module BABYLON.GUI {
  81534. /**
  81535. * Class used to create a stack panel in 3D on XY plane
  81536. */
  81537. export class StackPanel3D extends Container3D {
  81538. private _isVertical;
  81539. /**
  81540. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  81541. */
  81542. get isVertical(): boolean;
  81543. set isVertical(value: boolean);
  81544. /**
  81545. * Gets or sets the distance between elements
  81546. */
  81547. margin: number;
  81548. /**
  81549. * Creates new StackPanel
  81550. * @param isVertical
  81551. */
  81552. constructor(isVertical?: boolean);
  81553. protected _arrangeChildren(): void;
  81554. }
  81555. }
  81556. declare module BABYLON {
  81557. /**
  81558. * Configuration for glTF validation
  81559. */
  81560. export interface IGLTFValidationConfiguration {
  81561. /**
  81562. * The url of the glTF validator.
  81563. */
  81564. url: string;
  81565. }
  81566. /**
  81567. * glTF validation
  81568. */
  81569. export class GLTFValidation {
  81570. /**
  81571. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  81572. */
  81573. static Configuration: IGLTFValidationConfiguration;
  81574. private static _LoadScriptPromise;
  81575. /**
  81576. * Validate a glTF asset using the glTF-Validator.
  81577. * @param data The JSON of a glTF or the array buffer of a binary glTF
  81578. * @param rootUrl The root url for the glTF
  81579. * @param fileName The file name for the glTF
  81580. * @param getExternalResource The callback to get external resources for the glTF validator
  81581. * @returns A promise that resolves with the glTF validation results once complete
  81582. */
  81583. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  81584. }
  81585. }
  81586. declare module BABYLON {
  81587. /**
  81588. * Mode that determines the coordinate system to use.
  81589. */
  81590. export enum GLTFLoaderCoordinateSystemMode {
  81591. /**
  81592. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  81593. */
  81594. AUTO = 0,
  81595. /**
  81596. * Sets the useRightHandedSystem flag on the scene.
  81597. */
  81598. FORCE_RIGHT_HANDED = 1
  81599. }
  81600. /**
  81601. * Mode that determines what animations will start.
  81602. */
  81603. export enum GLTFLoaderAnimationStartMode {
  81604. /**
  81605. * No animation will start.
  81606. */
  81607. NONE = 0,
  81608. /**
  81609. * The first animation will start.
  81610. */
  81611. FIRST = 1,
  81612. /**
  81613. * All animations will start.
  81614. */
  81615. ALL = 2
  81616. }
  81617. /**
  81618. * Interface that contains the data for the glTF asset.
  81619. */
  81620. export interface IGLTFLoaderData {
  81621. /**
  81622. * The object that represents the glTF JSON.
  81623. */
  81624. json: Object;
  81625. /**
  81626. * The BIN chunk of a binary glTF.
  81627. */
  81628. bin: Nullable<IDataBuffer>;
  81629. }
  81630. /**
  81631. * Interface for extending the loader.
  81632. */
  81633. export interface IGLTFLoaderExtension {
  81634. /**
  81635. * The name of this extension.
  81636. */
  81637. readonly name: string;
  81638. /**
  81639. * Defines whether this extension is enabled.
  81640. */
  81641. enabled: boolean;
  81642. /**
  81643. * Defines the order of this extension.
  81644. * The loader sorts the extensions using these values when loading.
  81645. */
  81646. order?: number;
  81647. }
  81648. /**
  81649. * Loader state.
  81650. */
  81651. export enum GLTFLoaderState {
  81652. /**
  81653. * The asset is loading.
  81654. */
  81655. LOADING = 0,
  81656. /**
  81657. * The asset is ready for rendering.
  81658. */
  81659. READY = 1,
  81660. /**
  81661. * The asset is completely loaded.
  81662. */
  81663. COMPLETE = 2
  81664. }
  81665. /** @hidden */
  81666. export interface IImportMeshAsyncOutput {
  81667. meshes: AbstractMesh[];
  81668. geometries: Geometry[];
  81669. particleSystems: IParticleSystem[];
  81670. skeletons: Skeleton[];
  81671. animationGroups: AnimationGroup[];
  81672. lights: Light[];
  81673. transformNodes: TransformNode[];
  81674. }
  81675. /** @hidden */
  81676. export interface IGLTFLoader extends IDisposable {
  81677. readonly state: Nullable<GLTFLoaderState>;
  81678. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  81679. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  81680. }
  81681. /**
  81682. * File loader for loading glTF files into a scene.
  81683. */
  81684. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81685. /** @hidden */
  81686. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81687. /** @hidden */
  81688. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81689. /**
  81690. * Raised when the asset has been parsed
  81691. */
  81692. onParsedObservable: Observable<IGLTFLoaderData>;
  81693. private _onParsedObserver;
  81694. /**
  81695. * Raised when the asset has been parsed
  81696. */
  81697. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  81698. /**
  81699. * 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.
  81700. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  81701. * Defaults to true.
  81702. * @hidden
  81703. */
  81704. static IncrementalLoading: boolean;
  81705. /**
  81706. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  81707. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  81708. * @hidden
  81709. */
  81710. static HomogeneousCoordinates: boolean;
  81711. /**
  81712. * The coordinate system mode. Defaults to AUTO.
  81713. */
  81714. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  81715. /**
  81716. * The animation start mode. Defaults to FIRST.
  81717. */
  81718. animationStartMode: GLTFLoaderAnimationStartMode;
  81719. /**
  81720. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  81721. */
  81722. compileMaterials: boolean;
  81723. /**
  81724. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  81725. */
  81726. useClipPlane: boolean;
  81727. /**
  81728. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  81729. */
  81730. compileShadowGenerators: boolean;
  81731. /**
  81732. * Defines if the Alpha blended materials are only applied as coverage.
  81733. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  81734. * If true, no extra effects are applied to transparent pixels.
  81735. */
  81736. transparencyAsCoverage: boolean;
  81737. /**
  81738. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  81739. * Enabling will disable offline support and glTF validator.
  81740. * Defaults to false.
  81741. */
  81742. useRangeRequests: boolean;
  81743. /**
  81744. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  81745. */
  81746. createInstances: boolean;
  81747. /**
  81748. * 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.
  81749. */
  81750. alwaysComputeBoundingBox: boolean;
  81751. /**
  81752. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  81753. */
  81754. loadAllMaterials: boolean;
  81755. /**
  81756. * Function called before loading a url referenced by the asset.
  81757. */
  81758. preprocessUrlAsync: (url: string) => Promise<string>;
  81759. /**
  81760. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81761. * 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, ...)
  81762. */
  81763. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  81764. private _onMeshLoadedObserver;
  81765. /**
  81766. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81767. * 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, ...)
  81768. */
  81769. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  81770. /**
  81771. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  81772. */
  81773. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  81774. private _onTextureLoadedObserver;
  81775. /**
  81776. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  81777. */
  81778. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  81779. /**
  81780. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  81781. */
  81782. readonly onMaterialLoadedObservable: Observable<Material>;
  81783. private _onMaterialLoadedObserver;
  81784. /**
  81785. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  81786. */
  81787. set onMaterialLoaded(callback: (material: Material) => void);
  81788. /**
  81789. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  81790. */
  81791. readonly onCameraLoadedObservable: Observable<Camera>;
  81792. private _onCameraLoadedObserver;
  81793. /**
  81794. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  81795. */
  81796. set onCameraLoaded(callback: (camera: Camera) => void);
  81797. /**
  81798. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  81799. * For assets with LODs, raised when all of the LODs are complete.
  81800. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81801. */
  81802. readonly onCompleteObservable: Observable<void>;
  81803. private _onCompleteObserver;
  81804. /**
  81805. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  81806. * For assets with LODs, raised when all of the LODs are complete.
  81807. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81808. */
  81809. set onComplete(callback: () => void);
  81810. /**
  81811. * Observable raised when an error occurs.
  81812. */
  81813. readonly onErrorObservable: Observable<any>;
  81814. private _onErrorObserver;
  81815. /**
  81816. * Callback raised when an error occurs.
  81817. */
  81818. set onError(callback: (reason: any) => void);
  81819. /**
  81820. * Observable raised after the loader is disposed.
  81821. */
  81822. readonly onDisposeObservable: Observable<void>;
  81823. private _onDisposeObserver;
  81824. /**
  81825. * Callback raised after the loader is disposed.
  81826. */
  81827. set onDispose(callback: () => void);
  81828. /**
  81829. * Observable raised after a loader extension is created.
  81830. * Set additional options for a loader extension in this event.
  81831. */
  81832. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  81833. private _onExtensionLoadedObserver;
  81834. /**
  81835. * Callback raised after a loader extension is created.
  81836. */
  81837. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  81838. /**
  81839. * Defines if the loader logging is enabled.
  81840. */
  81841. get loggingEnabled(): boolean;
  81842. set loggingEnabled(value: boolean);
  81843. /**
  81844. * Defines if the loader should capture performance counters.
  81845. */
  81846. get capturePerformanceCounters(): boolean;
  81847. set capturePerformanceCounters(value: boolean);
  81848. /**
  81849. * Defines if the loader should validate the asset.
  81850. */
  81851. validate: boolean;
  81852. /**
  81853. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  81854. */
  81855. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  81856. private _onValidatedObserver;
  81857. /**
  81858. * Callback raised after a loader extension is created.
  81859. */
  81860. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  81861. private _loader;
  81862. private _progressCallback?;
  81863. private _requests;
  81864. private static magicBase64Encoded;
  81865. /**
  81866. * Name of the loader ("gltf")
  81867. */
  81868. name: string;
  81869. /** @hidden */
  81870. extensions: ISceneLoaderPluginExtensions;
  81871. /**
  81872. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  81873. */
  81874. dispose(): void;
  81875. /** @hidden */
  81876. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81877. /** @hidden */
  81878. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81879. /** @hidden */
  81880. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81881. meshes: AbstractMesh[];
  81882. particleSystems: IParticleSystem[];
  81883. skeletons: Skeleton[];
  81884. animationGroups: AnimationGroup[];
  81885. }>;
  81886. /** @hidden */
  81887. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81888. /** @hidden */
  81889. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81890. /** @hidden */
  81891. canDirectLoad(data: string): boolean;
  81892. /** @hidden */
  81893. directLoad(scene: Scene, data: string): Promise<any>;
  81894. /**
  81895. * The callback that allows custom handling of the root url based on the response url.
  81896. * @param rootUrl the original root url
  81897. * @param responseURL the response url if available
  81898. * @returns the new root url
  81899. */
  81900. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  81901. /** @hidden */
  81902. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  81903. /**
  81904. * The loader state or null if the loader is not active.
  81905. */
  81906. get loaderState(): Nullable<GLTFLoaderState>;
  81907. /**
  81908. * Returns a promise that resolves when the asset is completely loaded.
  81909. * @returns a promise that resolves when the asset is completely loaded.
  81910. */
  81911. whenCompleteAsync(): Promise<void>;
  81912. /** @hidden */
  81913. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  81914. /** @hidden */
  81915. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  81916. private _onProgress;
  81917. private _validate;
  81918. private _getLoader;
  81919. private _parseJson;
  81920. private _unpackBinaryAsync;
  81921. private _unpackBinaryV1Async;
  81922. private _unpackBinaryV2Async;
  81923. private static _parseVersion;
  81924. private static _compareVersion;
  81925. private static readonly _logSpaces;
  81926. private _logIndentLevel;
  81927. private _loggingEnabled;
  81928. /** @hidden */
  81929. _log: (message: string) => void;
  81930. /** @hidden */
  81931. _logOpen(message: string): void;
  81932. /** @hidden */
  81933. _logClose(): void;
  81934. private _logEnabled;
  81935. private _logDisabled;
  81936. private _capturePerformanceCounters;
  81937. /** @hidden */
  81938. _startPerformanceCounter: (counterName: string) => void;
  81939. /** @hidden */
  81940. _endPerformanceCounter: (counterName: string) => void;
  81941. private _startPerformanceCounterEnabled;
  81942. private _startPerformanceCounterDisabled;
  81943. private _endPerformanceCounterEnabled;
  81944. private _endPerformanceCounterDisabled;
  81945. }
  81946. }
  81947. declare module BABYLON.GLTF1 {
  81948. /**
  81949. * Enums
  81950. * @hidden
  81951. */
  81952. export enum EComponentType {
  81953. BYTE = 5120,
  81954. UNSIGNED_BYTE = 5121,
  81955. SHORT = 5122,
  81956. UNSIGNED_SHORT = 5123,
  81957. FLOAT = 5126
  81958. }
  81959. /** @hidden */
  81960. export enum EShaderType {
  81961. FRAGMENT = 35632,
  81962. VERTEX = 35633
  81963. }
  81964. /** @hidden */
  81965. export enum EParameterType {
  81966. BYTE = 5120,
  81967. UNSIGNED_BYTE = 5121,
  81968. SHORT = 5122,
  81969. UNSIGNED_SHORT = 5123,
  81970. INT = 5124,
  81971. UNSIGNED_INT = 5125,
  81972. FLOAT = 5126,
  81973. FLOAT_VEC2 = 35664,
  81974. FLOAT_VEC3 = 35665,
  81975. FLOAT_VEC4 = 35666,
  81976. INT_VEC2 = 35667,
  81977. INT_VEC3 = 35668,
  81978. INT_VEC4 = 35669,
  81979. BOOL = 35670,
  81980. BOOL_VEC2 = 35671,
  81981. BOOL_VEC3 = 35672,
  81982. BOOL_VEC4 = 35673,
  81983. FLOAT_MAT2 = 35674,
  81984. FLOAT_MAT3 = 35675,
  81985. FLOAT_MAT4 = 35676,
  81986. SAMPLER_2D = 35678
  81987. }
  81988. /** @hidden */
  81989. export enum ETextureWrapMode {
  81990. CLAMP_TO_EDGE = 33071,
  81991. MIRRORED_REPEAT = 33648,
  81992. REPEAT = 10497
  81993. }
  81994. /** @hidden */
  81995. export enum ETextureFilterType {
  81996. NEAREST = 9728,
  81997. LINEAR = 9728,
  81998. NEAREST_MIPMAP_NEAREST = 9984,
  81999. LINEAR_MIPMAP_NEAREST = 9985,
  82000. NEAREST_MIPMAP_LINEAR = 9986,
  82001. LINEAR_MIPMAP_LINEAR = 9987
  82002. }
  82003. /** @hidden */
  82004. export enum ETextureFormat {
  82005. ALPHA = 6406,
  82006. RGB = 6407,
  82007. RGBA = 6408,
  82008. LUMINANCE = 6409,
  82009. LUMINANCE_ALPHA = 6410
  82010. }
  82011. /** @hidden */
  82012. export enum ECullingType {
  82013. FRONT = 1028,
  82014. BACK = 1029,
  82015. FRONT_AND_BACK = 1032
  82016. }
  82017. /** @hidden */
  82018. export enum EBlendingFunction {
  82019. ZERO = 0,
  82020. ONE = 1,
  82021. SRC_COLOR = 768,
  82022. ONE_MINUS_SRC_COLOR = 769,
  82023. DST_COLOR = 774,
  82024. ONE_MINUS_DST_COLOR = 775,
  82025. SRC_ALPHA = 770,
  82026. ONE_MINUS_SRC_ALPHA = 771,
  82027. DST_ALPHA = 772,
  82028. ONE_MINUS_DST_ALPHA = 773,
  82029. CONSTANT_COLOR = 32769,
  82030. ONE_MINUS_CONSTANT_COLOR = 32770,
  82031. CONSTANT_ALPHA = 32771,
  82032. ONE_MINUS_CONSTANT_ALPHA = 32772,
  82033. SRC_ALPHA_SATURATE = 776
  82034. }
  82035. /** @hidden */
  82036. export interface IGLTFProperty {
  82037. extensions?: {
  82038. [key: string]: any;
  82039. };
  82040. extras?: Object;
  82041. }
  82042. /** @hidden */
  82043. export interface IGLTFChildRootProperty extends IGLTFProperty {
  82044. name?: string;
  82045. }
  82046. /** @hidden */
  82047. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  82048. bufferView: string;
  82049. byteOffset: number;
  82050. byteStride: number;
  82051. count: number;
  82052. type: string;
  82053. componentType: EComponentType;
  82054. max?: number[];
  82055. min?: number[];
  82056. name?: string;
  82057. }
  82058. /** @hidden */
  82059. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  82060. buffer: string;
  82061. byteOffset: number;
  82062. byteLength: number;
  82063. byteStride: number;
  82064. target?: number;
  82065. }
  82066. /** @hidden */
  82067. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  82068. uri: string;
  82069. byteLength?: number;
  82070. type?: string;
  82071. }
  82072. /** @hidden */
  82073. export interface IGLTFShader extends IGLTFChildRootProperty {
  82074. uri: string;
  82075. type: EShaderType;
  82076. }
  82077. /** @hidden */
  82078. export interface IGLTFProgram extends IGLTFChildRootProperty {
  82079. attributes: string[];
  82080. fragmentShader: string;
  82081. vertexShader: string;
  82082. }
  82083. /** @hidden */
  82084. export interface IGLTFTechniqueParameter {
  82085. type: number;
  82086. count?: number;
  82087. semantic?: string;
  82088. node?: string;
  82089. value?: number | boolean | string | Array<any>;
  82090. source?: string;
  82091. babylonValue?: any;
  82092. }
  82093. /** @hidden */
  82094. export interface IGLTFTechniqueCommonProfile {
  82095. lightingModel: string;
  82096. texcoordBindings: Object;
  82097. parameters?: Array<any>;
  82098. }
  82099. /** @hidden */
  82100. export interface IGLTFTechniqueStatesFunctions {
  82101. blendColor?: number[];
  82102. blendEquationSeparate?: number[];
  82103. blendFuncSeparate?: number[];
  82104. colorMask: boolean[];
  82105. cullFace: number[];
  82106. }
  82107. /** @hidden */
  82108. export interface IGLTFTechniqueStates {
  82109. enable: number[];
  82110. functions: IGLTFTechniqueStatesFunctions;
  82111. }
  82112. /** @hidden */
  82113. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  82114. parameters: {
  82115. [key: string]: IGLTFTechniqueParameter;
  82116. };
  82117. program: string;
  82118. attributes: {
  82119. [key: string]: string;
  82120. };
  82121. uniforms: {
  82122. [key: string]: string;
  82123. };
  82124. states: IGLTFTechniqueStates;
  82125. }
  82126. /** @hidden */
  82127. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  82128. technique?: string;
  82129. values: string[];
  82130. }
  82131. /** @hidden */
  82132. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  82133. attributes: {
  82134. [key: string]: string;
  82135. };
  82136. indices: string;
  82137. material: string;
  82138. mode?: number;
  82139. }
  82140. /** @hidden */
  82141. export interface IGLTFMesh extends IGLTFChildRootProperty {
  82142. primitives: IGLTFMeshPrimitive[];
  82143. }
  82144. /** @hidden */
  82145. export interface IGLTFImage extends IGLTFChildRootProperty {
  82146. uri: string;
  82147. }
  82148. /** @hidden */
  82149. export interface IGLTFSampler extends IGLTFChildRootProperty {
  82150. magFilter?: number;
  82151. minFilter?: number;
  82152. wrapS?: number;
  82153. wrapT?: number;
  82154. }
  82155. /** @hidden */
  82156. export interface IGLTFTexture extends IGLTFChildRootProperty {
  82157. sampler: string;
  82158. source: string;
  82159. format?: ETextureFormat;
  82160. internalFormat?: ETextureFormat;
  82161. target?: number;
  82162. type?: number;
  82163. babylonTexture?: Texture;
  82164. }
  82165. /** @hidden */
  82166. export interface IGLTFAmbienLight {
  82167. color?: number[];
  82168. }
  82169. /** @hidden */
  82170. export interface IGLTFDirectionalLight {
  82171. color?: number[];
  82172. }
  82173. /** @hidden */
  82174. export interface IGLTFPointLight {
  82175. color?: number[];
  82176. constantAttenuation?: number;
  82177. linearAttenuation?: number;
  82178. quadraticAttenuation?: number;
  82179. }
  82180. /** @hidden */
  82181. export interface IGLTFSpotLight {
  82182. color?: number[];
  82183. constantAttenuation?: number;
  82184. fallOfAngle?: number;
  82185. fallOffExponent?: number;
  82186. linearAttenuation?: number;
  82187. quadraticAttenuation?: number;
  82188. }
  82189. /** @hidden */
  82190. export interface IGLTFLight extends IGLTFChildRootProperty {
  82191. type: string;
  82192. }
  82193. /** @hidden */
  82194. export interface IGLTFCameraOrthographic {
  82195. xmag: number;
  82196. ymag: number;
  82197. zfar: number;
  82198. znear: number;
  82199. }
  82200. /** @hidden */
  82201. export interface IGLTFCameraPerspective {
  82202. aspectRatio: number;
  82203. yfov: number;
  82204. zfar: number;
  82205. znear: number;
  82206. }
  82207. /** @hidden */
  82208. export interface IGLTFCamera extends IGLTFChildRootProperty {
  82209. type: string;
  82210. }
  82211. /** @hidden */
  82212. export interface IGLTFAnimationChannelTarget {
  82213. id: string;
  82214. path: string;
  82215. }
  82216. /** @hidden */
  82217. export interface IGLTFAnimationChannel {
  82218. sampler: string;
  82219. target: IGLTFAnimationChannelTarget;
  82220. }
  82221. /** @hidden */
  82222. export interface IGLTFAnimationSampler {
  82223. input: string;
  82224. output: string;
  82225. interpolation?: string;
  82226. }
  82227. /** @hidden */
  82228. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  82229. channels?: IGLTFAnimationChannel[];
  82230. parameters?: {
  82231. [key: string]: string;
  82232. };
  82233. samplers?: {
  82234. [key: string]: IGLTFAnimationSampler;
  82235. };
  82236. }
  82237. /** @hidden */
  82238. export interface IGLTFNodeInstanceSkin {
  82239. skeletons: string[];
  82240. skin: string;
  82241. meshes: string[];
  82242. }
  82243. /** @hidden */
  82244. export interface IGLTFSkins extends IGLTFChildRootProperty {
  82245. bindShapeMatrix: number[];
  82246. inverseBindMatrices: string;
  82247. jointNames: string[];
  82248. babylonSkeleton?: Skeleton;
  82249. }
  82250. /** @hidden */
  82251. export interface IGLTFNode extends IGLTFChildRootProperty {
  82252. camera?: string;
  82253. children: string[];
  82254. skin?: string;
  82255. jointName?: string;
  82256. light?: string;
  82257. matrix: number[];
  82258. mesh?: string;
  82259. meshes?: string[];
  82260. rotation?: number[];
  82261. scale?: number[];
  82262. translation?: number[];
  82263. babylonNode?: Node;
  82264. }
  82265. /** @hidden */
  82266. export interface IGLTFScene extends IGLTFChildRootProperty {
  82267. nodes: string[];
  82268. }
  82269. /** @hidden */
  82270. export interface IGLTFRuntime {
  82271. extensions: {
  82272. [key: string]: any;
  82273. };
  82274. accessors: {
  82275. [key: string]: IGLTFAccessor;
  82276. };
  82277. buffers: {
  82278. [key: string]: IGLTFBuffer;
  82279. };
  82280. bufferViews: {
  82281. [key: string]: IGLTFBufferView;
  82282. };
  82283. meshes: {
  82284. [key: string]: IGLTFMesh;
  82285. };
  82286. lights: {
  82287. [key: string]: IGLTFLight;
  82288. };
  82289. cameras: {
  82290. [key: string]: IGLTFCamera;
  82291. };
  82292. nodes: {
  82293. [key: string]: IGLTFNode;
  82294. };
  82295. images: {
  82296. [key: string]: IGLTFImage;
  82297. };
  82298. textures: {
  82299. [key: string]: IGLTFTexture;
  82300. };
  82301. shaders: {
  82302. [key: string]: IGLTFShader;
  82303. };
  82304. programs: {
  82305. [key: string]: IGLTFProgram;
  82306. };
  82307. samplers: {
  82308. [key: string]: IGLTFSampler;
  82309. };
  82310. techniques: {
  82311. [key: string]: IGLTFTechnique;
  82312. };
  82313. materials: {
  82314. [key: string]: IGLTFMaterial;
  82315. };
  82316. animations: {
  82317. [key: string]: IGLTFAnimation;
  82318. };
  82319. skins: {
  82320. [key: string]: IGLTFSkins;
  82321. };
  82322. currentScene?: Object;
  82323. scenes: {
  82324. [key: string]: IGLTFScene;
  82325. };
  82326. extensionsUsed: string[];
  82327. extensionsRequired?: string[];
  82328. buffersCount: number;
  82329. shaderscount: number;
  82330. scene: Scene;
  82331. rootUrl: string;
  82332. loadedBufferCount: number;
  82333. loadedBufferViews: {
  82334. [name: string]: ArrayBufferView;
  82335. };
  82336. loadedShaderCount: number;
  82337. importOnlyMeshes: boolean;
  82338. importMeshesNames?: string[];
  82339. dummyNodes: Node[];
  82340. forAssetContainer: boolean;
  82341. }
  82342. /** @hidden */
  82343. export interface INodeToRoot {
  82344. bone: Bone;
  82345. node: IGLTFNode;
  82346. id: string;
  82347. }
  82348. /** @hidden */
  82349. export interface IJointNode {
  82350. node: IGLTFNode;
  82351. id: string;
  82352. }
  82353. }
  82354. declare module BABYLON.GLTF1 {
  82355. /**
  82356. * Utils functions for GLTF
  82357. * @hidden
  82358. */
  82359. export class GLTFUtils {
  82360. /**
  82361. * Sets the given "parameter" matrix
  82362. * @param scene: the Scene object
  82363. * @param source: the source node where to pick the matrix
  82364. * @param parameter: the GLTF technique parameter
  82365. * @param uniformName: the name of the shader's uniform
  82366. * @param shaderMaterial: the shader material
  82367. */
  82368. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  82369. /**
  82370. * Sets the given "parameter" matrix
  82371. * @param shaderMaterial: the shader material
  82372. * @param uniform: the name of the shader's uniform
  82373. * @param value: the value of the uniform
  82374. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  82375. */
  82376. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  82377. /**
  82378. * Returns the wrap mode of the texture
  82379. * @param mode: the mode value
  82380. */
  82381. static GetWrapMode(mode: number): number;
  82382. /**
  82383. * Returns the byte stride giving an accessor
  82384. * @param accessor: the GLTF accessor objet
  82385. */
  82386. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  82387. /**
  82388. * Returns the texture filter mode giving a mode value
  82389. * @param mode: the filter mode value
  82390. */
  82391. static GetTextureFilterMode(mode: number): ETextureFilterType;
  82392. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  82393. /**
  82394. * Returns a buffer from its accessor
  82395. * @param gltfRuntime: the GLTF runtime
  82396. * @param accessor: the GLTF accessor
  82397. */
  82398. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  82399. /**
  82400. * Decodes a buffer view into a string
  82401. * @param view: the buffer view
  82402. */
  82403. static DecodeBufferToText(view: ArrayBufferView): string;
  82404. /**
  82405. * Returns the default material of gltf. Related to
  82406. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  82407. * @param scene: the Babylon.js scene
  82408. */
  82409. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  82410. private static _DefaultMaterial;
  82411. }
  82412. }
  82413. declare module BABYLON.GLTF1 {
  82414. /**
  82415. * Implementation of the base glTF spec
  82416. * @hidden
  82417. */
  82418. export class GLTFLoaderBase {
  82419. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  82420. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82421. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  82422. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82423. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  82424. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82425. }
  82426. /**
  82427. * glTF V1 Loader
  82428. * @hidden
  82429. */
  82430. export class GLTFLoader implements IGLTFLoader {
  82431. static Extensions: {
  82432. [name: string]: GLTFLoaderExtension;
  82433. };
  82434. static RegisterExtension(extension: GLTFLoaderExtension): void;
  82435. state: Nullable<GLTFLoaderState>;
  82436. dispose(): void;
  82437. private _importMeshAsync;
  82438. /**
  82439. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  82440. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82441. * @param scene the scene the meshes should be added to
  82442. * @param forAssetContainer defines if the entities must be stored in the scene
  82443. * @param data gltf data containing information of the meshes in a loaded file
  82444. * @param rootUrl root url to load from
  82445. * @param onProgress event that fires when loading progress has occured
  82446. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82447. */
  82448. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  82449. private _loadAsync;
  82450. /**
  82451. * Imports all objects from a loaded gltf file and adds them to the scene
  82452. * @param scene the scene the objects should be added to
  82453. * @param data gltf data containing information of the meshes in a loaded file
  82454. * @param rootUrl root url to load from
  82455. * @param onProgress event that fires when loading progress has occured
  82456. * @returns a promise which completes when objects have been loaded to the scene
  82457. */
  82458. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  82459. private _loadShadersAsync;
  82460. private _loadBuffersAsync;
  82461. private _createNodes;
  82462. }
  82463. /** @hidden */
  82464. export abstract class GLTFLoaderExtension {
  82465. private _name;
  82466. constructor(name: string);
  82467. get name(): string;
  82468. /**
  82469. * Defines an override for loading the runtime
  82470. * Return true to stop further extensions from loading the runtime
  82471. */
  82472. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  82473. /**
  82474. * Defines an onverride for creating gltf runtime
  82475. * Return true to stop further extensions from creating the runtime
  82476. */
  82477. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  82478. /**
  82479. * Defines an override for loading buffers
  82480. * Return true to stop further extensions from loading this buffer
  82481. */
  82482. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  82483. /**
  82484. * Defines an override for loading texture buffers
  82485. * Return true to stop further extensions from loading this texture data
  82486. */
  82487. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82488. /**
  82489. * Defines an override for creating textures
  82490. * Return true to stop further extensions from loading this texture
  82491. */
  82492. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  82493. /**
  82494. * Defines an override for loading shader strings
  82495. * Return true to stop further extensions from loading this shader data
  82496. */
  82497. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82498. /**
  82499. * Defines an override for loading materials
  82500. * Return true to stop further extensions from loading this material
  82501. */
  82502. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82503. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82504. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82505. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82506. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82507. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82508. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82509. private static LoadTextureBufferAsync;
  82510. private static CreateTextureAsync;
  82511. private static ApplyExtensions;
  82512. }
  82513. }
  82514. declare module BABYLON.GLTF1 {
  82515. /** @hidden */
  82516. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82517. private _bin;
  82518. constructor();
  82519. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82520. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82521. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82522. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82523. }
  82524. }
  82525. declare module BABYLON.GLTF1 {
  82526. /** @hidden */
  82527. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  82528. constructor();
  82529. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  82530. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82531. private _loadTexture;
  82532. }
  82533. }
  82534. declare module BABYLON.GLTF2.Loader {
  82535. /**
  82536. * Loader interface with an index field.
  82537. */
  82538. export interface IArrayItem {
  82539. /**
  82540. * The index of this item in the array.
  82541. */
  82542. index: number;
  82543. }
  82544. /**
  82545. * Loader interface with additional members.
  82546. */
  82547. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  82548. /** @hidden */
  82549. _data?: Promise<ArrayBufferView>;
  82550. /** @hidden */
  82551. _babylonVertexBuffer?: Promise<VertexBuffer>;
  82552. }
  82553. /**
  82554. * Loader interface with additional members.
  82555. */
  82556. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  82557. }
  82558. /** @hidden */
  82559. export interface _IAnimationSamplerData {
  82560. input: Float32Array;
  82561. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  82562. output: Float32Array;
  82563. }
  82564. /**
  82565. * Loader interface with additional members.
  82566. */
  82567. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  82568. /** @hidden */
  82569. _data?: Promise<_IAnimationSamplerData>;
  82570. }
  82571. /**
  82572. * Loader interface with additional members.
  82573. */
  82574. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  82575. channels: IAnimationChannel[];
  82576. samplers: IAnimationSampler[];
  82577. /** @hidden */
  82578. _babylonAnimationGroup?: AnimationGroup;
  82579. }
  82580. /**
  82581. * Loader interface with additional members.
  82582. */
  82583. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  82584. /** @hidden */
  82585. _data?: Promise<ArrayBufferView>;
  82586. }
  82587. /**
  82588. * Loader interface with additional members.
  82589. */
  82590. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  82591. /** @hidden */
  82592. _data?: Promise<ArrayBufferView>;
  82593. /** @hidden */
  82594. _babylonBuffer?: Promise<Buffer>;
  82595. }
  82596. /**
  82597. * Loader interface with additional members.
  82598. */
  82599. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  82600. }
  82601. /**
  82602. * Loader interface with additional members.
  82603. */
  82604. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  82605. /** @hidden */
  82606. _data?: Promise<ArrayBufferView>;
  82607. }
  82608. /**
  82609. * Loader interface with additional members.
  82610. */
  82611. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  82612. }
  82613. /**
  82614. * Loader interface with additional members.
  82615. */
  82616. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  82617. }
  82618. /**
  82619. * Loader interface with additional members.
  82620. */
  82621. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  82622. baseColorTexture?: ITextureInfo;
  82623. metallicRoughnessTexture?: ITextureInfo;
  82624. }
  82625. /**
  82626. * Loader interface with additional members.
  82627. */
  82628. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  82629. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82630. normalTexture?: IMaterialNormalTextureInfo;
  82631. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82632. emissiveTexture?: ITextureInfo;
  82633. /** @hidden */
  82634. _data?: {
  82635. [babylonDrawMode: number]: {
  82636. babylonMaterial: Material;
  82637. babylonMeshes: AbstractMesh[];
  82638. promise: Promise<void>;
  82639. };
  82640. };
  82641. }
  82642. /**
  82643. * Loader interface with additional members.
  82644. */
  82645. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  82646. primitives: IMeshPrimitive[];
  82647. }
  82648. /**
  82649. * Loader interface with additional members.
  82650. */
  82651. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  82652. /** @hidden */
  82653. _instanceData?: {
  82654. babylonSourceMesh: Mesh;
  82655. promise: Promise<any>;
  82656. };
  82657. }
  82658. /**
  82659. * Loader interface with additional members.
  82660. */
  82661. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  82662. /**
  82663. * The parent glTF node.
  82664. */
  82665. parent?: INode;
  82666. /** @hidden */
  82667. _babylonTransformNode?: TransformNode;
  82668. /** @hidden */
  82669. _primitiveBabylonMeshes?: AbstractMesh[];
  82670. /** @hidden */
  82671. _babylonBones?: Bone[];
  82672. /** @hidden */
  82673. _numMorphTargets?: number;
  82674. }
  82675. /** @hidden */
  82676. export interface _ISamplerData {
  82677. noMipMaps: boolean;
  82678. samplingMode: number;
  82679. wrapU: number;
  82680. wrapV: number;
  82681. }
  82682. /**
  82683. * Loader interface with additional members.
  82684. */
  82685. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  82686. /** @hidden */
  82687. _data?: _ISamplerData;
  82688. }
  82689. /**
  82690. * Loader interface with additional members.
  82691. */
  82692. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  82693. }
  82694. /**
  82695. * Loader interface with additional members.
  82696. */
  82697. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  82698. /** @hidden */
  82699. _data?: {
  82700. babylonSkeleton: Skeleton;
  82701. promise: Promise<void>;
  82702. };
  82703. }
  82704. /**
  82705. * Loader interface with additional members.
  82706. */
  82707. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  82708. }
  82709. /**
  82710. * Loader interface with additional members.
  82711. */
  82712. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  82713. }
  82714. /**
  82715. * Loader interface with additional members.
  82716. */
  82717. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  82718. accessors?: IAccessor[];
  82719. animations?: IAnimation[];
  82720. buffers?: IBuffer[];
  82721. bufferViews?: IBufferView[];
  82722. cameras?: ICamera[];
  82723. images?: IImage[];
  82724. materials?: IMaterial[];
  82725. meshes?: IMesh[];
  82726. nodes?: INode[];
  82727. samplers?: ISampler[];
  82728. scenes?: IScene[];
  82729. skins?: ISkin[];
  82730. textures?: ITexture[];
  82731. }
  82732. }
  82733. declare module BABYLON.GLTF2 {
  82734. /**
  82735. * Interface for a glTF loader extension.
  82736. */
  82737. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  82738. /**
  82739. * Called after the loader state changes to LOADING.
  82740. */
  82741. onLoading?(): void;
  82742. /**
  82743. * Called after the loader state changes to READY.
  82744. */
  82745. onReady?(): void;
  82746. /**
  82747. * Define this method to modify the default behavior when loading scenes.
  82748. * @param context The context when loading the asset
  82749. * @param scene The glTF scene property
  82750. * @returns A promise that resolves when the load is complete or null if not handled
  82751. */
  82752. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  82753. /**
  82754. * Define this method to modify the default behavior when loading nodes.
  82755. * @param context The context when loading the asset
  82756. * @param node The glTF node property
  82757. * @param assign A function called synchronously after parsing the glTF properties
  82758. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  82759. */
  82760. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82761. /**
  82762. * Define this method to modify the default behavior when loading cameras.
  82763. * @param context The context when loading the asset
  82764. * @param camera The glTF camera property
  82765. * @param assign A function called synchronously after parsing the glTF properties
  82766. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  82767. */
  82768. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82769. /**
  82770. * @hidden
  82771. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  82772. * @param context The context when loading the asset
  82773. * @param primitive The glTF mesh primitive property
  82774. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  82775. */
  82776. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82777. /**
  82778. * @hidden
  82779. * Define this method to modify the default behavior when loading data for mesh primitives.
  82780. * @param context The context when loading the asset
  82781. * @param name The mesh name when loading the asset
  82782. * @param node The glTF node when loading the asset
  82783. * @param mesh The glTF mesh when loading the asset
  82784. * @param primitive The glTF mesh primitive property
  82785. * @param assign A function called synchronously after parsing the glTF properties
  82786. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82787. */
  82788. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82789. /**
  82790. * @hidden
  82791. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  82792. * @param context The context when loading the asset
  82793. * @param material The glTF material property
  82794. * @param assign A function called synchronously after parsing the glTF properties
  82795. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  82796. */
  82797. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82798. /**
  82799. * Define this method to modify the default behavior when creating materials.
  82800. * @param context The context when loading the asset
  82801. * @param material The glTF material property
  82802. * @param babylonDrawMode The draw mode for the Babylon material
  82803. * @returns The Babylon material or null if not handled
  82804. */
  82805. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82806. /**
  82807. * Define this method to modify the default behavior when loading material properties.
  82808. * @param context The context when loading the asset
  82809. * @param material The glTF material property
  82810. * @param babylonMaterial The Babylon material
  82811. * @returns A promise that resolves when the load is complete or null if not handled
  82812. */
  82813. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82814. /**
  82815. * Define this method to modify the default behavior when loading texture infos.
  82816. * @param context The context when loading the asset
  82817. * @param textureInfo The glTF texture info property
  82818. * @param assign A function called synchronously after parsing the glTF properties
  82819. * @param isColorData true if the texture held color data, else false
  82820. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82821. */
  82822. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void, isColorData: boolean): Nullable<Promise<BaseTexture>>;
  82823. /**
  82824. * @hidden
  82825. * Define this method to modify the default behavior when loading textures.
  82826. * @param context The context when loading the asset
  82827. * @param texture The glTF texture property
  82828. * @param assign A function called synchronously after parsing the glTF properties
  82829. * @param isColorData true if the texture held color data, else false
  82830. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82831. */
  82832. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void, isColorData: boolean): Nullable<Promise<BaseTexture>>;
  82833. /**
  82834. * Define this method to modify the default behavior when loading animations.
  82835. * @param context The context when loading the asset
  82836. * @param animation The glTF animation property
  82837. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  82838. */
  82839. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82840. /**
  82841. * @hidden
  82842. * Define this method to modify the default behavior when loading skins.
  82843. * @param context The context when loading the asset
  82844. * @param node The glTF node property
  82845. * @param skin The glTF skin property
  82846. * @returns A promise that resolves when the load is complete or null if not handled
  82847. */
  82848. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  82849. /**
  82850. * @hidden
  82851. * Define this method to modify the default behavior when loading uris.
  82852. * @param context The context when loading the asset
  82853. * @param property The glTF property associated with the uri
  82854. * @param uri The uri to load
  82855. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82856. */
  82857. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82858. /**
  82859. * Define this method to modify the default behavior when loading buffer views.
  82860. * @param context The context when loading the asset
  82861. * @param bufferView The glTF buffer view property
  82862. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82863. */
  82864. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  82865. /**
  82866. * Define this method to modify the default behavior when loading buffers.
  82867. * @param context The context when loading the asset
  82868. * @param buffer The glTF buffer property
  82869. * @param byteOffset The byte offset to load
  82870. * @param byteLength The byte length to load
  82871. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82872. */
  82873. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82874. }
  82875. }
  82876. declare module BABYLON.GLTF2 {
  82877. /**
  82878. * Helper class for working with arrays when loading the glTF asset
  82879. */
  82880. export class ArrayItem {
  82881. /**
  82882. * Gets an item from the given array.
  82883. * @param context The context when loading the asset
  82884. * @param array The array to get the item from
  82885. * @param index The index to the array
  82886. * @returns The array item
  82887. */
  82888. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  82889. /**
  82890. * Assign an `index` field to each item of the given array.
  82891. * @param array The array of items
  82892. */
  82893. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  82894. }
  82895. /**
  82896. * The glTF 2.0 loader
  82897. */
  82898. export class GLTFLoader implements IGLTFLoader {
  82899. /** @hidden */
  82900. _completePromises: Promise<any>[];
  82901. /** @hidden */
  82902. _forAssetContainer: boolean;
  82903. /** Storage */
  82904. _babylonLights: Light[];
  82905. /** @hidden */
  82906. _disableInstancedMesh: number;
  82907. private _disposed;
  82908. private _parent;
  82909. private _state;
  82910. private _extensions;
  82911. private _rootUrl;
  82912. private _fileName;
  82913. private _uniqueRootUrl;
  82914. private _gltf;
  82915. private _bin;
  82916. private _babylonScene;
  82917. private _rootBabylonMesh;
  82918. private _defaultBabylonMaterialData;
  82919. private static _RegisteredExtensions;
  82920. /**
  82921. * The default glTF sampler.
  82922. */
  82923. static readonly DefaultSampler: ISampler;
  82924. /**
  82925. * Registers a loader extension.
  82926. * @param name The name of the loader extension.
  82927. * @param factory The factory function that creates the loader extension.
  82928. */
  82929. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  82930. /**
  82931. * Unregisters a loader extension.
  82932. * @param name The name of the loader extension.
  82933. * @returns A boolean indicating whether the extension has been unregistered
  82934. */
  82935. static UnregisterExtension(name: string): boolean;
  82936. /**
  82937. * The loader state.
  82938. */
  82939. get state(): Nullable<GLTFLoaderState>;
  82940. /**
  82941. * The object that represents the glTF JSON.
  82942. */
  82943. get gltf(): IGLTF;
  82944. /**
  82945. * The BIN chunk of a binary glTF.
  82946. */
  82947. get bin(): Nullable<IDataBuffer>;
  82948. /**
  82949. * The parent file loader.
  82950. */
  82951. get parent(): GLTFFileLoader;
  82952. /**
  82953. * The Babylon scene when loading the asset.
  82954. */
  82955. get babylonScene(): Scene;
  82956. /**
  82957. * The root Babylon mesh when loading the asset.
  82958. */
  82959. get rootBabylonMesh(): Mesh;
  82960. /** @hidden */
  82961. constructor(parent: GLTFFileLoader);
  82962. /** @hidden */
  82963. dispose(): void;
  82964. /** @hidden */
  82965. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  82966. /** @hidden */
  82967. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82968. private _loadAsync;
  82969. private _loadData;
  82970. private _setupData;
  82971. private _loadExtensions;
  82972. private _checkExtensions;
  82973. private _setState;
  82974. private _createRootNode;
  82975. /**
  82976. * Loads a glTF scene.
  82977. * @param context The context when loading the asset
  82978. * @param scene The glTF scene property
  82979. * @returns A promise that resolves when the load is complete
  82980. */
  82981. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  82982. private _forEachPrimitive;
  82983. private _getGeometries;
  82984. private _getMeshes;
  82985. private _getTransformNodes;
  82986. private _getSkeletons;
  82987. private _getAnimationGroups;
  82988. private _startAnimations;
  82989. /**
  82990. * Loads a glTF node.
  82991. * @param context The context when loading the asset
  82992. * @param node The glTF node property
  82993. * @param assign A function called synchronously after parsing the glTF properties
  82994. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  82995. */
  82996. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  82997. private _loadMeshAsync;
  82998. /**
  82999. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  83000. * @param context The context when loading the asset
  83001. * @param name The mesh name when loading the asset
  83002. * @param node The glTF node when loading the asset
  83003. * @param mesh The glTF mesh when loading the asset
  83004. * @param primitive The glTF mesh primitive property
  83005. * @param assign A function called synchronously after parsing the glTF properties
  83006. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83007. */
  83008. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  83009. private _loadVertexDataAsync;
  83010. private _createMorphTargets;
  83011. private _loadMorphTargetsAsync;
  83012. private _loadMorphTargetVertexDataAsync;
  83013. private static _LoadTransform;
  83014. private _loadSkinAsync;
  83015. private _loadBones;
  83016. private _loadBone;
  83017. private _loadSkinInverseBindMatricesDataAsync;
  83018. private _updateBoneMatrices;
  83019. private _getNodeMatrix;
  83020. /**
  83021. * Loads a glTF camera.
  83022. * @param context The context when loading the asset
  83023. * @param camera The glTF camera property
  83024. * @param assign A function called synchronously after parsing the glTF properties
  83025. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  83026. */
  83027. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  83028. private _loadAnimationsAsync;
  83029. /**
  83030. * Loads a glTF animation.
  83031. * @param context The context when loading the asset
  83032. * @param animation The glTF animation property
  83033. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  83034. */
  83035. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  83036. /**
  83037. * @hidden Loads a glTF animation channel.
  83038. * @param context The context when loading the asset
  83039. * @param animationContext The context of the animation when loading the asset
  83040. * @param animation The glTF animation property
  83041. * @param channel The glTF animation channel property
  83042. * @param babylonAnimationGroup The babylon animation group property
  83043. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  83044. * @returns A void promise when the channel load is complete
  83045. */
  83046. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  83047. private _loadAnimationSamplerAsync;
  83048. private _loadBufferAsync;
  83049. /**
  83050. * Loads a glTF buffer view.
  83051. * @param context The context when loading the asset
  83052. * @param bufferView The glTF buffer view property
  83053. * @returns A promise that resolves with the loaded data when the load is complete
  83054. */
  83055. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  83056. private _loadAccessorAsync;
  83057. /** @hidden */
  83058. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  83059. private _loadIndicesAccessorAsync;
  83060. private _loadVertexBufferViewAsync;
  83061. private _loadVertexAccessorAsync;
  83062. private _loadMaterialMetallicRoughnessPropertiesAsync;
  83063. /** @hidden */
  83064. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  83065. private _createDefaultMaterial;
  83066. /**
  83067. * Creates a Babylon material from a glTF material.
  83068. * @param context The context when loading the asset
  83069. * @param material The glTF material property
  83070. * @param babylonDrawMode The draw mode for the Babylon material
  83071. * @returns The Babylon material
  83072. */
  83073. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  83074. /**
  83075. * Loads properties from a glTF material into a Babylon material.
  83076. * @param context The context when loading the asset
  83077. * @param material The glTF material property
  83078. * @param babylonMaterial The Babylon material
  83079. * @returns A promise that resolves when the load is complete
  83080. */
  83081. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83082. /**
  83083. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  83084. * @param context The context when loading the asset
  83085. * @param material The glTF material property
  83086. * @param babylonMaterial The Babylon material
  83087. * @returns A promise that resolves when the load is complete
  83088. */
  83089. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83090. /**
  83091. * Loads the alpha properties from a glTF material into a Babylon material.
  83092. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  83093. * @param context The context when loading the asset
  83094. * @param material The glTF material property
  83095. * @param babylonMaterial The Babylon material
  83096. */
  83097. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  83098. /**
  83099. * Loads a glTF texture info.
  83100. * @param context The context when loading the asset
  83101. * @param textureInfo The glTF texture info property
  83102. * @param assign A function called synchronously after parsing the glTF properties
  83103. * @param isColorData true if the texture held color data, else false
  83104. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  83105. */
  83106. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void, isColorData?: boolean): Promise<BaseTexture>;
  83107. /** @hidden */
  83108. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void, isColorData?: boolean): Promise<BaseTexture>;
  83109. /** @hidden */
  83110. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  83111. private _loadSampler;
  83112. /**
  83113. * Loads a glTF image.
  83114. * @param context The context when loading the asset
  83115. * @param image The glTF image property
  83116. * @returns A promise that resolves with the loaded data when the load is complete
  83117. */
  83118. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  83119. /**
  83120. * Loads a glTF uri.
  83121. * @param context The context when loading the asset
  83122. * @param property The glTF property associated with the uri
  83123. * @param uri The base64 or relative uri
  83124. * @returns A promise that resolves with the loaded data when the load is complete
  83125. */
  83126. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  83127. /**
  83128. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  83129. * @param babylonObject the Babylon object with metadata
  83130. * @param pointer the JSON pointer
  83131. */
  83132. static AddPointerMetadata(babylonObject: {
  83133. metadata: any;
  83134. }, pointer: string): void;
  83135. private static _GetTextureWrapMode;
  83136. private static _GetTextureSamplingMode;
  83137. private static _GetTypedArrayConstructor;
  83138. private static _GetTypedArray;
  83139. private static _GetNumComponents;
  83140. private static _ValidateUri;
  83141. /** @hidden */
  83142. static _GetDrawMode(context: string, mode: number | undefined): number;
  83143. private _compileMaterialsAsync;
  83144. private _compileShadowGeneratorsAsync;
  83145. private _forEachExtensions;
  83146. private _applyExtensions;
  83147. private _extensionsOnLoading;
  83148. private _extensionsOnReady;
  83149. private _extensionsLoadSceneAsync;
  83150. private _extensionsLoadNodeAsync;
  83151. private _extensionsLoadCameraAsync;
  83152. private _extensionsLoadVertexDataAsync;
  83153. private _extensionsLoadMeshPrimitiveAsync;
  83154. private _extensionsLoadMaterialAsync;
  83155. private _extensionsCreateMaterial;
  83156. private _extensionsLoadMaterialPropertiesAsync;
  83157. private _extensionsLoadTextureInfoAsync;
  83158. private _extensionsLoadTextureAsync;
  83159. private _extensionsLoadAnimationAsync;
  83160. private _extensionsLoadSkinAsync;
  83161. private _extensionsLoadUriAsync;
  83162. private _extensionsLoadBufferViewAsync;
  83163. private _extensionsLoadBufferAsync;
  83164. /**
  83165. * Helper method called by a loader extension to load an glTF extension.
  83166. * @param context The context when loading the asset
  83167. * @param property The glTF property to load the extension from
  83168. * @param extensionName The name of the extension to load
  83169. * @param actionAsync The action to run
  83170. * @returns The promise returned by actionAsync or null if the extension does not exist
  83171. */
  83172. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83173. /**
  83174. * Helper method called by a loader extension to load a glTF extra.
  83175. * @param context The context when loading the asset
  83176. * @param property The glTF property to load the extra from
  83177. * @param extensionName The name of the extension to load
  83178. * @param actionAsync The action to run
  83179. * @returns The promise returned by actionAsync or null if the extra does not exist
  83180. */
  83181. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83182. /**
  83183. * Checks for presence of an extension.
  83184. * @param name The name of the extension to check
  83185. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  83186. */
  83187. isExtensionUsed(name: string): boolean;
  83188. /**
  83189. * Increments the indentation level and logs a message.
  83190. * @param message The message to log
  83191. */
  83192. logOpen(message: string): void;
  83193. /**
  83194. * Decrements the indentation level.
  83195. */
  83196. logClose(): void;
  83197. /**
  83198. * Logs a message
  83199. * @param message The message to log
  83200. */
  83201. log(message: string): void;
  83202. /**
  83203. * Starts a performance counter.
  83204. * @param counterName The name of the performance counter
  83205. */
  83206. startPerformanceCounter(counterName: string): void;
  83207. /**
  83208. * Ends a performance counter.
  83209. * @param counterName The name of the performance counter
  83210. */
  83211. endPerformanceCounter(counterName: string): void;
  83212. }
  83213. }
  83214. declare module BABYLON.GLTF2.Loader.Extensions {
  83215. /** @hidden */
  83216. interface IEXTLightsImageBased_LightImageBased {
  83217. _babylonTexture?: BaseTexture;
  83218. _loaded?: Promise<void>;
  83219. }
  83220. /**
  83221. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  83222. */
  83223. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  83224. /**
  83225. * The name of this extension.
  83226. */
  83227. readonly name: string;
  83228. /**
  83229. * Defines whether this extension is enabled.
  83230. */
  83231. enabled: boolean;
  83232. private _loader;
  83233. private _lights?;
  83234. /** @hidden */
  83235. constructor(loader: GLTFLoader);
  83236. /** @hidden */
  83237. dispose(): void;
  83238. /** @hidden */
  83239. onLoading(): void;
  83240. /** @hidden */
  83241. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83242. private _loadLightAsync;
  83243. }
  83244. }
  83245. declare module BABYLON.GLTF2.Loader.Extensions {
  83246. /**
  83247. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  83248. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  83249. * !!! Experimental Extension Subject to Changes !!!
  83250. */
  83251. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  83252. /**
  83253. * The name of this extension.
  83254. */
  83255. readonly name: string;
  83256. /**
  83257. * Defines whether this extension is enabled.
  83258. */
  83259. enabled: boolean;
  83260. private _loader;
  83261. /** @hidden */
  83262. constructor(loader: GLTFLoader);
  83263. /** @hidden */
  83264. dispose(): void;
  83265. /** @hidden */
  83266. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83267. }
  83268. }
  83269. declare module BABYLON.GLTF2.Loader.Extensions {
  83270. /**
  83271. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  83272. */
  83273. export class EXT_texture_webp implements IGLTFLoaderExtension {
  83274. /** The name of this extension. */
  83275. readonly name: string;
  83276. /** Defines whether this extension is enabled. */
  83277. enabled: boolean;
  83278. private _loader;
  83279. /** @hidden */
  83280. constructor(loader: GLTFLoader);
  83281. /** @hidden */
  83282. dispose(): void;
  83283. /** @hidden */
  83284. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83285. }
  83286. }
  83287. declare module BABYLON.GLTF2.Loader.Extensions {
  83288. /**
  83289. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  83290. */
  83291. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  83292. /**
  83293. * The name of this extension.
  83294. */
  83295. readonly name: string;
  83296. /**
  83297. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  83298. */
  83299. dracoCompression?: DracoCompression;
  83300. /**
  83301. * Defines whether this extension is enabled.
  83302. */
  83303. enabled: boolean;
  83304. private _loader;
  83305. /** @hidden */
  83306. constructor(loader: GLTFLoader);
  83307. /** @hidden */
  83308. dispose(): void;
  83309. /** @hidden */
  83310. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83311. }
  83312. }
  83313. declare module BABYLON.GLTF2.Loader.Extensions {
  83314. /**
  83315. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  83316. */
  83317. export class KHR_lights implements IGLTFLoaderExtension {
  83318. /**
  83319. * The name of this extension.
  83320. */
  83321. readonly name: string;
  83322. /**
  83323. * Defines whether this extension is enabled.
  83324. */
  83325. enabled: boolean;
  83326. private _loader;
  83327. private _lights?;
  83328. /** @hidden */
  83329. constructor(loader: GLTFLoader);
  83330. /** @hidden */
  83331. dispose(): void;
  83332. /** @hidden */
  83333. onLoading(): void;
  83334. /** @hidden */
  83335. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83336. }
  83337. }
  83338. declare module BABYLON.GLTF2.Loader.Extensions {
  83339. /**
  83340. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  83341. */
  83342. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  83343. /**
  83344. * The name of this extension.
  83345. */
  83346. readonly name: string;
  83347. /**
  83348. * Defines whether this extension is enabled.
  83349. */
  83350. enabled: boolean;
  83351. /**
  83352. * Defines a number that determines the order the extensions are applied.
  83353. */
  83354. order: number;
  83355. private _loader;
  83356. /** @hidden */
  83357. constructor(loader: GLTFLoader);
  83358. /** @hidden */
  83359. dispose(): void;
  83360. /** @hidden */
  83361. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83362. private _loadSpecularGlossinessPropertiesAsync;
  83363. }
  83364. }
  83365. declare module BABYLON.GLTF2.Loader.Extensions {
  83366. /**
  83367. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  83368. */
  83369. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  83370. /**
  83371. * The name of this extension.
  83372. */
  83373. readonly name: string;
  83374. /**
  83375. * Defines whether this extension is enabled.
  83376. */
  83377. enabled: boolean;
  83378. /**
  83379. * Defines a number that determines the order the extensions are applied.
  83380. */
  83381. order: number;
  83382. private _loader;
  83383. /** @hidden */
  83384. constructor(loader: GLTFLoader);
  83385. /** @hidden */
  83386. dispose(): void;
  83387. /** @hidden */
  83388. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83389. private _loadUnlitPropertiesAsync;
  83390. }
  83391. }
  83392. declare module BABYLON.GLTF2.Loader.Extensions {
  83393. /**
  83394. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  83395. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  83396. */
  83397. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  83398. /**
  83399. * The name of this extension.
  83400. */
  83401. readonly name: string;
  83402. /**
  83403. * Defines whether this extension is enabled.
  83404. */
  83405. enabled: boolean;
  83406. /**
  83407. * Defines a number that determines the order the extensions are applied.
  83408. */
  83409. order: number;
  83410. private _loader;
  83411. /** @hidden */
  83412. constructor(loader: GLTFLoader);
  83413. /** @hidden */
  83414. dispose(): void;
  83415. /** @hidden */
  83416. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83417. private _loadClearCoatPropertiesAsync;
  83418. }
  83419. }
  83420. declare module BABYLON.GLTF2.Loader.Extensions {
  83421. /**
  83422. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  83423. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  83424. * !!! Experimental Extension Subject to Changes !!!
  83425. */
  83426. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  83427. /**
  83428. * The name of this extension.
  83429. */
  83430. readonly name: string;
  83431. /**
  83432. * Defines whether this extension is enabled.
  83433. */
  83434. enabled: boolean;
  83435. /**
  83436. * Defines a number that determines the order the extensions are applied.
  83437. */
  83438. order: number;
  83439. private _loader;
  83440. /** @hidden */
  83441. constructor(loader: GLTFLoader);
  83442. /** @hidden */
  83443. dispose(): void;
  83444. /** @hidden */
  83445. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83446. private _loadSheenPropertiesAsync;
  83447. }
  83448. }
  83449. declare module BABYLON.GLTF2.Loader.Extensions {
  83450. /**
  83451. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  83452. * !!! Experimental Extension Subject to Changes !!!
  83453. */
  83454. export class KHR_materials_specular implements IGLTFLoaderExtension {
  83455. /**
  83456. * The name of this extension.
  83457. */
  83458. readonly name: string;
  83459. /**
  83460. * Defines whether this extension is enabled.
  83461. */
  83462. enabled: boolean;
  83463. /**
  83464. * Defines a number that determines the order the extensions are applied.
  83465. */
  83466. order: number;
  83467. private _loader;
  83468. /** @hidden */
  83469. constructor(loader: GLTFLoader);
  83470. /** @hidden */
  83471. dispose(): void;
  83472. /** @hidden */
  83473. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83474. private _loadSpecularPropertiesAsync;
  83475. }
  83476. }
  83477. declare module BABYLON.GLTF2.Loader.Extensions {
  83478. /**
  83479. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  83480. * !!! Experimental Extension Subject to Changes !!!
  83481. */
  83482. export class KHR_materials_ior implements IGLTFLoaderExtension {
  83483. /**
  83484. * Default ior Value from the spec.
  83485. */
  83486. private static readonly _DEFAULT_IOR;
  83487. /**
  83488. * The name of this extension.
  83489. */
  83490. readonly name: string;
  83491. /**
  83492. * Defines whether this extension is enabled.
  83493. */
  83494. enabled: boolean;
  83495. /**
  83496. * Defines a number that determines the order the extensions are applied.
  83497. */
  83498. order: number;
  83499. private _loader;
  83500. /** @hidden */
  83501. constructor(loader: GLTFLoader);
  83502. /** @hidden */
  83503. dispose(): void;
  83504. /** @hidden */
  83505. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83506. private _loadIorPropertiesAsync;
  83507. }
  83508. }
  83509. declare module BABYLON.GLTF2.Loader.Extensions {
  83510. /**
  83511. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83512. * !!! Experimental Extension Subject to Changes !!!
  83513. */
  83514. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83515. /**
  83516. * The name of this extension.
  83517. */
  83518. readonly name: string;
  83519. /**
  83520. * Defines whether this extension is enabled.
  83521. */
  83522. enabled: boolean;
  83523. private _loader;
  83524. private _variants?;
  83525. /** @hidden */
  83526. constructor(loader: GLTFLoader);
  83527. /** @hidden */
  83528. dispose(): void;
  83529. /**
  83530. * Gets the list of available variant names for this asset.
  83531. * @param rootMesh The glTF root mesh
  83532. * @returns the list of all the variant names for this model
  83533. */
  83534. static GetAvailableVariants(rootMesh: Mesh): string[];
  83535. /**
  83536. * Gets the list of available variant names for this asset.
  83537. * @param rootMesh The glTF root mesh
  83538. * @returns the list of all the variant names for this model
  83539. */
  83540. getAvailableVariants(rootMesh: Mesh): string[];
  83541. /**
  83542. * Select a variant given a variant name or a list of variant names.
  83543. * @param rootMesh The glTF root mesh
  83544. * @param variantName The variant name(s) to select.
  83545. */
  83546. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83547. /**
  83548. * Select a variant given a variant name or a list of variant names.
  83549. * @param rootMesh The glTF root mesh
  83550. * @param variantName The variant name(s) to select.
  83551. */
  83552. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83553. /**
  83554. * Reset back to the original before selecting a variant.
  83555. * @param rootMesh The glTF root mesh
  83556. */
  83557. static Reset(rootMesh: Mesh): void;
  83558. /**
  83559. * Reset back to the original before selecting a variant.
  83560. * @param rootMesh The glTF root mesh
  83561. */
  83562. reset(rootMesh: Mesh): void;
  83563. /**
  83564. * Gets the last selected variant name(s) or null if original.
  83565. * @param rootMesh The glTF root mesh
  83566. * @returns The selected variant name(s).
  83567. */
  83568. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83569. /**
  83570. * Gets the last selected variant name(s) or null if original.
  83571. * @param rootMesh The glTF root mesh
  83572. * @returns The selected variant name(s).
  83573. */
  83574. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83575. private static _GetExtensionMetadata;
  83576. /** @hidden */
  83577. onLoading(): void;
  83578. /** @hidden */
  83579. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83580. }
  83581. }
  83582. declare module BABYLON.GLTF2.Loader.Extensions {
  83583. /**
  83584. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  83585. * !!! Experimental Extension Subject to Changes !!!
  83586. */
  83587. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  83588. /**
  83589. * The name of this extension.
  83590. */
  83591. readonly name: string;
  83592. /**
  83593. * Defines whether this extension is enabled.
  83594. */
  83595. enabled: boolean;
  83596. /**
  83597. * Defines a number that determines the order the extensions are applied.
  83598. */
  83599. order: number;
  83600. private _loader;
  83601. /** @hidden */
  83602. constructor(loader: GLTFLoader);
  83603. /** @hidden */
  83604. dispose(): void;
  83605. /** @hidden */
  83606. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83607. private _loadTransparentPropertiesAsync;
  83608. }
  83609. }
  83610. declare module BABYLON.GLTF2.Loader.Extensions {
  83611. /**
  83612. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  83613. */
  83614. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  83615. /**
  83616. * The name of this extension.
  83617. */
  83618. readonly name: string;
  83619. /**
  83620. * Defines whether this extension is enabled.
  83621. */
  83622. enabled: boolean;
  83623. /** @hidden */
  83624. constructor(loader: GLTFLoader);
  83625. /** @hidden */
  83626. dispose(): void;
  83627. }
  83628. }
  83629. declare module BABYLON.GLTF2.Loader.Extensions {
  83630. /**
  83631. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  83632. * !!! Experimental Extension Subject to Changes !!!
  83633. */
  83634. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  83635. /** The name of this extension. */
  83636. readonly name: string;
  83637. /** Defines whether this extension is enabled. */
  83638. enabled: boolean;
  83639. private _loader;
  83640. /** @hidden */
  83641. constructor(loader: GLTFLoader);
  83642. /** @hidden */
  83643. dispose(): void;
  83644. /** @hidden */
  83645. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void, isColorData?: boolean): Nullable<Promise<BaseTexture>>;
  83646. }
  83647. }
  83648. declare module BABYLON.GLTF2.Loader.Extensions {
  83649. /**
  83650. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  83651. */
  83652. export class KHR_texture_transform implements IGLTFLoaderExtension {
  83653. /**
  83654. * The name of this extension.
  83655. */
  83656. readonly name: string;
  83657. /**
  83658. * Defines whether this extension is enabled.
  83659. */
  83660. enabled: boolean;
  83661. private _loader;
  83662. /** @hidden */
  83663. constructor(loader: GLTFLoader);
  83664. /** @hidden */
  83665. dispose(): void;
  83666. /** @hidden */
  83667. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void, isColorData?: boolean): Nullable<Promise<BaseTexture>>;
  83668. }
  83669. }
  83670. declare module BABYLON.GLTF2.Loader.Extensions {
  83671. /**
  83672. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  83673. * !!! Experimental Extension Subject to Changes !!!
  83674. */
  83675. export class KHR_xmp implements IGLTFLoaderExtension {
  83676. /**
  83677. * The name of this extension.
  83678. */
  83679. readonly name: string;
  83680. /**
  83681. * Defines whether this extension is enabled.
  83682. */
  83683. enabled: boolean;
  83684. /**
  83685. * Defines a number that determines the order the extensions are applied.
  83686. */
  83687. order: number;
  83688. private _loader;
  83689. /** @hidden */
  83690. constructor(loader: GLTFLoader);
  83691. /** @hidden */
  83692. dispose(): void;
  83693. /**
  83694. * Called after the loader state changes to LOADING.
  83695. */
  83696. onLoading(): void;
  83697. }
  83698. }
  83699. declare module BABYLON.GLTF2.Loader.Extensions {
  83700. /**
  83701. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  83702. */
  83703. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  83704. /**
  83705. * The name of this extension.
  83706. */
  83707. readonly name: string;
  83708. /**
  83709. * Defines whether this extension is enabled.
  83710. */
  83711. enabled: boolean;
  83712. private _loader;
  83713. private _clips;
  83714. private _emitters;
  83715. /** @hidden */
  83716. constructor(loader: GLTFLoader);
  83717. /** @hidden */
  83718. dispose(): void;
  83719. /** @hidden */
  83720. onLoading(): void;
  83721. /** @hidden */
  83722. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83723. /** @hidden */
  83724. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83725. /** @hidden */
  83726. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83727. private _loadClipAsync;
  83728. private _loadEmitterAsync;
  83729. private _getEventAction;
  83730. private _loadAnimationEventAsync;
  83731. }
  83732. }
  83733. declare module BABYLON.GLTF2.Loader.Extensions {
  83734. /**
  83735. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  83736. */
  83737. export class MSFT_lod implements IGLTFLoaderExtension {
  83738. /**
  83739. * The name of this extension.
  83740. */
  83741. readonly name: string;
  83742. /**
  83743. * Defines whether this extension is enabled.
  83744. */
  83745. enabled: boolean;
  83746. /**
  83747. * Defines a number that determines the order the extensions are applied.
  83748. */
  83749. order: number;
  83750. /**
  83751. * Maximum number of LODs to load, starting from the lowest LOD.
  83752. */
  83753. maxLODsToLoad: number;
  83754. /**
  83755. * Observable raised when all node LODs of one level are loaded.
  83756. * The event data is the index of the loaded LOD starting from zero.
  83757. * Dispose the loader to cancel the loading of the next level of LODs.
  83758. */
  83759. onNodeLODsLoadedObservable: Observable<number>;
  83760. /**
  83761. * Observable raised when all material LODs of one level are loaded.
  83762. * The event data is the index of the loaded LOD starting from zero.
  83763. * Dispose the loader to cancel the loading of the next level of LODs.
  83764. */
  83765. onMaterialLODsLoadedObservable: Observable<number>;
  83766. private _loader;
  83767. private _bufferLODs;
  83768. private _nodeIndexLOD;
  83769. private _nodeSignalLODs;
  83770. private _nodePromiseLODs;
  83771. private _nodeBufferLODs;
  83772. private _materialIndexLOD;
  83773. private _materialSignalLODs;
  83774. private _materialPromiseLODs;
  83775. private _materialBufferLODs;
  83776. /** @hidden */
  83777. constructor(loader: GLTFLoader);
  83778. /** @hidden */
  83779. dispose(): void;
  83780. /** @hidden */
  83781. onReady(): void;
  83782. /** @hidden */
  83783. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83784. /** @hidden */
  83785. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83786. /** @hidden */
  83787. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83788. /** @hidden */
  83789. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83790. /** @hidden */
  83791. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83792. private _loadBufferLOD;
  83793. /**
  83794. * Gets an array of LOD properties from lowest to highest.
  83795. */
  83796. private _getLODs;
  83797. private _disposeTransformNode;
  83798. private _disposeMaterials;
  83799. }
  83800. }
  83801. declare module BABYLON.GLTF2.Loader.Extensions {
  83802. /** @hidden */
  83803. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  83804. readonly name: string;
  83805. enabled: boolean;
  83806. private _loader;
  83807. constructor(loader: GLTFLoader);
  83808. dispose(): void;
  83809. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83810. }
  83811. }
  83812. declare module BABYLON.GLTF2.Loader.Extensions {
  83813. /** @hidden */
  83814. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  83815. readonly name: string;
  83816. enabled: boolean;
  83817. private _loader;
  83818. constructor(loader: GLTFLoader);
  83819. dispose(): void;
  83820. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83821. }
  83822. }
  83823. declare module BABYLON.GLTF2.Loader.Extensions {
  83824. /**
  83825. * Store glTF extras (if present) in BJS objects' metadata
  83826. */
  83827. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  83828. /**
  83829. * The name of this extension.
  83830. */
  83831. readonly name: string;
  83832. /**
  83833. * Defines whether this extension is enabled.
  83834. */
  83835. enabled: boolean;
  83836. private _loader;
  83837. private _assignExtras;
  83838. /** @hidden */
  83839. constructor(loader: GLTFLoader);
  83840. /** @hidden */
  83841. dispose(): void;
  83842. /** @hidden */
  83843. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83844. /** @hidden */
  83845. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83846. /** @hidden */
  83847. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83848. }
  83849. }
  83850. declare module BABYLON {
  83851. /**
  83852. * Class reading and parsing the MTL file bundled with the obj file.
  83853. */
  83854. export class MTLFileLoader {
  83855. /**
  83856. * Invert Y-Axis of referenced textures on load
  83857. */
  83858. static INVERT_TEXTURE_Y: boolean;
  83859. /**
  83860. * All material loaded from the mtl will be set here
  83861. */
  83862. materials: StandardMaterial[];
  83863. /**
  83864. * This function will read the mtl file and create each material described inside
  83865. * This function could be improve by adding :
  83866. * -some component missing (Ni, Tf...)
  83867. * -including the specific options available
  83868. *
  83869. * @param scene defines the scene the material will be created in
  83870. * @param data defines the mtl data to parse
  83871. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  83872. * @param forAssetContainer defines if the material should be registered in the scene
  83873. */
  83874. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  83875. /**
  83876. * Gets the texture for the material.
  83877. *
  83878. * If the material is imported from input file,
  83879. * We sanitize the url to ensure it takes the textre from aside the material.
  83880. *
  83881. * @param rootUrl The root url to load from
  83882. * @param value The value stored in the mtl
  83883. * @return The Texture
  83884. */
  83885. private static _getTexture;
  83886. }
  83887. }
  83888. declare module BABYLON {
  83889. /**
  83890. * Options for loading OBJ/MTL files
  83891. */
  83892. type MeshLoadOptions = {
  83893. /**
  83894. * Defines if UVs are optimized by default during load.
  83895. */
  83896. OptimizeWithUV: boolean;
  83897. /**
  83898. * Defines custom scaling of UV coordinates of loaded meshes.
  83899. */
  83900. UVScaling: Vector2;
  83901. /**
  83902. * Invert model on y-axis (does a model scaling inversion)
  83903. */
  83904. InvertY: boolean;
  83905. /**
  83906. * Invert Y-Axis of referenced textures on load
  83907. */
  83908. InvertTextureY: boolean;
  83909. /**
  83910. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83911. */
  83912. ImportVertexColors: boolean;
  83913. /**
  83914. * Compute the normals for the model, even if normals are present in the file.
  83915. */
  83916. ComputeNormals: boolean;
  83917. /**
  83918. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83919. */
  83920. SkipMaterials: boolean;
  83921. /**
  83922. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83923. */
  83924. MaterialLoadingFailsSilently: boolean;
  83925. };
  83926. /**
  83927. * OBJ file type loader.
  83928. * This is a babylon scene loader plugin.
  83929. */
  83930. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  83931. /**
  83932. * Defines if UVs are optimized by default during load.
  83933. */
  83934. static OPTIMIZE_WITH_UV: boolean;
  83935. /**
  83936. * Invert model on y-axis (does a model scaling inversion)
  83937. */
  83938. static INVERT_Y: boolean;
  83939. /**
  83940. * Invert Y-Axis of referenced textures on load
  83941. */
  83942. static get INVERT_TEXTURE_Y(): boolean;
  83943. static set INVERT_TEXTURE_Y(value: boolean);
  83944. /**
  83945. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83946. */
  83947. static IMPORT_VERTEX_COLORS: boolean;
  83948. /**
  83949. * Compute the normals for the model, even if normals are present in the file.
  83950. */
  83951. static COMPUTE_NORMALS: boolean;
  83952. /**
  83953. * Defines custom scaling of UV coordinates of loaded meshes.
  83954. */
  83955. static UV_SCALING: Vector2;
  83956. /**
  83957. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83958. */
  83959. static SKIP_MATERIALS: boolean;
  83960. /**
  83961. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83962. *
  83963. * Defaults to true for backwards compatibility.
  83964. */
  83965. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  83966. /**
  83967. * Defines the name of the plugin.
  83968. */
  83969. name: string;
  83970. /**
  83971. * Defines the extension the plugin is able to load.
  83972. */
  83973. extensions: string;
  83974. /** @hidden */
  83975. obj: RegExp;
  83976. /** @hidden */
  83977. group: RegExp;
  83978. /** @hidden */
  83979. mtllib: RegExp;
  83980. /** @hidden */
  83981. usemtl: RegExp;
  83982. /** @hidden */
  83983. smooth: RegExp;
  83984. /** @hidden */
  83985. vertexPattern: RegExp;
  83986. /** @hidden */
  83987. normalPattern: RegExp;
  83988. /** @hidden */
  83989. uvPattern: RegExp;
  83990. /** @hidden */
  83991. facePattern1: RegExp;
  83992. /** @hidden */
  83993. facePattern2: RegExp;
  83994. /** @hidden */
  83995. facePattern3: RegExp;
  83996. /** @hidden */
  83997. facePattern4: RegExp;
  83998. /** @hidden */
  83999. facePattern5: RegExp;
  84000. private _forAssetContainer;
  84001. private _meshLoadOptions;
  84002. /**
  84003. * Creates loader for .OBJ files
  84004. *
  84005. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  84006. */
  84007. constructor(meshLoadOptions?: MeshLoadOptions);
  84008. private static get currentMeshLoadOptions();
  84009. /**
  84010. * Calls synchronously the MTL file attached to this obj.
  84011. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  84012. * Without this function materials are not displayed in the first frame (but displayed after).
  84013. * In consequence it is impossible to get material information in your HTML file
  84014. *
  84015. * @param url The URL of the MTL file
  84016. * @param rootUrl
  84017. * @param onSuccess Callback function to be called when the MTL file is loaded
  84018. * @private
  84019. */
  84020. private _loadMTL;
  84021. /**
  84022. * Instantiates a OBJ file loader plugin.
  84023. * @returns the created plugin
  84024. */
  84025. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  84026. /**
  84027. * If the data string can be loaded directly.
  84028. *
  84029. * @param data string containing the file data
  84030. * @returns if the data can be loaded directly
  84031. */
  84032. canDirectLoad(data: string): boolean;
  84033. /**
  84034. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  84035. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  84036. * @param scene the scene the meshes should be added to
  84037. * @param data the OBJ data to load
  84038. * @param rootUrl root url to load from
  84039. * @param onProgress event that fires when loading progress has occured
  84040. * @param fileName Defines the name of the file to load
  84041. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  84042. */
  84043. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  84044. meshes: AbstractMesh[];
  84045. particleSystems: IParticleSystem[];
  84046. skeletons: Skeleton[];
  84047. animationGroups: AnimationGroup[];
  84048. }>;
  84049. /**
  84050. * Imports all objects from the loaded OBJ data and adds them to the scene
  84051. * @param scene the scene the objects should be added to
  84052. * @param data the OBJ data to load
  84053. * @param rootUrl root url to load from
  84054. * @param onProgress event that fires when loading progress has occured
  84055. * @param fileName Defines the name of the file to load
  84056. * @returns a promise which completes when objects have been loaded to the scene
  84057. */
  84058. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  84059. /**
  84060. * Load into an asset container.
  84061. * @param scene The scene to load into
  84062. * @param data The data to import
  84063. * @param rootUrl The root url for scene and resources
  84064. * @param onProgress The callback when the load progresses
  84065. * @param fileName Defines the name of the file to load
  84066. * @returns The loaded asset container
  84067. */
  84068. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  84069. /**
  84070. * Read the OBJ file and create an Array of meshes.
  84071. * Each mesh contains all information given by the OBJ and the MTL file.
  84072. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  84073. *
  84074. * @param meshesNames
  84075. * @param scene Scene The scene where are displayed the data
  84076. * @param data String The content of the obj file
  84077. * @param rootUrl String The path to the folder
  84078. * @returns Array<AbstractMesh>
  84079. * @private
  84080. */
  84081. private _parseSolid;
  84082. }
  84083. }
  84084. declare module BABYLON {
  84085. /**
  84086. * STL file type loader.
  84087. * This is a babylon scene loader plugin.
  84088. */
  84089. export class STLFileLoader implements ISceneLoaderPlugin {
  84090. /** @hidden */
  84091. solidPattern: RegExp;
  84092. /** @hidden */
  84093. facetsPattern: RegExp;
  84094. /** @hidden */
  84095. normalPattern: RegExp;
  84096. /** @hidden */
  84097. vertexPattern: RegExp;
  84098. /**
  84099. * Defines the name of the plugin.
  84100. */
  84101. name: string;
  84102. /**
  84103. * Defines the extensions the stl loader is able to load.
  84104. * force data to come in as an ArrayBuffer
  84105. * we'll convert to string if it looks like it's an ASCII .stl
  84106. */
  84107. extensions: ISceneLoaderPluginExtensions;
  84108. /**
  84109. * Import meshes into a scene.
  84110. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  84111. * @param scene The scene to import into
  84112. * @param data The data to import
  84113. * @param rootUrl The root url for scene and resources
  84114. * @param meshes The meshes array to import into
  84115. * @param particleSystems The particle systems array to import into
  84116. * @param skeletons The skeletons array to import into
  84117. * @param onError The callback when import fails
  84118. * @returns True if successful or false otherwise
  84119. */
  84120. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  84121. /**
  84122. * Load into a scene.
  84123. * @param scene The scene to load into
  84124. * @param data The data to import
  84125. * @param rootUrl The root url for scene and resources
  84126. * @param onError The callback when import fails
  84127. * @returns true if successful or false otherwise
  84128. */
  84129. load(scene: Scene, data: any, rootUrl: string): boolean;
  84130. /**
  84131. * Load into an asset container.
  84132. * @param scene The scene to load into
  84133. * @param data The data to import
  84134. * @param rootUrl The root url for scene and resources
  84135. * @param onError The callback when import fails
  84136. * @returns The loaded asset container
  84137. */
  84138. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  84139. private _isBinary;
  84140. private _parseBinary;
  84141. private _parseASCII;
  84142. }
  84143. }
  84144. declare module BABYLON {
  84145. /**
  84146. * Class for generating OBJ data from a Babylon scene.
  84147. */
  84148. export class OBJExport {
  84149. /**
  84150. * Exports the geometry of a Mesh array in .OBJ file format (text)
  84151. * @param mesh defines the list of meshes to serialize
  84152. * @param materials defines if materials should be exported
  84153. * @param matlibname defines the name of the associated mtl file
  84154. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  84155. * @returns the OBJ content
  84156. */
  84157. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  84158. /**
  84159. * Exports the material(s) of a mesh in .MTL file format (text)
  84160. * @param mesh defines the mesh to extract the material from
  84161. * @returns the mtl content
  84162. */
  84163. static MTL(mesh: Mesh): string;
  84164. }
  84165. }
  84166. declare module BABYLON {
  84167. /** @hidden */
  84168. export var __IGLTFExporterExtension: number;
  84169. /**
  84170. * Interface for extending the exporter
  84171. * @hidden
  84172. */
  84173. export interface IGLTFExporterExtension {
  84174. /**
  84175. * The name of this extension
  84176. */
  84177. readonly name: string;
  84178. /**
  84179. * Defines whether this extension is enabled
  84180. */
  84181. enabled: boolean;
  84182. /**
  84183. * Defines whether this extension is required
  84184. */
  84185. required: boolean;
  84186. }
  84187. }
  84188. declare module BABYLON.GLTF2.Exporter {
  84189. /** @hidden */
  84190. export var __IGLTFExporterExtensionV2: number;
  84191. /**
  84192. * Interface for a glTF exporter extension
  84193. * @hidden
  84194. */
  84195. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  84196. /**
  84197. * Define this method to modify the default behavior before exporting a texture
  84198. * @param context The context when loading the asset
  84199. * @param babylonTexture The Babylon.js texture
  84200. * @param mimeType The mime-type of the generated image
  84201. * @returns A promise that resolves with the exported texture
  84202. */
  84203. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  84204. /**
  84205. * Define this method to get notified when a texture info is created
  84206. * @param context The context when loading the asset
  84207. * @param textureInfo The glTF texture info
  84208. * @param babylonTexture The Babylon.js texture
  84209. */
  84210. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84211. /**
  84212. * Define this method to modify the default behavior when exporting texture info
  84213. * @param context The context when loading the asset
  84214. * @param meshPrimitive glTF mesh primitive
  84215. * @param babylonSubMesh Babylon submesh
  84216. * @param binaryWriter glTF serializer binary writer instance
  84217. * @returns nullable IMeshPrimitive promise
  84218. */
  84219. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  84220. /**
  84221. * Define this method to modify the default behavior when exporting a node
  84222. * @param context The context when exporting the node
  84223. * @param node glTF node
  84224. * @param babylonNode BabylonJS node
  84225. * @returns nullable INode promise
  84226. */
  84227. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84228. [key: number]: number;
  84229. }): Promise<Nullable<INode>>;
  84230. /**
  84231. * Define this method to modify the default behavior when exporting a material
  84232. * @param material glTF material
  84233. * @param babylonMaterial BabylonJS material
  84234. * @returns nullable IMaterial promise
  84235. */
  84236. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  84237. /**
  84238. * Define this method to return additional textures to export from a material
  84239. * @param material glTF material
  84240. * @param babylonMaterial BabylonJS material
  84241. * @returns List of textures
  84242. */
  84243. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84244. /** Gets a boolean indicating that this extension was used */
  84245. wasUsed: boolean;
  84246. /** Gets a boolean indicating that this extension is required for the file to work */
  84247. required: boolean;
  84248. /**
  84249. * Called after the exporter state changes to EXPORTING
  84250. */
  84251. onExporting?(): void;
  84252. }
  84253. }
  84254. declare module BABYLON.GLTF2.Exporter {
  84255. /**
  84256. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  84257. * @hidden
  84258. */
  84259. export class _GLTFMaterialExporter {
  84260. /**
  84261. * Represents the dielectric specular values for R, G and B
  84262. */
  84263. private static readonly _DielectricSpecular;
  84264. /**
  84265. * Allows the maximum specular power to be defined for material calculations
  84266. */
  84267. private static readonly _MaxSpecularPower;
  84268. /**
  84269. * Mapping to store textures
  84270. */
  84271. private _textureMap;
  84272. /**
  84273. * Numeric tolerance value
  84274. */
  84275. private static readonly _Epsilon;
  84276. /**
  84277. * Reference to the glTF Exporter
  84278. */
  84279. private _exporter;
  84280. constructor(exporter: _Exporter);
  84281. /**
  84282. * Specifies if two colors are approximately equal in value
  84283. * @param color1 first color to compare to
  84284. * @param color2 second color to compare to
  84285. * @param epsilon threshold value
  84286. */
  84287. private static FuzzyEquals;
  84288. /**
  84289. * Gets the materials from a Babylon scene and converts them to glTF materials
  84290. * @param scene babylonjs scene
  84291. * @param mimeType texture mime type
  84292. * @param images array of images
  84293. * @param textures array of textures
  84294. * @param materials array of materials
  84295. * @param imageData mapping of texture names to base64 textures
  84296. * @param hasTextureCoords specifies if texture coordinates are present on the material
  84297. */
  84298. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  84299. /**
  84300. * Makes a copy of the glTF material without the texture parameters
  84301. * @param originalMaterial original glTF material
  84302. * @returns glTF material without texture parameters
  84303. */
  84304. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  84305. /**
  84306. * Specifies if the material has any texture parameters present
  84307. * @param material glTF Material
  84308. * @returns boolean specifying if texture parameters are present
  84309. */
  84310. _hasTexturesPresent(material: IMaterial): boolean;
  84311. /**
  84312. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  84313. * @param babylonStandardMaterial
  84314. * @returns glTF Metallic Roughness Material representation
  84315. */
  84316. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  84317. /**
  84318. * Computes the metallic factor
  84319. * @param diffuse diffused value
  84320. * @param specular specular value
  84321. * @param oneMinusSpecularStrength one minus the specular strength
  84322. * @returns metallic value
  84323. */
  84324. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  84325. /**
  84326. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  84327. * @param glTFMaterial glTF material
  84328. * @param babylonMaterial Babylon material
  84329. */
  84330. private static _SetAlphaMode;
  84331. /**
  84332. * Converts a Babylon Standard Material to a glTF Material
  84333. * @param babylonStandardMaterial BJS Standard Material
  84334. * @param mimeType mime type to use for the textures
  84335. * @param images array of glTF image interfaces
  84336. * @param textures array of glTF texture interfaces
  84337. * @param materials array of glTF material interfaces
  84338. * @param imageData map of image file name to data
  84339. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84340. */
  84341. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84342. private _finishMaterial;
  84343. /**
  84344. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84345. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  84346. * @param mimeType mime type to use for the textures
  84347. * @param images array of glTF image interfaces
  84348. * @param textures array of glTF texture interfaces
  84349. * @param materials array of glTF material interfaces
  84350. * @param imageData map of image file name to data
  84351. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84352. */
  84353. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84354. /**
  84355. * Converts an image typed array buffer to a base64 image
  84356. * @param buffer typed array buffer
  84357. * @param width width of the image
  84358. * @param height height of the image
  84359. * @param mimeType mimetype of the image
  84360. * @returns base64 image string
  84361. */
  84362. private _createBase64FromCanvasAsync;
  84363. /**
  84364. * Generates a white texture based on the specified width and height
  84365. * @param width width of the texture in pixels
  84366. * @param height height of the texture in pixels
  84367. * @param scene babylonjs scene
  84368. * @returns white texture
  84369. */
  84370. private _createWhiteTexture;
  84371. /**
  84372. * 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
  84373. * @param texture1 first texture to resize
  84374. * @param texture2 second texture to resize
  84375. * @param scene babylonjs scene
  84376. * @returns resized textures or null
  84377. */
  84378. private _resizeTexturesToSameDimensions;
  84379. /**
  84380. * Converts an array of pixels to a Float32Array
  84381. * Throws an error if the pixel format is not supported
  84382. * @param pixels - array buffer containing pixel values
  84383. * @returns Float32 of pixels
  84384. */
  84385. private _convertPixelArrayToFloat32;
  84386. /**
  84387. * Convert Specular Glossiness Textures to Metallic Roughness
  84388. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  84389. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  84390. * @param diffuseTexture texture used to store diffuse information
  84391. * @param specularGlossinessTexture texture used to store specular and glossiness information
  84392. * @param factors specular glossiness material factors
  84393. * @param mimeType the mime type to use for the texture
  84394. * @returns pbr metallic roughness interface or null
  84395. */
  84396. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  84397. /**
  84398. * Converts specular glossiness material properties to metallic roughness
  84399. * @param specularGlossiness interface with specular glossiness material properties
  84400. * @returns interface with metallic roughness material properties
  84401. */
  84402. private _convertSpecularGlossinessToMetallicRoughness;
  84403. /**
  84404. * Calculates the surface reflectance, independent of lighting conditions
  84405. * @param color Color source to calculate brightness from
  84406. * @returns number representing the perceived brightness, or zero if color is undefined
  84407. */
  84408. private _getPerceivedBrightness;
  84409. /**
  84410. * Returns the maximum color component value
  84411. * @param color
  84412. * @returns maximum color component value, or zero if color is null or undefined
  84413. */
  84414. private _getMaxComponent;
  84415. /**
  84416. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  84417. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84418. * @param mimeType mime type to use for the textures
  84419. * @param images array of glTF image interfaces
  84420. * @param textures array of glTF texture interfaces
  84421. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84422. * @param imageData map of image file name to data
  84423. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84424. * @returns glTF PBR Metallic Roughness factors
  84425. */
  84426. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84427. private _getGLTFTextureSampler;
  84428. private _getGLTFTextureWrapMode;
  84429. private _getGLTFTextureWrapModesSampler;
  84430. /**
  84431. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  84432. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84433. * @param mimeType mime type to use for the textures
  84434. * @param images array of glTF image interfaces
  84435. * @param textures array of glTF texture interfaces
  84436. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84437. * @param imageData map of image file name to data
  84438. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84439. * @returns glTF PBR Metallic Roughness factors
  84440. */
  84441. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  84442. /**
  84443. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84444. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84445. * @param mimeType mime type to use for the textures
  84446. * @param images array of glTF image interfaces
  84447. * @param textures array of glTF texture interfaces
  84448. * @param materials array of glTF material interfaces
  84449. * @param imageData map of image file name to data
  84450. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84451. */
  84452. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84453. private setMetallicRoughnessPbrMaterial;
  84454. private getPixelsFromTexture;
  84455. /**
  84456. * Extracts a texture from a Babylon texture into file data and glTF data
  84457. * @param babylonTexture Babylon texture to extract
  84458. * @param mimeType Mime Type of the babylonTexture
  84459. * @return glTF texture info, or null if the texture format is not supported
  84460. */
  84461. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84462. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84463. /**
  84464. * Builds a texture from base64 string
  84465. * @param base64Texture base64 texture string
  84466. * @param baseTextureName Name to use for the texture
  84467. * @param mimeType image mime type for the texture
  84468. * @param images array of images
  84469. * @param textures array of textures
  84470. * @param imageData map of image data
  84471. * @returns glTF texture info, or null if the texture format is not supported
  84472. */
  84473. private _getTextureInfoFromBase64;
  84474. }
  84475. }
  84476. declare module BABYLON {
  84477. /**
  84478. * Class for holding and downloading glTF file data
  84479. */
  84480. export class GLTFData {
  84481. /**
  84482. * Object which contains the file name as the key and its data as the value
  84483. */
  84484. glTFFiles: {
  84485. [fileName: string]: string | Blob;
  84486. };
  84487. /**
  84488. * Initializes the glTF file object
  84489. */
  84490. constructor();
  84491. /**
  84492. * Downloads the glTF data as files based on their names and data
  84493. */
  84494. downloadFiles(): void;
  84495. }
  84496. }
  84497. declare module BABYLON {
  84498. /**
  84499. * Holds a collection of exporter options and parameters
  84500. */
  84501. export interface IExportOptions {
  84502. /**
  84503. * Function which indicates whether a babylon node should be exported or not
  84504. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  84505. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84506. */
  84507. shouldExportNode?(node: Node): boolean;
  84508. /**
  84509. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84510. * @param metadata source metadata to read from
  84511. * @returns the data to store to glTF node extras
  84512. */
  84513. metadataSelector?(metadata: any): any;
  84514. /**
  84515. * The sample rate to bake animation curves
  84516. */
  84517. animationSampleRate?: number;
  84518. /**
  84519. * Begin serialization without waiting for the scene to be ready
  84520. */
  84521. exportWithoutWaitingForScene?: boolean;
  84522. /**
  84523. * Indicates if coordinate system swapping root nodes should be included in export
  84524. */
  84525. includeCoordinateSystemConversionNodes?: boolean;
  84526. }
  84527. /**
  84528. * Class for generating glTF data from a Babylon scene.
  84529. */
  84530. export class GLTF2Export {
  84531. /**
  84532. * Exports the geometry of the scene to .gltf file format asynchronously
  84533. * @param scene Babylon scene with scene hierarchy information
  84534. * @param filePrefix File prefix to use when generating the glTF file
  84535. * @param options Exporter options
  84536. * @returns Returns an object with a .gltf file and associates texture names
  84537. * as keys and their data and paths as values
  84538. */
  84539. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84540. private static _PreExportAsync;
  84541. private static _PostExportAsync;
  84542. /**
  84543. * Exports the geometry of the scene to .glb file format asychronously
  84544. * @param scene Babylon scene with scene hierarchy information
  84545. * @param filePrefix File prefix to use when generating glb file
  84546. * @param options Exporter options
  84547. * @returns Returns an object with a .glb filename as key and data as value
  84548. */
  84549. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84550. }
  84551. }
  84552. declare module BABYLON.GLTF2.Exporter {
  84553. /**
  84554. * @hidden
  84555. */
  84556. export class _GLTFUtilities {
  84557. /**
  84558. * Creates a buffer view based on the supplied arguments
  84559. * @param bufferIndex index value of the specified buffer
  84560. * @param byteOffset byte offset value
  84561. * @param byteLength byte length of the bufferView
  84562. * @param byteStride byte distance between conequential elements
  84563. * @param name name of the buffer view
  84564. * @returns bufferView for glTF
  84565. */
  84566. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  84567. /**
  84568. * Creates an accessor based on the supplied arguments
  84569. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  84570. * @param name The name of the accessor
  84571. * @param type The type of the accessor
  84572. * @param componentType The datatype of components in the attribute
  84573. * @param count The number of attributes referenced by this accessor
  84574. * @param byteOffset The offset relative to the start of the bufferView in bytes
  84575. * @param min Minimum value of each component in this attribute
  84576. * @param max Maximum value of each component in this attribute
  84577. * @returns accessor for glTF
  84578. */
  84579. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  84580. /**
  84581. * Calculates the minimum and maximum values of an array of position floats
  84582. * @param positions Positions array of a mesh
  84583. * @param vertexStart Starting vertex offset to calculate min and max values
  84584. * @param vertexCount Number of vertices to check for min and max values
  84585. * @returns min number array and max number array
  84586. */
  84587. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  84588. min: number[];
  84589. max: number[];
  84590. };
  84591. /**
  84592. * Converts a new right-handed Vector3
  84593. * @param vector vector3 array
  84594. * @returns right-handed Vector3
  84595. */
  84596. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  84597. /**
  84598. * Converts a Vector3 to right-handed
  84599. * @param vector Vector3 to convert to right-handed
  84600. */
  84601. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  84602. /**
  84603. * Converts a three element number array to right-handed
  84604. * @param vector number array to convert to right-handed
  84605. */
  84606. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  84607. /**
  84608. * Converts a new right-handed Vector3
  84609. * @param vector vector3 array
  84610. * @returns right-handed Vector3
  84611. */
  84612. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  84613. /**
  84614. * Converts a Vector3 to right-handed
  84615. * @param vector Vector3 to convert to right-handed
  84616. */
  84617. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  84618. /**
  84619. * Converts a three element number array to right-handed
  84620. * @param vector number array to convert to right-handed
  84621. */
  84622. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  84623. /**
  84624. * Converts a Vector4 to right-handed
  84625. * @param vector Vector4 to convert to right-handed
  84626. */
  84627. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  84628. /**
  84629. * Converts a Vector4 to right-handed
  84630. * @param vector Vector4 to convert to right-handed
  84631. */
  84632. static _GetRightHandedArray4FromRef(vector: number[]): void;
  84633. /**
  84634. * Converts a Quaternion to right-handed
  84635. * @param quaternion Source quaternion to convert to right-handed
  84636. */
  84637. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  84638. /**
  84639. * Converts a Quaternion to right-handed
  84640. * @param quaternion Source quaternion to convert to right-handed
  84641. */
  84642. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  84643. static _NormalizeTangentFromRef(tangent: Vector4): void;
  84644. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  84645. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  84646. }
  84647. }
  84648. declare module BABYLON.GLTF2.Exporter {
  84649. /**
  84650. * Converts Babylon Scene into glTF 2.0.
  84651. * @hidden
  84652. */
  84653. export class _Exporter {
  84654. /**
  84655. * Stores the glTF to export
  84656. */
  84657. _glTF: IGLTF;
  84658. /**
  84659. * Stores all generated buffer views, which represents views into the main glTF buffer data
  84660. */
  84661. _bufferViews: IBufferView[];
  84662. /**
  84663. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  84664. */
  84665. _accessors: IAccessor[];
  84666. /**
  84667. * Stores all the generated nodes, which contains transform and/or mesh information per node
  84668. */
  84669. _nodes: INode[];
  84670. /**
  84671. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  84672. */
  84673. private _scenes;
  84674. /**
  84675. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  84676. */
  84677. private _meshes;
  84678. /**
  84679. * Stores all the generated material information, which represents the appearance of each primitive
  84680. */
  84681. _materials: IMaterial[];
  84682. _materialMap: {
  84683. [materialID: number]: number;
  84684. };
  84685. /**
  84686. * Stores all the generated texture information, which is referenced by glTF materials
  84687. */
  84688. _textures: ITexture[];
  84689. /**
  84690. * Stores all the generated image information, which is referenced by glTF textures
  84691. */
  84692. _images: IImage[];
  84693. /**
  84694. * Stores all the texture samplers
  84695. */
  84696. _samplers: ISampler[];
  84697. /**
  84698. * Stores all the generated glTF skins
  84699. */
  84700. _skins: ISkin[];
  84701. /**
  84702. * Stores all the generated animation samplers, which is referenced by glTF animations
  84703. */
  84704. /**
  84705. * Stores the animations for glTF models
  84706. */
  84707. private _animations;
  84708. /**
  84709. * Stores the total amount of bytes stored in the glTF buffer
  84710. */
  84711. private _totalByteLength;
  84712. /**
  84713. * Stores a reference to the Babylon scene containing the source geometry and material information
  84714. */
  84715. _babylonScene: Scene;
  84716. /**
  84717. * Stores a map of the image data, where the key is the file name and the value
  84718. * is the image data
  84719. */
  84720. _imageData: {
  84721. [fileName: string]: {
  84722. data: Uint8Array;
  84723. mimeType: ImageMimeType;
  84724. };
  84725. };
  84726. protected _orderedImageData: Array<{
  84727. data: Uint8Array;
  84728. mimeType: ImageMimeType;
  84729. }>;
  84730. /**
  84731. * Stores a map of the unique id of a node to its index in the node array
  84732. */
  84733. _nodeMap: {
  84734. [key: number]: number;
  84735. };
  84736. /**
  84737. * Specifies if the source Babylon scene was left handed, and needed conversion.
  84738. */
  84739. _convertToRightHandedSystem: boolean;
  84740. /**
  84741. * Specifies if a Babylon node should be converted to right-handed on export
  84742. */
  84743. _convertToRightHandedSystemMap: {
  84744. [nodeId: number]: boolean;
  84745. };
  84746. _includeCoordinateSystemConversionNodes: boolean;
  84747. /**
  84748. * Baked animation sample rate
  84749. */
  84750. private _animationSampleRate;
  84751. private _options;
  84752. private _localEngine;
  84753. _glTFMaterialExporter: _GLTFMaterialExporter;
  84754. private _extensions;
  84755. private static _ExtensionNames;
  84756. private static _ExtensionFactories;
  84757. private _applyExtension;
  84758. private _applyExtensions;
  84759. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  84760. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  84761. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84762. [key: number]: number;
  84763. }): Promise<Nullable<INode>>;
  84764. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  84765. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  84766. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84767. private _forEachExtensions;
  84768. private _extensionsOnExporting;
  84769. /**
  84770. * Load glTF serializer extensions
  84771. */
  84772. private _loadExtensions;
  84773. /**
  84774. * Creates a glTF Exporter instance, which can accept optional exporter options
  84775. * @param babylonScene Babylon scene object
  84776. * @param options Options to modify the behavior of the exporter
  84777. */
  84778. constructor(babylonScene: Scene, options?: IExportOptions);
  84779. dispose(): void;
  84780. /**
  84781. * Registers a glTF exporter extension
  84782. * @param name Name of the extension to export
  84783. * @param factory The factory function that creates the exporter extension
  84784. */
  84785. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  84786. /**
  84787. * Un-registers an exporter extension
  84788. * @param name The name fo the exporter extension
  84789. * @returns A boolean indicating whether the extension has been un-registered
  84790. */
  84791. static UnregisterExtension(name: string): boolean;
  84792. /**
  84793. * Lazy load a local engine
  84794. */
  84795. _getLocalEngine(): Engine;
  84796. private reorderIndicesBasedOnPrimitiveMode;
  84797. /**
  84798. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  84799. * clock-wise during export to glTF
  84800. * @param submesh BabylonJS submesh
  84801. * @param primitiveMode Primitive mode of the mesh
  84802. * @param sideOrientation the winding order of the submesh
  84803. * @param vertexBufferKind The type of vertex attribute
  84804. * @param meshAttributeArray The vertex attribute data
  84805. * @param byteOffset The offset to the binary data
  84806. * @param binaryWriter The binary data for the glTF file
  84807. * @param convertToRightHandedSystem Converts the values to right-handed
  84808. */
  84809. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  84810. /**
  84811. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  84812. * clock-wise during export to glTF
  84813. * @param submesh BabylonJS submesh
  84814. * @param primitiveMode Primitive mode of the mesh
  84815. * @param sideOrientation the winding order of the submesh
  84816. * @param vertexBufferKind The type of vertex attribute
  84817. * @param meshAttributeArray The vertex attribute data
  84818. * @param byteOffset The offset to the binary data
  84819. * @param binaryWriter The binary data for the glTF file
  84820. * @param convertToRightHandedSystem Converts the values to right-handed
  84821. */
  84822. private reorderTriangleFillMode;
  84823. /**
  84824. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  84825. * clock-wise during export to glTF
  84826. * @param submesh BabylonJS submesh
  84827. * @param primitiveMode Primitive mode of the mesh
  84828. * @param sideOrientation the winding order of the submesh
  84829. * @param vertexBufferKind The type of vertex attribute
  84830. * @param meshAttributeArray The vertex attribute data
  84831. * @param byteOffset The offset to the binary data
  84832. * @param binaryWriter The binary data for the glTF file
  84833. * @param convertToRightHandedSystem Converts the values to right-handed
  84834. */
  84835. private reorderTriangleStripDrawMode;
  84836. /**
  84837. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  84838. * clock-wise during export to glTF
  84839. * @param submesh BabylonJS submesh
  84840. * @param primitiveMode Primitive mode of the mesh
  84841. * @param sideOrientation the winding order of the submesh
  84842. * @param vertexBufferKind The type of vertex attribute
  84843. * @param meshAttributeArray The vertex attribute data
  84844. * @param byteOffset The offset to the binary data
  84845. * @param binaryWriter The binary data for the glTF file
  84846. * @param convertToRightHandedSystem Converts the values to right-handed
  84847. */
  84848. private reorderTriangleFanMode;
  84849. /**
  84850. * Writes the vertex attribute data to binary
  84851. * @param vertices The vertices to write to the binary writer
  84852. * @param byteOffset The offset into the binary writer to overwrite binary data
  84853. * @param vertexAttributeKind The vertex attribute type
  84854. * @param meshAttributeArray The vertex attribute data
  84855. * @param binaryWriter The writer containing the binary data
  84856. * @param convertToRightHandedSystem Converts the values to right-handed
  84857. */
  84858. private writeVertexAttributeData;
  84859. /**
  84860. * Writes mesh attribute data to a data buffer
  84861. * Returns the bytelength of the data
  84862. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84863. * @param meshAttributeArray Array containing the attribute data
  84864. * @param byteStride Specifies the space between data
  84865. * @param binaryWriter The buffer to write the binary data to
  84866. * @param convertToRightHandedSystem Converts the values to right-handed
  84867. */
  84868. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  84869. /**
  84870. * Writes mesh attribute data to a data buffer
  84871. * Returns the bytelength of the data
  84872. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84873. * @param meshAttributeArray Array containing the attribute data
  84874. * @param byteStride Specifies the space between data
  84875. * @param binaryWriter The buffer to write the binary data to
  84876. * @param convertToRightHandedSystem Converts the values to right-handed
  84877. */
  84878. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  84879. /**
  84880. * Generates glTF json data
  84881. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  84882. * @param glTFPrefix Text to use when prefixing a glTF file
  84883. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  84884. * @returns json data as string
  84885. */
  84886. private generateJSON;
  84887. /**
  84888. * Generates data for .gltf and .bin files based on the glTF prefix string
  84889. * @param glTFPrefix Text to use when prefixing a glTF file
  84890. * @param dispose Dispose the exporter
  84891. * @returns GLTFData with glTF file data
  84892. */
  84893. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84894. /**
  84895. * Creates a binary buffer for glTF
  84896. * @returns array buffer for binary data
  84897. */
  84898. private _generateBinaryAsync;
  84899. /**
  84900. * Pads the number to a multiple of 4
  84901. * @param num number to pad
  84902. * @returns padded number
  84903. */
  84904. private _getPadding;
  84905. /**
  84906. * @hidden
  84907. */
  84908. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84909. /**
  84910. * Sets the TRS for each node
  84911. * @param node glTF Node for storing the transformation data
  84912. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  84913. * @param convertToRightHandedSystem Converts the values to right-handed
  84914. */
  84915. private setNodeTransformation;
  84916. private getVertexBufferFromMesh;
  84917. /**
  84918. * Creates a bufferview based on the vertices type for the Babylon mesh
  84919. * @param kind Indicates the type of vertices data
  84920. * @param componentType Indicates the numerical type used to store the data
  84921. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  84922. * @param binaryWriter The buffer to write the bufferview data to
  84923. * @param convertToRightHandedSystem Converts the values to right-handed
  84924. */
  84925. private createBufferViewKind;
  84926. /**
  84927. * Creates a bufferview based on the vertices type for the Babylon mesh
  84928. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  84929. * @param babylonMorphTarget the morph target to be exported
  84930. * @param binaryWriter The buffer to write the bufferview data to
  84931. * @param convertToRightHandedSystem Converts the values to right-handed
  84932. */
  84933. private setMorphTargetAttributes;
  84934. /**
  84935. * The primitive mode of the Babylon mesh
  84936. * @param babylonMesh The BabylonJS mesh
  84937. */
  84938. private getMeshPrimitiveMode;
  84939. /**
  84940. * Sets the primitive mode of the glTF mesh primitive
  84941. * @param meshPrimitive glTF mesh primitive
  84942. * @param primitiveMode The primitive mode
  84943. */
  84944. private setPrimitiveMode;
  84945. /**
  84946. * Sets the vertex attribute accessor based of the glTF mesh primitive
  84947. * @param meshPrimitive glTF mesh primitive
  84948. * @param attributeKind vertex attribute
  84949. * @returns boolean specifying if uv coordinates are present
  84950. */
  84951. private setAttributeKind;
  84952. /**
  84953. * Sets data for the primitive attributes of each submesh
  84954. * @param mesh glTF Mesh object to store the primitive attribute information
  84955. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  84956. * @param binaryWriter Buffer to write the attribute data to
  84957. * @param convertToRightHandedSystem Converts the values to right-handed
  84958. */
  84959. private setPrimitiveAttributesAsync;
  84960. /**
  84961. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  84962. * @param node The node to check
  84963. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  84964. */
  84965. private isBabylonCoordinateSystemConvertingNode;
  84966. /**
  84967. * Creates a glTF scene based on the array of meshes
  84968. * Returns the the total byte offset
  84969. * @param babylonScene Babylon scene to get the mesh data from
  84970. * @param binaryWriter Buffer to write binary data to
  84971. */
  84972. private createSceneAsync;
  84973. /**
  84974. * Creates a mapping of Node unique id to node index and handles animations
  84975. * @param babylonScene Babylon Scene
  84976. * @param nodes Babylon transform nodes
  84977. * @param binaryWriter Buffer to write binary data to
  84978. * @returns Node mapping of unique id to index
  84979. */
  84980. private createNodeMapAndAnimationsAsync;
  84981. /**
  84982. * Creates a glTF node from a Babylon mesh
  84983. * @param babylonMesh Source Babylon mesh
  84984. * @param binaryWriter Buffer for storing geometry data
  84985. * @param convertToRightHandedSystem Converts the values to right-handed
  84986. * @param nodeMap Node mapping of unique id to glTF node index
  84987. * @returns glTF node
  84988. */
  84989. private createNodeAsync;
  84990. /**
  84991. * Creates a glTF skin from a Babylon skeleton
  84992. * @param babylonScene Babylon Scene
  84993. * @param nodes Babylon transform nodes
  84994. * @param binaryWriter Buffer to write binary data to
  84995. * @returns Node mapping of unique id to index
  84996. */
  84997. private createSkinsAsync;
  84998. }
  84999. /**
  85000. * @hidden
  85001. *
  85002. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  85003. */
  85004. export class _BinaryWriter {
  85005. /**
  85006. * Array buffer which stores all binary data
  85007. */
  85008. private _arrayBuffer;
  85009. /**
  85010. * View of the array buffer
  85011. */
  85012. private _dataView;
  85013. /**
  85014. * byte offset of data in array buffer
  85015. */
  85016. private _byteOffset;
  85017. /**
  85018. * Initialize binary writer with an initial byte length
  85019. * @param byteLength Initial byte length of the array buffer
  85020. */
  85021. constructor(byteLength: number);
  85022. /**
  85023. * Resize the array buffer to the specified byte length
  85024. * @param byteLength
  85025. */
  85026. private resizeBuffer;
  85027. /**
  85028. * Get an array buffer with the length of the byte offset
  85029. * @returns ArrayBuffer resized to the byte offset
  85030. */
  85031. getArrayBuffer(): ArrayBuffer;
  85032. /**
  85033. * Get the byte offset of the array buffer
  85034. * @returns byte offset
  85035. */
  85036. getByteOffset(): number;
  85037. /**
  85038. * Stores an UInt8 in the array buffer
  85039. * @param entry
  85040. * @param byteOffset If defined, specifies where to set the value as an offset.
  85041. */
  85042. setUInt8(entry: number, byteOffset?: number): void;
  85043. /**
  85044. * Stores an UInt16 in the array buffer
  85045. * @param entry
  85046. * @param byteOffset If defined, specifies where to set the value as an offset.
  85047. */
  85048. setUInt16(entry: number, byteOffset?: number): void;
  85049. /**
  85050. * Gets an UInt32 in the array buffer
  85051. * @param entry
  85052. * @param byteOffset If defined, specifies where to set the value as an offset.
  85053. */
  85054. getUInt32(byteOffset: number): number;
  85055. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85056. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85057. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85058. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85059. /**
  85060. * Stores a Float32 in the array buffer
  85061. * @param entry
  85062. */
  85063. setFloat32(entry: number, byteOffset?: number): void;
  85064. /**
  85065. * Stores an UInt32 in the array buffer
  85066. * @param entry
  85067. * @param byteOffset If defined, specifies where to set the value as an offset.
  85068. */
  85069. setUInt32(entry: number, byteOffset?: number): void;
  85070. }
  85071. }
  85072. declare module BABYLON.GLTF2.Exporter {
  85073. /**
  85074. * @hidden
  85075. * Interface to store animation data.
  85076. */
  85077. export interface _IAnimationData {
  85078. /**
  85079. * Keyframe data.
  85080. */
  85081. inputs: number[];
  85082. /**
  85083. * Value data.
  85084. */
  85085. outputs: number[][];
  85086. /**
  85087. * Animation interpolation data.
  85088. */
  85089. samplerInterpolation: AnimationSamplerInterpolation;
  85090. /**
  85091. * Minimum keyframe value.
  85092. */
  85093. inputsMin: number;
  85094. /**
  85095. * Maximum keyframe value.
  85096. */
  85097. inputsMax: number;
  85098. }
  85099. /**
  85100. * @hidden
  85101. */
  85102. export interface _IAnimationInfo {
  85103. /**
  85104. * The target channel for the animation
  85105. */
  85106. animationChannelTargetPath: AnimationChannelTargetPath;
  85107. /**
  85108. * The glTF accessor type for the data.
  85109. */
  85110. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  85111. /**
  85112. * Specifies if quaternions should be used.
  85113. */
  85114. useQuaternion: boolean;
  85115. }
  85116. /**
  85117. * @hidden
  85118. * Utility class for generating glTF animation data from BabylonJS.
  85119. */
  85120. export class _GLTFAnimation {
  85121. /**
  85122. * @ignore
  85123. *
  85124. * Creates glTF channel animation from BabylonJS animation.
  85125. * @param babylonTransformNode - BabylonJS mesh.
  85126. * @param animation - animation.
  85127. * @param animationChannelTargetPath - The target animation channel.
  85128. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  85129. * @param useQuaternion - Specifies if quaternions are used.
  85130. * @returns nullable IAnimationData
  85131. */
  85132. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  85133. private static _DeduceAnimationInfo;
  85134. /**
  85135. * @ignore
  85136. * Create node animations from the transform node animations
  85137. * @param babylonNode
  85138. * @param runtimeGLTFAnimation
  85139. * @param idleGLTFAnimations
  85140. * @param nodeMap
  85141. * @param nodes
  85142. * @param binaryWriter
  85143. * @param bufferViews
  85144. * @param accessors
  85145. * @param convertToRightHandedSystem
  85146. * @param animationSampleRate
  85147. */
  85148. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85149. [key: number]: number;
  85150. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85151. /**
  85152. * @ignore
  85153. * Create individual morph animations from the mesh's morph target animation tracks
  85154. * @param babylonNode
  85155. * @param runtimeGLTFAnimation
  85156. * @param idleGLTFAnimations
  85157. * @param nodeMap
  85158. * @param nodes
  85159. * @param binaryWriter
  85160. * @param bufferViews
  85161. * @param accessors
  85162. * @param convertToRightHandedSystem
  85163. * @param animationSampleRate
  85164. */
  85165. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85166. [key: number]: number;
  85167. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85168. /**
  85169. * @ignore
  85170. * Create node and morph animations from the animation groups
  85171. * @param babylonScene
  85172. * @param glTFAnimations
  85173. * @param nodeMap
  85174. * @param nodes
  85175. * @param binaryWriter
  85176. * @param bufferViews
  85177. * @param accessors
  85178. * @param convertToRightHandedSystemMap
  85179. * @param animationSampleRate
  85180. */
  85181. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  85182. [key: number]: number;
  85183. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  85184. [nodeId: number]: boolean;
  85185. }, animationSampleRate: number): void;
  85186. private static AddAnimation;
  85187. /**
  85188. * Create a baked animation
  85189. * @param babylonTransformNode BabylonJS mesh
  85190. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  85191. * @param animationChannelTargetPath animation target channel
  85192. * @param minFrame minimum animation frame
  85193. * @param maxFrame maximum animation frame
  85194. * @param fps frames per second of the animation
  85195. * @param inputs input key frames of the animation
  85196. * @param outputs output key frame data of the animation
  85197. * @param convertToRightHandedSystem converts the values to right-handed
  85198. * @param useQuaternion specifies if quaternions should be used
  85199. */
  85200. private static _CreateBakedAnimation;
  85201. private static _ConvertFactorToVector3OrQuaternion;
  85202. private static _SetInterpolatedValue;
  85203. /**
  85204. * Creates linear animation from the animation key frames
  85205. * @param babylonTransformNode BabylonJS mesh
  85206. * @param animation BabylonJS animation
  85207. * @param animationChannelTargetPath The target animation channel
  85208. * @param frameDelta The difference between the last and first frame of the animation
  85209. * @param inputs Array to store the key frame times
  85210. * @param outputs Array to store the key frame data
  85211. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85212. * @param useQuaternion Specifies if quaternions are used in the animation
  85213. */
  85214. private static _CreateLinearOrStepAnimation;
  85215. /**
  85216. * Creates cubic spline animation from the animation key frames
  85217. * @param babylonTransformNode BabylonJS mesh
  85218. * @param animation BabylonJS animation
  85219. * @param animationChannelTargetPath The target animation channel
  85220. * @param frameDelta The difference between the last and first frame of the animation
  85221. * @param inputs Array to store the key frame times
  85222. * @param outputs Array to store the key frame data
  85223. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85224. * @param useQuaternion Specifies if quaternions are used in the animation
  85225. */
  85226. private static _CreateCubicSplineAnimation;
  85227. private static _GetBasePositionRotationOrScale;
  85228. /**
  85229. * Adds a key frame value
  85230. * @param keyFrame
  85231. * @param animation
  85232. * @param outputs
  85233. * @param animationChannelTargetPath
  85234. * @param basePositionRotationOrScale
  85235. * @param convertToRightHandedSystem
  85236. * @param useQuaternion
  85237. */
  85238. private static _AddKeyframeValue;
  85239. /**
  85240. * Determine the interpolation based on the key frames
  85241. * @param keyFrames
  85242. * @param animationChannelTargetPath
  85243. * @param useQuaternion
  85244. */
  85245. private static _DeduceInterpolation;
  85246. /**
  85247. * Adds an input tangent or output tangent to the output data
  85248. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  85249. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  85250. * @param outputs The animation data by keyframe
  85251. * @param animationChannelTargetPath The target animation channel
  85252. * @param interpolation The interpolation type
  85253. * @param keyFrame The key frame with the animation data
  85254. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  85255. * @param useQuaternion Specifies if quaternions are used
  85256. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  85257. */
  85258. private static AddSplineTangent;
  85259. /**
  85260. * Get the minimum and maximum key frames' frame values
  85261. * @param keyFrames animation key frames
  85262. * @returns the minimum and maximum key frame value
  85263. */
  85264. private static calculateMinMaxKeyFrames;
  85265. }
  85266. }
  85267. declare module BABYLON.GLTF2.Exporter {
  85268. /** @hidden */
  85269. export var textureTransformPixelShader: {
  85270. name: string;
  85271. shader: string;
  85272. };
  85273. }
  85274. declare module BABYLON.GLTF2.Exporter.Extensions {
  85275. /**
  85276. * @hidden
  85277. */
  85278. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  85279. private _recordedTextures;
  85280. /** Name of this extension */
  85281. readonly name: string;
  85282. /** Defines whether this extension is enabled */
  85283. enabled: boolean;
  85284. /** Defines whether this extension is required */
  85285. required: boolean;
  85286. /** Reference to the glTF exporter */
  85287. private _wasUsed;
  85288. constructor(exporter: _Exporter);
  85289. dispose(): void;
  85290. /** @hidden */
  85291. get wasUsed(): boolean;
  85292. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85293. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  85294. /**
  85295. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  85296. * @param babylonTexture
  85297. * @param offset
  85298. * @param rotation
  85299. * @param scale
  85300. * @param scene
  85301. */
  85302. private _textureTransformTextureAsync;
  85303. }
  85304. }
  85305. declare module BABYLON.GLTF2.Exporter.Extensions {
  85306. /**
  85307. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  85308. */
  85309. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  85310. /** The name of this extension. */
  85311. readonly name: string;
  85312. /** Defines whether this extension is enabled. */
  85313. enabled: boolean;
  85314. /** Defines whether this extension is required */
  85315. required: boolean;
  85316. /** Reference to the glTF exporter */
  85317. private _exporter;
  85318. private _lights;
  85319. /** @hidden */
  85320. constructor(exporter: _Exporter);
  85321. /** @hidden */
  85322. dispose(): void;
  85323. /** @hidden */
  85324. get wasUsed(): boolean;
  85325. /** @hidden */
  85326. onExporting(): void;
  85327. /**
  85328. * Define this method to modify the default behavior when exporting a node
  85329. * @param context The context when exporting the node
  85330. * @param node glTF node
  85331. * @param babylonNode BabylonJS node
  85332. * @param nodeMap Node mapping of unique id to glTF node index
  85333. * @returns nullable INode promise
  85334. */
  85335. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85336. [key: number]: number;
  85337. }): Promise<Nullable<INode>>;
  85338. }
  85339. }
  85340. declare module BABYLON.GLTF2.Exporter.Extensions {
  85341. /**
  85342. * @hidden
  85343. */
  85344. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  85345. /** Name of this extension */
  85346. readonly name: string;
  85347. /** Defines whether this extension is enabled */
  85348. enabled: boolean;
  85349. /** Defines whether this extension is required */
  85350. required: boolean;
  85351. /** Reference to the glTF exporter */
  85352. private _textureInfos;
  85353. private _exportedTextures;
  85354. private _wasUsed;
  85355. constructor(exporter: _Exporter);
  85356. dispose(): void;
  85357. /** @hidden */
  85358. get wasUsed(): boolean;
  85359. private _getTextureIndex;
  85360. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85361. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85362. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85363. }
  85364. }
  85365. declare module BABYLON.GLTF2.Exporter.Extensions {
  85366. /**
  85367. * @hidden
  85368. */
  85369. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85370. /** Name of this extension */
  85371. readonly name: string;
  85372. /** Defines whether this extension is enabled */
  85373. enabled: boolean;
  85374. /** Defines whether this extension is required */
  85375. required: boolean;
  85376. private _wasUsed;
  85377. constructor(exporter: _Exporter);
  85378. /** @hidden */
  85379. get wasUsed(): boolean;
  85380. dispose(): void;
  85381. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85382. }
  85383. }
  85384. declare module BABYLON {
  85385. /**
  85386. * Class for generating STL data from a Babylon scene.
  85387. */
  85388. export class STLExport {
  85389. /**
  85390. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  85391. * @param meshes list defines the mesh to serialize
  85392. * @param download triggers the automatic download of the file.
  85393. * @param fileName changes the downloads fileName.
  85394. * @param binary changes the STL to a binary type.
  85395. * @param isLittleEndian toggle for binary type exporter.
  85396. * @returns the STL as UTF8 string
  85397. */
  85398. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  85399. }
  85400. }
  85401. declare module "babylonjs-gltf2interface" {
  85402. export = BABYLON.GLTF2;
  85403. }
  85404. /**
  85405. * Module for glTF 2.0 Interface
  85406. */
  85407. declare module BABYLON.GLTF2 {
  85408. /**
  85409. * The datatype of the components in the attribute
  85410. */
  85411. const enum AccessorComponentType {
  85412. /**
  85413. * Byte
  85414. */
  85415. BYTE = 5120,
  85416. /**
  85417. * Unsigned Byte
  85418. */
  85419. UNSIGNED_BYTE = 5121,
  85420. /**
  85421. * Short
  85422. */
  85423. SHORT = 5122,
  85424. /**
  85425. * Unsigned Short
  85426. */
  85427. UNSIGNED_SHORT = 5123,
  85428. /**
  85429. * Unsigned Int
  85430. */
  85431. UNSIGNED_INT = 5125,
  85432. /**
  85433. * Float
  85434. */
  85435. FLOAT = 5126,
  85436. }
  85437. /**
  85438. * Specifies if the attirbute is a scalar, vector, or matrix
  85439. */
  85440. const enum AccessorType {
  85441. /**
  85442. * Scalar
  85443. */
  85444. SCALAR = "SCALAR",
  85445. /**
  85446. * Vector2
  85447. */
  85448. VEC2 = "VEC2",
  85449. /**
  85450. * Vector3
  85451. */
  85452. VEC3 = "VEC3",
  85453. /**
  85454. * Vector4
  85455. */
  85456. VEC4 = "VEC4",
  85457. /**
  85458. * Matrix2x2
  85459. */
  85460. MAT2 = "MAT2",
  85461. /**
  85462. * Matrix3x3
  85463. */
  85464. MAT3 = "MAT3",
  85465. /**
  85466. * Matrix4x4
  85467. */
  85468. MAT4 = "MAT4",
  85469. }
  85470. /**
  85471. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85472. */
  85473. const enum AnimationChannelTargetPath {
  85474. /**
  85475. * Translation
  85476. */
  85477. TRANSLATION = "translation",
  85478. /**
  85479. * Rotation
  85480. */
  85481. ROTATION = "rotation",
  85482. /**
  85483. * Scale
  85484. */
  85485. SCALE = "scale",
  85486. /**
  85487. * Weights
  85488. */
  85489. WEIGHTS = "weights",
  85490. }
  85491. /**
  85492. * Interpolation algorithm
  85493. */
  85494. const enum AnimationSamplerInterpolation {
  85495. /**
  85496. * The animated values are linearly interpolated between keyframes
  85497. */
  85498. LINEAR = "LINEAR",
  85499. /**
  85500. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  85501. */
  85502. STEP = "STEP",
  85503. /**
  85504. * The animation's interpolation is computed using a cubic spline with specified tangents
  85505. */
  85506. CUBICSPLINE = "CUBICSPLINE",
  85507. }
  85508. /**
  85509. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85510. */
  85511. const enum CameraType {
  85512. /**
  85513. * A perspective camera containing properties to create a perspective projection matrix
  85514. */
  85515. PERSPECTIVE = "perspective",
  85516. /**
  85517. * An orthographic camera containing properties to create an orthographic projection matrix
  85518. */
  85519. ORTHOGRAPHIC = "orthographic",
  85520. }
  85521. /**
  85522. * The mime-type of the image
  85523. */
  85524. const enum ImageMimeType {
  85525. /**
  85526. * JPEG Mime-type
  85527. */
  85528. JPEG = "image/jpeg",
  85529. /**
  85530. * PNG Mime-type
  85531. */
  85532. PNG = "image/png",
  85533. }
  85534. /**
  85535. * The alpha rendering mode of the material
  85536. */
  85537. const enum MaterialAlphaMode {
  85538. /**
  85539. * The alpha value is ignored and the rendered output is fully opaque
  85540. */
  85541. OPAQUE = "OPAQUE",
  85542. /**
  85543. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  85544. */
  85545. MASK = "MASK",
  85546. /**
  85547. * 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)
  85548. */
  85549. BLEND = "BLEND",
  85550. }
  85551. /**
  85552. * The type of the primitives to render
  85553. */
  85554. const enum MeshPrimitiveMode {
  85555. /**
  85556. * Points
  85557. */
  85558. POINTS = 0,
  85559. /**
  85560. * Lines
  85561. */
  85562. LINES = 1,
  85563. /**
  85564. * Line Loop
  85565. */
  85566. LINE_LOOP = 2,
  85567. /**
  85568. * Line Strip
  85569. */
  85570. LINE_STRIP = 3,
  85571. /**
  85572. * Triangles
  85573. */
  85574. TRIANGLES = 4,
  85575. /**
  85576. * Triangle Strip
  85577. */
  85578. TRIANGLE_STRIP = 5,
  85579. /**
  85580. * Triangle Fan
  85581. */
  85582. TRIANGLE_FAN = 6,
  85583. }
  85584. /**
  85585. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85586. */
  85587. const enum TextureMagFilter {
  85588. /**
  85589. * Nearest
  85590. */
  85591. NEAREST = 9728,
  85592. /**
  85593. * Linear
  85594. */
  85595. LINEAR = 9729,
  85596. }
  85597. /**
  85598. * Minification filter. All valid values correspond to WebGL enums
  85599. */
  85600. const enum TextureMinFilter {
  85601. /**
  85602. * Nearest
  85603. */
  85604. NEAREST = 9728,
  85605. /**
  85606. * Linear
  85607. */
  85608. LINEAR = 9729,
  85609. /**
  85610. * Nearest Mip-Map Nearest
  85611. */
  85612. NEAREST_MIPMAP_NEAREST = 9984,
  85613. /**
  85614. * Linear Mipmap Nearest
  85615. */
  85616. LINEAR_MIPMAP_NEAREST = 9985,
  85617. /**
  85618. * Nearest Mipmap Linear
  85619. */
  85620. NEAREST_MIPMAP_LINEAR = 9986,
  85621. /**
  85622. * Linear Mipmap Linear
  85623. */
  85624. LINEAR_MIPMAP_LINEAR = 9987,
  85625. }
  85626. /**
  85627. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85628. */
  85629. const enum TextureWrapMode {
  85630. /**
  85631. * Clamp to Edge
  85632. */
  85633. CLAMP_TO_EDGE = 33071,
  85634. /**
  85635. * Mirrored Repeat
  85636. */
  85637. MIRRORED_REPEAT = 33648,
  85638. /**
  85639. * Repeat
  85640. */
  85641. REPEAT = 10497,
  85642. }
  85643. /**
  85644. * glTF Property
  85645. */
  85646. interface IProperty {
  85647. /**
  85648. * Dictionary object with extension-specific objects
  85649. */
  85650. extensions?: {
  85651. [key: string]: any;
  85652. };
  85653. /**
  85654. * Application-Specific data
  85655. */
  85656. extras?: any;
  85657. }
  85658. /**
  85659. * glTF Child of Root Property
  85660. */
  85661. interface IChildRootProperty extends IProperty {
  85662. /**
  85663. * The user-defined name of this object
  85664. */
  85665. name?: string;
  85666. }
  85667. /**
  85668. * Indices of those attributes that deviate from their initialization value
  85669. */
  85670. interface IAccessorSparseIndices extends IProperty {
  85671. /**
  85672. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85673. */
  85674. bufferView: number;
  85675. /**
  85676. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85677. */
  85678. byteOffset?: number;
  85679. /**
  85680. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  85681. */
  85682. componentType: AccessorComponentType;
  85683. }
  85684. /**
  85685. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  85686. */
  85687. interface IAccessorSparseValues extends IProperty {
  85688. /**
  85689. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85690. */
  85691. bufferView: number;
  85692. /**
  85693. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85694. */
  85695. byteOffset?: number;
  85696. }
  85697. /**
  85698. * Sparse storage of attributes that deviate from their initialization value
  85699. */
  85700. interface IAccessorSparse extends IProperty {
  85701. /**
  85702. * The number of attributes encoded in this sparse accessor
  85703. */
  85704. count: number;
  85705. /**
  85706. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  85707. */
  85708. indices: IAccessorSparseIndices;
  85709. /**
  85710. * 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
  85711. */
  85712. values: IAccessorSparseValues;
  85713. }
  85714. /**
  85715. * 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
  85716. */
  85717. interface IAccessor extends IChildRootProperty {
  85718. /**
  85719. * The index of the bufferview
  85720. */
  85721. bufferView?: number;
  85722. /**
  85723. * The offset relative to the start of the bufferView in bytes
  85724. */
  85725. byteOffset?: number;
  85726. /**
  85727. * The datatype of components in the attribute
  85728. */
  85729. componentType: AccessorComponentType;
  85730. /**
  85731. * Specifies whether integer data values should be normalized
  85732. */
  85733. normalized?: boolean;
  85734. /**
  85735. * The number of attributes referenced by this accessor
  85736. */
  85737. count: number;
  85738. /**
  85739. * Specifies if the attribute is a scalar, vector, or matrix
  85740. */
  85741. type: AccessorType;
  85742. /**
  85743. * Maximum value of each component in this attribute
  85744. */
  85745. max?: number[];
  85746. /**
  85747. * Minimum value of each component in this attribute
  85748. */
  85749. min?: number[];
  85750. /**
  85751. * Sparse storage of attributes that deviate from their initialization value
  85752. */
  85753. sparse?: IAccessorSparse;
  85754. }
  85755. /**
  85756. * Targets an animation's sampler at a node's property
  85757. */
  85758. interface IAnimationChannel extends IProperty {
  85759. /**
  85760. * The index of a sampler in this animation used to compute the value for the target
  85761. */
  85762. sampler: number;
  85763. /**
  85764. * The index of the node and TRS property to target
  85765. */
  85766. target: IAnimationChannelTarget;
  85767. }
  85768. /**
  85769. * The index of the node and TRS property that an animation channel targets
  85770. */
  85771. interface IAnimationChannelTarget extends IProperty {
  85772. /**
  85773. * The index of the node to target
  85774. */
  85775. node: number;
  85776. /**
  85777. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85778. */
  85779. path: AnimationChannelTargetPath;
  85780. }
  85781. /**
  85782. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85783. */
  85784. interface IAnimationSampler extends IProperty {
  85785. /**
  85786. * The index of an accessor containing keyframe input values, e.g., time
  85787. */
  85788. input: number;
  85789. /**
  85790. * Interpolation algorithm
  85791. */
  85792. interpolation?: AnimationSamplerInterpolation;
  85793. /**
  85794. * The index of an accessor, containing keyframe output values
  85795. */
  85796. output: number;
  85797. }
  85798. /**
  85799. * A keyframe animation
  85800. */
  85801. interface IAnimation extends IChildRootProperty {
  85802. /**
  85803. * An array of channels, each of which targets an animation's sampler at a node's property
  85804. */
  85805. channels: IAnimationChannel[];
  85806. /**
  85807. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85808. */
  85809. samplers: IAnimationSampler[];
  85810. }
  85811. /**
  85812. * Metadata about the glTF asset
  85813. */
  85814. interface IAsset extends IChildRootProperty {
  85815. /**
  85816. * A copyright message suitable for display to credit the content creator
  85817. */
  85818. copyright?: string;
  85819. /**
  85820. * Tool that generated this glTF model. Useful for debugging
  85821. */
  85822. generator?: string;
  85823. /**
  85824. * The glTF version that this asset targets
  85825. */
  85826. version: string;
  85827. /**
  85828. * The minimum glTF version that this asset targets
  85829. */
  85830. minVersion?: string;
  85831. }
  85832. /**
  85833. * A buffer points to binary geometry, animation, or skins
  85834. */
  85835. interface IBuffer extends IChildRootProperty {
  85836. /**
  85837. * 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
  85838. */
  85839. uri?: string;
  85840. /**
  85841. * The length of the buffer in bytes
  85842. */
  85843. byteLength: number;
  85844. }
  85845. /**
  85846. * A view into a buffer generally representing a subset of the buffer
  85847. */
  85848. interface IBufferView extends IChildRootProperty {
  85849. /**
  85850. * The index of the buffer
  85851. */
  85852. buffer: number;
  85853. /**
  85854. * The offset into the buffer in bytes
  85855. */
  85856. byteOffset?: number;
  85857. /**
  85858. * The lenth of the bufferView in bytes
  85859. */
  85860. byteLength: number;
  85861. /**
  85862. * The stride, in bytes
  85863. */
  85864. byteStride?: number;
  85865. }
  85866. /**
  85867. * An orthographic camera containing properties to create an orthographic projection matrix
  85868. */
  85869. interface ICameraOrthographic extends IProperty {
  85870. /**
  85871. * The floating-point horizontal magnification of the view. Must not be zero
  85872. */
  85873. xmag: number;
  85874. /**
  85875. * The floating-point vertical magnification of the view. Must not be zero
  85876. */
  85877. ymag: number;
  85878. /**
  85879. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  85880. */
  85881. zfar: number;
  85882. /**
  85883. * The floating-point distance to the near clipping plane
  85884. */
  85885. znear: number;
  85886. }
  85887. /**
  85888. * A perspective camera containing properties to create a perspective projection matrix
  85889. */
  85890. interface ICameraPerspective extends IProperty {
  85891. /**
  85892. * The floating-point aspect ratio of the field of view
  85893. */
  85894. aspectRatio?: number;
  85895. /**
  85896. * The floating-point vertical field of view in radians
  85897. */
  85898. yfov: number;
  85899. /**
  85900. * The floating-point distance to the far clipping plane
  85901. */
  85902. zfar?: number;
  85903. /**
  85904. * The floating-point distance to the near clipping plane
  85905. */
  85906. znear: number;
  85907. }
  85908. /**
  85909. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85910. */
  85911. interface ICamera extends IChildRootProperty {
  85912. /**
  85913. * An orthographic camera containing properties to create an orthographic projection matrix
  85914. */
  85915. orthographic?: ICameraOrthographic;
  85916. /**
  85917. * A perspective camera containing properties to create a perspective projection matrix
  85918. */
  85919. perspective?: ICameraPerspective;
  85920. /**
  85921. * Specifies if the camera uses a perspective or orthographic projection
  85922. */
  85923. type: CameraType;
  85924. }
  85925. /**
  85926. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  85927. */
  85928. interface IImage extends IChildRootProperty {
  85929. /**
  85930. * 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
  85931. */
  85932. uri?: string;
  85933. /**
  85934. * The image's MIME type
  85935. */
  85936. mimeType?: ImageMimeType;
  85937. /**
  85938. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  85939. */
  85940. bufferView?: number;
  85941. }
  85942. /**
  85943. * Material Normal Texture Info
  85944. */
  85945. interface IMaterialNormalTextureInfo extends ITextureInfo {
  85946. /**
  85947. * The scalar multiplier applied to each normal vector of the normal texture
  85948. */
  85949. scale?: number;
  85950. }
  85951. /**
  85952. * Material Occlusion Texture Info
  85953. */
  85954. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  85955. /**
  85956. * A scalar multiplier controlling the amount of occlusion applied
  85957. */
  85958. strength?: number;
  85959. }
  85960. /**
  85961. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  85962. */
  85963. interface IMaterialPbrMetallicRoughness {
  85964. /**
  85965. * The material's base color factor
  85966. */
  85967. baseColorFactor?: number[];
  85968. /**
  85969. * The base color texture
  85970. */
  85971. baseColorTexture?: ITextureInfo;
  85972. /**
  85973. * The metalness of the material
  85974. */
  85975. metallicFactor?: number;
  85976. /**
  85977. * The roughness of the material
  85978. */
  85979. roughnessFactor?: number;
  85980. /**
  85981. * The metallic-roughness texture
  85982. */
  85983. metallicRoughnessTexture?: ITextureInfo;
  85984. }
  85985. /**
  85986. * The material appearance of a primitive
  85987. */
  85988. interface IMaterial extends IChildRootProperty {
  85989. /**
  85990. * 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
  85991. */
  85992. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  85993. /**
  85994. * The normal map texture
  85995. */
  85996. normalTexture?: IMaterialNormalTextureInfo;
  85997. /**
  85998. * The occlusion map texture
  85999. */
  86000. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86001. /**
  86002. * The emissive map texture
  86003. */
  86004. emissiveTexture?: ITextureInfo;
  86005. /**
  86006. * 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
  86007. */
  86008. emissiveFactor?: number[];
  86009. /**
  86010. * The alpha rendering mode of the material
  86011. */
  86012. alphaMode?: MaterialAlphaMode;
  86013. /**
  86014. * The alpha cutoff value of the material
  86015. */
  86016. alphaCutoff?: number;
  86017. /**
  86018. * Specifies whether the material is double sided
  86019. */
  86020. doubleSided?: boolean;
  86021. }
  86022. /**
  86023. * Geometry to be rendered with the given material
  86024. */
  86025. interface IMeshPrimitive extends IProperty {
  86026. /**
  86027. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  86028. */
  86029. attributes: {
  86030. [name: string]: number;
  86031. };
  86032. /**
  86033. * The index of the accessor that contains the indices
  86034. */
  86035. indices?: number;
  86036. /**
  86037. * The index of the material to apply to this primitive when rendering
  86038. */
  86039. material?: number;
  86040. /**
  86041. * The type of primitives to render. All valid values correspond to WebGL enums
  86042. */
  86043. mode?: MeshPrimitiveMode;
  86044. /**
  86045. * 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
  86046. */
  86047. targets?: {
  86048. [name: string]: number;
  86049. }[];
  86050. }
  86051. /**
  86052. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  86053. */
  86054. interface IMesh extends IChildRootProperty {
  86055. /**
  86056. * An array of primitives, each defining geometry to be rendered with a material
  86057. */
  86058. primitives: IMeshPrimitive[];
  86059. /**
  86060. * Array of weights to be applied to the Morph Targets
  86061. */
  86062. weights?: number[];
  86063. }
  86064. /**
  86065. * A node in the node hierarchy
  86066. */
  86067. interface INode extends IChildRootProperty {
  86068. /**
  86069. * The index of the camera referenced by this node
  86070. */
  86071. camera?: number;
  86072. /**
  86073. * The indices of this node's children
  86074. */
  86075. children?: number[];
  86076. /**
  86077. * The index of the skin referenced by this node
  86078. */
  86079. skin?: number;
  86080. /**
  86081. * A floating-point 4x4 transformation matrix stored in column-major order
  86082. */
  86083. matrix?: number[];
  86084. /**
  86085. * The index of the mesh in this node
  86086. */
  86087. mesh?: number;
  86088. /**
  86089. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  86090. */
  86091. rotation?: number[];
  86092. /**
  86093. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  86094. */
  86095. scale?: number[];
  86096. /**
  86097. * The node's translation along the x, y, and z axes
  86098. */
  86099. translation?: number[];
  86100. /**
  86101. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  86102. */
  86103. weights?: number[];
  86104. }
  86105. /**
  86106. * Texture sampler properties for filtering and wrapping modes
  86107. */
  86108. interface ISampler extends IChildRootProperty {
  86109. /**
  86110. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86111. */
  86112. magFilter?: TextureMagFilter;
  86113. /**
  86114. * Minification filter. All valid values correspond to WebGL enums
  86115. */
  86116. minFilter?: TextureMinFilter;
  86117. /**
  86118. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86119. */
  86120. wrapS?: TextureWrapMode;
  86121. /**
  86122. * T (V) wrapping mode. All valid values correspond to WebGL enums
  86123. */
  86124. wrapT?: TextureWrapMode;
  86125. }
  86126. /**
  86127. * The root nodes of a scene
  86128. */
  86129. interface IScene extends IChildRootProperty {
  86130. /**
  86131. * The indices of each root node
  86132. */
  86133. nodes: number[];
  86134. }
  86135. /**
  86136. * Joints and matrices defining a skin
  86137. */
  86138. interface ISkin extends IChildRootProperty {
  86139. /**
  86140. * 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
  86141. */
  86142. inverseBindMatrices?: number;
  86143. /**
  86144. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  86145. */
  86146. skeleton?: number;
  86147. /**
  86148. * 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)
  86149. */
  86150. joints: number[];
  86151. }
  86152. /**
  86153. * A texture and its sampler
  86154. */
  86155. interface ITexture extends IChildRootProperty {
  86156. /**
  86157. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  86158. */
  86159. sampler?: number;
  86160. /**
  86161. * The index of the image used by this texture
  86162. */
  86163. source: number;
  86164. }
  86165. /**
  86166. * Reference to a texture
  86167. */
  86168. interface ITextureInfo extends IProperty {
  86169. /**
  86170. * The index of the texture
  86171. */
  86172. index: number;
  86173. /**
  86174. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  86175. */
  86176. texCoord?: number;
  86177. }
  86178. /**
  86179. * The root object for a glTF asset
  86180. */
  86181. interface IGLTF extends IProperty {
  86182. /**
  86183. * An array of accessors. An accessor is a typed view into a bufferView
  86184. */
  86185. accessors?: IAccessor[];
  86186. /**
  86187. * An array of keyframe animations
  86188. */
  86189. animations?: IAnimation[];
  86190. /**
  86191. * Metadata about the glTF asset
  86192. */
  86193. asset: IAsset;
  86194. /**
  86195. * An array of buffers. A buffer points to binary geometry, animation, or skins
  86196. */
  86197. buffers?: IBuffer[];
  86198. /**
  86199. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  86200. */
  86201. bufferViews?: IBufferView[];
  86202. /**
  86203. * An array of cameras
  86204. */
  86205. cameras?: ICamera[];
  86206. /**
  86207. * Names of glTF extensions used somewhere in this asset
  86208. */
  86209. extensionsUsed?: string[];
  86210. /**
  86211. * Names of glTF extensions required to properly load this asset
  86212. */
  86213. extensionsRequired?: string[];
  86214. /**
  86215. * An array of images. An image defines data used to create a texture
  86216. */
  86217. images?: IImage[];
  86218. /**
  86219. * An array of materials. A material defines the appearance of a primitive
  86220. */
  86221. materials?: IMaterial[];
  86222. /**
  86223. * An array of meshes. A mesh is a set of primitives to be rendered
  86224. */
  86225. meshes?: IMesh[];
  86226. /**
  86227. * An array of nodes
  86228. */
  86229. nodes?: INode[];
  86230. /**
  86231. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  86232. */
  86233. samplers?: ISampler[];
  86234. /**
  86235. * The index of the default scene
  86236. */
  86237. scene?: number;
  86238. /**
  86239. * An array of scenes
  86240. */
  86241. scenes?: IScene[];
  86242. /**
  86243. * An array of skins. A skin is defined by joints and matrices
  86244. */
  86245. skins?: ISkin[];
  86246. /**
  86247. * An array of textures
  86248. */
  86249. textures?: ITexture[];
  86250. }
  86251. /**
  86252. * The glTF validation results
  86253. * @ignore
  86254. */
  86255. interface IGLTFValidationResults {
  86256. info: {
  86257. generator: string;
  86258. hasAnimations: boolean;
  86259. hasDefaultScene: boolean;
  86260. hasMaterials: boolean;
  86261. hasMorphTargets: boolean;
  86262. hasSkins: boolean;
  86263. hasTextures: boolean;
  86264. maxAttributesUsed: number;
  86265. primitivesCount: number
  86266. };
  86267. issues: {
  86268. messages: Array<string>;
  86269. numErrors: number;
  86270. numHints: number;
  86271. numInfos: number;
  86272. numWarnings: number;
  86273. truncated: boolean
  86274. };
  86275. mimeType: string;
  86276. uri: string;
  86277. validatedAt: string;
  86278. validatorVersion: string;
  86279. }
  86280. /**
  86281. * The glTF validation options
  86282. */
  86283. interface IGLTFValidationOptions {
  86284. /** Uri to use */
  86285. uri?: string;
  86286. /** Function used to load external resources */
  86287. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  86288. /** Boolean indicating that we need to validate accessor data */
  86289. validateAccessorData?: boolean;
  86290. /** max number of issues allowed */
  86291. maxIssues?: number;
  86292. /** Ignored issues */
  86293. ignoredIssues?: Array<string>;
  86294. /** Value to override severy settings */
  86295. severityOverrides?: Object;
  86296. }
  86297. /**
  86298. * The glTF validator object
  86299. * @ignore
  86300. */
  86301. interface IGLTFValidator {
  86302. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86303. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86304. }
  86305. /**
  86306. * Interfaces from the EXT_lights_image_based extension
  86307. */
  86308. /** @hidden */
  86309. interface IEXTLightsImageBased_LightReferenceImageBased {
  86310. light: number;
  86311. }
  86312. /** @hidden */
  86313. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  86314. intensity: number;
  86315. rotation: number[];
  86316. specularImageSize: number;
  86317. specularImages: number[][];
  86318. irradianceCoefficients: number[][];
  86319. }
  86320. /** @hidden */
  86321. interface IEXTLightsImageBased {
  86322. lights: IEXTLightsImageBased_LightImageBased[];
  86323. }
  86324. /**
  86325. * Interfaces from the EXT_mesh_gpu_instancing extension
  86326. * !!! Experimental Extension Subject to Changes !!!
  86327. */
  86328. /** @hidden */
  86329. interface IEXTMeshGpuInstancing {
  86330. mesh?: number;
  86331. attributes: { [name: string]: number };
  86332. }
  86333. /**
  86334. * Interfaces from the KHR_draco_mesh_compression extension
  86335. */
  86336. /** @hidden */
  86337. interface IKHRDracoMeshCompression {
  86338. bufferView: number;
  86339. attributes: { [name: string]: number };
  86340. }
  86341. /**
  86342. * Interfaces from the KHR_lights_punctual extension
  86343. */
  86344. /** @hidden */
  86345. const enum IKHRLightsPunctual_LightType {
  86346. DIRECTIONAL = "directional",
  86347. POINT = "point",
  86348. SPOT = "spot"
  86349. }
  86350. /** @hidden */
  86351. interface IKHRLightsPunctual_LightReference {
  86352. light: number;
  86353. }
  86354. /** @hidden */
  86355. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  86356. type: IKHRLightsPunctual_LightType;
  86357. color?: number[];
  86358. intensity?: number;
  86359. range?: number;
  86360. spot?: {
  86361. innerConeAngle?: number;
  86362. outerConeAngle?: number;
  86363. };
  86364. }
  86365. /** @hidden */
  86366. interface IKHRLightsPunctual {
  86367. lights: IKHRLightsPunctual_Light[];
  86368. }
  86369. /**
  86370. * Interfaces from the KHR_materials_clearcoat extension
  86371. * !!! Experimental Extension Subject to Changes !!!
  86372. */
  86373. /** @hidden */
  86374. interface IKHRMaterialsClearcoat {
  86375. clearcoatFactor: number;
  86376. clearcoatTexture: ITextureInfo;
  86377. clearcoatRoughnessFactor: number;
  86378. clearcoatRoughnessTexture: ITextureInfo;
  86379. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  86380. }
  86381. /**
  86382. * Interfaces from the KHR_materials_ior extension
  86383. * !!! Experimental Extension Subject to Changes !!!
  86384. */
  86385. /** @hidden */
  86386. interface IKHRMaterialsIor {
  86387. ior: number;
  86388. }
  86389. /**
  86390. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  86391. */
  86392. /** @hidden */
  86393. interface IKHRMaterialsPbrSpecularGlossiness {
  86394. diffuseFactor: number[];
  86395. diffuseTexture: ITextureInfo;
  86396. specularFactor: number[];
  86397. glossinessFactor: number;
  86398. specularGlossinessTexture: ITextureInfo;
  86399. }
  86400. /**
  86401. * Interfaces from the KHR_materials_sheen extension
  86402. * !!! Experimental Extension Subject to Changes !!!
  86403. */
  86404. /** @hidden */
  86405. interface IKHRMaterialsSheen {
  86406. sheenColorFactor?: number[];
  86407. sheenColorTexture?: ITextureInfo;
  86408. sheenRoughnessFactor?: number;
  86409. sheenRoughnessTexture?: ITextureInfo;
  86410. }
  86411. /**
  86412. * Interfaces from the KHR_materials_specular extension
  86413. * !!! Experimental Extension Subject to Changes !!!
  86414. */
  86415. /** @hidden */
  86416. interface IKHRMaterialsSpecular {
  86417. specularFactor: number;
  86418. specularColorFactor: number[];
  86419. specularTexture: ITextureInfo;
  86420. }
  86421. /**
  86422. * Interfaces from the KHR_materials_transmission extension
  86423. * !!! Experimental Extension Subject to Changes !!!
  86424. */
  86425. /** @hidden */
  86426. interface IKHRMaterialsTransmission {
  86427. transmissionFactor?: number;
  86428. transmissionTexture?: ITextureInfo;
  86429. }
  86430. /**
  86431. * Interfaces from the KHR_materials_variants extension
  86432. * !!! Experimental Extension Subject to Changes !!!
  86433. */
  86434. /** @hidden */
  86435. interface IKHRMaterialVariants_Mapping extends IProperty {
  86436. mappings: Array<{
  86437. variants: number[];
  86438. material: number;
  86439. }>;
  86440. }
  86441. /** @hidden */
  86442. interface IKHRMaterialVariants_Variant extends IProperty {
  86443. name: string;
  86444. }
  86445. /** @hidden */
  86446. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  86447. variants: Array<IKHRMaterialVariants_Variant>;
  86448. }
  86449. /**
  86450. * Interfaces from the KHR_texture_basisu extension
  86451. * !!! Experimental Extension Subject to Changes !!!
  86452. */
  86453. /** @hidden */
  86454. interface IKHRTextureBasisU {
  86455. source: number;
  86456. }
  86457. /**
  86458. * Interfaces from the EXT_texture_webp extension
  86459. */
  86460. /** @hidden */
  86461. interface IEXTTextureWebP {
  86462. source: number;
  86463. }
  86464. /**
  86465. * Interfaces from the KHR_texture_transform extension
  86466. */
  86467. /** @hidden */
  86468. interface IKHRTextureTransform {
  86469. offset?: number[];
  86470. rotation?: number;
  86471. scale?: number[];
  86472. texCoord?: number;
  86473. }
  86474. /**
  86475. * Interfaces from the KHR_xmp extension
  86476. * !!! Experimental Extension Subject to Changes !!!
  86477. */
  86478. /** @hidden */
  86479. interface IKHRXmp_Data {
  86480. [key: string]: unknown;
  86481. }
  86482. /** @hidden */
  86483. interface IKHRXmp_Gltf {
  86484. packets: IKHRXmp_Data[];
  86485. }
  86486. /** @hidden */
  86487. interface IKHRXmp_Node {
  86488. packet: number;
  86489. }
  86490. /**
  86491. * Interfaces from the MSFT_audio_emitter extension
  86492. */
  86493. /** @hidden */
  86494. interface IMSFTAudioEmitter_ClipReference {
  86495. clip: number;
  86496. weight?: number;
  86497. }
  86498. /** @hidden */
  86499. interface IMSFTAudioEmitter_EmittersReference {
  86500. emitters: number[];
  86501. }
  86502. /** @hidden */
  86503. const enum IMSFTAudioEmitter_DistanceModel {
  86504. linear = "linear",
  86505. inverse = "inverse",
  86506. exponential = "exponential",
  86507. }
  86508. /** @hidden */
  86509. interface IMSFTAudioEmitter_Emitter {
  86510. name?: string;
  86511. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86512. refDistance?: number;
  86513. maxDistance?: number;
  86514. rolloffFactor?: number;
  86515. innerAngle?: number;
  86516. outerAngle?: number;
  86517. loop?: boolean;
  86518. volume?: number;
  86519. clips: IMSFTAudioEmitter_ClipReference[];
  86520. }
  86521. /** @hidden */
  86522. const enum IMSFTAudioEmitter_AudioMimeType {
  86523. WAV = "audio/wav",
  86524. }
  86525. /** @hidden */
  86526. interface IMSFTAudioEmitter_Clip extends IProperty {
  86527. uri?: string;
  86528. bufferView?: number;
  86529. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  86530. }
  86531. /** @hidden */
  86532. const enum IMSFTAudioEmitter_AnimationEventAction {
  86533. play = "play",
  86534. pause = "pause",
  86535. stop = "stop",
  86536. }
  86537. /** @hidden */
  86538. interface IMSFTAudioEmitter_AnimationEvent {
  86539. action: IMSFTAudioEmitter_AnimationEventAction;
  86540. emitter: number;
  86541. time: number;
  86542. startOffset?: number;
  86543. }
  86544. /**
  86545. * Interfaces from the MSFT_lod extension
  86546. */
  86547. /** @hidden */
  86548. interface IMSFTLOD {
  86549. ids: number[];
  86550. }
  86551. }
  86552. declare module BABYLON {
  86553. /** @hidden */
  86554. export var cellPixelShader: {
  86555. name: string;
  86556. shader: string;
  86557. };
  86558. }
  86559. declare module BABYLON {
  86560. /** @hidden */
  86561. export var cellVertexShader: {
  86562. name: string;
  86563. shader: string;
  86564. };
  86565. }
  86566. declare module BABYLON {
  86567. export class CellMaterial extends BABYLON.PushMaterial {
  86568. private _diffuseTexture;
  86569. diffuseTexture: BABYLON.BaseTexture;
  86570. diffuseColor: BABYLON.Color3;
  86571. _computeHighLevel: boolean;
  86572. computeHighLevel: boolean;
  86573. private _disableLighting;
  86574. disableLighting: boolean;
  86575. private _maxSimultaneousLights;
  86576. maxSimultaneousLights: number;
  86577. constructor(name: string, scene: BABYLON.Scene);
  86578. needAlphaBlending(): boolean;
  86579. needAlphaTesting(): boolean;
  86580. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86581. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86582. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86583. getAnimatables(): BABYLON.IAnimatable[];
  86584. getActiveTextures(): BABYLON.BaseTexture[];
  86585. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86586. dispose(forceDisposeEffect?: boolean): void;
  86587. getClassName(): string;
  86588. clone(name: string): CellMaterial;
  86589. serialize(): any;
  86590. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  86591. }
  86592. }
  86593. declare module BABYLON {
  86594. export class CustomShaderStructure {
  86595. FragmentStore: string;
  86596. VertexStore: string;
  86597. constructor();
  86598. }
  86599. export class ShaderSpecialParts {
  86600. constructor();
  86601. Fragment_Begin: string;
  86602. Fragment_Definitions: string;
  86603. Fragment_MainBegin: string;
  86604. Fragment_Custom_Diffuse: string;
  86605. Fragment_Before_Lights: string;
  86606. Fragment_Before_Fog: string;
  86607. Fragment_Custom_Alpha: string;
  86608. Fragment_Before_FragColor: string;
  86609. Vertex_Begin: string;
  86610. Vertex_Definitions: string;
  86611. Vertex_MainBegin: string;
  86612. Vertex_Before_PositionUpdated: string;
  86613. Vertex_Before_NormalUpdated: string;
  86614. Vertex_After_WorldPosComputed: string;
  86615. Vertex_MainEnd: string;
  86616. }
  86617. export class CustomMaterial extends BABYLON.StandardMaterial {
  86618. static ShaderIndexer: number;
  86619. CustomParts: ShaderSpecialParts;
  86620. _isCreatedShader: boolean;
  86621. _createdShaderName: string;
  86622. _customUniform: string[];
  86623. _newUniforms: string[];
  86624. _newUniformInstances: {
  86625. [name: string]: any;
  86626. };
  86627. _newSamplerInstances: {
  86628. [name: string]: BABYLON.Texture;
  86629. };
  86630. _customAttributes: string[];
  86631. FragmentShader: string;
  86632. VertexShader: string;
  86633. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86634. ReviewUniform(name: string, arr: string[]): string[];
  86635. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86636. constructor(name: string, scene: BABYLON.Scene);
  86637. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  86638. AddAttribute(name: string): CustomMaterial;
  86639. Fragment_Begin(shaderPart: string): CustomMaterial;
  86640. Fragment_Definitions(shaderPart: string): CustomMaterial;
  86641. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  86642. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  86643. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  86644. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  86645. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  86646. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  86647. Vertex_Begin(shaderPart: string): CustomMaterial;
  86648. Vertex_Definitions(shaderPart: string): CustomMaterial;
  86649. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  86650. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  86651. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  86652. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  86653. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  86654. }
  86655. }
  86656. declare module BABYLON {
  86657. export class ShaderAlebdoParts {
  86658. constructor();
  86659. Fragment_Begin: string;
  86660. Fragment_Definitions: string;
  86661. Fragment_MainBegin: string;
  86662. Fragment_Custom_Albedo: string;
  86663. Fragment_Before_Lights: string;
  86664. Fragment_Custom_MetallicRoughness: string;
  86665. Fragment_Custom_MicroSurface: string;
  86666. Fragment_Before_Fog: string;
  86667. Fragment_Custom_Alpha: string;
  86668. Fragment_Before_FragColor: string;
  86669. Vertex_Begin: string;
  86670. Vertex_Definitions: string;
  86671. Vertex_MainBegin: string;
  86672. Vertex_Before_PositionUpdated: string;
  86673. Vertex_Before_NormalUpdated: string;
  86674. Vertex_After_WorldPosComputed: string;
  86675. Vertex_MainEnd: string;
  86676. }
  86677. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  86678. static ShaderIndexer: number;
  86679. CustomParts: ShaderAlebdoParts;
  86680. _isCreatedShader: boolean;
  86681. _createdShaderName: string;
  86682. _customUniform: string[];
  86683. _newUniforms: string[];
  86684. _newUniformInstances: {
  86685. [name: string]: any;
  86686. };
  86687. _newSamplerInstances: {
  86688. [name: string]: BABYLON.Texture;
  86689. };
  86690. _customAttributes: string[];
  86691. FragmentShader: string;
  86692. VertexShader: string;
  86693. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86694. ReviewUniform(name: string, arr: string[]): string[];
  86695. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86696. constructor(name: string, scene: BABYLON.Scene);
  86697. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  86698. AddAttribute(name: string): PBRCustomMaterial;
  86699. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  86700. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  86701. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  86702. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  86703. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  86704. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  86705. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  86706. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  86707. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  86708. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  86709. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  86710. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  86711. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  86712. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  86713. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  86714. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  86715. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  86716. }
  86717. }
  86718. declare module BABYLON {
  86719. /** @hidden */
  86720. export var firePixelShader: {
  86721. name: string;
  86722. shader: string;
  86723. };
  86724. }
  86725. declare module BABYLON {
  86726. /** @hidden */
  86727. export var fireVertexShader: {
  86728. name: string;
  86729. shader: string;
  86730. };
  86731. }
  86732. declare module BABYLON {
  86733. export class FireMaterial extends BABYLON.PushMaterial {
  86734. private _diffuseTexture;
  86735. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86736. private _distortionTexture;
  86737. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86738. private _opacityTexture;
  86739. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86740. diffuseColor: BABYLON.Color3;
  86741. speed: number;
  86742. private _scaledDiffuse;
  86743. private _lastTime;
  86744. constructor(name: string, scene: BABYLON.Scene);
  86745. needAlphaBlending(): boolean;
  86746. needAlphaTesting(): boolean;
  86747. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86748. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86749. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86750. getAnimatables(): BABYLON.IAnimatable[];
  86751. getActiveTextures(): BABYLON.BaseTexture[];
  86752. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86753. getClassName(): string;
  86754. dispose(forceDisposeEffect?: boolean): void;
  86755. clone(name: string): FireMaterial;
  86756. serialize(): any;
  86757. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  86758. }
  86759. }
  86760. declare module BABYLON {
  86761. /** @hidden */
  86762. export var furPixelShader: {
  86763. name: string;
  86764. shader: string;
  86765. };
  86766. }
  86767. declare module BABYLON {
  86768. /** @hidden */
  86769. export var furVertexShader: {
  86770. name: string;
  86771. shader: string;
  86772. };
  86773. }
  86774. declare module BABYLON {
  86775. export class FurMaterial extends BABYLON.PushMaterial {
  86776. private _diffuseTexture;
  86777. diffuseTexture: BABYLON.BaseTexture;
  86778. private _heightTexture;
  86779. heightTexture: BABYLON.BaseTexture;
  86780. diffuseColor: BABYLON.Color3;
  86781. furLength: number;
  86782. furAngle: number;
  86783. furColor: BABYLON.Color3;
  86784. furOffset: number;
  86785. furSpacing: number;
  86786. furGravity: BABYLON.Vector3;
  86787. furSpeed: number;
  86788. furDensity: number;
  86789. furOcclusion: number;
  86790. furTexture: BABYLON.DynamicTexture;
  86791. private _disableLighting;
  86792. disableLighting: boolean;
  86793. private _maxSimultaneousLights;
  86794. maxSimultaneousLights: number;
  86795. highLevelFur: boolean;
  86796. _meshes: BABYLON.AbstractMesh[];
  86797. private _furTime;
  86798. constructor(name: string, scene: BABYLON.Scene);
  86799. get furTime(): number;
  86800. set furTime(furTime: number);
  86801. needAlphaBlending(): boolean;
  86802. needAlphaTesting(): boolean;
  86803. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86804. updateFur(): void;
  86805. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86806. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86807. getAnimatables(): BABYLON.IAnimatable[];
  86808. getActiveTextures(): BABYLON.BaseTexture[];
  86809. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86810. dispose(forceDisposeEffect?: boolean): void;
  86811. clone(name: string): FurMaterial;
  86812. serialize(): any;
  86813. getClassName(): string;
  86814. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  86815. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  86816. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  86817. }
  86818. }
  86819. declare module BABYLON {
  86820. /** @hidden */
  86821. export var gradientPixelShader: {
  86822. name: string;
  86823. shader: string;
  86824. };
  86825. }
  86826. declare module BABYLON {
  86827. /** @hidden */
  86828. export var gradientVertexShader: {
  86829. name: string;
  86830. shader: string;
  86831. };
  86832. }
  86833. declare module BABYLON {
  86834. export class GradientMaterial extends BABYLON.PushMaterial {
  86835. private _maxSimultaneousLights;
  86836. maxSimultaneousLights: number;
  86837. topColor: BABYLON.Color3;
  86838. topColorAlpha: number;
  86839. bottomColor: BABYLON.Color3;
  86840. bottomColorAlpha: number;
  86841. offset: number;
  86842. scale: number;
  86843. smoothness: number;
  86844. private _disableLighting;
  86845. disableLighting: boolean;
  86846. constructor(name: string, scene: BABYLON.Scene);
  86847. needAlphaBlending(): boolean;
  86848. needAlphaTesting(): boolean;
  86849. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86850. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86851. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86852. getAnimatables(): BABYLON.IAnimatable[];
  86853. dispose(forceDisposeEffect?: boolean): void;
  86854. clone(name: string): GradientMaterial;
  86855. serialize(): any;
  86856. getClassName(): string;
  86857. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  86858. }
  86859. }
  86860. declare module BABYLON {
  86861. /** @hidden */
  86862. export var gridPixelShader: {
  86863. name: string;
  86864. shader: string;
  86865. };
  86866. }
  86867. declare module BABYLON {
  86868. /** @hidden */
  86869. export var gridVertexShader: {
  86870. name: string;
  86871. shader: string;
  86872. };
  86873. }
  86874. declare module BABYLON {
  86875. /**
  86876. * The grid materials allows you to wrap any shape with a grid.
  86877. * Colors are customizable.
  86878. */
  86879. export class GridMaterial extends BABYLON.PushMaterial {
  86880. /**
  86881. * Main color of the grid (e.g. between lines)
  86882. */
  86883. mainColor: BABYLON.Color3;
  86884. /**
  86885. * Color of the grid lines.
  86886. */
  86887. lineColor: BABYLON.Color3;
  86888. /**
  86889. * The scale of the grid compared to unit.
  86890. */
  86891. gridRatio: number;
  86892. /**
  86893. * Allows setting an offset for the grid lines.
  86894. */
  86895. gridOffset: BABYLON.Vector3;
  86896. /**
  86897. * The frequency of thicker lines.
  86898. */
  86899. majorUnitFrequency: number;
  86900. /**
  86901. * The visibility of minor units in the grid.
  86902. */
  86903. minorUnitVisibility: number;
  86904. /**
  86905. * The grid opacity outside of the lines.
  86906. */
  86907. opacity: number;
  86908. /**
  86909. * Determine RBG output is premultiplied by alpha value.
  86910. */
  86911. preMultiplyAlpha: boolean;
  86912. private _opacityTexture;
  86913. opacityTexture: BABYLON.BaseTexture;
  86914. private _gridControl;
  86915. /**
  86916. * constructor
  86917. * @param name The name given to the material in order to identify it afterwards.
  86918. * @param scene The scene the material is used in.
  86919. */
  86920. constructor(name: string, scene: BABYLON.Scene);
  86921. /**
  86922. * Returns wehter or not the grid requires alpha blending.
  86923. */
  86924. needAlphaBlending(): boolean;
  86925. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86926. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86927. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86928. /**
  86929. * Dispose the material and its associated resources.
  86930. * @param forceDisposeEffect will also dispose the used effect when true
  86931. */
  86932. dispose(forceDisposeEffect?: boolean): void;
  86933. clone(name: string): GridMaterial;
  86934. serialize(): any;
  86935. getClassName(): string;
  86936. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  86937. }
  86938. }
  86939. declare module BABYLON {
  86940. /** @hidden */
  86941. export var lavaPixelShader: {
  86942. name: string;
  86943. shader: string;
  86944. };
  86945. }
  86946. declare module BABYLON {
  86947. /** @hidden */
  86948. export var lavaVertexShader: {
  86949. name: string;
  86950. shader: string;
  86951. };
  86952. }
  86953. declare module BABYLON {
  86954. export class LavaMaterial extends BABYLON.PushMaterial {
  86955. private _diffuseTexture;
  86956. diffuseTexture: BABYLON.BaseTexture;
  86957. noiseTexture: BABYLON.BaseTexture;
  86958. fogColor: BABYLON.Color3;
  86959. speed: number;
  86960. movingSpeed: number;
  86961. lowFrequencySpeed: number;
  86962. fogDensity: number;
  86963. private _lastTime;
  86964. diffuseColor: BABYLON.Color3;
  86965. private _disableLighting;
  86966. disableLighting: boolean;
  86967. private _unlit;
  86968. unlit: boolean;
  86969. private _maxSimultaneousLights;
  86970. maxSimultaneousLights: number;
  86971. private _scaledDiffuse;
  86972. constructor(name: string, scene: BABYLON.Scene);
  86973. needAlphaBlending(): boolean;
  86974. needAlphaTesting(): boolean;
  86975. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86976. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86977. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86978. getAnimatables(): BABYLON.IAnimatable[];
  86979. getActiveTextures(): BABYLON.BaseTexture[];
  86980. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86981. dispose(forceDisposeEffect?: boolean): void;
  86982. clone(name: string): LavaMaterial;
  86983. serialize(): any;
  86984. getClassName(): string;
  86985. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  86986. }
  86987. }
  86988. declare module BABYLON {
  86989. /** @hidden */
  86990. export var mixPixelShader: {
  86991. name: string;
  86992. shader: string;
  86993. };
  86994. }
  86995. declare module BABYLON {
  86996. /** @hidden */
  86997. export var mixVertexShader: {
  86998. name: string;
  86999. shader: string;
  87000. };
  87001. }
  87002. declare module BABYLON {
  87003. export class MixMaterial extends BABYLON.PushMaterial {
  87004. /**
  87005. * Mix textures
  87006. */
  87007. private _mixTexture1;
  87008. mixTexture1: BABYLON.BaseTexture;
  87009. private _mixTexture2;
  87010. mixTexture2: BABYLON.BaseTexture;
  87011. /**
  87012. * Diffuse textures
  87013. */
  87014. private _diffuseTexture1;
  87015. diffuseTexture1: BABYLON.Texture;
  87016. private _diffuseTexture2;
  87017. diffuseTexture2: BABYLON.Texture;
  87018. private _diffuseTexture3;
  87019. diffuseTexture3: BABYLON.Texture;
  87020. private _diffuseTexture4;
  87021. diffuseTexture4: BABYLON.Texture;
  87022. private _diffuseTexture5;
  87023. diffuseTexture5: BABYLON.Texture;
  87024. private _diffuseTexture6;
  87025. diffuseTexture6: BABYLON.Texture;
  87026. private _diffuseTexture7;
  87027. diffuseTexture7: BABYLON.Texture;
  87028. private _diffuseTexture8;
  87029. diffuseTexture8: BABYLON.Texture;
  87030. /**
  87031. * Uniforms
  87032. */
  87033. diffuseColor: BABYLON.Color3;
  87034. specularColor: BABYLON.Color3;
  87035. specularPower: number;
  87036. private _disableLighting;
  87037. disableLighting: boolean;
  87038. private _maxSimultaneousLights;
  87039. maxSimultaneousLights: number;
  87040. constructor(name: string, scene: BABYLON.Scene);
  87041. needAlphaBlending(): boolean;
  87042. needAlphaTesting(): boolean;
  87043. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87044. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87045. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87046. getAnimatables(): BABYLON.IAnimatable[];
  87047. getActiveTextures(): BABYLON.BaseTexture[];
  87048. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87049. dispose(forceDisposeEffect?: boolean): void;
  87050. clone(name: string): MixMaterial;
  87051. serialize(): any;
  87052. getClassName(): string;
  87053. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  87054. }
  87055. }
  87056. declare module BABYLON {
  87057. /** @hidden */
  87058. export var normalPixelShader: {
  87059. name: string;
  87060. shader: string;
  87061. };
  87062. }
  87063. declare module BABYLON {
  87064. /** @hidden */
  87065. export var normalVertexShader: {
  87066. name: string;
  87067. shader: string;
  87068. };
  87069. }
  87070. declare module BABYLON {
  87071. export class NormalMaterial extends BABYLON.PushMaterial {
  87072. private _diffuseTexture;
  87073. diffuseTexture: BABYLON.BaseTexture;
  87074. diffuseColor: BABYLON.Color3;
  87075. private _disableLighting;
  87076. disableLighting: boolean;
  87077. private _maxSimultaneousLights;
  87078. maxSimultaneousLights: number;
  87079. constructor(name: string, scene: BABYLON.Scene);
  87080. needAlphaBlending(): boolean;
  87081. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87082. needAlphaTesting(): boolean;
  87083. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87084. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87085. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87086. getAnimatables(): BABYLON.IAnimatable[];
  87087. getActiveTextures(): BABYLON.BaseTexture[];
  87088. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87089. dispose(forceDisposeEffect?: boolean): void;
  87090. clone(name: string): NormalMaterial;
  87091. serialize(): any;
  87092. getClassName(): string;
  87093. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  87094. }
  87095. }
  87096. declare module BABYLON {
  87097. /** @hidden */
  87098. export var shadowOnlyPixelShader: {
  87099. name: string;
  87100. shader: string;
  87101. };
  87102. }
  87103. declare module BABYLON {
  87104. /** @hidden */
  87105. export var shadowOnlyVertexShader: {
  87106. name: string;
  87107. shader: string;
  87108. };
  87109. }
  87110. declare module BABYLON {
  87111. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  87112. private _activeLight;
  87113. private _needAlphaBlending;
  87114. constructor(name: string, scene: BABYLON.Scene);
  87115. shadowColor: BABYLON.Color3;
  87116. needAlphaBlending(): boolean;
  87117. needAlphaTesting(): boolean;
  87118. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87119. get activeLight(): BABYLON.IShadowLight;
  87120. set activeLight(light: BABYLON.IShadowLight);
  87121. private _getFirstShadowLightForMesh;
  87122. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87123. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87124. clone(name: string): ShadowOnlyMaterial;
  87125. serialize(): any;
  87126. getClassName(): string;
  87127. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  87128. }
  87129. }
  87130. declare module BABYLON {
  87131. /** @hidden */
  87132. export var simplePixelShader: {
  87133. name: string;
  87134. shader: string;
  87135. };
  87136. }
  87137. declare module BABYLON {
  87138. /** @hidden */
  87139. export var simpleVertexShader: {
  87140. name: string;
  87141. shader: string;
  87142. };
  87143. }
  87144. declare module BABYLON {
  87145. export class SimpleMaterial extends BABYLON.PushMaterial {
  87146. private _diffuseTexture;
  87147. diffuseTexture: BABYLON.BaseTexture;
  87148. diffuseColor: BABYLON.Color3;
  87149. private _disableLighting;
  87150. disableLighting: boolean;
  87151. private _maxSimultaneousLights;
  87152. maxSimultaneousLights: number;
  87153. constructor(name: string, scene: BABYLON.Scene);
  87154. needAlphaBlending(): boolean;
  87155. needAlphaTesting(): boolean;
  87156. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87157. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87158. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87159. getAnimatables(): BABYLON.IAnimatable[];
  87160. getActiveTextures(): BABYLON.BaseTexture[];
  87161. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87162. dispose(forceDisposeEffect?: boolean): void;
  87163. clone(name: string): SimpleMaterial;
  87164. serialize(): any;
  87165. getClassName(): string;
  87166. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  87167. }
  87168. }
  87169. declare module BABYLON {
  87170. /** @hidden */
  87171. export var skyPixelShader: {
  87172. name: string;
  87173. shader: string;
  87174. };
  87175. }
  87176. declare module BABYLON {
  87177. /** @hidden */
  87178. export var skyVertexShader: {
  87179. name: string;
  87180. shader: string;
  87181. };
  87182. }
  87183. declare module BABYLON {
  87184. /**
  87185. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  87186. * @see https://doc.babylonjs.com/extensions/sky
  87187. */
  87188. export class SkyMaterial extends BABYLON.PushMaterial {
  87189. /**
  87190. * Defines the overall luminance of sky in interval ]0, 1[.
  87191. */
  87192. luminance: number;
  87193. /**
  87194. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  87195. */
  87196. turbidity: number;
  87197. /**
  87198. * Defines the sky appearance (light intensity).
  87199. */
  87200. rayleigh: number;
  87201. /**
  87202. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  87203. */
  87204. mieCoefficient: number;
  87205. /**
  87206. * Defines the amount of haze particles following the Mie scattering theory.
  87207. */
  87208. mieDirectionalG: number;
  87209. /**
  87210. * Defines the distance of the sun according to the active scene camera.
  87211. */
  87212. distance: number;
  87213. /**
  87214. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  87215. * "inclined".
  87216. */
  87217. inclination: number;
  87218. /**
  87219. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  87220. * an object direction and a reference direction.
  87221. */
  87222. azimuth: number;
  87223. /**
  87224. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  87225. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  87226. */
  87227. sunPosition: BABYLON.Vector3;
  87228. /**
  87229. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  87230. * .sunPosition property.
  87231. */
  87232. useSunPosition: boolean;
  87233. /**
  87234. * Defines an offset vector used to get a horizon offset.
  87235. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  87236. */
  87237. cameraOffset: BABYLON.Vector3;
  87238. private _cameraPosition;
  87239. /**
  87240. * Instantiates a new sky material.
  87241. * This material allows to create dynamic and texture free
  87242. * effects for skyboxes by taking care of the atmosphere state.
  87243. * @see https://doc.babylonjs.com/extensions/sky
  87244. * @param name Define the name of the material in the scene
  87245. * @param scene Define the scene the material belong to
  87246. */
  87247. constructor(name: string, scene: BABYLON.Scene);
  87248. /**
  87249. * Specifies if the material will require alpha blending
  87250. * @returns a boolean specifying if alpha blending is needed
  87251. */
  87252. needAlphaBlending(): boolean;
  87253. /**
  87254. * Specifies if this material should be rendered in alpha test mode
  87255. * @returns false as the sky material doesn't need alpha testing.
  87256. */
  87257. needAlphaTesting(): boolean;
  87258. /**
  87259. * Get the texture used for alpha test purpose.
  87260. * @returns null as the sky material has no texture.
  87261. */
  87262. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87263. /**
  87264. * Get if the submesh is ready to be used and all its information available.
  87265. * Child classes can use it to update shaders
  87266. * @param mesh defines the mesh to check
  87267. * @param subMesh defines which submesh to check
  87268. * @param useInstances specifies that instances should be used
  87269. * @returns a boolean indicating that the submesh is ready or not
  87270. */
  87271. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87272. /**
  87273. * Binds the submesh to this material by preparing the effect and shader to draw
  87274. * @param world defines the world transformation matrix
  87275. * @param mesh defines the mesh containing the submesh
  87276. * @param subMesh defines the submesh to bind the material to
  87277. */
  87278. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87279. /**
  87280. * Get the list of animatables in the material.
  87281. * @returns the list of animatables object used in the material
  87282. */
  87283. getAnimatables(): BABYLON.IAnimatable[];
  87284. /**
  87285. * Disposes the material
  87286. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87287. */
  87288. dispose(forceDisposeEffect?: boolean): void;
  87289. /**
  87290. * Makes a duplicate of the material, and gives it a new name
  87291. * @param name defines the new name for the duplicated material
  87292. * @returns the cloned material
  87293. */
  87294. clone(name: string): SkyMaterial;
  87295. /**
  87296. * Serializes this material in a JSON representation
  87297. * @returns the serialized material object
  87298. */
  87299. serialize(): any;
  87300. /**
  87301. * Gets the current class name of the material e.g. "SkyMaterial"
  87302. * Mainly use in serialization.
  87303. * @returns the class name
  87304. */
  87305. getClassName(): string;
  87306. /**
  87307. * Creates a sky material from parsed material data
  87308. * @param source defines the JSON representation of the material
  87309. * @param scene defines the hosting scene
  87310. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87311. * @returns a new sky material
  87312. */
  87313. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  87314. }
  87315. }
  87316. declare module BABYLON {
  87317. /** @hidden */
  87318. export var terrainPixelShader: {
  87319. name: string;
  87320. shader: string;
  87321. };
  87322. }
  87323. declare module BABYLON {
  87324. /** @hidden */
  87325. export var terrainVertexShader: {
  87326. name: string;
  87327. shader: string;
  87328. };
  87329. }
  87330. declare module BABYLON {
  87331. export class TerrainMaterial extends BABYLON.PushMaterial {
  87332. private _mixTexture;
  87333. mixTexture: BABYLON.BaseTexture;
  87334. private _diffuseTexture1;
  87335. diffuseTexture1: BABYLON.Texture;
  87336. private _diffuseTexture2;
  87337. diffuseTexture2: BABYLON.Texture;
  87338. private _diffuseTexture3;
  87339. diffuseTexture3: BABYLON.Texture;
  87340. private _bumpTexture1;
  87341. bumpTexture1: BABYLON.Texture;
  87342. private _bumpTexture2;
  87343. bumpTexture2: BABYLON.Texture;
  87344. private _bumpTexture3;
  87345. bumpTexture3: BABYLON.Texture;
  87346. diffuseColor: BABYLON.Color3;
  87347. specularColor: BABYLON.Color3;
  87348. specularPower: number;
  87349. private _disableLighting;
  87350. disableLighting: boolean;
  87351. private _maxSimultaneousLights;
  87352. maxSimultaneousLights: number;
  87353. constructor(name: string, scene: BABYLON.Scene);
  87354. needAlphaBlending(): boolean;
  87355. needAlphaTesting(): boolean;
  87356. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87357. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87358. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87359. getAnimatables(): BABYLON.IAnimatable[];
  87360. getActiveTextures(): BABYLON.BaseTexture[];
  87361. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87362. dispose(forceDisposeEffect?: boolean): void;
  87363. clone(name: string): TerrainMaterial;
  87364. serialize(): any;
  87365. getClassName(): string;
  87366. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  87367. }
  87368. }
  87369. declare module BABYLON {
  87370. /** @hidden */
  87371. export var triplanarPixelShader: {
  87372. name: string;
  87373. shader: string;
  87374. };
  87375. }
  87376. declare module BABYLON {
  87377. /** @hidden */
  87378. export var triplanarVertexShader: {
  87379. name: string;
  87380. shader: string;
  87381. };
  87382. }
  87383. declare module BABYLON {
  87384. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  87385. mixTexture: BABYLON.BaseTexture;
  87386. private _diffuseTextureX;
  87387. diffuseTextureX: BABYLON.BaseTexture;
  87388. private _diffuseTextureY;
  87389. diffuseTextureY: BABYLON.BaseTexture;
  87390. private _diffuseTextureZ;
  87391. diffuseTextureZ: BABYLON.BaseTexture;
  87392. private _normalTextureX;
  87393. normalTextureX: BABYLON.BaseTexture;
  87394. private _normalTextureY;
  87395. normalTextureY: BABYLON.BaseTexture;
  87396. private _normalTextureZ;
  87397. normalTextureZ: BABYLON.BaseTexture;
  87398. tileSize: number;
  87399. diffuseColor: BABYLON.Color3;
  87400. specularColor: BABYLON.Color3;
  87401. specularPower: number;
  87402. private _disableLighting;
  87403. disableLighting: boolean;
  87404. private _maxSimultaneousLights;
  87405. maxSimultaneousLights: number;
  87406. constructor(name: string, scene: BABYLON.Scene);
  87407. needAlphaBlending(): boolean;
  87408. needAlphaTesting(): boolean;
  87409. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87410. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87411. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87412. getAnimatables(): BABYLON.IAnimatable[];
  87413. getActiveTextures(): BABYLON.BaseTexture[];
  87414. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87415. dispose(forceDisposeEffect?: boolean): void;
  87416. clone(name: string): TriPlanarMaterial;
  87417. serialize(): any;
  87418. getClassName(): string;
  87419. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  87420. }
  87421. }
  87422. declare module BABYLON {
  87423. /** @hidden */
  87424. export var waterPixelShader: {
  87425. name: string;
  87426. shader: string;
  87427. };
  87428. }
  87429. declare module BABYLON {
  87430. /** @hidden */
  87431. export var waterVertexShader: {
  87432. name: string;
  87433. shader: string;
  87434. };
  87435. }
  87436. declare module BABYLON {
  87437. export class WaterMaterial extends BABYLON.PushMaterial {
  87438. renderTargetSize: BABYLON.Vector2;
  87439. private _bumpTexture;
  87440. bumpTexture: BABYLON.BaseTexture;
  87441. diffuseColor: BABYLON.Color3;
  87442. specularColor: BABYLON.Color3;
  87443. specularPower: number;
  87444. private _disableLighting;
  87445. disableLighting: boolean;
  87446. private _maxSimultaneousLights;
  87447. maxSimultaneousLights: number;
  87448. /**
  87449. * Defines the wind force.
  87450. */
  87451. windForce: number;
  87452. /**
  87453. * Defines the direction of the wind in the plane (X, Z).
  87454. */
  87455. windDirection: BABYLON.Vector2;
  87456. /**
  87457. * Defines the height of the waves.
  87458. */
  87459. waveHeight: number;
  87460. /**
  87461. * Defines the bump height related to the bump map.
  87462. */
  87463. bumpHeight: number;
  87464. /**
  87465. * Defines wether or not: to add a smaller moving bump to less steady waves.
  87466. */
  87467. private _bumpSuperimpose;
  87468. bumpSuperimpose: boolean;
  87469. /**
  87470. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  87471. */
  87472. private _fresnelSeparate;
  87473. fresnelSeparate: boolean;
  87474. /**
  87475. * Defines wether or not bump Wwves modify the reflection.
  87476. */
  87477. private _bumpAffectsReflection;
  87478. bumpAffectsReflection: boolean;
  87479. /**
  87480. * Defines the water color blended with the refraction (near).
  87481. */
  87482. waterColor: BABYLON.Color3;
  87483. /**
  87484. * Defines the blend factor related to the water color.
  87485. */
  87486. colorBlendFactor: number;
  87487. /**
  87488. * Defines the water color blended with the reflection (far).
  87489. */
  87490. waterColor2: BABYLON.Color3;
  87491. /**
  87492. * Defines the blend factor related to the water color (reflection, far).
  87493. */
  87494. colorBlendFactor2: number;
  87495. /**
  87496. * Defines the maximum length of a wave.
  87497. */
  87498. waveLength: number;
  87499. /**
  87500. * Defines the waves speed.
  87501. */
  87502. waveSpeed: number;
  87503. /**
  87504. * 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.
  87505. */
  87506. waveCount: number;
  87507. /**
  87508. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  87509. * will avoid calculating useless pixels in the pixel shader of the water material.
  87510. */
  87511. disableClipPlane: boolean;
  87512. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87513. private _mesh;
  87514. private _refractionRTT;
  87515. private _reflectionRTT;
  87516. private _reflectionTransform;
  87517. private _lastTime;
  87518. private _lastDeltaTime;
  87519. private _useLogarithmicDepth;
  87520. private _waitingRenderList;
  87521. private _imageProcessingConfiguration;
  87522. private _imageProcessingObserver;
  87523. /**
  87524. * Gets a boolean indicating that current material needs to register RTT
  87525. */
  87526. get hasRenderTargetTextures(): boolean;
  87527. /**
  87528. * Constructor
  87529. */
  87530. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  87531. get useLogarithmicDepth(): boolean;
  87532. set useLogarithmicDepth(value: boolean);
  87533. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87534. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87535. addToRenderList(node: any): void;
  87536. enableRenderTargets(enable: boolean): void;
  87537. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  87538. get renderTargetsEnabled(): boolean;
  87539. needAlphaBlending(): boolean;
  87540. needAlphaTesting(): boolean;
  87541. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87542. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87543. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87544. private _createRenderTargets;
  87545. getAnimatables(): BABYLON.IAnimatable[];
  87546. getActiveTextures(): BABYLON.BaseTexture[];
  87547. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87548. dispose(forceDisposeEffect?: boolean): void;
  87549. clone(name: string): WaterMaterial;
  87550. serialize(): any;
  87551. getClassName(): string;
  87552. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  87553. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  87554. }
  87555. }
  87556. declare module BABYLON {
  87557. /** @hidden */
  87558. export var asciiartPixelShader: {
  87559. name: string;
  87560. shader: string;
  87561. };
  87562. }
  87563. declare module BABYLON {
  87564. /**
  87565. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  87566. *
  87567. * It basically takes care rendering the font front the given font size to a texture.
  87568. * This is used later on in the postprocess.
  87569. */
  87570. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  87571. private _font;
  87572. private _text;
  87573. private _charSize;
  87574. /**
  87575. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87576. */
  87577. get charSize(): number;
  87578. /**
  87579. * Create a new instance of the Ascii Art FontTexture class
  87580. * @param name the name of the texture
  87581. * @param font the font to use, use the W3C CSS notation
  87582. * @param text the caracter set to use in the rendering.
  87583. * @param scene the scene that owns the texture
  87584. */
  87585. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87586. /**
  87587. * Gets the max char width of a font.
  87588. * @param font the font to use, use the W3C CSS notation
  87589. * @return the max char width
  87590. */
  87591. private getFontWidth;
  87592. /**
  87593. * Gets the max char height of a font.
  87594. * @param font the font to use, use the W3C CSS notation
  87595. * @return the max char height
  87596. */
  87597. private getFontHeight;
  87598. /**
  87599. * Clones the current AsciiArtTexture.
  87600. * @return the clone of the texture.
  87601. */
  87602. clone(): AsciiArtFontTexture;
  87603. /**
  87604. * Parses a json object representing the texture and returns an instance of it.
  87605. * @param source the source JSON representation
  87606. * @param scene the scene to create the texture for
  87607. * @return the parsed texture
  87608. */
  87609. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  87610. }
  87611. /**
  87612. * Option available in the Ascii Art Post Process.
  87613. */
  87614. export interface IAsciiArtPostProcessOptions {
  87615. /**
  87616. * The font to use following the w3c font definition.
  87617. */
  87618. font?: string;
  87619. /**
  87620. * The character set to use in the postprocess.
  87621. */
  87622. characterSet?: string;
  87623. /**
  87624. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87625. * This number is defined between 0 and 1;
  87626. */
  87627. mixToTile?: number;
  87628. /**
  87629. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87630. * This number is defined between 0 and 1;
  87631. */
  87632. mixToNormal?: number;
  87633. }
  87634. /**
  87635. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  87636. *
  87637. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87638. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  87639. */
  87640. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  87641. /**
  87642. * The font texture used to render the char in the post process.
  87643. */
  87644. private _asciiArtFontTexture;
  87645. /**
  87646. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87647. * This number is defined between 0 and 1;
  87648. */
  87649. mixToTile: number;
  87650. /**
  87651. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87652. * This number is defined between 0 and 1;
  87653. */
  87654. mixToNormal: number;
  87655. /**
  87656. * Instantiates a new Ascii Art Post Process.
  87657. * @param name the name to give to the postprocess
  87658. * @camera the camera to apply the post process to.
  87659. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  87660. */
  87661. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  87662. }
  87663. }
  87664. declare module BABYLON {
  87665. /** @hidden */
  87666. export var digitalrainPixelShader: {
  87667. name: string;
  87668. shader: string;
  87669. };
  87670. }
  87671. declare module BABYLON {
  87672. /**
  87673. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  87674. *
  87675. * It basically takes care rendering the font front the given font size to a texture.
  87676. * This is used later on in the postprocess.
  87677. */
  87678. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  87679. private _font;
  87680. private _text;
  87681. private _charSize;
  87682. /**
  87683. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87684. */
  87685. get charSize(): number;
  87686. /**
  87687. * Create a new instance of the Digital Rain FontTexture class
  87688. * @param name the name of the texture
  87689. * @param font the font to use, use the W3C CSS notation
  87690. * @param text the caracter set to use in the rendering.
  87691. * @param scene the scene that owns the texture
  87692. */
  87693. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87694. /**
  87695. * Gets the max char width of a font.
  87696. * @param font the font to use, use the W3C CSS notation
  87697. * @return the max char width
  87698. */
  87699. private getFontWidth;
  87700. /**
  87701. * Gets the max char height of a font.
  87702. * @param font the font to use, use the W3C CSS notation
  87703. * @return the max char height
  87704. */
  87705. private getFontHeight;
  87706. /**
  87707. * Clones the current DigitalRainFontTexture.
  87708. * @return the clone of the texture.
  87709. */
  87710. clone(): DigitalRainFontTexture;
  87711. /**
  87712. * Parses a json object representing the texture and returns an instance of it.
  87713. * @param source the source JSON representation
  87714. * @param scene the scene to create the texture for
  87715. * @return the parsed texture
  87716. */
  87717. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  87718. }
  87719. /**
  87720. * Option available in the Digital Rain Post Process.
  87721. */
  87722. export interface IDigitalRainPostProcessOptions {
  87723. /**
  87724. * The font to use following the w3c font definition.
  87725. */
  87726. font?: string;
  87727. /**
  87728. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87729. * This number is defined between 0 and 1;
  87730. */
  87731. mixToTile?: number;
  87732. /**
  87733. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87734. * This number is defined between 0 and 1;
  87735. */
  87736. mixToNormal?: number;
  87737. }
  87738. /**
  87739. * DigitalRainPostProcess helps rendering everithing in digital rain.
  87740. *
  87741. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87742. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  87743. */
  87744. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  87745. /**
  87746. * The font texture used to render the char in the post process.
  87747. */
  87748. private _digitalRainFontTexture;
  87749. /**
  87750. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87751. * This number is defined between 0 and 1;
  87752. */
  87753. mixToTile: number;
  87754. /**
  87755. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87756. * This number is defined between 0 and 1;
  87757. */
  87758. mixToNormal: number;
  87759. /**
  87760. * Instantiates a new Digital Rain Post Process.
  87761. * @param name the name to give to the postprocess
  87762. * @camera the camera to apply the post process to.
  87763. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  87764. */
  87765. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  87766. }
  87767. }
  87768. declare module BABYLON {
  87769. /** @hidden */
  87770. export var brickProceduralTexturePixelShader: {
  87771. name: string;
  87772. shader: string;
  87773. };
  87774. }
  87775. declare module BABYLON {
  87776. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  87777. private _numberOfBricksHeight;
  87778. private _numberOfBricksWidth;
  87779. private _jointColor;
  87780. private _brickColor;
  87781. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87782. updateShaderUniforms(): void;
  87783. get numberOfBricksHeight(): number;
  87784. set numberOfBricksHeight(value: number);
  87785. get numberOfBricksWidth(): number;
  87786. set numberOfBricksWidth(value: number);
  87787. get jointColor(): BABYLON.Color3;
  87788. set jointColor(value: BABYLON.Color3);
  87789. get brickColor(): BABYLON.Color3;
  87790. set brickColor(value: BABYLON.Color3);
  87791. /**
  87792. * Serializes this brick procedural texture
  87793. * @returns a serialized brick procedural texture object
  87794. */
  87795. serialize(): any;
  87796. /**
  87797. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  87798. * @param parsedTexture defines parsed texture data
  87799. * @param scene defines the current scene
  87800. * @param rootUrl defines the root URL containing brick procedural texture information
  87801. * @returns a parsed Brick Procedural BABYLON.Texture
  87802. */
  87803. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  87804. }
  87805. }
  87806. declare module BABYLON {
  87807. /** @hidden */
  87808. export var cloudProceduralTexturePixelShader: {
  87809. name: string;
  87810. shader: string;
  87811. };
  87812. }
  87813. declare module BABYLON {
  87814. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  87815. private _skyColor;
  87816. private _cloudColor;
  87817. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87818. updateShaderUniforms(): void;
  87819. get skyColor(): BABYLON.Color4;
  87820. set skyColor(value: BABYLON.Color4);
  87821. get cloudColor(): BABYLON.Color4;
  87822. set cloudColor(value: BABYLON.Color4);
  87823. /**
  87824. * Serializes this cloud procedural texture
  87825. * @returns a serialized cloud procedural texture object
  87826. */
  87827. serialize(): any;
  87828. /**
  87829. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  87830. * @param parsedTexture defines parsed texture data
  87831. * @param scene defines the current scene
  87832. * @param rootUrl defines the root URL containing cloud procedural texture information
  87833. * @returns a parsed Cloud Procedural BABYLON.Texture
  87834. */
  87835. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  87836. }
  87837. }
  87838. declare module BABYLON {
  87839. /** @hidden */
  87840. export var fireProceduralTexturePixelShader: {
  87841. name: string;
  87842. shader: string;
  87843. };
  87844. }
  87845. declare module BABYLON {
  87846. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  87847. private _time;
  87848. private _speed;
  87849. private _autoGenerateTime;
  87850. private _fireColors;
  87851. private _alphaThreshold;
  87852. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87853. updateShaderUniforms(): void;
  87854. render(useCameraPostProcess?: boolean): void;
  87855. static get PurpleFireColors(): BABYLON.Color3[];
  87856. static get GreenFireColors(): BABYLON.Color3[];
  87857. static get RedFireColors(): BABYLON.Color3[];
  87858. static get BlueFireColors(): BABYLON.Color3[];
  87859. get autoGenerateTime(): boolean;
  87860. set autoGenerateTime(value: boolean);
  87861. get fireColors(): BABYLON.Color3[];
  87862. set fireColors(value: BABYLON.Color3[]);
  87863. get time(): number;
  87864. set time(value: number);
  87865. get speed(): BABYLON.Vector2;
  87866. set speed(value: BABYLON.Vector2);
  87867. get alphaThreshold(): number;
  87868. set alphaThreshold(value: number);
  87869. /**
  87870. * Serializes this fire procedural texture
  87871. * @returns a serialized fire procedural texture object
  87872. */
  87873. serialize(): any;
  87874. /**
  87875. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  87876. * @param parsedTexture defines parsed texture data
  87877. * @param scene defines the current scene
  87878. * @param rootUrl defines the root URL containing fire procedural texture information
  87879. * @returns a parsed Fire Procedural BABYLON.Texture
  87880. */
  87881. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  87882. }
  87883. }
  87884. declare module BABYLON {
  87885. /** @hidden */
  87886. export var grassProceduralTexturePixelShader: {
  87887. name: string;
  87888. shader: string;
  87889. };
  87890. }
  87891. declare module BABYLON {
  87892. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  87893. private _grassColors;
  87894. private _groundColor;
  87895. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87896. updateShaderUniforms(): void;
  87897. get grassColors(): BABYLON.Color3[];
  87898. set grassColors(value: BABYLON.Color3[]);
  87899. get groundColor(): BABYLON.Color3;
  87900. set groundColor(value: BABYLON.Color3);
  87901. /**
  87902. * Serializes this grass procedural texture
  87903. * @returns a serialized grass procedural texture object
  87904. */
  87905. serialize(): any;
  87906. /**
  87907. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  87908. * @param parsedTexture defines parsed texture data
  87909. * @param scene defines the current scene
  87910. * @param rootUrl defines the root URL containing grass procedural texture information
  87911. * @returns a parsed Grass Procedural BABYLON.Texture
  87912. */
  87913. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  87914. }
  87915. }
  87916. declare module BABYLON {
  87917. /** @hidden */
  87918. export var marbleProceduralTexturePixelShader: {
  87919. name: string;
  87920. shader: string;
  87921. };
  87922. }
  87923. declare module BABYLON {
  87924. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  87925. private _numberOfTilesHeight;
  87926. private _numberOfTilesWidth;
  87927. private _amplitude;
  87928. private _jointColor;
  87929. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87930. updateShaderUniforms(): void;
  87931. get numberOfTilesHeight(): number;
  87932. set numberOfTilesHeight(value: number);
  87933. get amplitude(): number;
  87934. set amplitude(value: number);
  87935. get numberOfTilesWidth(): number;
  87936. set numberOfTilesWidth(value: number);
  87937. get jointColor(): BABYLON.Color3;
  87938. set jointColor(value: BABYLON.Color3);
  87939. /**
  87940. * Serializes this marble procedural texture
  87941. * @returns a serialized marble procedural texture object
  87942. */
  87943. serialize(): any;
  87944. /**
  87945. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  87946. * @param parsedTexture defines parsed texture data
  87947. * @param scene defines the current scene
  87948. * @param rootUrl defines the root URL containing marble procedural texture information
  87949. * @returns a parsed Marble Procedural BABYLON.Texture
  87950. */
  87951. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  87952. }
  87953. }
  87954. declare module BABYLON {
  87955. /** @hidden */
  87956. export var normalMapProceduralTexturePixelShader: {
  87957. name: string;
  87958. shader: string;
  87959. };
  87960. }
  87961. declare module BABYLON {
  87962. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  87963. private _baseTexture;
  87964. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87965. updateShaderUniforms(): void;
  87966. render(useCameraPostProcess?: boolean): void;
  87967. resize(size: any, generateMipMaps: any): void;
  87968. get baseTexture(): BABYLON.Texture;
  87969. set baseTexture(texture: BABYLON.Texture);
  87970. /**
  87971. * Serializes this normal map procedural texture
  87972. * @returns a serialized normal map procedural texture object
  87973. */
  87974. serialize(): any;
  87975. /**
  87976. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  87977. * @param parsedTexture defines parsed texture data
  87978. * @param scene defines the current scene
  87979. * @param rootUrl defines the root URL containing normal map procedural texture information
  87980. * @returns a parsed Normal Map Procedural BABYLON.Texture
  87981. */
  87982. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  87983. }
  87984. }
  87985. declare module BABYLON {
  87986. /** @hidden */
  87987. export var perlinNoiseProceduralTexturePixelShader: {
  87988. name: string;
  87989. shader: string;
  87990. };
  87991. }
  87992. declare module BABYLON {
  87993. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  87994. time: number;
  87995. timeScale: number;
  87996. translationSpeed: number;
  87997. private _currentTranslation;
  87998. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87999. updateShaderUniforms(): void;
  88000. render(useCameraPostProcess?: boolean): void;
  88001. resize(size: any, generateMipMaps: any): void;
  88002. /**
  88003. * Serializes this perlin noise procedural texture
  88004. * @returns a serialized perlin noise procedural texture object
  88005. */
  88006. serialize(): any;
  88007. /**
  88008. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  88009. * @param parsedTexture defines parsed texture data
  88010. * @param scene defines the current scene
  88011. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  88012. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  88013. */
  88014. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  88015. }
  88016. }
  88017. declare module BABYLON {
  88018. /** @hidden */
  88019. export var roadProceduralTexturePixelShader: {
  88020. name: string;
  88021. shader: string;
  88022. };
  88023. }
  88024. declare module BABYLON {
  88025. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  88026. private _roadColor;
  88027. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88028. updateShaderUniforms(): void;
  88029. get roadColor(): BABYLON.Color3;
  88030. set roadColor(value: BABYLON.Color3);
  88031. /**
  88032. * Serializes this road procedural texture
  88033. * @returns a serialized road procedural texture object
  88034. */
  88035. serialize(): any;
  88036. /**
  88037. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  88038. * @param parsedTexture defines parsed texture data
  88039. * @param scene defines the current scene
  88040. * @param rootUrl defines the root URL containing road procedural texture information
  88041. * @returns a parsed Road Procedural BABYLON.Texture
  88042. */
  88043. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  88044. }
  88045. }
  88046. declare module BABYLON {
  88047. /** @hidden */
  88048. export var starfieldProceduralTexturePixelShader: {
  88049. name: string;
  88050. shader: string;
  88051. };
  88052. }
  88053. declare module BABYLON {
  88054. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  88055. private _time;
  88056. private _alpha;
  88057. private _beta;
  88058. private _zoom;
  88059. private _formuparam;
  88060. private _stepsize;
  88061. private _tile;
  88062. private _brightness;
  88063. private _darkmatter;
  88064. private _distfading;
  88065. private _saturation;
  88066. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88067. updateShaderUniforms(): void;
  88068. get time(): number;
  88069. set time(value: number);
  88070. get alpha(): number;
  88071. set alpha(value: number);
  88072. get beta(): number;
  88073. set beta(value: number);
  88074. get formuparam(): number;
  88075. set formuparam(value: number);
  88076. get stepsize(): number;
  88077. set stepsize(value: number);
  88078. get zoom(): number;
  88079. set zoom(value: number);
  88080. get tile(): number;
  88081. set tile(value: number);
  88082. get brightness(): number;
  88083. set brightness(value: number);
  88084. get darkmatter(): number;
  88085. set darkmatter(value: number);
  88086. get distfading(): number;
  88087. set distfading(value: number);
  88088. get saturation(): number;
  88089. set saturation(value: number);
  88090. /**
  88091. * Serializes this starfield procedural texture
  88092. * @returns a serialized starfield procedural texture object
  88093. */
  88094. serialize(): any;
  88095. /**
  88096. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  88097. * @param parsedTexture defines parsed texture data
  88098. * @param scene defines the current scene
  88099. * @param rootUrl defines the root URL containing startfield procedural texture information
  88100. * @returns a parsed Starfield Procedural BABYLON.Texture
  88101. */
  88102. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  88103. }
  88104. }
  88105. declare module BABYLON {
  88106. /** @hidden */
  88107. export var woodProceduralTexturePixelShader: {
  88108. name: string;
  88109. shader: string;
  88110. };
  88111. }
  88112. declare module BABYLON {
  88113. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  88114. private _ampScale;
  88115. private _woodColor;
  88116. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88117. updateShaderUniforms(): void;
  88118. get ampScale(): number;
  88119. set ampScale(value: number);
  88120. get woodColor(): BABYLON.Color3;
  88121. set woodColor(value: BABYLON.Color3);
  88122. /**
  88123. * Serializes this wood procedural texture
  88124. * @returns a serialized wood procedural texture object
  88125. */
  88126. serialize(): any;
  88127. /**
  88128. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  88129. * @param parsedTexture defines parsed texture data
  88130. * @param scene defines the current scene
  88131. * @param rootUrl defines the root URL containing wood procedural texture information
  88132. * @returns a parsed Wood Procedural BABYLON.Texture
  88133. */
  88134. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  88135. }
  88136. }