documentation.d.ts 3.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handeled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used througouht the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. private static _LogCache;
  333. /**
  334. * Gets a value indicating the number of loading errors
  335. * @ignorenaming
  336. */
  337. static errorsCount: number;
  338. /**
  339. * Callback called when a new log is added
  340. */
  341. static OnNewCacheEntry: (entry: string) => void;
  342. private static _AddLogEntry;
  343. private static _FormatMessage;
  344. private static _LogDisabled;
  345. private static _LogEnabled;
  346. private static _WarnDisabled;
  347. private static _WarnEnabled;
  348. private static _ErrorDisabled;
  349. private static _ErrorEnabled;
  350. /**
  351. * Log a message to the console
  352. */
  353. static Log: (message: string) => void;
  354. /**
  355. * Write a warning message to the console
  356. */
  357. static Warn: (message: string) => void;
  358. /**
  359. * Write an error message to the console
  360. */
  361. static Error: (message: string) => void;
  362. /**
  363. * Gets current log cache (list of logs)
  364. */
  365. static get LogCache(): string;
  366. /**
  367. * Clears the log cache
  368. */
  369. static ClearLogCache(): void;
  370. /**
  371. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  372. */
  373. static set LogLevels(level: number);
  374. }
  375. }
  376. declare module BABYLON {
  377. /** @hidden */
  378. export class _TypeStore {
  379. /** @hidden */
  380. static RegisteredTypes: {
  381. [key: string]: Object;
  382. };
  383. /** @hidden */
  384. static GetClass(fqdn: string): any;
  385. }
  386. }
  387. declare module BABYLON {
  388. /**
  389. * Helper to manipulate strings
  390. */
  391. export class StringTools {
  392. /**
  393. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  394. * @param str Source string
  395. * @param suffix Suffix to search for in the source string
  396. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  397. */
  398. static EndsWith(str: string, suffix: string): boolean;
  399. /**
  400. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static StartsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Decodes a buffer into a string
  408. * @param buffer The buffer to decode
  409. * @returns The decoded string
  410. */
  411. static Decode(buffer: Uint8Array | Uint16Array): string;
  412. /**
  413. * Encode a buffer to a base64 string
  414. * @param buffer defines the buffer to encode
  415. * @returns the encoded string
  416. */
  417. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  418. /**
  419. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  420. * @param num the number to convert and pad
  421. * @param length the expected length of the string
  422. * @returns the padded string
  423. */
  424. static PadNumber(num: number, length: number): string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Class containing a set of static utilities functions for deep copy.
  430. */
  431. export class DeepCopier {
  432. /**
  433. * Tries to copy an object by duplicating every property
  434. * @param source defines the source object
  435. * @param destination defines the target object
  436. * @param doNotCopyList defines a list of properties to avoid
  437. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  438. */
  439. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  440. }
  441. }
  442. declare module BABYLON {
  443. /**
  444. * Class containing a set of static utilities functions for precision date
  445. */
  446. export class PrecisionDate {
  447. /**
  448. * Gets either window.performance.now() if supported or Date.now() else
  449. */
  450. static get Now(): number;
  451. }
  452. }
  453. declare module BABYLON {
  454. /** @hidden */
  455. export class _DevTools {
  456. static WarnImport(name: string): string;
  457. }
  458. }
  459. declare module BABYLON {
  460. /**
  461. * Interface used to define the mechanism to get data from the network
  462. */
  463. export interface IWebRequest {
  464. /**
  465. * Returns client's response url
  466. */
  467. responseURL: string;
  468. /**
  469. * Returns client's status
  470. */
  471. status: number;
  472. /**
  473. * Returns client's status as a text
  474. */
  475. statusText: string;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  481. */
  482. export class WebRequest implements IWebRequest {
  483. private readonly _xhr;
  484. /**
  485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  486. * i.e. when loading files, where the server/service expects an Authorization header
  487. */
  488. static CustomRequestHeaders: {
  489. [key: string]: string;
  490. };
  491. /**
  492. * Add callback functions in this array to update all the requests before they get sent to the network
  493. */
  494. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  495. private _injectCustomRequestHeaders;
  496. /**
  497. * Gets or sets a function to be called when loading progress changes
  498. */
  499. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  500. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  501. /**
  502. * Returns client's state
  503. */
  504. get readyState(): number;
  505. /**
  506. * Returns client's status
  507. */
  508. get status(): number;
  509. /**
  510. * Returns client's status as a text
  511. */
  512. get statusText(): string;
  513. /**
  514. * Returns client's response
  515. */
  516. get response(): any;
  517. /**
  518. * Returns client's response url
  519. */
  520. get responseURL(): string;
  521. /**
  522. * Returns client's response as text
  523. */
  524. get responseText(): string;
  525. /**
  526. * Gets or sets the expected response type
  527. */
  528. get responseType(): XMLHttpRequestResponseType;
  529. set responseType(value: XMLHttpRequestResponseType);
  530. /** @hidden */
  531. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  532. /** @hidden */
  533. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  534. /**
  535. * Cancels any network activity
  536. */
  537. abort(): void;
  538. /**
  539. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  540. * @param body defines an optional request body
  541. */
  542. send(body?: Document | BodyInit | null): void;
  543. /**
  544. * Sets the request method, request URL
  545. * @param method defines the method to use (GET, POST, etc..)
  546. * @param url defines the url to connect with
  547. */
  548. open(method: string, url: string): void;
  549. /**
  550. * Sets the value of a request header.
  551. * @param name The name of the header whose value is to be set
  552. * @param value The value to set as the body of the header
  553. */
  554. setRequestHeader(name: string, value: string): void;
  555. /**
  556. * Get the string containing the text of a particular header's value.
  557. * @param name The name of the header
  558. * @returns The string containing the text of the given header name
  559. */
  560. getResponseHeader(name: string): Nullable<string>;
  561. }
  562. }
  563. declare module BABYLON {
  564. /**
  565. * File request interface
  566. */
  567. export interface IFileRequest {
  568. /**
  569. * Raised when the request is complete (success or error).
  570. */
  571. onCompleteObservable: Observable<IFileRequest>;
  572. /**
  573. * Aborts the request for a file.
  574. */
  575. abort: () => void;
  576. }
  577. }
  578. declare module BABYLON {
  579. /**
  580. * Define options used to create a render target texture
  581. */
  582. export class RenderTargetCreationOptions {
  583. /**
  584. * Specifies is mipmaps must be generated
  585. */
  586. generateMipMaps?: boolean;
  587. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  588. generateDepthBuffer?: boolean;
  589. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  590. generateStencilBuffer?: boolean;
  591. /** Defines texture type (int by default) */
  592. type?: number;
  593. /** Defines sampling mode (trilinear by default) */
  594. samplingMode?: number;
  595. /** Defines format (RGBA by default) */
  596. format?: number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /** Defines the cross module used constants to avoid circular dependncies */
  601. export class Constants {
  602. /** Defines that alpha blending is disabled */
  603. static readonly ALPHA_DISABLE: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  605. static readonly ALPHA_ADD: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  607. static readonly ALPHA_COMBINE: number;
  608. /** Defines that alpha blending is DEST - SRC * DEST */
  609. static readonly ALPHA_SUBTRACT: number;
  610. /** Defines that alpha blending is SRC * DEST */
  611. static readonly ALPHA_MULTIPLY: number;
  612. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  613. static readonly ALPHA_MAXIMIZED: number;
  614. /** Defines that alpha blending is SRC + DEST */
  615. static readonly ALPHA_ONEONE: number;
  616. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  617. static readonly ALPHA_PREMULTIPLIED: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  620. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  623. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  624. static readonly ALPHA_INTERPOLATE: number;
  625. /**
  626. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  627. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  628. */
  629. static readonly ALPHA_SCREENMODE: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST
  632. * Alpha will be set to SRC ALPHA + DST ALPHA
  633. */
  634. static readonly ALPHA_ONEONE_ONEONE: number;
  635. /**
  636. * Defines that alpha blending is SRC * DST ALPHA + DST
  637. * Alpha will be set to 0
  638. */
  639. static readonly ALPHA_ALPHATOCOLOR: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. */
  643. static readonly ALPHA_REVERSEONEMINUS: number;
  644. /**
  645. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  646. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  647. */
  648. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  649. /**
  650. * Defines that alpha blending is SRC + DST
  651. * Alpha will be set to SRC ALPHA
  652. */
  653. static readonly ALPHA_ONEONE_ONEZERO: number;
  654. /**
  655. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  656. * Alpha will be set to DST ALPHA
  657. */
  658. static readonly ALPHA_EXCLUSION: number;
  659. /** Defines that alpha blending equation a SUM */
  660. static readonly ALPHA_EQUATION_ADD: number;
  661. /** Defines that alpha blending equation a SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  663. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  664. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  665. /** Defines that alpha blending equation a MAX operation */
  666. static readonly ALPHA_EQUATION_MAX: number;
  667. /** Defines that alpha blending equation a MIN operation */
  668. static readonly ALPHA_EQUATION_MIN: number;
  669. /**
  670. * Defines that alpha blending equation a DARKEN operation:
  671. * It takes the min of the src and sums the alpha channels.
  672. */
  673. static readonly ALPHA_EQUATION_DARKEN: number;
  674. /** Defines that the ressource is not delayed*/
  675. static readonly DELAYLOADSTATE_NONE: number;
  676. /** Defines that the ressource was successfully delay loaded */
  677. static readonly DELAYLOADSTATE_LOADED: number;
  678. /** Defines that the ressource is currently delay loading */
  679. static readonly DELAYLOADSTATE_LOADING: number;
  680. /** Defines that the ressource is delayed and has not started loading */
  681. static readonly DELAYLOADSTATE_NOTLOADED: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  683. static readonly NEVER: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  685. static readonly ALWAYS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  687. static readonly LESS: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  689. static readonly EQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  691. static readonly LEQUAL: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  693. static readonly GREATER: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  695. static readonly GEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  697. static readonly NOTEQUAL: number;
  698. /** Passed to stencilOperation to specify that stencil value must be kept */
  699. static readonly KEEP: number;
  700. /** Passed to stencilOperation to specify that stencil value must be replaced */
  701. static readonly REPLACE: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented */
  703. static readonly INCR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented */
  705. static readonly DECR: number;
  706. /** Passed to stencilOperation to specify that stencil value must be inverted */
  707. static readonly INVERT: number;
  708. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  709. static readonly INCR_WRAP: number;
  710. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  711. static readonly DECR_WRAP: number;
  712. /** Texture is not repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  714. /** Texture is repeating outside of 0..1 UVs */
  715. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  716. /** Texture is repeating and mirrored */
  717. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  718. /** ALPHA */
  719. static readonly TEXTUREFORMAT_ALPHA: number;
  720. /** LUMINANCE */
  721. static readonly TEXTUREFORMAT_LUMINANCE: number;
  722. /** LUMINANCE_ALPHA */
  723. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  724. /** RGB */
  725. static readonly TEXTUREFORMAT_RGB: number;
  726. /** RGBA */
  727. static readonly TEXTUREFORMAT_RGBA: number;
  728. /** RED */
  729. static readonly TEXTUREFORMAT_RED: number;
  730. /** RED (2nd reference) */
  731. static readonly TEXTUREFORMAT_R: number;
  732. /** RG */
  733. static readonly TEXTUREFORMAT_RG: number;
  734. /** RED_INTEGER */
  735. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  736. /** RED_INTEGER (2nd reference) */
  737. static readonly TEXTUREFORMAT_R_INTEGER: number;
  738. /** RG_INTEGER */
  739. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  740. /** RGB_INTEGER */
  741. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  742. /** RGBA_INTEGER */
  743. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  744. /** UNSIGNED_BYTE */
  745. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  746. /** UNSIGNED_BYTE (2nd reference) */
  747. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  748. /** FLOAT */
  749. static readonly TEXTURETYPE_FLOAT: number;
  750. /** HALF_FLOAT */
  751. static readonly TEXTURETYPE_HALF_FLOAT: number;
  752. /** BYTE */
  753. static readonly TEXTURETYPE_BYTE: number;
  754. /** SHORT */
  755. static readonly TEXTURETYPE_SHORT: number;
  756. /** UNSIGNED_SHORT */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  758. /** INT */
  759. static readonly TEXTURETYPE_INT: number;
  760. /** UNSIGNED_INT */
  761. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  762. /** UNSIGNED_SHORT_4_4_4_4 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  764. /** UNSIGNED_SHORT_5_5_5_1 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  766. /** UNSIGNED_SHORT_5_6_5 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  768. /** UNSIGNED_INT_2_10_10_10_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  770. /** UNSIGNED_INT_24_8 */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  772. /** UNSIGNED_INT_10F_11F_11F_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  774. /** UNSIGNED_INT_5_9_9_9_REV */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  776. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  777. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  778. /** nearest is mag = nearest and min = nearest and no mip */
  779. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  780. /** mag = nearest and min = nearest and mip = none */
  781. static readonly TEXTURE_NEAREST_NEAREST: number;
  782. /** Bilinear is mag = linear and min = linear and no mip */
  783. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  784. /** mag = linear and min = linear and mip = none */
  785. static readonly TEXTURE_LINEAR_LINEAR: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  788. /** Trilinear is mag = linear and min = linear and mip = linear */
  789. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = nearest and mip = nearest */
  791. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = nearest */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  794. /** mag = nearest and min = linear and mip = linear */
  795. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  796. /** mag = nearest and min = linear and mip = none */
  797. static readonly TEXTURE_NEAREST_LINEAR: number;
  798. /** nearest is mag = nearest and min = nearest and mip = linear */
  799. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  800. /** mag = linear and min = nearest and mip = nearest */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  802. /** mag = linear and min = nearest and mip = linear */
  803. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  804. /** Bilinear is mag = linear and min = linear and mip = nearest */
  805. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = none */
  807. static readonly TEXTURE_LINEAR_NEAREST: number;
  808. /** Explicit coordinates mode */
  809. static readonly TEXTURE_EXPLICIT_MODE: number;
  810. /** Spherical coordinates mode */
  811. static readonly TEXTURE_SPHERICAL_MODE: number;
  812. /** Planar coordinates mode */
  813. static readonly TEXTURE_PLANAR_MODE: number;
  814. /** Cubic coordinates mode */
  815. static readonly TEXTURE_CUBIC_MODE: number;
  816. /** Projection coordinates mode */
  817. static readonly TEXTURE_PROJECTION_MODE: number;
  818. /** Skybox coordinates mode */
  819. static readonly TEXTURE_SKYBOX_MODE: number;
  820. /** Inverse Cubic coordinates mode */
  821. static readonly TEXTURE_INVCUBIC_MODE: number;
  822. /** Equirectangular coordinates mode */
  823. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  826. /** Equirectangular Fixed Mirrored coordinates mode */
  827. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  828. /** Offline (baking) quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  830. /** High quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  832. /** Medium quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  834. /** Low quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  836. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  837. static readonly SCALEMODE_FLOOR: number;
  838. /** Defines that texture rescaling will look for the nearest power of 2 size */
  839. static readonly SCALEMODE_NEAREST: number;
  840. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  841. static readonly SCALEMODE_CEILING: number;
  842. /**
  843. * The dirty texture flag value
  844. */
  845. static readonly MATERIAL_TextureDirtyFlag: number;
  846. /**
  847. * The dirty light flag value
  848. */
  849. static readonly MATERIAL_LightDirtyFlag: number;
  850. /**
  851. * The dirty fresnel flag value
  852. */
  853. static readonly MATERIAL_FresnelDirtyFlag: number;
  854. /**
  855. * The dirty attribute flag value
  856. */
  857. static readonly MATERIAL_AttributesDirtyFlag: number;
  858. /**
  859. * The dirty misc flag value
  860. */
  861. static readonly MATERIAL_MiscDirtyFlag: number;
  862. /**
  863. * The dirty prepass flag value
  864. */
  865. static readonly MATERIAL_PrePassDirtyFlag: number;
  866. /**
  867. * The all dirty flag value
  868. */
  869. static readonly MATERIAL_AllDirtyFlag: number;
  870. /**
  871. * Returns the triangle fill mode
  872. */
  873. static readonly MATERIAL_TriangleFillMode: number;
  874. /**
  875. * Returns the wireframe mode
  876. */
  877. static readonly MATERIAL_WireFrameFillMode: number;
  878. /**
  879. * Returns the point fill mode
  880. */
  881. static readonly MATERIAL_PointFillMode: number;
  882. /**
  883. * Returns the point list draw mode
  884. */
  885. static readonly MATERIAL_PointListDrawMode: number;
  886. /**
  887. * Returns the line list draw mode
  888. */
  889. static readonly MATERIAL_LineListDrawMode: number;
  890. /**
  891. * Returns the line loop draw mode
  892. */
  893. static readonly MATERIAL_LineLoopDrawMode: number;
  894. /**
  895. * Returns the line strip draw mode
  896. */
  897. static readonly MATERIAL_LineStripDrawMode: number;
  898. /**
  899. * Returns the triangle strip draw mode
  900. */
  901. static readonly MATERIAL_TriangleStripDrawMode: number;
  902. /**
  903. * Returns the triangle fan draw mode
  904. */
  905. static readonly MATERIAL_TriangleFanDrawMode: number;
  906. /**
  907. * Stores the clock-wise side orientation
  908. */
  909. static readonly MATERIAL_ClockWiseSideOrientation: number;
  910. /**
  911. * Stores the counter clock-wise side orientation
  912. */
  913. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  914. /**
  915. * Nothing
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_NothingTrigger: number;
  919. /**
  920. * On pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickTrigger: number;
  924. /**
  925. * On left pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnLeftPickTrigger: number;
  929. /**
  930. * On right pick
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnRightPickTrigger: number;
  934. /**
  935. * On center pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnCenterPickTrigger: number;
  939. /**
  940. * On pick down
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickDownTrigger: number;
  944. /**
  945. * On double pick
  946. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnDoublePickTrigger: number;
  949. /**
  950. * On pick up
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickUpTrigger: number;
  954. /**
  955. * On pick out.
  956. * This trigger will only be raised if you also declared a OnPickDown
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPickOutTrigger: number;
  960. /**
  961. * On long press
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnLongPressTrigger: number;
  965. /**
  966. * On pointer over
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnPointerOverTrigger: number;
  970. /**
  971. * On pointer out
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnPointerOutTrigger: number;
  975. /**
  976. * On every frame
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnEveryFrameTrigger: number;
  980. /**
  981. * On intersection enter
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnIntersectionEnterTrigger: number;
  985. /**
  986. * On intersection exit
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnIntersectionExitTrigger: number;
  990. /**
  991. * On key down
  992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  993. */
  994. static readonly ACTION_OnKeyDownTrigger: number;
  995. /**
  996. * On key up
  997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  998. */
  999. static readonly ACTION_OnKeyUpTrigger: number;
  1000. /**
  1001. * Billboard mode will only apply to Y axis
  1002. */
  1003. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1004. /**
  1005. * Billboard mode will apply to all axes
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1008. /**
  1009. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1012. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1013. * Test order :
  1014. * Is the bounding sphere outside the frustum ?
  1015. * If not, are the bounding box vertices outside the frustum ?
  1016. * It not, then the cullable object is in the frustum.
  1017. */
  1018. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1019. /** Culling strategy : Bounding Sphere Only.
  1020. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1021. * It's also less accurate than the standard because some not visible objects can still be selected.
  1022. * Test : is the bounding sphere outside the frustum ?
  1023. * If not, then the cullable object is in the frustum.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1026. /** Culling strategy : Optimistic Inclusion.
  1027. * This in an inclusion test first, then the standard exclusion test.
  1028. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1030. * Anyway, it's as accurate as the standard strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the default culling strategy.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1036. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1037. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1038. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1039. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1040. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1041. * Test :
  1042. * Is the cullable object bounding sphere center in the frustum ?
  1043. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1044. */
  1045. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1046. /**
  1047. * No logging while loading
  1048. */
  1049. static readonly SCENELOADER_NO_LOGGING: number;
  1050. /**
  1051. * Minimal logging while loading
  1052. */
  1053. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1054. /**
  1055. * Summary logging while loading
  1056. */
  1057. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1058. /**
  1059. * Detailled logging while loading
  1060. */
  1061. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1062. /**
  1063. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1064. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1065. */
  1066. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1067. /**
  1068. * Constant used to retrieve the position texture index in the textures array in the prepass
  1069. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1070. */
  1071. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1072. /**
  1073. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1074. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1075. */
  1076. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1077. /**
  1078. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1079. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1080. */
  1081. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1082. /**
  1083. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1084. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1085. */
  1086. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1087. /**
  1088. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1089. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1090. */
  1091. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1092. /**
  1093. * Constant used to retrieve albedo index in the textures array in the prepass
  1094. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1095. */
  1096. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1097. }
  1098. }
  1099. declare module BABYLON {
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. * @param options options to be passed to the loader
  1123. */
  1124. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1125. /**
  1126. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1127. * @param data contains the texture data
  1128. * @param texture defines the BabylonJS internal texture
  1129. * @param callback defines the method to call once ready to upload
  1130. * @param options options to be passed to the loader
  1131. */
  1132. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1133. }
  1134. }
  1135. declare module BABYLON {
  1136. /**
  1137. * Class used to store and describe the pipeline context associated with an effect
  1138. */
  1139. export interface IPipelineContext {
  1140. /**
  1141. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1142. */
  1143. isAsync: boolean;
  1144. /**
  1145. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1146. */
  1147. isReady: boolean;
  1148. /** @hidden */
  1149. _getVertexShaderCode(): string | null;
  1150. /** @hidden */
  1151. _getFragmentShaderCode(): string | null;
  1152. /** @hidden */
  1153. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1154. }
  1155. }
  1156. declare module BABYLON {
  1157. /**
  1158. * Class used to store gfx data (like WebGLBuffer)
  1159. */
  1160. export class DataBuffer {
  1161. /**
  1162. * Gets or sets the number of objects referencing this buffer
  1163. */
  1164. references: number;
  1165. /** Gets or sets the size of the underlying buffer */
  1166. capacity: number;
  1167. /**
  1168. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1169. */
  1170. is32Bits: boolean;
  1171. /**
  1172. * Gets the underlying buffer
  1173. */
  1174. get underlyingResource(): any;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export interface IShaderProcessor {
  1180. attributeProcessor?: (attribute: string) => string;
  1181. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1182. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1183. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1184. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1185. lineProcessor?: (line: string, isFragment: boolean) => string;
  1186. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1187. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  1188. }
  1189. }
  1190. declare module BABYLON {
  1191. /** @hidden */
  1192. export interface ProcessingOptions {
  1193. defines: string[];
  1194. indexParameters: any;
  1195. isFragment: boolean;
  1196. shouldUseHighPrecisionShader: boolean;
  1197. supportsUniformBuffers: boolean;
  1198. shadersRepository: string;
  1199. includesShadersStore: {
  1200. [key: string]: string;
  1201. };
  1202. processor?: IShaderProcessor;
  1203. version: string;
  1204. platformName: string;
  1205. lookForClosingBracketForUniformBuffer?: boolean;
  1206. }
  1207. }
  1208. declare module BABYLON {
  1209. /** @hidden */
  1210. export class ShaderCodeNode {
  1211. line: string;
  1212. children: ShaderCodeNode[];
  1213. additionalDefineKey?: string;
  1214. additionalDefineValue?: string;
  1215. isValid(preprocessors: {
  1216. [key: string]: string;
  1217. }): boolean;
  1218. process(preprocessors: {
  1219. [key: string]: string;
  1220. }, options: ProcessingOptions): string;
  1221. }
  1222. }
  1223. declare module BABYLON {
  1224. /** @hidden */
  1225. export class ShaderCodeCursor {
  1226. private _lines;
  1227. lineIndex: number;
  1228. get currentLine(): string;
  1229. get canRead(): boolean;
  1230. set lines(value: string[]);
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /** @hidden */
  1235. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1236. process(preprocessors: {
  1237. [key: string]: string;
  1238. }, options: ProcessingOptions): string;
  1239. }
  1240. }
  1241. declare module BABYLON {
  1242. /** @hidden */
  1243. export class ShaderDefineExpression {
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. private static _OperatorPriority;
  1248. private static _Stack;
  1249. static postfixToInfix(postfix: string[]): string;
  1250. static infixToPostfix(infix: string): string[];
  1251. }
  1252. }
  1253. declare module BABYLON {
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. not: boolean;
  1267. constructor(define: string, not?: boolean);
  1268. isTrue(preprocessors: {
  1269. [key: string]: string;
  1270. }): boolean;
  1271. }
  1272. }
  1273. declare module BABYLON {
  1274. /** @hidden */
  1275. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1276. leftOperand: ShaderDefineExpression;
  1277. rightOperand: ShaderDefineExpression;
  1278. isTrue(preprocessors: {
  1279. [key: string]: string;
  1280. }): boolean;
  1281. }
  1282. }
  1283. declare module BABYLON {
  1284. /** @hidden */
  1285. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1286. leftOperand: ShaderDefineExpression;
  1287. rightOperand: ShaderDefineExpression;
  1288. isTrue(preprocessors: {
  1289. [key: string]: string;
  1290. }): boolean;
  1291. }
  1292. }
  1293. declare module BABYLON {
  1294. /** @hidden */
  1295. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1296. define: string;
  1297. operand: string;
  1298. testValue: string;
  1299. constructor(define: string, operand: string, testValue: string);
  1300. isTrue(preprocessors: {
  1301. [key: string]: string;
  1302. }): boolean;
  1303. }
  1304. }
  1305. declare module BABYLON {
  1306. /**
  1307. * Class used to enable access to offline support
  1308. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1309. */
  1310. export interface IOfflineProvider {
  1311. /**
  1312. * Gets a boolean indicating if scene must be saved in the database
  1313. */
  1314. enableSceneOffline: boolean;
  1315. /**
  1316. * Gets a boolean indicating if textures must be saved in the database
  1317. */
  1318. enableTexturesOffline: boolean;
  1319. /**
  1320. * Open the offline support and make it available
  1321. * @param successCallback defines the callback to call on success
  1322. * @param errorCallback defines the callback to call on error
  1323. */
  1324. open(successCallback: () => void, errorCallback: () => void): void;
  1325. /**
  1326. * Loads an image from the offline support
  1327. * @param url defines the url to load from
  1328. * @param image defines the target DOM image
  1329. */
  1330. loadImage(url: string, image: HTMLImageElement): void;
  1331. /**
  1332. * Loads a file from offline support
  1333. * @param url defines the URL to load from
  1334. * @param sceneLoaded defines a callback to call on success
  1335. * @param progressCallBack defines a callback to call when progress changed
  1336. * @param errorCallback defines a callback to call on error
  1337. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1338. */
  1339. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1340. }
  1341. }
  1342. declare module BABYLON {
  1343. /**
  1344. * Class used to help managing file picking and drag'n'drop
  1345. * File Storage
  1346. */
  1347. export class FilesInputStore {
  1348. /**
  1349. * List of files ready to be loaded
  1350. */
  1351. static FilesToLoad: {
  1352. [key: string]: File;
  1353. };
  1354. }
  1355. }
  1356. declare module BABYLON {
  1357. /**
  1358. * Class used to define a retry strategy when error happens while loading assets
  1359. */
  1360. export class RetryStrategy {
  1361. /**
  1362. * Function used to defines an exponential back off strategy
  1363. * @param maxRetries defines the maximum number of retries (3 by default)
  1364. * @param baseInterval defines the interval between retries
  1365. * @returns the strategy function to use
  1366. */
  1367. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1368. }
  1369. }
  1370. declare module BABYLON {
  1371. /**
  1372. * @ignore
  1373. * Application error to support additional information when loading a file
  1374. */
  1375. export abstract class BaseError extends Error {
  1376. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1377. }
  1378. }
  1379. declare module BABYLON {
  1380. /** @ignore */
  1381. export class LoadFileError extends BaseError {
  1382. request?: WebRequest;
  1383. file?: File;
  1384. /**
  1385. * Creates a new LoadFileError
  1386. * @param message defines the message of the error
  1387. * @param request defines the optional web request
  1388. * @param file defines the optional file
  1389. */
  1390. constructor(message: string, object?: WebRequest | File);
  1391. }
  1392. /** @ignore */
  1393. export class RequestFileError extends BaseError {
  1394. request: WebRequest;
  1395. /**
  1396. * Creates a new LoadFileError
  1397. * @param message defines the message of the error
  1398. * @param request defines the optional web request
  1399. */
  1400. constructor(message: string, request: WebRequest);
  1401. }
  1402. /** @ignore */
  1403. export class ReadFileError extends BaseError {
  1404. file: File;
  1405. /**
  1406. * Creates a new ReadFileError
  1407. * @param message defines the message of the error
  1408. * @param file defines the optional file
  1409. */
  1410. constructor(message: string, file: File);
  1411. }
  1412. /**
  1413. * @hidden
  1414. */
  1415. export class FileTools {
  1416. /**
  1417. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1418. */
  1419. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1420. /**
  1421. * Gets or sets the base URL to use to load assets
  1422. */
  1423. static BaseUrl: string;
  1424. /**
  1425. * Default behaviour for cors in the application.
  1426. * It can be a string if the expected behavior is identical in the entire app.
  1427. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1428. */
  1429. static CorsBehavior: string | ((url: string | string[]) => string);
  1430. /**
  1431. * Gets or sets a function used to pre-process url before using them to load assets
  1432. */
  1433. static PreprocessUrl: (url: string) => string;
  1434. /**
  1435. * Removes unwanted characters from an url
  1436. * @param url defines the url to clean
  1437. * @returns the cleaned url
  1438. */
  1439. private static _CleanUrl;
  1440. /**
  1441. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1442. * @param url define the url we are trying
  1443. * @param element define the dom element where to configure the cors policy
  1444. */
  1445. static SetCorsBehavior(url: string | string[], element: {
  1446. crossOrigin: string | null;
  1447. }): void;
  1448. /**
  1449. * Loads an image as an HTMLImageElement.
  1450. * @param input url string, ArrayBuffer, or Blob to load
  1451. * @param onLoad callback called when the image successfully loads
  1452. * @param onError callback called when the image fails to load
  1453. * @param offlineProvider offline provider for caching
  1454. * @param mimeType optional mime type
  1455. * @returns the HTMLImageElement of the loaded image
  1456. */
  1457. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1458. /**
  1459. * Reads a file from a File object
  1460. * @param file defines the file to load
  1461. * @param onSuccess defines the callback to call when data is loaded
  1462. * @param onProgress defines the callback to call during loading process
  1463. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1464. * @param onError defines the callback to call when an error occurs
  1465. * @returns a file request object
  1466. */
  1467. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1468. /**
  1469. * Loads a file from a url
  1470. * @param url url to load
  1471. * @param onSuccess callback called when the file successfully loads
  1472. * @param onProgress callback called while file is loading (if the server supports this mode)
  1473. * @param offlineProvider defines the offline provider for caching
  1474. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1475. * @param onError callback called when the file fails to load
  1476. * @returns a file request object
  1477. */
  1478. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1479. /**
  1480. * Loads a file
  1481. * @param url url to load
  1482. * @param onSuccess callback called when the file successfully loads
  1483. * @param onProgress callback called while file is loading (if the server supports this mode)
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @param onOpened callback called when the web request is opened
  1487. * @returns a file request object
  1488. */
  1489. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1490. /**
  1491. * Checks if the loaded document was accessed via `file:`-Protocol.
  1492. * @returns boolean
  1493. */
  1494. static IsFileURL(): boolean;
  1495. }
  1496. }
  1497. declare module BABYLON {
  1498. /** @hidden */
  1499. export class ShaderProcessor {
  1500. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1501. private static _ProcessPrecision;
  1502. private static _ExtractOperation;
  1503. private static _BuildSubExpression;
  1504. private static _BuildExpression;
  1505. private static _MoveCursorWithinIf;
  1506. private static _MoveCursor;
  1507. private static _EvaluatePreProcessors;
  1508. private static _PreparePreProcessors;
  1509. private static _ProcessShaderConversion;
  1510. private static _ProcessIncludes;
  1511. /**
  1512. * Loads a file from a url
  1513. * @param url url to load
  1514. * @param onSuccess callback called when the file successfully loads
  1515. * @param onProgress callback called while file is loading (if the server supports this mode)
  1516. * @param offlineProvider defines the offline provider for caching
  1517. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1518. * @param onError callback called when the file fails to load
  1519. * @returns a file request object
  1520. * @hidden
  1521. */
  1522. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1523. }
  1524. }
  1525. declare module BABYLON {
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IColor4Like {
  1530. r: float;
  1531. g: float;
  1532. b: float;
  1533. a: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IColor3Like {
  1539. r: float;
  1540. g: float;
  1541. b: float;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IVector4Like {
  1547. x: float;
  1548. y: float;
  1549. z: float;
  1550. w: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IVector3Like {
  1556. x: float;
  1557. y: float;
  1558. z: float;
  1559. }
  1560. /**
  1561. * @hidden
  1562. */
  1563. export interface IVector2Like {
  1564. x: float;
  1565. y: float;
  1566. }
  1567. /**
  1568. * @hidden
  1569. */
  1570. export interface IMatrixLike {
  1571. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1572. updateFlag: int;
  1573. }
  1574. /**
  1575. * @hidden
  1576. */
  1577. export interface IViewportLike {
  1578. x: float;
  1579. y: float;
  1580. width: float;
  1581. height: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IPlaneLike {
  1587. normal: IVector3Like;
  1588. d: float;
  1589. normalize(): void;
  1590. }
  1591. }
  1592. declare module BABYLON {
  1593. /**
  1594. * Interface used to define common properties for effect fallbacks
  1595. */
  1596. export interface IEffectFallbacks {
  1597. /**
  1598. * Removes the defines that should be removed when falling back.
  1599. * @param currentDefines defines the current define statements for the shader.
  1600. * @param effect defines the current effect we try to compile
  1601. * @returns The resulting defines with defines of the current rank removed.
  1602. */
  1603. reduce(currentDefines: string, effect: Effect): string;
  1604. /**
  1605. * Removes the fallback from the bound mesh.
  1606. */
  1607. unBindMesh(): void;
  1608. /**
  1609. * Checks to see if more fallbacks are still availible.
  1610. */
  1611. hasMoreFallbacks: boolean;
  1612. }
  1613. }
  1614. declare module BABYLON {
  1615. /**
  1616. * Interface for the size containing width and height
  1617. */
  1618. export interface ISize {
  1619. /**
  1620. * Width
  1621. */
  1622. width: number;
  1623. /**
  1624. * Heighht
  1625. */
  1626. height: number;
  1627. }
  1628. /**
  1629. * Size containing widht and height
  1630. */
  1631. export class Size implements ISize {
  1632. /**
  1633. * Width
  1634. */
  1635. width: number;
  1636. /**
  1637. * Height
  1638. */
  1639. height: number;
  1640. /**
  1641. * Creates a Size object from the given width and height (floats).
  1642. * @param width width of the new size
  1643. * @param height height of the new size
  1644. */
  1645. constructor(width: number, height: number);
  1646. /**
  1647. * Returns a string with the Size width and height
  1648. * @returns a string with the Size width and height
  1649. */
  1650. toString(): string;
  1651. /**
  1652. * "Size"
  1653. * @returns the string "Size"
  1654. */
  1655. getClassName(): string;
  1656. /**
  1657. * Returns the Size hash code.
  1658. * @returns a hash code for a unique width and height
  1659. */
  1660. getHashCode(): number;
  1661. /**
  1662. * Updates the current size from the given one.
  1663. * @param src the given size
  1664. */
  1665. copyFrom(src: Size): void;
  1666. /**
  1667. * Updates in place the current Size from the given floats.
  1668. * @param width width of the new size
  1669. * @param height height of the new size
  1670. * @returns the updated Size.
  1671. */
  1672. copyFromFloats(width: number, height: number): Size;
  1673. /**
  1674. * Updates in place the current Size from the given floats.
  1675. * @param width width to set
  1676. * @param height height to set
  1677. * @returns the updated Size.
  1678. */
  1679. set(width: number, height: number): Size;
  1680. /**
  1681. * Multiplies the width and height by numbers
  1682. * @param w factor to multiple the width by
  1683. * @param h factor to multiple the height by
  1684. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1685. */
  1686. multiplyByFloats(w: number, h: number): Size;
  1687. /**
  1688. * Clones the size
  1689. * @returns a new Size copied from the given one.
  1690. */
  1691. clone(): Size;
  1692. /**
  1693. * True if the current Size and the given one width and height are strictly equal.
  1694. * @param other the other size to compare against
  1695. * @returns True if the current Size and the given one width and height are strictly equal.
  1696. */
  1697. equals(other: Size): boolean;
  1698. /**
  1699. * The surface of the Size : width * height (float).
  1700. */
  1701. get surface(): number;
  1702. /**
  1703. * Create a new size of zero
  1704. * @returns a new Size set to (0.0, 0.0)
  1705. */
  1706. static Zero(): Size;
  1707. /**
  1708. * Sums the width and height of two sizes
  1709. * @param otherSize size to add to this size
  1710. * @returns a new Size set as the addition result of the current Size and the given one.
  1711. */
  1712. add(otherSize: Size): Size;
  1713. /**
  1714. * Subtracts the width and height of two
  1715. * @param otherSize size to subtract to this size
  1716. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1717. */
  1718. subtract(otherSize: Size): Size;
  1719. /**
  1720. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1721. * @param start starting size to lerp between
  1722. * @param end end size to lerp between
  1723. * @param amount amount to lerp between the start and end values
  1724. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1725. */
  1726. static Lerp(start: Size, end: Size, amount: number): Size;
  1727. }
  1728. }
  1729. declare module BABYLON {
  1730. /**
  1731. * Base class of all the textures in babylon.
  1732. * It groups all the common properties required to work with Thin Engine.
  1733. */
  1734. export class ThinTexture {
  1735. protected _wrapU: number;
  1736. /**
  1737. * | Value | Type | Description |
  1738. * | ----- | ------------------ | ----------- |
  1739. * | 0 | CLAMP_ADDRESSMODE | |
  1740. * | 1 | WRAP_ADDRESSMODE | |
  1741. * | 2 | MIRROR_ADDRESSMODE | |
  1742. */
  1743. get wrapU(): number;
  1744. set wrapU(value: number);
  1745. protected _wrapV: number;
  1746. /**
  1747. * | Value | Type | Description |
  1748. * | ----- | ------------------ | ----------- |
  1749. * | 0 | CLAMP_ADDRESSMODE | |
  1750. * | 1 | WRAP_ADDRESSMODE | |
  1751. * | 2 | MIRROR_ADDRESSMODE | |
  1752. */
  1753. get wrapV(): number;
  1754. set wrapV(value: number);
  1755. /**
  1756. * | Value | Type | Description |
  1757. * | ----- | ------------------ | ----------- |
  1758. * | 0 | CLAMP_ADDRESSMODE | |
  1759. * | 1 | WRAP_ADDRESSMODE | |
  1760. * | 2 | MIRROR_ADDRESSMODE | |
  1761. */
  1762. wrapR: number;
  1763. /**
  1764. * With compliant hardware and browser (supporting anisotropic filtering)
  1765. * this defines the level of anisotropic filtering in the texture.
  1766. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  1767. */
  1768. anisotropicFilteringLevel: number;
  1769. /**
  1770. * Define the current state of the loading sequence when in delayed load mode.
  1771. */
  1772. delayLoadState: number;
  1773. /**
  1774. * How a texture is mapped.
  1775. * Unused in thin texture mode.
  1776. */
  1777. get coordinatesMode(): number;
  1778. /**
  1779. * Define if the texture is a cube texture or if false a 2d texture.
  1780. */
  1781. get isCube(): boolean;
  1782. set isCube(value: boolean);
  1783. /**
  1784. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  1785. */
  1786. get is3D(): boolean;
  1787. set is3D(value: boolean);
  1788. /**
  1789. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  1790. */
  1791. get is2DArray(): boolean;
  1792. set is2DArray(value: boolean);
  1793. /**
  1794. * Get the class name of the texture.
  1795. * @returns "ThinTexture"
  1796. */
  1797. getClassName(): string;
  1798. /** @hidden */
  1799. _texture: Nullable<InternalTexture>;
  1800. protected _engine: Nullable<ThinEngine>;
  1801. private _cachedSize;
  1802. private _cachedBaseSize;
  1803. /**
  1804. * Instantiates a new ThinTexture.
  1805. * Base class of all the textures in babylon.
  1806. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  1807. * @param internalTexture Define the internalTexture to wrap
  1808. */
  1809. constructor(internalTexture: Nullable<InternalTexture>);
  1810. /**
  1811. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  1812. * @returns true if fully ready
  1813. */
  1814. isReady(): boolean;
  1815. /**
  1816. * Triggers the load sequence in delayed load mode.
  1817. */
  1818. delayLoad(): void;
  1819. /**
  1820. * Get the underlying lower level texture from Babylon.
  1821. * @returns the insternal texture
  1822. */
  1823. getInternalTexture(): Nullable<InternalTexture>;
  1824. /**
  1825. * Get the size of the texture.
  1826. * @returns the texture size.
  1827. */
  1828. getSize(): ISize;
  1829. /**
  1830. * Get the base size of the texture.
  1831. * It can be different from the size if the texture has been resized for POT for instance
  1832. * @returns the base size
  1833. */
  1834. getBaseSize(): ISize;
  1835. /**
  1836. * Update the sampling mode of the texture.
  1837. * Default is Trilinear mode.
  1838. *
  1839. * | Value | Type | Description |
  1840. * | ----- | ------------------ | ----------- |
  1841. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  1842. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  1843. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  1844. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  1845. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  1846. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  1847. * | 7 | NEAREST_LINEAR | |
  1848. * | 8 | NEAREST_NEAREST | |
  1849. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  1850. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  1851. * | 11 | LINEAR_LINEAR | |
  1852. * | 12 | LINEAR_NEAREST | |
  1853. *
  1854. * > _mag_: magnification filter (close to the viewer)
  1855. * > _min_: minification filter (far from the viewer)
  1856. * > _mip_: filter used between mip map levels
  1857. *@param samplingMode Define the new sampling mode of the texture
  1858. */
  1859. updateSamplingMode(samplingMode: number): void;
  1860. /**
  1861. * Release and destroy the underlying lower level texture aka internalTexture.
  1862. */
  1863. releaseInternalTexture(): void;
  1864. /**
  1865. * Dispose the texture and release its associated resources.
  1866. */
  1867. dispose(): void;
  1868. }
  1869. }
  1870. declare module BABYLON {
  1871. /**
  1872. * Defines an array and its length.
  1873. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  1874. */
  1875. export interface ISmartArrayLike<T> {
  1876. /**
  1877. * The data of the array.
  1878. */
  1879. data: Array<T>;
  1880. /**
  1881. * The active length of the array.
  1882. */
  1883. length: number;
  1884. }
  1885. /**
  1886. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  1887. */
  1888. export class SmartArray<T> implements ISmartArrayLike<T> {
  1889. /**
  1890. * The full set of data from the array.
  1891. */
  1892. data: Array<T>;
  1893. /**
  1894. * The active length of the array.
  1895. */
  1896. length: number;
  1897. protected _id: number;
  1898. /**
  1899. * Instantiates a Smart Array.
  1900. * @param capacity defines the default capacity of the array.
  1901. */
  1902. constructor(capacity: number);
  1903. /**
  1904. * Pushes a value at the end of the active data.
  1905. * @param value defines the object to push in the array.
  1906. */
  1907. push(value: T): void;
  1908. /**
  1909. * Iterates over the active data and apply the lambda to them.
  1910. * @param func defines the action to apply on each value.
  1911. */
  1912. forEach(func: (content: T) => void): void;
  1913. /**
  1914. * Sorts the full sets of data.
  1915. * @param compareFn defines the comparison function to apply.
  1916. */
  1917. sort(compareFn: (a: T, b: T) => number): void;
  1918. /**
  1919. * Resets the active data to an empty array.
  1920. */
  1921. reset(): void;
  1922. /**
  1923. * Releases all the data from the array as well as the array.
  1924. */
  1925. dispose(): void;
  1926. /**
  1927. * Concats the active data with a given array.
  1928. * @param array defines the data to concatenate with.
  1929. */
  1930. concat(array: any): void;
  1931. /**
  1932. * Returns the position of a value in the active data.
  1933. * @param value defines the value to find the index for
  1934. * @returns the index if found in the active data otherwise -1
  1935. */
  1936. indexOf(value: T): number;
  1937. /**
  1938. * Returns whether an element is part of the active data.
  1939. * @param value defines the value to look for
  1940. * @returns true if found in the active data otherwise false
  1941. */
  1942. contains(value: T): boolean;
  1943. private static _GlobalId;
  1944. }
  1945. /**
  1946. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  1947. * The data in this array can only be present once
  1948. */
  1949. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  1950. private _duplicateId;
  1951. /**
  1952. * Pushes a value at the end of the active data.
  1953. * THIS DOES NOT PREVENT DUPPLICATE DATA
  1954. * @param value defines the object to push in the array.
  1955. */
  1956. push(value: T): void;
  1957. /**
  1958. * Pushes a value at the end of the active data.
  1959. * If the data is already present, it won t be added again
  1960. * @param value defines the object to push in the array.
  1961. * @returns true if added false if it was already present
  1962. */
  1963. pushNoDuplicate(value: T): boolean;
  1964. /**
  1965. * Resets the active data to an empty array.
  1966. */
  1967. reset(): void;
  1968. /**
  1969. * Concats the active data with a given array.
  1970. * This ensures no dupplicate will be present in the result.
  1971. * @param array defines the data to concatenate with.
  1972. */
  1973. concatWithNoDuplicate(array: any): void;
  1974. }
  1975. }
  1976. declare module BABYLON {
  1977. /**
  1978. * Class used to evalaute queries containing `and` and `or` operators
  1979. */
  1980. export class AndOrNotEvaluator {
  1981. /**
  1982. * Evaluate a query
  1983. * @param query defines the query to evaluate
  1984. * @param evaluateCallback defines the callback used to filter result
  1985. * @returns true if the query matches
  1986. */
  1987. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1988. private static _HandleParenthesisContent;
  1989. private static _SimplifyNegation;
  1990. }
  1991. }
  1992. declare module BABYLON {
  1993. /**
  1994. * Class used to store custom tags
  1995. */
  1996. export class Tags {
  1997. /**
  1998. * Adds support for tags on the given object
  1999. * @param obj defines the object to use
  2000. */
  2001. static EnableFor(obj: any): void;
  2002. /**
  2003. * Removes tags support
  2004. * @param obj defines the object to use
  2005. */
  2006. static DisableFor(obj: any): void;
  2007. /**
  2008. * Gets a boolean indicating if the given object has tags
  2009. * @param obj defines the object to use
  2010. * @returns a boolean
  2011. */
  2012. static HasTags(obj: any): boolean;
  2013. /**
  2014. * Gets the tags available on a given object
  2015. * @param obj defines the object to use
  2016. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2017. * @returns the tags
  2018. */
  2019. static GetTags(obj: any, asString?: boolean): any;
  2020. /**
  2021. * Adds tags to an object
  2022. * @param obj defines the object to use
  2023. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2024. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2025. */
  2026. static AddTagsTo(obj: any, tagsString: string): void;
  2027. /**
  2028. * @hidden
  2029. */
  2030. static _AddTagTo(obj: any, tag: string): void;
  2031. /**
  2032. * Removes specific tags from a specific object
  2033. * @param obj defines the object to use
  2034. * @param tagsString defines the tags to remove
  2035. */
  2036. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2037. /**
  2038. * @hidden
  2039. */
  2040. static _RemoveTagFrom(obj: any, tag: string): void;
  2041. /**
  2042. * Defines if tags hosted on an object match a given query
  2043. * @param obj defines the object to use
  2044. * @param tagsQuery defines the tag query
  2045. * @returns a boolean
  2046. */
  2047. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2048. }
  2049. }
  2050. declare module BABYLON {
  2051. /**
  2052. * Scalar computation library
  2053. */
  2054. export class Scalar {
  2055. /**
  2056. * Two pi constants convenient for computation.
  2057. */
  2058. static TwoPi: number;
  2059. /**
  2060. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2061. * @param a number
  2062. * @param b number
  2063. * @param epsilon (default = 1.401298E-45)
  2064. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2065. */
  2066. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2067. /**
  2068. * Returns a string : the upper case translation of the number i to hexadecimal.
  2069. * @param i number
  2070. * @returns the upper case translation of the number i to hexadecimal.
  2071. */
  2072. static ToHex(i: number): string;
  2073. /**
  2074. * Returns -1 if value is negative and +1 is value is positive.
  2075. * @param value the value
  2076. * @returns the value itself if it's equal to zero.
  2077. */
  2078. static Sign(value: number): number;
  2079. /**
  2080. * Returns the value itself if it's between min and max.
  2081. * Returns min if the value is lower than min.
  2082. * Returns max if the value is greater than max.
  2083. * @param value the value to clmap
  2084. * @param min the min value to clamp to (default: 0)
  2085. * @param max the max value to clamp to (default: 1)
  2086. * @returns the clamped value
  2087. */
  2088. static Clamp(value: number, min?: number, max?: number): number;
  2089. /**
  2090. * the log2 of value.
  2091. * @param value the value to compute log2 of
  2092. * @returns the log2 of value.
  2093. */
  2094. static Log2(value: number): number;
  2095. /**
  2096. * Loops the value, so that it is never larger than length and never smaller than 0.
  2097. *
  2098. * This is similar to the modulo operator but it works with floating point numbers.
  2099. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2100. * With t = 5 and length = 2.5, the result would be 0.0.
  2101. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2102. * @param value the value
  2103. * @param length the length
  2104. * @returns the looped value
  2105. */
  2106. static Repeat(value: number, length: number): number;
  2107. /**
  2108. * Normalize the value between 0.0 and 1.0 using min and max values
  2109. * @param value value to normalize
  2110. * @param min max to normalize between
  2111. * @param max min to normalize between
  2112. * @returns the normalized value
  2113. */
  2114. static Normalize(value: number, min: number, max: number): number;
  2115. /**
  2116. * Denormalize the value from 0.0 and 1.0 using min and max values
  2117. * @param normalized value to denormalize
  2118. * @param min max to denormalize between
  2119. * @param max min to denormalize between
  2120. * @returns the denormalized value
  2121. */
  2122. static Denormalize(normalized: number, min: number, max: number): number;
  2123. /**
  2124. * Calculates the shortest difference between two given angles given in degrees.
  2125. * @param current current angle in degrees
  2126. * @param target target angle in degrees
  2127. * @returns the delta
  2128. */
  2129. static DeltaAngle(current: number, target: number): number;
  2130. /**
  2131. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2132. * @param tx value
  2133. * @param length length
  2134. * @returns The returned value will move back and forth between 0 and length
  2135. */
  2136. static PingPong(tx: number, length: number): number;
  2137. /**
  2138. * Interpolates between min and max with smoothing at the limits.
  2139. *
  2140. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2141. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2142. * @param from from
  2143. * @param to to
  2144. * @param tx value
  2145. * @returns the smooth stepped value
  2146. */
  2147. static SmoothStep(from: number, to: number, tx: number): number;
  2148. /**
  2149. * Moves a value current towards target.
  2150. *
  2151. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2152. * Negative values of maxDelta pushes the value away from target.
  2153. * @param current current value
  2154. * @param target target value
  2155. * @param maxDelta max distance to move
  2156. * @returns resulting value
  2157. */
  2158. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2159. /**
  2160. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2161. *
  2162. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2163. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2164. * @param current current value
  2165. * @param target target value
  2166. * @param maxDelta max distance to move
  2167. * @returns resulting angle
  2168. */
  2169. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2170. /**
  2171. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2172. * @param start start value
  2173. * @param end target value
  2174. * @param amount amount to lerp between
  2175. * @returns the lerped value
  2176. */
  2177. static Lerp(start: number, end: number, amount: number): number;
  2178. /**
  2179. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2180. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2181. * @param start start value
  2182. * @param end target value
  2183. * @param amount amount to lerp between
  2184. * @returns the lerped value
  2185. */
  2186. static LerpAngle(start: number, end: number, amount: number): number;
  2187. /**
  2188. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2189. * @param a start value
  2190. * @param b target value
  2191. * @param value value between a and b
  2192. * @returns the inverseLerp value
  2193. */
  2194. static InverseLerp(a: number, b: number, value: number): number;
  2195. /**
  2196. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2197. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2198. * @param value1 spline value
  2199. * @param tangent1 spline value
  2200. * @param value2 spline value
  2201. * @param tangent2 spline value
  2202. * @param amount input value
  2203. * @returns hermite result
  2204. */
  2205. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2206. /**
  2207. * Returns a random float number between and min and max values
  2208. * @param min min value of random
  2209. * @param max max value of random
  2210. * @returns random value
  2211. */
  2212. static RandomRange(min: number, max: number): number;
  2213. /**
  2214. * This function returns percentage of a number in a given range.
  2215. *
  2216. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2217. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2218. * @param number to convert to percentage
  2219. * @param min min range
  2220. * @param max max range
  2221. * @returns the percentage
  2222. */
  2223. static RangeToPercent(number: number, min: number, max: number): number;
  2224. /**
  2225. * This function returns number that corresponds to the percentage in a given range.
  2226. *
  2227. * PercentToRange(0.34,0,100) will return 34.
  2228. * @param percent to convert to number
  2229. * @param min min range
  2230. * @param max max range
  2231. * @returns the number
  2232. */
  2233. static PercentToRange(percent: number, min: number, max: number): number;
  2234. /**
  2235. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2236. * @param angle The angle to normalize in radian.
  2237. * @return The converted angle.
  2238. */
  2239. static NormalizeRadians(angle: number): number;
  2240. }
  2241. }
  2242. declare module BABYLON {
  2243. /**
  2244. * Constant used to convert a value to gamma space
  2245. * @ignorenaming
  2246. */
  2247. export const ToGammaSpace: number;
  2248. /**
  2249. * Constant used to convert a value to linear space
  2250. * @ignorenaming
  2251. */
  2252. export const ToLinearSpace = 2.2;
  2253. /**
  2254. * Constant used to define the minimal number value in Babylon.js
  2255. * @ignorenaming
  2256. */
  2257. let Epsilon: number;
  2258. }
  2259. declare module BABYLON {
  2260. /**
  2261. * Class used to represent a viewport on screen
  2262. */
  2263. export class Viewport {
  2264. /** viewport left coordinate */
  2265. x: number;
  2266. /** viewport top coordinate */
  2267. y: number;
  2268. /**viewport width */
  2269. width: number;
  2270. /** viewport height */
  2271. height: number;
  2272. /**
  2273. * Creates a Viewport object located at (x, y) and sized (width, height)
  2274. * @param x defines viewport left coordinate
  2275. * @param y defines viewport top coordinate
  2276. * @param width defines the viewport width
  2277. * @param height defines the viewport height
  2278. */
  2279. constructor(
  2280. /** viewport left coordinate */
  2281. x: number,
  2282. /** viewport top coordinate */
  2283. y: number,
  2284. /**viewport width */
  2285. width: number,
  2286. /** viewport height */
  2287. height: number);
  2288. /**
  2289. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2290. * @param renderWidth defines the rendering width
  2291. * @param renderHeight defines the rendering height
  2292. * @returns a new Viewport
  2293. */
  2294. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2295. /**
  2296. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2297. * @param renderWidth defines the rendering width
  2298. * @param renderHeight defines the rendering height
  2299. * @param ref defines the target viewport
  2300. * @returns the current viewport
  2301. */
  2302. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2303. /**
  2304. * Returns a new Viewport copied from the current one
  2305. * @returns a new Viewport
  2306. */
  2307. clone(): Viewport;
  2308. }
  2309. }
  2310. declare module BABYLON {
  2311. /**
  2312. * Class containing a set of static utilities functions for arrays.
  2313. */
  2314. export class ArrayTools {
  2315. /**
  2316. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2317. * @param size the number of element to construct and put in the array
  2318. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2319. * @returns a new array filled with new objects
  2320. */
  2321. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2322. }
  2323. }
  2324. declare module BABYLON {
  2325. /**
  2326. * Represents a plane by the equation ax + by + cz + d = 0
  2327. */
  2328. export class Plane {
  2329. private static _TmpMatrix;
  2330. /**
  2331. * Normal of the plane (a,b,c)
  2332. */
  2333. normal: Vector3;
  2334. /**
  2335. * d component of the plane
  2336. */
  2337. d: number;
  2338. /**
  2339. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2340. * @param a a component of the plane
  2341. * @param b b component of the plane
  2342. * @param c c component of the plane
  2343. * @param d d component of the plane
  2344. */
  2345. constructor(a: number, b: number, c: number, d: number);
  2346. /**
  2347. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2348. */
  2349. asArray(): number[];
  2350. /**
  2351. * @returns a new plane copied from the current Plane.
  2352. */
  2353. clone(): Plane;
  2354. /**
  2355. * @returns the string "Plane".
  2356. */
  2357. getClassName(): string;
  2358. /**
  2359. * @returns the Plane hash code.
  2360. */
  2361. getHashCode(): number;
  2362. /**
  2363. * Normalize the current Plane in place.
  2364. * @returns the updated Plane.
  2365. */
  2366. normalize(): Plane;
  2367. /**
  2368. * Applies a transformation the plane and returns the result
  2369. * @param transformation the transformation matrix to be applied to the plane
  2370. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2371. */
  2372. transform(transformation: DeepImmutable<Matrix>): Plane;
  2373. /**
  2374. * Compute the dot product between the point and the plane normal
  2375. * @param point point to calculate the dot product with
  2376. * @returns the dot product (float) of the point coordinates and the plane normal.
  2377. */
  2378. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2379. /**
  2380. * Updates the current Plane from the plane defined by the three given points.
  2381. * @param point1 one of the points used to contruct the plane
  2382. * @param point2 one of the points used to contruct the plane
  2383. * @param point3 one of the points used to contruct the plane
  2384. * @returns the updated Plane.
  2385. */
  2386. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2387. /**
  2388. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  2389. * Note that for this function to work as expected you should make sure that:
  2390. * - direction and the plane normal are normalized
  2391. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2392. * @param direction the direction to check if the plane is facing
  2393. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2394. * @returns True if the plane is facing the given direction
  2395. */
  2396. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2397. /**
  2398. * Calculates the distance to a point
  2399. * @param point point to calculate distance to
  2400. * @returns the signed distance (float) from the given point to the Plane.
  2401. */
  2402. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2403. /**
  2404. * Creates a plane from an array
  2405. * @param array the array to create a plane from
  2406. * @returns a new Plane from the given array.
  2407. */
  2408. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2409. /**
  2410. * Creates a plane from three points
  2411. * @param point1 point used to create the plane
  2412. * @param point2 point used to create the plane
  2413. * @param point3 point used to create the plane
  2414. * @returns a new Plane defined by the three given points.
  2415. */
  2416. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2417. /**
  2418. * Creates a plane from an origin point and a normal
  2419. * @param origin origin of the plane to be constructed
  2420. * @param normal normal of the plane to be constructed
  2421. * @returns a new Plane the normal vector to this plane at the given origin point.
  2422. * Note : the vector "normal" is updated because normalized.
  2423. */
  2424. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2425. /**
  2426. * Calculates the distance from a plane and a point
  2427. * @param origin origin of the plane to be constructed
  2428. * @param normal normal of the plane to be constructed
  2429. * @param point point to calculate distance to
  2430. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2431. */
  2432. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2433. }
  2434. }
  2435. declare module BABYLON {
  2436. /** @hidden */
  2437. export class PerformanceConfigurator {
  2438. /** @hidden */
  2439. static MatrixUse64Bits: boolean;
  2440. /** @hidden */
  2441. static MatrixTrackPrecisionChange: boolean;
  2442. /** @hidden */
  2443. static MatrixCurrentType: any;
  2444. /** @hidden */
  2445. static MatrixTrackedMatrices: Array<any> | null;
  2446. /** @hidden */
  2447. static SetMatrixPrecision(use64bits: boolean): void;
  2448. }
  2449. }
  2450. declare module BABYLON {
  2451. /**
  2452. * Class representing a vector containing 2 coordinates
  2453. */
  2454. export class Vector2 {
  2455. /** defines the first coordinate */
  2456. x: number;
  2457. /** defines the second coordinate */
  2458. y: number;
  2459. /**
  2460. * Creates a new Vector2 from the given x and y coordinates
  2461. * @param x defines the first coordinate
  2462. * @param y defines the second coordinate
  2463. */
  2464. constructor(
  2465. /** defines the first coordinate */
  2466. x?: number,
  2467. /** defines the second coordinate */
  2468. y?: number);
  2469. /**
  2470. * Gets a string with the Vector2 coordinates
  2471. * @returns a string with the Vector2 coordinates
  2472. */
  2473. toString(): string;
  2474. /**
  2475. * Gets class name
  2476. * @returns the string "Vector2"
  2477. */
  2478. getClassName(): string;
  2479. /**
  2480. * Gets current vector hash code
  2481. * @returns the Vector2 hash code as a number
  2482. */
  2483. getHashCode(): number;
  2484. /**
  2485. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2486. * @param array defines the source array
  2487. * @param index defines the offset in source array
  2488. * @returns the current Vector2
  2489. */
  2490. toArray(array: FloatArray, index?: number): Vector2;
  2491. /**
  2492. * Update the current vector from an array
  2493. * @param array defines the destination array
  2494. * @param index defines the offset in the destination array
  2495. * @returns the current Vector3
  2496. */
  2497. fromArray(array: FloatArray, index?: number): Vector2;
  2498. /**
  2499. * Copy the current vector to an array
  2500. * @returns a new array with 2 elements: the Vector2 coordinates.
  2501. */
  2502. asArray(): number[];
  2503. /**
  2504. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2505. * @param source defines the source Vector2
  2506. * @returns the current updated Vector2
  2507. */
  2508. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2509. /**
  2510. * Sets the Vector2 coordinates with the given floats
  2511. * @param x defines the first coordinate
  2512. * @param y defines the second coordinate
  2513. * @returns the current updated Vector2
  2514. */
  2515. copyFromFloats(x: number, y: number): Vector2;
  2516. /**
  2517. * Sets the Vector2 coordinates with the given floats
  2518. * @param x defines the first coordinate
  2519. * @param y defines the second coordinate
  2520. * @returns the current updated Vector2
  2521. */
  2522. set(x: number, y: number): Vector2;
  2523. /**
  2524. * Add another vector with the current one
  2525. * @param otherVector defines the other vector
  2526. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2527. */
  2528. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2529. /**
  2530. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2531. * @param otherVector defines the other vector
  2532. * @param result defines the target vector
  2533. * @returns the unmodified current Vector2
  2534. */
  2535. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2536. /**
  2537. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2538. * @param otherVector defines the other vector
  2539. * @returns the current updated Vector2
  2540. */
  2541. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2542. /**
  2543. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2544. * @param otherVector defines the other vector
  2545. * @returns a new Vector2
  2546. */
  2547. addVector3(otherVector: Vector3): Vector2;
  2548. /**
  2549. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2550. * @param otherVector defines the other vector
  2551. * @returns a new Vector2
  2552. */
  2553. subtract(otherVector: Vector2): Vector2;
  2554. /**
  2555. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2556. * @param otherVector defines the other vector
  2557. * @param result defines the target vector
  2558. * @returns the unmodified current Vector2
  2559. */
  2560. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2561. /**
  2562. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2563. * @param otherVector defines the other vector
  2564. * @returns the current updated Vector2
  2565. */
  2566. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2567. /**
  2568. * Multiplies in place the current Vector2 coordinates by the given ones
  2569. * @param otherVector defines the other vector
  2570. * @returns the current updated Vector2
  2571. */
  2572. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2573. /**
  2574. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2575. * @param otherVector defines the other vector
  2576. * @returns a new Vector2
  2577. */
  2578. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2579. /**
  2580. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2581. * @param otherVector defines the other vector
  2582. * @param result defines the target vector
  2583. * @returns the unmodified current Vector2
  2584. */
  2585. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2586. /**
  2587. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2588. * @param x defines the first coordinate
  2589. * @param y defines the second coordinate
  2590. * @returns a new Vector2
  2591. */
  2592. multiplyByFloats(x: number, y: number): Vector2;
  2593. /**
  2594. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2595. * @param otherVector defines the other vector
  2596. * @returns a new Vector2
  2597. */
  2598. divide(otherVector: Vector2): Vector2;
  2599. /**
  2600. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2601. * @param otherVector defines the other vector
  2602. * @param result defines the target vector
  2603. * @returns the unmodified current Vector2
  2604. */
  2605. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2606. /**
  2607. * Divides the current Vector2 coordinates by the given ones
  2608. * @param otherVector defines the other vector
  2609. * @returns the current updated Vector2
  2610. */
  2611. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2612. /**
  2613. * Gets a new Vector2 with current Vector2 negated coordinates
  2614. * @returns a new Vector2
  2615. */
  2616. negate(): Vector2;
  2617. /**
  2618. * Negate this vector in place
  2619. * @returns this
  2620. */
  2621. negateInPlace(): Vector2;
  2622. /**
  2623. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2624. * @param result defines the Vector3 object where to store the result
  2625. * @returns the current Vector2
  2626. */
  2627. negateToRef(result: Vector2): Vector2;
  2628. /**
  2629. * Multiply the Vector2 coordinates by scale
  2630. * @param scale defines the scaling factor
  2631. * @returns the current updated Vector2
  2632. */
  2633. scaleInPlace(scale: number): Vector2;
  2634. /**
  2635. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2636. * @param scale defines the scaling factor
  2637. * @returns a new Vector2
  2638. */
  2639. scale(scale: number): Vector2;
  2640. /**
  2641. * Scale the current Vector2 values by a factor to a given Vector2
  2642. * @param scale defines the scale factor
  2643. * @param result defines the Vector2 object where to store the result
  2644. * @returns the unmodified current Vector2
  2645. */
  2646. scaleToRef(scale: number, result: Vector2): Vector2;
  2647. /**
  2648. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2649. * @param scale defines the scale factor
  2650. * @param result defines the Vector2 object where to store the result
  2651. * @returns the unmodified current Vector2
  2652. */
  2653. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2654. /**
  2655. * Gets a boolean if two vectors are equals
  2656. * @param otherVector defines the other vector
  2657. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2658. */
  2659. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2660. /**
  2661. * Gets a boolean if two vectors are equals (using an epsilon value)
  2662. * @param otherVector defines the other vector
  2663. * @param epsilon defines the minimal distance to consider equality
  2664. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2665. */
  2666. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2667. /**
  2668. * Gets a new Vector2 from current Vector2 floored values
  2669. * @returns a new Vector2
  2670. */
  2671. floor(): Vector2;
  2672. /**
  2673. * Gets a new Vector2 from current Vector2 floored values
  2674. * @returns a new Vector2
  2675. */
  2676. fract(): Vector2;
  2677. /**
  2678. * Gets the length of the vector
  2679. * @returns the vector length (float)
  2680. */
  2681. length(): number;
  2682. /**
  2683. * Gets the vector squared length
  2684. * @returns the vector squared length (float)
  2685. */
  2686. lengthSquared(): number;
  2687. /**
  2688. * Normalize the vector
  2689. * @returns the current updated Vector2
  2690. */
  2691. normalize(): Vector2;
  2692. /**
  2693. * Gets a new Vector2 copied from the Vector2
  2694. * @returns a new Vector2
  2695. */
  2696. clone(): Vector2;
  2697. /**
  2698. * Gets a new Vector2(0, 0)
  2699. * @returns a new Vector2
  2700. */
  2701. static Zero(): Vector2;
  2702. /**
  2703. * Gets a new Vector2(1, 1)
  2704. * @returns a new Vector2
  2705. */
  2706. static One(): Vector2;
  2707. /**
  2708. * Gets a new Vector2 set from the given index element of the given array
  2709. * @param array defines the data source
  2710. * @param offset defines the offset in the data source
  2711. * @returns a new Vector2
  2712. */
  2713. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2714. /**
  2715. * Sets "result" from the given index element of the given array
  2716. * @param array defines the data source
  2717. * @param offset defines the offset in the data source
  2718. * @param result defines the target vector
  2719. */
  2720. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2721. /**
  2722. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2723. * @param value1 defines 1st point of control
  2724. * @param value2 defines 2nd point of control
  2725. * @param value3 defines 3rd point of control
  2726. * @param value4 defines 4th point of control
  2727. * @param amount defines the interpolation factor
  2728. * @returns a new Vector2
  2729. */
  2730. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2731. /**
  2732. * 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".
  2733. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2734. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2735. * @param value defines the value to clamp
  2736. * @param min defines the lower limit
  2737. * @param max defines the upper limit
  2738. * @returns a new Vector2
  2739. */
  2740. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2741. /**
  2742. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2743. * @param value1 defines the 1st control point
  2744. * @param tangent1 defines the outgoing tangent
  2745. * @param value2 defines the 2nd control point
  2746. * @param tangent2 defines the incoming tangent
  2747. * @param amount defines the interpolation factor
  2748. * @returns a new Vector2
  2749. */
  2750. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2751. /**
  2752. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2753. * @param start defines the start vector
  2754. * @param end defines the end vector
  2755. * @param amount defines the interpolation factor
  2756. * @returns a new Vector2
  2757. */
  2758. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2759. /**
  2760. * Gets the dot product of the vector "left" and the vector "right"
  2761. * @param left defines first vector
  2762. * @param right defines second vector
  2763. * @returns the dot product (float)
  2764. */
  2765. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2766. /**
  2767. * Returns a new Vector2 equal to the normalized given vector
  2768. * @param vector defines the vector to normalize
  2769. * @returns a new Vector2
  2770. */
  2771. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2772. /**
  2773. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2774. * @param left defines 1st vector
  2775. * @param right defines 2nd vector
  2776. * @returns a new Vector2
  2777. */
  2778. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2779. /**
  2780. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2781. * @param left defines 1st vector
  2782. * @param right defines 2nd vector
  2783. * @returns a new Vector2
  2784. */
  2785. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2786. /**
  2787. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2788. * @param vector defines the vector to transform
  2789. * @param transformation defines the matrix to apply
  2790. * @returns a new Vector2
  2791. */
  2792. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2793. /**
  2794. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2795. * @param vector defines the vector to transform
  2796. * @param transformation defines the matrix to apply
  2797. * @param result defines the target vector
  2798. */
  2799. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2800. /**
  2801. * Determines if a given vector is included in a triangle
  2802. * @param p defines the vector to test
  2803. * @param p0 defines 1st triangle point
  2804. * @param p1 defines 2nd triangle point
  2805. * @param p2 defines 3rd triangle point
  2806. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2807. */
  2808. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2809. /**
  2810. * Gets the distance between the vectors "value1" and "value2"
  2811. * @param value1 defines first vector
  2812. * @param value2 defines second vector
  2813. * @returns the distance between vectors
  2814. */
  2815. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2816. /**
  2817. * Returns the squared distance between the vectors "value1" and "value2"
  2818. * @param value1 defines first vector
  2819. * @param value2 defines second vector
  2820. * @returns the squared distance between vectors
  2821. */
  2822. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2823. /**
  2824. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2825. * @param value1 defines first vector
  2826. * @param value2 defines second vector
  2827. * @returns a new Vector2
  2828. */
  2829. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2830. /**
  2831. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2832. * @param p defines the middle point
  2833. * @param segA defines one point of the segment
  2834. * @param segB defines the other point of the segment
  2835. * @returns the shortest distance
  2836. */
  2837. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2838. }
  2839. /**
  2840. * Class used to store (x,y,z) vector representation
  2841. * A Vector3 is the main object used in 3D geometry
  2842. * It can represent etiher the coordinates of a point the space, either a direction
  2843. * Reminder: js uses a left handed forward facing system
  2844. */
  2845. export class Vector3 {
  2846. private static _UpReadOnly;
  2847. private static _ZeroReadOnly;
  2848. /** @hidden */
  2849. _x: number;
  2850. /** @hidden */
  2851. _y: number;
  2852. /** @hidden */
  2853. _z: number;
  2854. /** @hidden */
  2855. _isDirty: boolean;
  2856. /** Gets or sets the x coordinate */
  2857. get x(): number;
  2858. set x(value: number);
  2859. /** Gets or sets the y coordinate */
  2860. get y(): number;
  2861. set y(value: number);
  2862. /** Gets or sets the z coordinate */
  2863. get z(): number;
  2864. set z(value: number);
  2865. /**
  2866. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2867. * @param x defines the first coordinates (on X axis)
  2868. * @param y defines the second coordinates (on Y axis)
  2869. * @param z defines the third coordinates (on Z axis)
  2870. */
  2871. constructor(x?: number, y?: number, z?: number);
  2872. /**
  2873. * Creates a string representation of the Vector3
  2874. * @returns a string with the Vector3 coordinates.
  2875. */
  2876. toString(): string;
  2877. /**
  2878. * Gets the class name
  2879. * @returns the string "Vector3"
  2880. */
  2881. getClassName(): string;
  2882. /**
  2883. * Creates the Vector3 hash code
  2884. * @returns a number which tends to be unique between Vector3 instances
  2885. */
  2886. getHashCode(): number;
  2887. /**
  2888. * Creates an array containing three elements : the coordinates of the Vector3
  2889. * @returns a new array of numbers
  2890. */
  2891. asArray(): number[];
  2892. /**
  2893. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2894. * @param array defines the destination array
  2895. * @param index defines the offset in the destination array
  2896. * @returns the current Vector3
  2897. */
  2898. toArray(array: FloatArray, index?: number): Vector3;
  2899. /**
  2900. * Update the current vector from an array
  2901. * @param array defines the destination array
  2902. * @param index defines the offset in the destination array
  2903. * @returns the current Vector3
  2904. */
  2905. fromArray(array: FloatArray, index?: number): Vector3;
  2906. /**
  2907. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2908. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2909. */
  2910. toQuaternion(): Quaternion;
  2911. /**
  2912. * Adds the given vector to the current Vector3
  2913. * @param otherVector defines the second operand
  2914. * @returns the current updated Vector3
  2915. */
  2916. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2917. /**
  2918. * Adds the given coordinates to the current Vector3
  2919. * @param x defines the x coordinate of the operand
  2920. * @param y defines the y coordinate of the operand
  2921. * @param z defines the z coordinate of the operand
  2922. * @returns the current updated Vector3
  2923. */
  2924. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2925. /**
  2926. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2927. * @param otherVector defines the second operand
  2928. * @returns the resulting Vector3
  2929. */
  2930. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2931. /**
  2932. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2933. * @param otherVector defines the second operand
  2934. * @param result defines the Vector3 object where to store the result
  2935. * @returns the current Vector3
  2936. */
  2937. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2938. /**
  2939. * Subtract the given vector from the current Vector3
  2940. * @param otherVector defines the second operand
  2941. * @returns the current updated Vector3
  2942. */
  2943. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2944. /**
  2945. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2946. * @param otherVector defines the second operand
  2947. * @returns the resulting Vector3
  2948. */
  2949. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2950. /**
  2951. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2952. * @param otherVector defines the second operand
  2953. * @param result defines the Vector3 object where to store the result
  2954. * @returns the current Vector3
  2955. */
  2956. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2957. /**
  2958. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2959. * @param x defines the x coordinate of the operand
  2960. * @param y defines the y coordinate of the operand
  2961. * @param z defines the z coordinate of the operand
  2962. * @returns the resulting Vector3
  2963. */
  2964. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2965. /**
  2966. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2967. * @param x defines the x coordinate of the operand
  2968. * @param y defines the y coordinate of the operand
  2969. * @param z defines the z coordinate of the operand
  2970. * @param result defines the Vector3 object where to store the result
  2971. * @returns the current Vector3
  2972. */
  2973. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2974. /**
  2975. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2976. * @returns a new Vector3
  2977. */
  2978. negate(): Vector3;
  2979. /**
  2980. * Negate this vector in place
  2981. * @returns this
  2982. */
  2983. negateInPlace(): Vector3;
  2984. /**
  2985. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2986. * @param result defines the Vector3 object where to store the result
  2987. * @returns the current Vector3
  2988. */
  2989. negateToRef(result: Vector3): Vector3;
  2990. /**
  2991. * Multiplies the Vector3 coordinates by the float "scale"
  2992. * @param scale defines the multiplier factor
  2993. * @returns the current updated Vector3
  2994. */
  2995. scaleInPlace(scale: number): Vector3;
  2996. /**
  2997. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2998. * @param scale defines the multiplier factor
  2999. * @returns a new Vector3
  3000. */
  3001. scale(scale: number): Vector3;
  3002. /**
  3003. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3004. * @param scale defines the multiplier factor
  3005. * @param result defines the Vector3 object where to store the result
  3006. * @returns the current Vector3
  3007. */
  3008. scaleToRef(scale: number, result: Vector3): Vector3;
  3009. /**
  3010. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3011. * @param scale defines the scale factor
  3012. * @param result defines the Vector3 object where to store the result
  3013. * @returns the unmodified current Vector3
  3014. */
  3015. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3016. /**
  3017. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3018. * @param origin defines the origin of the projection ray
  3019. * @param plane defines the plane to project to
  3020. * @returns the projected vector3
  3021. */
  3022. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3023. /**
  3024. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3025. * @param origin defines the origin of the projection ray
  3026. * @param plane defines the plane to project to
  3027. * @param result defines the Vector3 where to store the result
  3028. */
  3029. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3030. /**
  3031. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3032. * @param otherVector defines the second operand
  3033. * @returns true if both vectors are equals
  3034. */
  3035. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3036. /**
  3037. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3038. * @param otherVector defines the second operand
  3039. * @param epsilon defines the minimal distance to define values as equals
  3040. * @returns true if both vectors are distant less than epsilon
  3041. */
  3042. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3043. /**
  3044. * Returns true if the current Vector3 coordinates equals the given floats
  3045. * @param x defines the x coordinate of the operand
  3046. * @param y defines the y coordinate of the operand
  3047. * @param z defines the z coordinate of the operand
  3048. * @returns true if both vectors are equals
  3049. */
  3050. equalsToFloats(x: number, y: number, z: number): boolean;
  3051. /**
  3052. * Multiplies the current Vector3 coordinates by the given ones
  3053. * @param otherVector defines the second operand
  3054. * @returns the current updated Vector3
  3055. */
  3056. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3057. /**
  3058. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3059. * @param otherVector defines the second operand
  3060. * @returns the new Vector3
  3061. */
  3062. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3063. /**
  3064. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3065. * @param otherVector defines the second operand
  3066. * @param result defines the Vector3 object where to store the result
  3067. * @returns the current Vector3
  3068. */
  3069. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3070. /**
  3071. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3072. * @param x defines the x coordinate of the operand
  3073. * @param y defines the y coordinate of the operand
  3074. * @param z defines the z coordinate of the operand
  3075. * @returns the new Vector3
  3076. */
  3077. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3078. /**
  3079. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3080. * @param otherVector defines the second operand
  3081. * @returns the new Vector3
  3082. */
  3083. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3084. /**
  3085. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3086. * @param otherVector defines the second operand
  3087. * @param result defines the Vector3 object where to store the result
  3088. * @returns the current Vector3
  3089. */
  3090. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3091. /**
  3092. * Divides the current Vector3 coordinates by the given ones.
  3093. * @param otherVector defines the second operand
  3094. * @returns the current updated Vector3
  3095. */
  3096. divideInPlace(otherVector: Vector3): Vector3;
  3097. /**
  3098. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3099. * @param other defines the second operand
  3100. * @returns the current updated Vector3
  3101. */
  3102. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3103. /**
  3104. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3105. * @param other defines the second operand
  3106. * @returns the current updated Vector3
  3107. */
  3108. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3109. /**
  3110. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3111. * @param x defines the x coordinate of the operand
  3112. * @param y defines the y coordinate of the operand
  3113. * @param z defines the z coordinate of the operand
  3114. * @returns the current updated Vector3
  3115. */
  3116. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3117. /**
  3118. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3119. * @param x defines the x coordinate of the operand
  3120. * @param y defines the y coordinate of the operand
  3121. * @param z defines the z coordinate of the operand
  3122. * @returns the current updated Vector3
  3123. */
  3124. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3125. /**
  3126. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3127. * Check if is non uniform within a certain amount of decimal places to account for this
  3128. * @param epsilon the amount the values can differ
  3129. * @returns if the the vector is non uniform to a certain number of decimal places
  3130. */
  3131. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3132. /**
  3133. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3134. */
  3135. get isNonUniform(): boolean;
  3136. /**
  3137. * Gets a new Vector3 from current Vector3 floored values
  3138. * @returns a new Vector3
  3139. */
  3140. floor(): Vector3;
  3141. /**
  3142. * Gets a new Vector3 from current Vector3 floored values
  3143. * @returns a new Vector3
  3144. */
  3145. fract(): Vector3;
  3146. /**
  3147. * Gets the length of the Vector3
  3148. * @returns the length of the Vector3
  3149. */
  3150. length(): number;
  3151. /**
  3152. * Gets the squared length of the Vector3
  3153. * @returns squared length of the Vector3
  3154. */
  3155. lengthSquared(): number;
  3156. /**
  3157. * Normalize the current Vector3.
  3158. * Please note that this is an in place operation.
  3159. * @returns the current updated Vector3
  3160. */
  3161. normalize(): Vector3;
  3162. /**
  3163. * Reorders the x y z properties of the vector in place
  3164. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3165. * @returns the current updated vector
  3166. */
  3167. reorderInPlace(order: string): this;
  3168. /**
  3169. * Rotates the vector around 0,0,0 by a quaternion
  3170. * @param quaternion the rotation quaternion
  3171. * @param result vector to store the result
  3172. * @returns the resulting vector
  3173. */
  3174. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3175. /**
  3176. * Rotates a vector around a given point
  3177. * @param quaternion the rotation quaternion
  3178. * @param point the point to rotate around
  3179. * @param result vector to store the result
  3180. * @returns the resulting vector
  3181. */
  3182. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3183. /**
  3184. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3185. * The cross product is then orthogonal to both current and "other"
  3186. * @param other defines the right operand
  3187. * @returns the cross product
  3188. */
  3189. cross(other: Vector3): Vector3;
  3190. /**
  3191. * Normalize the current Vector3 with the given input length.
  3192. * Please note that this is an in place operation.
  3193. * @param len the length of the vector
  3194. * @returns the current updated Vector3
  3195. */
  3196. normalizeFromLength(len: number): Vector3;
  3197. /**
  3198. * Normalize the current Vector3 to a new vector
  3199. * @returns the new Vector3
  3200. */
  3201. normalizeToNew(): Vector3;
  3202. /**
  3203. * Normalize the current Vector3 to the reference
  3204. * @param reference define the Vector3 to update
  3205. * @returns the updated Vector3
  3206. */
  3207. normalizeToRef(reference: Vector3): Vector3;
  3208. /**
  3209. * Creates a new Vector3 copied from the current Vector3
  3210. * @returns the new Vector3
  3211. */
  3212. clone(): Vector3;
  3213. /**
  3214. * Copies the given vector coordinates to the current Vector3 ones
  3215. * @param source defines the source Vector3
  3216. * @returns the current updated Vector3
  3217. */
  3218. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3219. /**
  3220. * Copies the given floats to the current Vector3 coordinates
  3221. * @param x defines the x coordinate of the operand
  3222. * @param y defines the y coordinate of the operand
  3223. * @param z defines the z coordinate of the operand
  3224. * @returns the current updated Vector3
  3225. */
  3226. copyFromFloats(x: number, y: number, z: number): Vector3;
  3227. /**
  3228. * Copies the given floats to the current Vector3 coordinates
  3229. * @param x defines the x coordinate of the operand
  3230. * @param y defines the y coordinate of the operand
  3231. * @param z defines the z coordinate of the operand
  3232. * @returns the current updated Vector3
  3233. */
  3234. set(x: number, y: number, z: number): Vector3;
  3235. /**
  3236. * Copies the given float to the current Vector3 coordinates
  3237. * @param v defines the x, y and z coordinates of the operand
  3238. * @returns the current updated Vector3
  3239. */
  3240. setAll(v: number): Vector3;
  3241. /**
  3242. * Get the clip factor between two vectors
  3243. * @param vector0 defines the first operand
  3244. * @param vector1 defines the second operand
  3245. * @param axis defines the axis to use
  3246. * @param size defines the size along the axis
  3247. * @returns the clip factor
  3248. */
  3249. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3250. /**
  3251. * Get angle between two vectors
  3252. * @param vector0 angle between vector0 and vector1
  3253. * @param vector1 angle between vector0 and vector1
  3254. * @param normal direction of the normal
  3255. * @return the angle between vector0 and vector1
  3256. */
  3257. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3258. /**
  3259. * Returns a new Vector3 set from the index "offset" of the given array
  3260. * @param array defines the source array
  3261. * @param offset defines the offset in the source array
  3262. * @returns the new Vector3
  3263. */
  3264. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3265. /**
  3266. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3267. * @param array defines the source array
  3268. * @param offset defines the offset in the source array
  3269. * @returns the new Vector3
  3270. * @deprecated Please use FromArray instead.
  3271. */
  3272. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3273. /**
  3274. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3275. * @param array defines the source array
  3276. * @param offset defines the offset in the source array
  3277. * @param result defines the Vector3 where to store the result
  3278. */
  3279. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3280. /**
  3281. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3282. * @param array defines the source array
  3283. * @param offset defines the offset in the source array
  3284. * @param result defines the Vector3 where to store the result
  3285. * @deprecated Please use FromArrayToRef instead.
  3286. */
  3287. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3288. /**
  3289. * Sets the given vector "result" with the given floats.
  3290. * @param x defines the x coordinate of the source
  3291. * @param y defines the y coordinate of the source
  3292. * @param z defines the z coordinate of the source
  3293. * @param result defines the Vector3 where to store the result
  3294. */
  3295. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3296. /**
  3297. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3298. * @returns a new empty Vector3
  3299. */
  3300. static Zero(): Vector3;
  3301. /**
  3302. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3303. * @returns a new unit Vector3
  3304. */
  3305. static One(): Vector3;
  3306. /**
  3307. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3308. * @returns a new up Vector3
  3309. */
  3310. static Up(): Vector3;
  3311. /**
  3312. * Gets a up Vector3 that must not be updated
  3313. */
  3314. static get UpReadOnly(): DeepImmutable<Vector3>;
  3315. /**
  3316. * Gets a zero Vector3 that must not be updated
  3317. */
  3318. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3319. /**
  3320. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3321. * @returns a new down Vector3
  3322. */
  3323. static Down(): Vector3;
  3324. /**
  3325. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3326. * @param rightHandedSystem is the scene right-handed (negative z)
  3327. * @returns a new forward Vector3
  3328. */
  3329. static Forward(rightHandedSystem?: boolean): Vector3;
  3330. /**
  3331. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3332. * @param rightHandedSystem is the scene right-handed (negative-z)
  3333. * @returns a new forward Vector3
  3334. */
  3335. static Backward(rightHandedSystem?: boolean): Vector3;
  3336. /**
  3337. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3338. * @returns a new right Vector3
  3339. */
  3340. static Right(): Vector3;
  3341. /**
  3342. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3343. * @returns a new left Vector3
  3344. */
  3345. static Left(): Vector3;
  3346. /**
  3347. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3348. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3349. * @param vector defines the Vector3 to transform
  3350. * @param transformation defines the transformation matrix
  3351. * @returns the transformed Vector3
  3352. */
  3353. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3354. /**
  3355. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3356. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3357. * @param vector defines the Vector3 to transform
  3358. * @param transformation defines the transformation matrix
  3359. * @param result defines the Vector3 where to store the result
  3360. */
  3361. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3362. /**
  3363. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3364. * This method computes tranformed coordinates only, not transformed direction vectors
  3365. * @param x define the x coordinate of the source vector
  3366. * @param y define the y coordinate of the source vector
  3367. * @param z define the z coordinate of the source vector
  3368. * @param transformation defines the transformation matrix
  3369. * @param result defines the Vector3 where to store the result
  3370. */
  3371. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3372. /**
  3373. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3374. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3375. * @param vector defines the Vector3 to transform
  3376. * @param transformation defines the transformation matrix
  3377. * @returns the new Vector3
  3378. */
  3379. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3380. /**
  3381. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3382. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3383. * @param vector defines the Vector3 to transform
  3384. * @param transformation defines the transformation matrix
  3385. * @param result defines the Vector3 where to store the result
  3386. */
  3387. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3388. /**
  3389. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3390. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3391. * @param x define the x coordinate of the source vector
  3392. * @param y define the y coordinate of the source vector
  3393. * @param z define the z coordinate of the source vector
  3394. * @param transformation defines the transformation matrix
  3395. * @param result defines the Vector3 where to store the result
  3396. */
  3397. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3398. /**
  3399. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3400. * @param value1 defines the first control point
  3401. * @param value2 defines the second control point
  3402. * @param value3 defines the third control point
  3403. * @param value4 defines the fourth control point
  3404. * @param amount defines the amount on the spline to use
  3405. * @returns the new Vector3
  3406. */
  3407. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3408. /**
  3409. * 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"
  3410. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3411. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3412. * @param value defines the current value
  3413. * @param min defines the lower range value
  3414. * @param max defines the upper range value
  3415. * @returns the new Vector3
  3416. */
  3417. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3418. /**
  3419. * 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"
  3420. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3421. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3422. * @param value defines the current value
  3423. * @param min defines the lower range value
  3424. * @param max defines the upper range value
  3425. * @param result defines the Vector3 where to store the result
  3426. */
  3427. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3428. /**
  3429. * Checks if a given vector is inside a specific range
  3430. * @param v defines the vector to test
  3431. * @param min defines the minimum range
  3432. * @param max defines the maximum range
  3433. */
  3434. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3435. /**
  3436. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3437. * @param value1 defines the first control point
  3438. * @param tangent1 defines the first tangent vector
  3439. * @param value2 defines the second control point
  3440. * @param tangent2 defines the second tangent vector
  3441. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3442. * @returns the new Vector3
  3443. */
  3444. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3445. /**
  3446. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3447. * @param start defines the start value
  3448. * @param end defines the end value
  3449. * @param amount max defines amount between both (between 0 and 1)
  3450. * @returns the new Vector3
  3451. */
  3452. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3453. /**
  3454. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3455. * @param start defines the start value
  3456. * @param end defines the end value
  3457. * @param amount max defines amount between both (between 0 and 1)
  3458. * @param result defines the Vector3 where to store the result
  3459. */
  3460. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3461. /**
  3462. * Returns the dot product (float) between the vectors "left" and "right"
  3463. * @param left defines the left operand
  3464. * @param right defines the right operand
  3465. * @returns the dot product
  3466. */
  3467. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3468. /**
  3469. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3470. * The cross product is then orthogonal to both "left" and "right"
  3471. * @param left defines the left operand
  3472. * @param right defines the right operand
  3473. * @returns the cross product
  3474. */
  3475. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3476. /**
  3477. * Sets the given vector "result" with the cross product of "left" and "right"
  3478. * The cross product is then orthogonal to both "left" and "right"
  3479. * @param left defines the left operand
  3480. * @param right defines the right operand
  3481. * @param result defines the Vector3 where to store the result
  3482. */
  3483. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3484. /**
  3485. * Returns a new Vector3 as the normalization of the given vector
  3486. * @param vector defines the Vector3 to normalize
  3487. * @returns the new Vector3
  3488. */
  3489. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3490. /**
  3491. * Sets the given vector "result" with the normalization of the given first vector
  3492. * @param vector defines the Vector3 to normalize
  3493. * @param result defines the Vector3 where to store the result
  3494. */
  3495. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3496. /**
  3497. * Project a Vector3 onto screen space
  3498. * @param vector defines the Vector3 to project
  3499. * @param world defines the world matrix to use
  3500. * @param transform defines the transform (view x projection) matrix to use
  3501. * @param viewport defines the screen viewport to use
  3502. * @returns the new Vector3
  3503. */
  3504. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3505. /**
  3506. * Project a Vector3 onto screen space to reference
  3507. * @param vector defines the Vector3 to project
  3508. * @param world defines the world matrix to use
  3509. * @param transform defines the transform (view x projection) matrix to use
  3510. * @param viewport defines the screen viewport to use
  3511. * @param result the vector in which the screen space will be stored
  3512. * @returns the new Vector3
  3513. */
  3514. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3515. /** @hidden */
  3516. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3517. /**
  3518. * Unproject from screen space to object space
  3519. * @param source defines the screen space Vector3 to use
  3520. * @param viewportWidth defines the current width of the viewport
  3521. * @param viewportHeight defines the current height of the viewport
  3522. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3523. * @param transform defines the transform (view x projection) matrix to use
  3524. * @returns the new Vector3
  3525. */
  3526. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3527. /**
  3528. * Unproject from screen space to object space
  3529. * @param source defines the screen space Vector3 to use
  3530. * @param viewportWidth defines the current width of the viewport
  3531. * @param viewportHeight defines the current height of the viewport
  3532. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3533. * @param view defines the view matrix to use
  3534. * @param projection defines the projection matrix to use
  3535. * @returns the new Vector3
  3536. */
  3537. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3538. /**
  3539. * Unproject from screen space to object space
  3540. * @param source defines the screen space Vector3 to use
  3541. * @param viewportWidth defines the current width of the viewport
  3542. * @param viewportHeight defines the current height of the viewport
  3543. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3544. * @param view defines the view matrix to use
  3545. * @param projection defines the projection matrix to use
  3546. * @param result defines the Vector3 where to store the result
  3547. */
  3548. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3549. /**
  3550. * Unproject from screen space to object space
  3551. * @param sourceX defines the screen space x coordinate to use
  3552. * @param sourceY defines the screen space y coordinate to use
  3553. * @param sourceZ defines the screen space z coordinate to use
  3554. * @param viewportWidth defines the current width of the viewport
  3555. * @param viewportHeight defines the current height of the viewport
  3556. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3557. * @param view defines the view matrix to use
  3558. * @param projection defines the projection matrix to use
  3559. * @param result defines the Vector3 where to store the result
  3560. */
  3561. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3562. /**
  3563. * Gets the minimal coordinate values between two Vector3
  3564. * @param left defines the first operand
  3565. * @param right defines the second operand
  3566. * @returns the new Vector3
  3567. */
  3568. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3569. /**
  3570. * Gets the maximal coordinate values between two Vector3
  3571. * @param left defines the first operand
  3572. * @param right defines the second operand
  3573. * @returns the new Vector3
  3574. */
  3575. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3576. /**
  3577. * Returns the distance between the vectors "value1" and "value2"
  3578. * @param value1 defines the first operand
  3579. * @param value2 defines the second operand
  3580. * @returns the distance
  3581. */
  3582. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3583. /**
  3584. * Returns the squared distance between the vectors "value1" and "value2"
  3585. * @param value1 defines the first operand
  3586. * @param value2 defines the second operand
  3587. * @returns the squared distance
  3588. */
  3589. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3590. /**
  3591. * Returns a new Vector3 located at the center between "value1" and "value2"
  3592. * @param value1 defines the first operand
  3593. * @param value2 defines the second operand
  3594. * @returns the new Vector3
  3595. */
  3596. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3597. /**
  3598. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3599. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3600. * to something in order to rotate it from its local system to the given target system
  3601. * Note: axis1, axis2 and axis3 are normalized during this operation
  3602. * @param axis1 defines the first axis
  3603. * @param axis2 defines the second axis
  3604. * @param axis3 defines the third axis
  3605. * @returns a new Vector3
  3606. */
  3607. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3608. /**
  3609. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3610. * @param axis1 defines the first axis
  3611. * @param axis2 defines the second axis
  3612. * @param axis3 defines the third axis
  3613. * @param ref defines the Vector3 where to store the result
  3614. */
  3615. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3616. }
  3617. /**
  3618. * Vector4 class created for EulerAngle class conversion to Quaternion
  3619. */
  3620. export class Vector4 {
  3621. /** x value of the vector */
  3622. x: number;
  3623. /** y value of the vector */
  3624. y: number;
  3625. /** z value of the vector */
  3626. z: number;
  3627. /** w value of the vector */
  3628. w: number;
  3629. /**
  3630. * Creates a Vector4 object from the given floats.
  3631. * @param x x value of the vector
  3632. * @param y y value of the vector
  3633. * @param z z value of the vector
  3634. * @param w w value of the vector
  3635. */
  3636. constructor(
  3637. /** x value of the vector */
  3638. x: number,
  3639. /** y value of the vector */
  3640. y: number,
  3641. /** z value of the vector */
  3642. z: number,
  3643. /** w value of the vector */
  3644. w: number);
  3645. /**
  3646. * Returns the string with the Vector4 coordinates.
  3647. * @returns a string containing all the vector values
  3648. */
  3649. toString(): string;
  3650. /**
  3651. * Returns the string "Vector4".
  3652. * @returns "Vector4"
  3653. */
  3654. getClassName(): string;
  3655. /**
  3656. * Returns the Vector4 hash code.
  3657. * @returns a unique hash code
  3658. */
  3659. getHashCode(): number;
  3660. /**
  3661. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3662. * @returns the resulting array
  3663. */
  3664. asArray(): number[];
  3665. /**
  3666. * Populates the given array from the given index with the Vector4 coordinates.
  3667. * @param array array to populate
  3668. * @param index index of the array to start at (default: 0)
  3669. * @returns the Vector4.
  3670. */
  3671. toArray(array: FloatArray, index?: number): Vector4;
  3672. /**
  3673. * Update the current vector from an array
  3674. * @param array defines the destination array
  3675. * @param index defines the offset in the destination array
  3676. * @returns the current Vector3
  3677. */
  3678. fromArray(array: FloatArray, index?: number): Vector4;
  3679. /**
  3680. * Adds the given vector to the current Vector4.
  3681. * @param otherVector the vector to add
  3682. * @returns the updated Vector4.
  3683. */
  3684. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3685. /**
  3686. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3687. * @param otherVector the vector to add
  3688. * @returns the resulting vector
  3689. */
  3690. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3691. /**
  3692. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3693. * @param otherVector the vector to add
  3694. * @param result the vector to store the result
  3695. * @returns the current Vector4.
  3696. */
  3697. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3698. /**
  3699. * Subtract in place the given vector from the current Vector4.
  3700. * @param otherVector the vector to subtract
  3701. * @returns the updated Vector4.
  3702. */
  3703. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3704. /**
  3705. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3706. * @param otherVector the vector to add
  3707. * @returns the new vector with the result
  3708. */
  3709. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3710. /**
  3711. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3712. * @param otherVector the vector to subtract
  3713. * @param result the vector to store the result
  3714. * @returns the current Vector4.
  3715. */
  3716. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3717. /**
  3718. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3719. */
  3720. /**
  3721. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3722. * @param x value to subtract
  3723. * @param y value to subtract
  3724. * @param z value to subtract
  3725. * @param w value to subtract
  3726. * @returns new vector containing the result
  3727. */
  3728. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3729. /**
  3730. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3731. * @param x value to subtract
  3732. * @param y value to subtract
  3733. * @param z value to subtract
  3734. * @param w value to subtract
  3735. * @param result the vector to store the result in
  3736. * @returns the current Vector4.
  3737. */
  3738. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3739. /**
  3740. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3741. * @returns a new vector with the negated values
  3742. */
  3743. negate(): Vector4;
  3744. /**
  3745. * Negate this vector in place
  3746. * @returns this
  3747. */
  3748. negateInPlace(): Vector4;
  3749. /**
  3750. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3751. * @param result defines the Vector3 object where to store the result
  3752. * @returns the current Vector4
  3753. */
  3754. negateToRef(result: Vector4): Vector4;
  3755. /**
  3756. * Multiplies the current Vector4 coordinates by scale (float).
  3757. * @param scale the number to scale with
  3758. * @returns the updated Vector4.
  3759. */
  3760. scaleInPlace(scale: number): Vector4;
  3761. /**
  3762. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3763. * @param scale the number to scale with
  3764. * @returns a new vector with the result
  3765. */
  3766. scale(scale: number): Vector4;
  3767. /**
  3768. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3769. * @param scale the number to scale with
  3770. * @param result a vector to store the result in
  3771. * @returns the current Vector4.
  3772. */
  3773. scaleToRef(scale: number, result: Vector4): Vector4;
  3774. /**
  3775. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3776. * @param scale defines the scale factor
  3777. * @param result defines the Vector4 object where to store the result
  3778. * @returns the unmodified current Vector4
  3779. */
  3780. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3781. /**
  3782. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3783. * @param otherVector the vector to compare against
  3784. * @returns true if they are equal
  3785. */
  3786. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3787. /**
  3788. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3789. * @param otherVector vector to compare against
  3790. * @param epsilon (Default: very small number)
  3791. * @returns true if they are equal
  3792. */
  3793. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3794. /**
  3795. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3796. * @param x x value to compare against
  3797. * @param y y value to compare against
  3798. * @param z z value to compare against
  3799. * @param w w value to compare against
  3800. * @returns true if equal
  3801. */
  3802. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3803. /**
  3804. * Multiplies in place the current Vector4 by the given one.
  3805. * @param otherVector vector to multiple with
  3806. * @returns the updated Vector4.
  3807. */
  3808. multiplyInPlace(otherVector: Vector4): Vector4;
  3809. /**
  3810. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3811. * @param otherVector vector to multiple with
  3812. * @returns resulting new vector
  3813. */
  3814. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3815. /**
  3816. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3817. * @param otherVector vector to multiple with
  3818. * @param result vector to store the result
  3819. * @returns the current Vector4.
  3820. */
  3821. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3822. /**
  3823. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3824. * @param x x value multiply with
  3825. * @param y y value multiply with
  3826. * @param z z value multiply with
  3827. * @param w w value multiply with
  3828. * @returns resulting new vector
  3829. */
  3830. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3831. /**
  3832. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3833. * @param otherVector vector to devide with
  3834. * @returns resulting new vector
  3835. */
  3836. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3837. /**
  3838. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3839. * @param otherVector vector to devide with
  3840. * @param result vector to store the result
  3841. * @returns the current Vector4.
  3842. */
  3843. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3844. /**
  3845. * Divides the current Vector3 coordinates by the given ones.
  3846. * @param otherVector vector to devide with
  3847. * @returns the updated Vector3.
  3848. */
  3849. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3850. /**
  3851. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3852. * @param other defines the second operand
  3853. * @returns the current updated Vector4
  3854. */
  3855. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3856. /**
  3857. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3858. * @param other defines the second operand
  3859. * @returns the current updated Vector4
  3860. */
  3861. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3862. /**
  3863. * Gets a new Vector4 from current Vector4 floored values
  3864. * @returns a new Vector4
  3865. */
  3866. floor(): Vector4;
  3867. /**
  3868. * Gets a new Vector4 from current Vector3 floored values
  3869. * @returns a new Vector4
  3870. */
  3871. fract(): Vector4;
  3872. /**
  3873. * Returns the Vector4 length (float).
  3874. * @returns the length
  3875. */
  3876. length(): number;
  3877. /**
  3878. * Returns the Vector4 squared length (float).
  3879. * @returns the length squared
  3880. */
  3881. lengthSquared(): number;
  3882. /**
  3883. * Normalizes in place the Vector4.
  3884. * @returns the updated Vector4.
  3885. */
  3886. normalize(): Vector4;
  3887. /**
  3888. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3889. * @returns this converted to a new vector3
  3890. */
  3891. toVector3(): Vector3;
  3892. /**
  3893. * Returns a new Vector4 copied from the current one.
  3894. * @returns the new cloned vector
  3895. */
  3896. clone(): Vector4;
  3897. /**
  3898. * Updates the current Vector4 with the given one coordinates.
  3899. * @param source the source vector to copy from
  3900. * @returns the updated Vector4.
  3901. */
  3902. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3903. /**
  3904. * Updates the current Vector4 coordinates with the given floats.
  3905. * @param x float to copy from
  3906. * @param y float to copy from
  3907. * @param z float to copy from
  3908. * @param w float to copy from
  3909. * @returns the updated Vector4.
  3910. */
  3911. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3912. /**
  3913. * Updates the current Vector4 coordinates with the given floats.
  3914. * @param x float to set from
  3915. * @param y float to set from
  3916. * @param z float to set from
  3917. * @param w float to set from
  3918. * @returns the updated Vector4.
  3919. */
  3920. set(x: number, y: number, z: number, w: number): Vector4;
  3921. /**
  3922. * Copies the given float to the current Vector3 coordinates
  3923. * @param v defines the x, y, z and w coordinates of the operand
  3924. * @returns the current updated Vector3
  3925. */
  3926. setAll(v: number): Vector4;
  3927. /**
  3928. * Returns a new Vector4 set from the starting index of the given array.
  3929. * @param array the array to pull values from
  3930. * @param offset the offset into the array to start at
  3931. * @returns the new vector
  3932. */
  3933. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3934. /**
  3935. * Updates the given vector "result" from the starting index of the given array.
  3936. * @param array the array to pull values from
  3937. * @param offset the offset into the array to start at
  3938. * @param result the vector to store the result in
  3939. */
  3940. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3941. /**
  3942. * Updates the given vector "result" from the starting index of the given Float32Array.
  3943. * @param array the array to pull values from
  3944. * @param offset the offset into the array to start at
  3945. * @param result the vector to store the result in
  3946. */
  3947. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3948. /**
  3949. * Updates the given vector "result" coordinates from the given floats.
  3950. * @param x float to set from
  3951. * @param y float to set from
  3952. * @param z float to set from
  3953. * @param w float to set from
  3954. * @param result the vector to the floats in
  3955. */
  3956. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3957. /**
  3958. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3959. * @returns the new vector
  3960. */
  3961. static Zero(): Vector4;
  3962. /**
  3963. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3964. * @returns the new vector
  3965. */
  3966. static One(): Vector4;
  3967. /**
  3968. * Returns a new normalized Vector4 from the given one.
  3969. * @param vector the vector to normalize
  3970. * @returns the vector
  3971. */
  3972. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3973. /**
  3974. * Updates the given vector "result" from the normalization of the given one.
  3975. * @param vector the vector to normalize
  3976. * @param result the vector to store the result in
  3977. */
  3978. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3979. /**
  3980. * Returns a vector with the minimum values from the left and right vectors
  3981. * @param left left vector to minimize
  3982. * @param right right vector to minimize
  3983. * @returns a new vector with the minimum of the left and right vector values
  3984. */
  3985. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3986. /**
  3987. * Returns a vector with the maximum values from the left and right vectors
  3988. * @param left left vector to maximize
  3989. * @param right right vector to maximize
  3990. * @returns a new vector with the maximum of the left and right vector values
  3991. */
  3992. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3993. /**
  3994. * Returns the distance (float) between the vectors "value1" and "value2".
  3995. * @param value1 value to calulate the distance between
  3996. * @param value2 value to calulate the distance between
  3997. * @return the distance between the two vectors
  3998. */
  3999. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4000. /**
  4001. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4002. * @param value1 value to calulate the distance between
  4003. * @param value2 value to calulate the distance between
  4004. * @return the distance between the two vectors squared
  4005. */
  4006. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4007. /**
  4008. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4009. * @param value1 value to calulate the center between
  4010. * @param value2 value to calulate the center between
  4011. * @return the center between the two vectors
  4012. */
  4013. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4014. /**
  4015. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4016. * This methods computes transformed normalized direction vectors only.
  4017. * @param vector the vector to transform
  4018. * @param transformation the transformation matrix to apply
  4019. * @returns the new vector
  4020. */
  4021. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4022. /**
  4023. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4024. * This methods computes transformed normalized direction vectors only.
  4025. * @param vector the vector to transform
  4026. * @param transformation the transformation matrix to apply
  4027. * @param result the vector to store the result in
  4028. */
  4029. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4030. /**
  4031. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4032. * This methods computes transformed normalized direction vectors only.
  4033. * @param x value to transform
  4034. * @param y value to transform
  4035. * @param z value to transform
  4036. * @param w value to transform
  4037. * @param transformation the transformation matrix to apply
  4038. * @param result the vector to store the results in
  4039. */
  4040. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4041. /**
  4042. * Creates a new Vector4 from a Vector3
  4043. * @param source defines the source data
  4044. * @param w defines the 4th component (default is 0)
  4045. * @returns a new Vector4
  4046. */
  4047. static FromVector3(source: Vector3, w?: number): Vector4;
  4048. }
  4049. /**
  4050. * Class used to store quaternion data
  4051. * @see https://en.wikipedia.org/wiki/Quaternion
  4052. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4053. */
  4054. export class Quaternion {
  4055. /** @hidden */
  4056. _x: number;
  4057. /** @hidden */
  4058. _y: number;
  4059. /** @hidden */
  4060. _z: number;
  4061. /** @hidden */
  4062. _w: number;
  4063. /** @hidden */
  4064. _isDirty: boolean;
  4065. /** Gets or sets the x coordinate */
  4066. get x(): number;
  4067. set x(value: number);
  4068. /** Gets or sets the y coordinate */
  4069. get y(): number;
  4070. set y(value: number);
  4071. /** Gets or sets the z coordinate */
  4072. get z(): number;
  4073. set z(value: number);
  4074. /** Gets or sets the w coordinate */
  4075. get w(): number;
  4076. set w(value: number);
  4077. /**
  4078. * Creates a new Quaternion from the given floats
  4079. * @param x defines the first component (0 by default)
  4080. * @param y defines the second component (0 by default)
  4081. * @param z defines the third component (0 by default)
  4082. * @param w defines the fourth component (1.0 by default)
  4083. */
  4084. constructor(x?: number, y?: number, z?: number, w?: number);
  4085. /**
  4086. * Gets a string representation for the current quaternion
  4087. * @returns a string with the Quaternion coordinates
  4088. */
  4089. toString(): string;
  4090. /**
  4091. * Gets the class name of the quaternion
  4092. * @returns the string "Quaternion"
  4093. */
  4094. getClassName(): string;
  4095. /**
  4096. * Gets a hash code for this quaternion
  4097. * @returns the quaternion hash code
  4098. */
  4099. getHashCode(): number;
  4100. /**
  4101. * Copy the quaternion to an array
  4102. * @returns a new array populated with 4 elements from the quaternion coordinates
  4103. */
  4104. asArray(): number[];
  4105. /**
  4106. * Check if two quaternions are equals
  4107. * @param otherQuaternion defines the second operand
  4108. * @return true if the current quaternion and the given one coordinates are strictly equals
  4109. */
  4110. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4111. /**
  4112. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4113. * @param otherQuaternion defines the other quaternion
  4114. * @param epsilon defines the minimal distance to consider equality
  4115. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4116. */
  4117. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4118. /**
  4119. * Clone the current quaternion
  4120. * @returns a new quaternion copied from the current one
  4121. */
  4122. clone(): Quaternion;
  4123. /**
  4124. * Copy a quaternion to the current one
  4125. * @param other defines the other quaternion
  4126. * @returns the updated current quaternion
  4127. */
  4128. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4129. /**
  4130. * Updates the current quaternion with the given float coordinates
  4131. * @param x defines the x coordinate
  4132. * @param y defines the y coordinate
  4133. * @param z defines the z coordinate
  4134. * @param w defines the w coordinate
  4135. * @returns the updated current quaternion
  4136. */
  4137. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4138. /**
  4139. * Updates the current quaternion from the given float coordinates
  4140. * @param x defines the x coordinate
  4141. * @param y defines the y coordinate
  4142. * @param z defines the z coordinate
  4143. * @param w defines the w coordinate
  4144. * @returns the updated current quaternion
  4145. */
  4146. set(x: number, y: number, z: number, w: number): Quaternion;
  4147. /**
  4148. * Adds two quaternions
  4149. * @param other defines the second operand
  4150. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4151. */
  4152. add(other: DeepImmutable<Quaternion>): Quaternion;
  4153. /**
  4154. * Add a quaternion to the current one
  4155. * @param other defines the quaternion to add
  4156. * @returns the current quaternion
  4157. */
  4158. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4159. /**
  4160. * Subtract two quaternions
  4161. * @param other defines the second operand
  4162. * @returns a new quaternion as the subtraction result of the given one from the current one
  4163. */
  4164. subtract(other: Quaternion): Quaternion;
  4165. /**
  4166. * Multiplies the current quaternion by a scale factor
  4167. * @param value defines the scale factor
  4168. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4169. */
  4170. scale(value: number): Quaternion;
  4171. /**
  4172. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4173. * @param scale defines the scale factor
  4174. * @param result defines the Quaternion object where to store the result
  4175. * @returns the unmodified current quaternion
  4176. */
  4177. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4178. /**
  4179. * Multiplies in place the current quaternion by a scale factor
  4180. * @param value defines the scale factor
  4181. * @returns the current modified quaternion
  4182. */
  4183. scaleInPlace(value: number): Quaternion;
  4184. /**
  4185. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4186. * @param scale defines the scale factor
  4187. * @param result defines the Quaternion object where to store the result
  4188. * @returns the unmodified current quaternion
  4189. */
  4190. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4191. /**
  4192. * Multiplies two quaternions
  4193. * @param q1 defines the second operand
  4194. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4195. */
  4196. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4197. /**
  4198. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4199. * @param q1 defines the second operand
  4200. * @param result defines the target quaternion
  4201. * @returns the current quaternion
  4202. */
  4203. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4204. /**
  4205. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4206. * @param q1 defines the second operand
  4207. * @returns the currentupdated quaternion
  4208. */
  4209. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4210. /**
  4211. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4212. * @param ref defines the target quaternion
  4213. * @returns the current quaternion
  4214. */
  4215. conjugateToRef(ref: Quaternion): Quaternion;
  4216. /**
  4217. * Conjugates in place (1-q) the current quaternion
  4218. * @returns the current updated quaternion
  4219. */
  4220. conjugateInPlace(): Quaternion;
  4221. /**
  4222. * Conjugates in place (1-q) the current quaternion
  4223. * @returns a new quaternion
  4224. */
  4225. conjugate(): Quaternion;
  4226. /**
  4227. * Gets length of current quaternion
  4228. * @returns the quaternion length (float)
  4229. */
  4230. length(): number;
  4231. /**
  4232. * Normalize in place the current quaternion
  4233. * @returns the current updated quaternion
  4234. */
  4235. normalize(): Quaternion;
  4236. /**
  4237. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4238. * @param order is a reserved parameter and is ignored for now
  4239. * @returns a new Vector3 containing the Euler angles
  4240. */
  4241. toEulerAngles(order?: string): Vector3;
  4242. /**
  4243. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4244. * @param result defines the vector which will be filled with the Euler angles
  4245. * @returns the current unchanged quaternion
  4246. */
  4247. toEulerAnglesToRef(result: Vector3): Quaternion;
  4248. /**
  4249. * Updates the given rotation matrix with the current quaternion values
  4250. * @param result defines the target matrix
  4251. * @returns the current unchanged quaternion
  4252. */
  4253. toRotationMatrix(result: Matrix): Quaternion;
  4254. /**
  4255. * Updates the current quaternion from the given rotation matrix values
  4256. * @param matrix defines the source matrix
  4257. * @returns the current updated quaternion
  4258. */
  4259. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4260. /**
  4261. * Creates a new quaternion from a rotation matrix
  4262. * @param matrix defines the source matrix
  4263. * @returns a new quaternion created from the given rotation matrix values
  4264. */
  4265. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4266. /**
  4267. * Updates the given quaternion with the given rotation matrix values
  4268. * @param matrix defines the source matrix
  4269. * @param result defines the target quaternion
  4270. */
  4271. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4272. /**
  4273. * Returns the dot product (float) between the quaternions "left" and "right"
  4274. * @param left defines the left operand
  4275. * @param right defines the right operand
  4276. * @returns the dot product
  4277. */
  4278. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4279. /**
  4280. * Checks if the two quaternions are close to each other
  4281. * @param quat0 defines the first quaternion to check
  4282. * @param quat1 defines the second quaternion to check
  4283. * @returns true if the two quaternions are close to each other
  4284. */
  4285. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4286. /**
  4287. * Creates an empty quaternion
  4288. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4289. */
  4290. static Zero(): Quaternion;
  4291. /**
  4292. * Inverse a given quaternion
  4293. * @param q defines the source quaternion
  4294. * @returns a new quaternion as the inverted current quaternion
  4295. */
  4296. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4297. /**
  4298. * Inverse a given quaternion
  4299. * @param q defines the source quaternion
  4300. * @param result the quaternion the result will be stored in
  4301. * @returns the result quaternion
  4302. */
  4303. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4304. /**
  4305. * Creates an identity quaternion
  4306. * @returns the identity quaternion
  4307. */
  4308. static Identity(): Quaternion;
  4309. /**
  4310. * Gets a boolean indicating if the given quaternion is identity
  4311. * @param quaternion defines the quaternion to check
  4312. * @returns true if the quaternion is identity
  4313. */
  4314. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4315. /**
  4316. * Creates a quaternion from a rotation around an axis
  4317. * @param axis defines the axis to use
  4318. * @param angle defines the angle to use
  4319. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4320. */
  4321. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4322. /**
  4323. * Creates a rotation around an axis and stores it into the given quaternion
  4324. * @param axis defines the axis to use
  4325. * @param angle defines the angle to use
  4326. * @param result defines the target quaternion
  4327. * @returns the target quaternion
  4328. */
  4329. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4330. /**
  4331. * Creates a new quaternion from data stored into an array
  4332. * @param array defines the data source
  4333. * @param offset defines the offset in the source array where the data starts
  4334. * @returns a new quaternion
  4335. */
  4336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4337. /**
  4338. * Updates the given quaternion "result" from the starting index of the given array.
  4339. * @param array the array to pull values from
  4340. * @param offset the offset into the array to start at
  4341. * @param result the quaternion to store the result in
  4342. */
  4343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4344. /**
  4345. * Create a quaternion from Euler rotation angles
  4346. * @param x Pitch
  4347. * @param y Yaw
  4348. * @param z Roll
  4349. * @returns the new Quaternion
  4350. */
  4351. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4352. /**
  4353. * Updates a quaternion from Euler rotation angles
  4354. * @param x Pitch
  4355. * @param y Yaw
  4356. * @param z Roll
  4357. * @param result the quaternion to store the result
  4358. * @returns the updated quaternion
  4359. */
  4360. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4361. /**
  4362. * Create a quaternion from Euler rotation vector
  4363. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4364. * @returns the new Quaternion
  4365. */
  4366. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4367. /**
  4368. * Updates a quaternion from Euler rotation vector
  4369. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4370. * @param result the quaternion to store the result
  4371. * @returns the updated quaternion
  4372. */
  4373. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4374. /**
  4375. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4376. * @param yaw defines the rotation around Y axis
  4377. * @param pitch defines the rotation around X axis
  4378. * @param roll defines the rotation around Z axis
  4379. * @returns the new quaternion
  4380. */
  4381. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4382. /**
  4383. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4384. * @param yaw defines the rotation around Y axis
  4385. * @param pitch defines the rotation around X axis
  4386. * @param roll defines the rotation around Z axis
  4387. * @param result defines the target quaternion
  4388. */
  4389. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4390. /**
  4391. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4392. * @param alpha defines the rotation around first axis
  4393. * @param beta defines the rotation around second axis
  4394. * @param gamma defines the rotation around third axis
  4395. * @returns the new quaternion
  4396. */
  4397. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4398. /**
  4399. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4400. * @param alpha defines the rotation around first axis
  4401. * @param beta defines the rotation around second axis
  4402. * @param gamma defines the rotation around third axis
  4403. * @param result defines the target quaternion
  4404. */
  4405. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4406. /**
  4407. * 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)
  4408. * @param axis1 defines the first axis
  4409. * @param axis2 defines the second axis
  4410. * @param axis3 defines the third axis
  4411. * @returns the new quaternion
  4412. */
  4413. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4414. /**
  4415. * 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
  4416. * @param axis1 defines the first axis
  4417. * @param axis2 defines the second axis
  4418. * @param axis3 defines the third axis
  4419. * @param ref defines the target quaternion
  4420. */
  4421. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4422. /**
  4423. * Interpolates between two quaternions
  4424. * @param left defines first quaternion
  4425. * @param right defines second quaternion
  4426. * @param amount defines the gradient to use
  4427. * @returns the new interpolated quaternion
  4428. */
  4429. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4430. /**
  4431. * Interpolates between two quaternions and stores it into a target quaternion
  4432. * @param left defines first quaternion
  4433. * @param right defines second quaternion
  4434. * @param amount defines the gradient to use
  4435. * @param result defines the target quaternion
  4436. */
  4437. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4438. /**
  4439. * Interpolate between two quaternions using Hermite interpolation
  4440. * @param value1 defines first quaternion
  4441. * @param tangent1 defines the incoming tangent
  4442. * @param value2 defines second quaternion
  4443. * @param tangent2 defines the outgoing tangent
  4444. * @param amount defines the target quaternion
  4445. * @returns the new interpolated quaternion
  4446. */
  4447. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4448. }
  4449. /**
  4450. * Class used to store matrix data (4x4)
  4451. */
  4452. export class Matrix {
  4453. /**
  4454. * Gets the precision of matrix computations
  4455. */
  4456. static get Use64Bits(): boolean;
  4457. private static _updateFlagSeed;
  4458. private static _identityReadOnly;
  4459. private _isIdentity;
  4460. private _isIdentityDirty;
  4461. private _isIdentity3x2;
  4462. private _isIdentity3x2Dirty;
  4463. /**
  4464. * Gets the update flag of the matrix which is an unique number for the matrix.
  4465. * It will be incremented every time the matrix data change.
  4466. * You can use it to speed the comparison between two versions of the same matrix.
  4467. */
  4468. updateFlag: number;
  4469. private readonly _m;
  4470. /**
  4471. * Gets the internal data of the matrix
  4472. */
  4473. get m(): DeepImmutable<Float32Array | Array<number>>;
  4474. /** @hidden */
  4475. _markAsUpdated(): void;
  4476. /** @hidden */
  4477. private _updateIdentityStatus;
  4478. /**
  4479. * Creates an empty matrix (filled with zeros)
  4480. */
  4481. constructor();
  4482. /**
  4483. * Check if the current matrix is identity
  4484. * @returns true is the matrix is the identity matrix
  4485. */
  4486. isIdentity(): boolean;
  4487. /**
  4488. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4489. * @returns true is the matrix is the identity matrix
  4490. */
  4491. isIdentityAs3x2(): boolean;
  4492. /**
  4493. * Gets the determinant of the matrix
  4494. * @returns the matrix determinant
  4495. */
  4496. determinant(): number;
  4497. /**
  4498. * Returns the matrix as a Float32Array or Array<number>
  4499. * @returns the matrix underlying array
  4500. */
  4501. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4502. /**
  4503. * Returns the matrix as a Float32Array or Array<number>
  4504. * @returns the matrix underlying array.
  4505. */
  4506. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4507. /**
  4508. * Inverts the current matrix in place
  4509. * @returns the current inverted matrix
  4510. */
  4511. invert(): Matrix;
  4512. /**
  4513. * Sets all the matrix elements to zero
  4514. * @returns the current matrix
  4515. */
  4516. reset(): Matrix;
  4517. /**
  4518. * Adds the current matrix with a second one
  4519. * @param other defines the matrix to add
  4520. * @returns a new matrix as the addition of the current matrix and the given one
  4521. */
  4522. add(other: DeepImmutable<Matrix>): Matrix;
  4523. /**
  4524. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4525. * @param other defines the matrix to add
  4526. * @param result defines the target matrix
  4527. * @returns the current matrix
  4528. */
  4529. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4530. /**
  4531. * Adds in place the given matrix to the current matrix
  4532. * @param other defines the second operand
  4533. * @returns the current updated matrix
  4534. */
  4535. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4536. /**
  4537. * Sets the given matrix to the current inverted Matrix
  4538. * @param other defines the target matrix
  4539. * @returns the unmodified current matrix
  4540. */
  4541. invertToRef(other: Matrix): Matrix;
  4542. /**
  4543. * add a value at the specified position in the current Matrix
  4544. * @param index the index of the value within the matrix. between 0 and 15.
  4545. * @param value the value to be added
  4546. * @returns the current updated matrix
  4547. */
  4548. addAtIndex(index: number, value: number): Matrix;
  4549. /**
  4550. * mutiply the specified position in the current Matrix by a value
  4551. * @param index the index of the value within the matrix. between 0 and 15.
  4552. * @param value the value to be added
  4553. * @returns the current updated matrix
  4554. */
  4555. multiplyAtIndex(index: number, value: number): Matrix;
  4556. /**
  4557. * Inserts the translation vector (using 3 floats) in the current matrix
  4558. * @param x defines the 1st component of the translation
  4559. * @param y defines the 2nd component of the translation
  4560. * @param z defines the 3rd component of the translation
  4561. * @returns the current updated matrix
  4562. */
  4563. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4564. /**
  4565. * Adds the translation vector (using 3 floats) in the current matrix
  4566. * @param x defines the 1st component of the translation
  4567. * @param y defines the 2nd component of the translation
  4568. * @param z defines the 3rd component of the translation
  4569. * @returns the current updated matrix
  4570. */
  4571. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4572. /**
  4573. * Inserts the translation vector in the current matrix
  4574. * @param vector3 defines the translation to insert
  4575. * @returns the current updated matrix
  4576. */
  4577. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4578. /**
  4579. * Gets the translation value of the current matrix
  4580. * @returns a new Vector3 as the extracted translation from the matrix
  4581. */
  4582. getTranslation(): Vector3;
  4583. /**
  4584. * Fill a Vector3 with the extracted translation from the matrix
  4585. * @param result defines the Vector3 where to store the translation
  4586. * @returns the current matrix
  4587. */
  4588. getTranslationToRef(result: Vector3): Matrix;
  4589. /**
  4590. * Remove rotation and scaling part from the matrix
  4591. * @returns the updated matrix
  4592. */
  4593. removeRotationAndScaling(): Matrix;
  4594. /**
  4595. * Multiply two matrices
  4596. * @param other defines the second operand
  4597. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4598. */
  4599. multiply(other: DeepImmutable<Matrix>): Matrix;
  4600. /**
  4601. * Copy the current matrix from the given one
  4602. * @param other defines the source matrix
  4603. * @returns the current updated matrix
  4604. */
  4605. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4606. /**
  4607. * Populates the given array from the starting index with the current matrix values
  4608. * @param array defines the target array
  4609. * @param offset defines the offset in the target array where to start storing values
  4610. * @returns the current matrix
  4611. */
  4612. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4613. /**
  4614. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4615. * @param other defines the second operand
  4616. * @param result defines the matrix where to store the multiplication
  4617. * @returns the current matrix
  4618. */
  4619. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4620. /**
  4621. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4622. * @param other defines the second operand
  4623. * @param result defines the array where to store the multiplication
  4624. * @param offset defines the offset in the target array where to start storing values
  4625. * @returns the current matrix
  4626. */
  4627. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4628. /**
  4629. * Check equality between this matrix and a second one
  4630. * @param value defines the second matrix to compare
  4631. * @returns true is the current matrix and the given one values are strictly equal
  4632. */
  4633. equals(value: DeepImmutable<Matrix>): boolean;
  4634. /**
  4635. * Clone the current matrix
  4636. * @returns a new matrix from the current matrix
  4637. */
  4638. clone(): Matrix;
  4639. /**
  4640. * Returns the name of the current matrix class
  4641. * @returns the string "Matrix"
  4642. */
  4643. getClassName(): string;
  4644. /**
  4645. * Gets the hash code of the current matrix
  4646. * @returns the hash code
  4647. */
  4648. getHashCode(): number;
  4649. /**
  4650. * Decomposes the current Matrix into a translation, rotation and scaling components
  4651. * @param scale defines the scale vector3 given as a reference to update
  4652. * @param rotation defines the rotation quaternion given as a reference to update
  4653. * @param translation defines the translation vector3 given as a reference to update
  4654. * @returns true if operation was successful
  4655. */
  4656. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4657. /**
  4658. * Gets specific row of the matrix
  4659. * @param index defines the number of the row to get
  4660. * @returns the index-th row of the current matrix as a new Vector4
  4661. */
  4662. getRow(index: number): Nullable<Vector4>;
  4663. /**
  4664. * Sets the index-th row of the current matrix to the vector4 values
  4665. * @param index defines the number of the row to set
  4666. * @param row defines the target vector4
  4667. * @returns the updated current matrix
  4668. */
  4669. setRow(index: number, row: Vector4): Matrix;
  4670. /**
  4671. * Compute the transpose of the matrix
  4672. * @returns the new transposed matrix
  4673. */
  4674. transpose(): Matrix;
  4675. /**
  4676. * Compute the transpose of the matrix and store it in a given matrix
  4677. * @param result defines the target matrix
  4678. * @returns the current matrix
  4679. */
  4680. transposeToRef(result: Matrix): Matrix;
  4681. /**
  4682. * Sets the index-th row of the current matrix with the given 4 x float values
  4683. * @param index defines the row index
  4684. * @param x defines the x component to set
  4685. * @param y defines the y component to set
  4686. * @param z defines the z component to set
  4687. * @param w defines the w component to set
  4688. * @returns the updated current matrix
  4689. */
  4690. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4691. /**
  4692. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4693. * @param scale defines the scale factor
  4694. * @returns a new matrix
  4695. */
  4696. scale(scale: number): Matrix;
  4697. /**
  4698. * Scale the current matrix values by a factor to a given result matrix
  4699. * @param scale defines the scale factor
  4700. * @param result defines the matrix to store the result
  4701. * @returns the current matrix
  4702. */
  4703. scaleToRef(scale: number, result: Matrix): Matrix;
  4704. /**
  4705. * Scale the current matrix values by a factor and add the result to a given matrix
  4706. * @param scale defines the scale factor
  4707. * @param result defines the Matrix to store the result
  4708. * @returns the current matrix
  4709. */
  4710. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4711. /**
  4712. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4713. * @param ref matrix to store the result
  4714. */
  4715. toNormalMatrix(ref: Matrix): void;
  4716. /**
  4717. * Gets only rotation part of the current matrix
  4718. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4719. */
  4720. getRotationMatrix(): Matrix;
  4721. /**
  4722. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4723. * @param result defines the target matrix to store data to
  4724. * @returns the current matrix
  4725. */
  4726. getRotationMatrixToRef(result: Matrix): Matrix;
  4727. /**
  4728. * Toggles model matrix from being right handed to left handed in place and vice versa
  4729. */
  4730. toggleModelMatrixHandInPlace(): void;
  4731. /**
  4732. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4733. */
  4734. toggleProjectionMatrixHandInPlace(): void;
  4735. /**
  4736. * Creates a matrix from an array
  4737. * @param array defines the source array
  4738. * @param offset defines an offset in the source array
  4739. * @returns a new Matrix set from the starting index of the given array
  4740. */
  4741. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4742. /**
  4743. * Copy the content of an array into a given matrix
  4744. * @param array defines the source array
  4745. * @param offset defines an offset in the source array
  4746. * @param result defines the target matrix
  4747. */
  4748. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4749. /**
  4750. * Stores an array into a matrix after having multiplied each component by a given factor
  4751. * @param array defines the source array
  4752. * @param offset defines the offset in the source array
  4753. * @param scale defines the scaling factor
  4754. * @param result defines the target matrix
  4755. */
  4756. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4757. /**
  4758. * Gets an identity matrix that must not be updated
  4759. */
  4760. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4761. /**
  4762. * Stores a list of values (16) inside a given matrix
  4763. * @param initialM11 defines 1st value of 1st row
  4764. * @param initialM12 defines 2nd value of 1st row
  4765. * @param initialM13 defines 3rd value of 1st row
  4766. * @param initialM14 defines 4th value of 1st row
  4767. * @param initialM21 defines 1st value of 2nd row
  4768. * @param initialM22 defines 2nd value of 2nd row
  4769. * @param initialM23 defines 3rd value of 2nd row
  4770. * @param initialM24 defines 4th value of 2nd row
  4771. * @param initialM31 defines 1st value of 3rd row
  4772. * @param initialM32 defines 2nd value of 3rd row
  4773. * @param initialM33 defines 3rd value of 3rd row
  4774. * @param initialM34 defines 4th value of 3rd row
  4775. * @param initialM41 defines 1st value of 4th row
  4776. * @param initialM42 defines 2nd value of 4th row
  4777. * @param initialM43 defines 3rd value of 4th row
  4778. * @param initialM44 defines 4th value of 4th row
  4779. * @param result defines the target matrix
  4780. */
  4781. 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;
  4782. /**
  4783. * Creates new matrix from a list of values (16)
  4784. * @param initialM11 defines 1st value of 1st row
  4785. * @param initialM12 defines 2nd value of 1st row
  4786. * @param initialM13 defines 3rd value of 1st row
  4787. * @param initialM14 defines 4th value of 1st row
  4788. * @param initialM21 defines 1st value of 2nd row
  4789. * @param initialM22 defines 2nd value of 2nd row
  4790. * @param initialM23 defines 3rd value of 2nd row
  4791. * @param initialM24 defines 4th value of 2nd row
  4792. * @param initialM31 defines 1st value of 3rd row
  4793. * @param initialM32 defines 2nd value of 3rd row
  4794. * @param initialM33 defines 3rd value of 3rd row
  4795. * @param initialM34 defines 4th value of 3rd row
  4796. * @param initialM41 defines 1st value of 4th row
  4797. * @param initialM42 defines 2nd value of 4th row
  4798. * @param initialM43 defines 3rd value of 4th row
  4799. * @param initialM44 defines 4th value of 4th row
  4800. * @returns the new matrix
  4801. */
  4802. 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;
  4803. /**
  4804. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4805. * @param scale defines the scale vector3
  4806. * @param rotation defines the rotation quaternion
  4807. * @param translation defines the translation vector3
  4808. * @returns a new matrix
  4809. */
  4810. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4811. /**
  4812. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4813. * @param scale defines the scale vector3
  4814. * @param rotation defines the rotation quaternion
  4815. * @param translation defines the translation vector3
  4816. * @param result defines the target matrix
  4817. */
  4818. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4819. /**
  4820. * Creates a new identity matrix
  4821. * @returns a new identity matrix
  4822. */
  4823. static Identity(): Matrix;
  4824. /**
  4825. * Creates a new identity matrix and stores the result in a given matrix
  4826. * @param result defines the target matrix
  4827. */
  4828. static IdentityToRef(result: Matrix): void;
  4829. /**
  4830. * Creates a new zero matrix
  4831. * @returns a new zero matrix
  4832. */
  4833. static Zero(): Matrix;
  4834. /**
  4835. * Creates a new rotation matrix for "angle" radians around the X axis
  4836. * @param angle defines the angle (in radians) to use
  4837. * @return the new matrix
  4838. */
  4839. static RotationX(angle: number): Matrix;
  4840. /**
  4841. * Creates a new matrix as the invert of a given matrix
  4842. * @param source defines the source matrix
  4843. * @returns the new matrix
  4844. */
  4845. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4846. /**
  4847. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4848. * @param angle defines the angle (in radians) to use
  4849. * @param result defines the target matrix
  4850. */
  4851. static RotationXToRef(angle: number, result: Matrix): void;
  4852. /**
  4853. * Creates a new rotation matrix for "angle" radians around the Y axis
  4854. * @param angle defines the angle (in radians) to use
  4855. * @return the new matrix
  4856. */
  4857. static RotationY(angle: number): Matrix;
  4858. /**
  4859. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4860. * @param angle defines the angle (in radians) to use
  4861. * @param result defines the target matrix
  4862. */
  4863. static RotationYToRef(angle: number, result: Matrix): void;
  4864. /**
  4865. * Creates a new rotation matrix for "angle" radians around the Z axis
  4866. * @param angle defines the angle (in radians) to use
  4867. * @return the new matrix
  4868. */
  4869. static RotationZ(angle: number): Matrix;
  4870. /**
  4871. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4872. * @param angle defines the angle (in radians) to use
  4873. * @param result defines the target matrix
  4874. */
  4875. static RotationZToRef(angle: number, result: Matrix): void;
  4876. /**
  4877. * Creates a new rotation matrix for "angle" radians around the given axis
  4878. * @param axis defines the axis to use
  4879. * @param angle defines the angle (in radians) to use
  4880. * @return the new matrix
  4881. */
  4882. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4883. /**
  4884. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4885. * @param axis defines the axis to use
  4886. * @param angle defines the angle (in radians) to use
  4887. * @param result defines the target matrix
  4888. */
  4889. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4890. /**
  4891. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4892. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4893. * @param from defines the vector to align
  4894. * @param to defines the vector to align to
  4895. * @param result defines the target matrix
  4896. */
  4897. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4898. /**
  4899. * Creates a rotation matrix
  4900. * @param yaw defines the yaw angle in radians (Y axis)
  4901. * @param pitch defines the pitch angle in radians (X axis)
  4902. * @param roll defines the roll angle in radians (Z axis)
  4903. * @returns the new rotation matrix
  4904. */
  4905. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4906. /**
  4907. * Creates a rotation matrix and stores it in a given matrix
  4908. * @param yaw defines the yaw angle in radians (Y axis)
  4909. * @param pitch defines the pitch angle in radians (X axis)
  4910. * @param roll defines the roll angle in radians (Z axis)
  4911. * @param result defines the target matrix
  4912. */
  4913. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4914. /**
  4915. * Creates a scaling matrix
  4916. * @param x defines the scale factor on X axis
  4917. * @param y defines the scale factor on Y axis
  4918. * @param z defines the scale factor on Z axis
  4919. * @returns the new matrix
  4920. */
  4921. static Scaling(x: number, y: number, z: number): Matrix;
  4922. /**
  4923. * Creates a scaling matrix and stores it in a given matrix
  4924. * @param x defines the scale factor on X axis
  4925. * @param y defines the scale factor on Y axis
  4926. * @param z defines the scale factor on Z axis
  4927. * @param result defines the target matrix
  4928. */
  4929. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4930. /**
  4931. * Creates a translation matrix
  4932. * @param x defines the translation on X axis
  4933. * @param y defines the translation on Y axis
  4934. * @param z defines the translationon Z axis
  4935. * @returns the new matrix
  4936. */
  4937. static Translation(x: number, y: number, z: number): Matrix;
  4938. /**
  4939. * Creates a translation matrix and stores it in a given matrix
  4940. * @param x defines the translation on X axis
  4941. * @param y defines the translation on Y axis
  4942. * @param z defines the translationon Z axis
  4943. * @param result defines the target matrix
  4944. */
  4945. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4946. /**
  4947. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4948. * @param startValue defines the start value
  4949. * @param endValue defines the end value
  4950. * @param gradient defines the gradient factor
  4951. * @returns the new matrix
  4952. */
  4953. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4954. /**
  4955. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4956. * @param startValue defines the start value
  4957. * @param endValue defines the end value
  4958. * @param gradient defines the gradient factor
  4959. * @param result defines the Matrix object where to store data
  4960. */
  4961. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4962. /**
  4963. * Builds a new matrix whose values are computed by:
  4964. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4965. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4966. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4967. * @param startValue defines the first matrix
  4968. * @param endValue defines the second matrix
  4969. * @param gradient defines the gradient between the two matrices
  4970. * @returns the new matrix
  4971. */
  4972. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4973. /**
  4974. * Update a matrix to values which are computed by:
  4975. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4976. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4977. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4978. * @param startValue defines the first matrix
  4979. * @param endValue defines the second matrix
  4980. * @param gradient defines the gradient between the two matrices
  4981. * @param result defines the target matrix
  4982. */
  4983. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4984. /**
  4985. * 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"
  4986. * This function works in left handed mode
  4987. * @param eye defines the final position of the entity
  4988. * @param target defines where the entity should look at
  4989. * @param up defines the up vector for the entity
  4990. * @returns the new matrix
  4991. */
  4992. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4993. /**
  4994. * 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".
  4995. * This function works in left handed mode
  4996. * @param eye defines the final position of the entity
  4997. * @param target defines where the entity should look at
  4998. * @param up defines the up vector for the entity
  4999. * @param result defines the target matrix
  5000. */
  5001. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5002. /**
  5003. * 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"
  5004. * This function works in right handed mode
  5005. * @param eye defines the final position of the entity
  5006. * @param target defines where the entity should look at
  5007. * @param up defines the up vector for the entity
  5008. * @returns the new matrix
  5009. */
  5010. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5011. /**
  5012. * 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".
  5013. * This function works in right handed mode
  5014. * @param eye defines the final position of the entity
  5015. * @param target defines where the entity should look at
  5016. * @param up defines the up vector for the entity
  5017. * @param result defines the target matrix
  5018. */
  5019. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5020. /**
  5021. * Create a left-handed orthographic projection matrix
  5022. * @param width defines the viewport width
  5023. * @param height defines the viewport height
  5024. * @param znear defines the near clip plane
  5025. * @param zfar defines the far clip plane
  5026. * @returns a new matrix as a left-handed orthographic projection matrix
  5027. */
  5028. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5029. /**
  5030. * Store a left-handed orthographic projection to a given matrix
  5031. * @param width defines the viewport width
  5032. * @param height defines the viewport height
  5033. * @param znear defines the near clip plane
  5034. * @param zfar defines the far clip plane
  5035. * @param result defines the target matrix
  5036. */
  5037. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5038. /**
  5039. * Create a left-handed orthographic projection matrix
  5040. * @param left defines the viewport left coordinate
  5041. * @param right defines the viewport right coordinate
  5042. * @param bottom defines the viewport bottom coordinate
  5043. * @param top defines the viewport top coordinate
  5044. * @param znear defines the near clip plane
  5045. * @param zfar defines the far clip plane
  5046. * @returns a new matrix as a left-handed orthographic projection matrix
  5047. */
  5048. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5049. /**
  5050. * Stores a left-handed orthographic projection into a given matrix
  5051. * @param left defines the viewport left coordinate
  5052. * @param right defines the viewport right coordinate
  5053. * @param bottom defines the viewport bottom coordinate
  5054. * @param top defines the viewport top coordinate
  5055. * @param znear defines the near clip plane
  5056. * @param zfar defines the far clip plane
  5057. * @param result defines the target matrix
  5058. */
  5059. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5060. /**
  5061. * Creates a right-handed orthographic projection matrix
  5062. * @param left defines the viewport left coordinate
  5063. * @param right defines the viewport right coordinate
  5064. * @param bottom defines the viewport bottom coordinate
  5065. * @param top defines the viewport top coordinate
  5066. * @param znear defines the near clip plane
  5067. * @param zfar defines the far clip plane
  5068. * @returns a new matrix as a right-handed orthographic projection matrix
  5069. */
  5070. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5071. /**
  5072. * Stores a right-handed orthographic projection into a given matrix
  5073. * @param left defines the viewport left coordinate
  5074. * @param right defines the viewport right coordinate
  5075. * @param bottom defines the viewport bottom coordinate
  5076. * @param top defines the viewport top coordinate
  5077. * @param znear defines the near clip plane
  5078. * @param zfar defines the far clip plane
  5079. * @param result defines the target matrix
  5080. */
  5081. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5082. /**
  5083. * Creates a left-handed perspective projection matrix
  5084. * @param width defines the viewport width
  5085. * @param height defines the viewport height
  5086. * @param znear defines the near clip plane
  5087. * @param zfar defines the far clip plane
  5088. * @returns a new matrix as a left-handed perspective projection matrix
  5089. */
  5090. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5091. /**
  5092. * Creates a left-handed perspective projection matrix
  5093. * @param fov defines the horizontal field of view
  5094. * @param aspect defines the aspect ratio
  5095. * @param znear defines the near clip plane
  5096. * @param zfar defines the far clip plane
  5097. * @returns a new matrix as a left-handed perspective projection matrix
  5098. */
  5099. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5100. /**
  5101. * Stores a left-handed perspective projection into a given matrix
  5102. * @param fov defines the horizontal field of view
  5103. * @param aspect defines the aspect ratio
  5104. * @param znear defines the near clip plane
  5105. * @param zfar defines the far clip plane
  5106. * @param result defines the target matrix
  5107. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5108. */
  5109. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5110. /**
  5111. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5112. * @param fov defines the horizontal field of view
  5113. * @param aspect defines the aspect ratio
  5114. * @param znear defines the near clip plane
  5115. * @param zfar not used as infinity is used as far clip
  5116. * @param result defines the target matrix
  5117. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5118. */
  5119. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5120. /**
  5121. * Creates a right-handed perspective projection matrix
  5122. * @param fov defines the horizontal field of view
  5123. * @param aspect defines the aspect ratio
  5124. * @param znear defines the near clip plane
  5125. * @param zfar defines the far clip plane
  5126. * @returns a new matrix as a right-handed perspective projection matrix
  5127. */
  5128. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5129. /**
  5130. * Stores a right-handed perspective projection into a given matrix
  5131. * @param fov defines the horizontal field of view
  5132. * @param aspect defines the aspect ratio
  5133. * @param znear defines the near clip plane
  5134. * @param zfar defines the far clip plane
  5135. * @param result defines the target matrix
  5136. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5137. */
  5138. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5139. /**
  5140. * Stores a right-handed perspective projection into a given matrix
  5141. * @param fov defines the horizontal field of view
  5142. * @param aspect defines the aspect ratio
  5143. * @param znear defines the near clip plane
  5144. * @param zfar not used as infinity is used as far clip
  5145. * @param result defines the target matrix
  5146. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5147. */
  5148. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5149. /**
  5150. * Stores a perspective projection for WebVR info a given matrix
  5151. * @param fov defines the field of view
  5152. * @param znear defines the near clip plane
  5153. * @param zfar defines the far clip plane
  5154. * @param result defines the target matrix
  5155. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5156. */
  5157. static PerspectiveFovWebVRToRef(fov: {
  5158. upDegrees: number;
  5159. downDegrees: number;
  5160. leftDegrees: number;
  5161. rightDegrees: number;
  5162. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5163. /**
  5164. * Computes a complete transformation matrix
  5165. * @param viewport defines the viewport to use
  5166. * @param world defines the world matrix
  5167. * @param view defines the view matrix
  5168. * @param projection defines the projection matrix
  5169. * @param zmin defines the near clip plane
  5170. * @param zmax defines the far clip plane
  5171. * @returns the transformation matrix
  5172. */
  5173. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5174. /**
  5175. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5176. * @param matrix defines the matrix to use
  5177. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5178. */
  5179. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5180. /**
  5181. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5182. * @param matrix defines the matrix to use
  5183. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5184. */
  5185. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5186. /**
  5187. * Compute the transpose of a given matrix
  5188. * @param matrix defines the matrix to transpose
  5189. * @returns the new matrix
  5190. */
  5191. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5192. /**
  5193. * Compute the transpose of a matrix and store it in a target matrix
  5194. * @param matrix defines the matrix to transpose
  5195. * @param result defines the target matrix
  5196. */
  5197. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5198. /**
  5199. * Computes a reflection matrix from a plane
  5200. * @param plane defines the reflection plane
  5201. * @returns a new matrix
  5202. */
  5203. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5204. /**
  5205. * Computes a reflection matrix from a plane
  5206. * @param plane defines the reflection plane
  5207. * @param result defines the target matrix
  5208. */
  5209. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5210. /**
  5211. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5212. * @param xaxis defines the value of the 1st axis
  5213. * @param yaxis defines the value of the 2nd axis
  5214. * @param zaxis defines the value of the 3rd axis
  5215. * @param result defines the target matrix
  5216. */
  5217. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5218. /**
  5219. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5220. * @param quat defines the quaternion to use
  5221. * @param result defines the target matrix
  5222. */
  5223. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5224. }
  5225. /**
  5226. * @hidden
  5227. */
  5228. export class TmpVectors {
  5229. static Vector2: Vector2[];
  5230. static Vector3: Vector3[];
  5231. static Vector4: Vector4[];
  5232. static Quaternion: Quaternion[];
  5233. static Matrix: Matrix[];
  5234. }
  5235. }
  5236. declare module BABYLON {
  5237. /**
  5238. * Defines potential orientation for back face culling
  5239. */
  5240. export enum Orientation {
  5241. /**
  5242. * Clockwise
  5243. */
  5244. CW = 0,
  5245. /** Counter clockwise */
  5246. CCW = 1
  5247. }
  5248. /** Class used to represent a Bezier curve */
  5249. export class BezierCurve {
  5250. /**
  5251. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5252. * @param t defines the time
  5253. * @param x1 defines the left coordinate on X axis
  5254. * @param y1 defines the left coordinate on Y axis
  5255. * @param x2 defines the right coordinate on X axis
  5256. * @param y2 defines the right coordinate on Y axis
  5257. * @returns the interpolated value
  5258. */
  5259. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5260. }
  5261. /**
  5262. * Defines angle representation
  5263. */
  5264. export class Angle {
  5265. private _radians;
  5266. /**
  5267. * Creates an Angle object of "radians" radians (float).
  5268. * @param radians the angle in radians
  5269. */
  5270. constructor(radians: number);
  5271. /**
  5272. * Get value in degrees
  5273. * @returns the Angle value in degrees (float)
  5274. */
  5275. degrees(): number;
  5276. /**
  5277. * Get value in radians
  5278. * @returns the Angle value in radians (float)
  5279. */
  5280. radians(): number;
  5281. /**
  5282. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5283. * @param a defines first point as the origin
  5284. * @param b defines point
  5285. * @returns a new Angle
  5286. */
  5287. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5288. /**
  5289. * Gets a new Angle object from the given float in radians
  5290. * @param radians defines the angle value in radians
  5291. * @returns a new Angle
  5292. */
  5293. static FromRadians(radians: number): Angle;
  5294. /**
  5295. * Gets a new Angle object from the given float in degrees
  5296. * @param degrees defines the angle value in degrees
  5297. * @returns a new Angle
  5298. */
  5299. static FromDegrees(degrees: number): Angle;
  5300. }
  5301. /**
  5302. * This represents an arc in a 2d space.
  5303. */
  5304. export class Arc2 {
  5305. /** Defines the start point of the arc */
  5306. startPoint: Vector2;
  5307. /** Defines the mid point of the arc */
  5308. midPoint: Vector2;
  5309. /** Defines the end point of the arc */
  5310. endPoint: Vector2;
  5311. /**
  5312. * Defines the center point of the arc.
  5313. */
  5314. centerPoint: Vector2;
  5315. /**
  5316. * Defines the radius of the arc.
  5317. */
  5318. radius: number;
  5319. /**
  5320. * Defines the angle of the arc (from mid point to end point).
  5321. */
  5322. angle: Angle;
  5323. /**
  5324. * Defines the start angle of the arc (from start point to middle point).
  5325. */
  5326. startAngle: Angle;
  5327. /**
  5328. * Defines the orientation of the arc (clock wise/counter clock wise).
  5329. */
  5330. orientation: Orientation;
  5331. /**
  5332. * Creates an Arc object from the three given points : start, middle and end.
  5333. * @param startPoint Defines the start point of the arc
  5334. * @param midPoint Defines the midlle point of the arc
  5335. * @param endPoint Defines the end point of the arc
  5336. */
  5337. constructor(
  5338. /** Defines the start point of the arc */
  5339. startPoint: Vector2,
  5340. /** Defines the mid point of the arc */
  5341. midPoint: Vector2,
  5342. /** Defines the end point of the arc */
  5343. endPoint: Vector2);
  5344. }
  5345. /**
  5346. * Represents a 2D path made up of multiple 2D points
  5347. */
  5348. export class Path2 {
  5349. private _points;
  5350. private _length;
  5351. /**
  5352. * If the path start and end point are the same
  5353. */
  5354. closed: boolean;
  5355. /**
  5356. * Creates a Path2 object from the starting 2D coordinates x and y.
  5357. * @param x the starting points x value
  5358. * @param y the starting points y value
  5359. */
  5360. constructor(x: number, y: number);
  5361. /**
  5362. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5363. * @param x the added points x value
  5364. * @param y the added points y value
  5365. * @returns the updated Path2.
  5366. */
  5367. addLineTo(x: number, y: number): Path2;
  5368. /**
  5369. * 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.
  5370. * @param midX middle point x value
  5371. * @param midY middle point y value
  5372. * @param endX end point x value
  5373. * @param endY end point y value
  5374. * @param numberOfSegments (default: 36)
  5375. * @returns the updated Path2.
  5376. */
  5377. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5378. /**
  5379. * Closes the Path2.
  5380. * @returns the Path2.
  5381. */
  5382. close(): Path2;
  5383. /**
  5384. * Gets the sum of the distance between each sequential point in the path
  5385. * @returns the Path2 total length (float).
  5386. */
  5387. length(): number;
  5388. /**
  5389. * Gets the points which construct the path
  5390. * @returns the Path2 internal array of points.
  5391. */
  5392. getPoints(): Vector2[];
  5393. /**
  5394. * Retreives the point at the distance aways from the starting point
  5395. * @param normalizedLengthPosition the length along the path to retreive the point from
  5396. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5397. */
  5398. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5399. /**
  5400. * Creates a new path starting from an x and y position
  5401. * @param x starting x value
  5402. * @param y starting y value
  5403. * @returns a new Path2 starting at the coordinates (x, y).
  5404. */
  5405. static StartingAt(x: number, y: number): Path2;
  5406. }
  5407. /**
  5408. * Represents a 3D path made up of multiple 3D points
  5409. */
  5410. export class Path3D {
  5411. /**
  5412. * an array of Vector3, the curve axis of the Path3D
  5413. */
  5414. path: Vector3[];
  5415. private _curve;
  5416. private _distances;
  5417. private _tangents;
  5418. private _normals;
  5419. private _binormals;
  5420. private _raw;
  5421. private _alignTangentsWithPath;
  5422. private readonly _pointAtData;
  5423. /**
  5424. * new Path3D(path, normal, raw)
  5425. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5426. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5427. * @param path an array of Vector3, the curve axis of the Path3D
  5428. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5429. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5430. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5431. */
  5432. constructor(
  5433. /**
  5434. * an array of Vector3, the curve axis of the Path3D
  5435. */
  5436. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5437. /**
  5438. * Returns the Path3D array of successive Vector3 designing its curve.
  5439. * @returns the Path3D array of successive Vector3 designing its curve.
  5440. */
  5441. getCurve(): Vector3[];
  5442. /**
  5443. * Returns the Path3D array of successive Vector3 designing its curve.
  5444. * @returns the Path3D array of successive Vector3 designing its curve.
  5445. */
  5446. getPoints(): Vector3[];
  5447. /**
  5448. * @returns the computed length (float) of the path.
  5449. */
  5450. length(): number;
  5451. /**
  5452. * Returns an array populated with tangent vectors on each Path3D curve point.
  5453. * @returns an array populated with tangent vectors on each Path3D curve point.
  5454. */
  5455. getTangents(): Vector3[];
  5456. /**
  5457. * Returns an array populated with normal vectors on each Path3D curve point.
  5458. * @returns an array populated with normal vectors on each Path3D curve point.
  5459. */
  5460. getNormals(): Vector3[];
  5461. /**
  5462. * Returns an array populated with binormal vectors on each Path3D curve point.
  5463. * @returns an array populated with binormal vectors on each Path3D curve point.
  5464. */
  5465. getBinormals(): Vector3[];
  5466. /**
  5467. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5468. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5469. */
  5470. getDistances(): number[];
  5471. /**
  5472. * Returns an interpolated point along this path
  5473. * @param position the position of the point along this path, from 0.0 to 1.0
  5474. * @returns a new Vector3 as the point
  5475. */
  5476. getPointAt(position: number): Vector3;
  5477. /**
  5478. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5479. * @param position the position of the point along this path, from 0.0 to 1.0
  5480. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5481. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5482. */
  5483. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5484. /**
  5485. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5486. * @param position the position of the point along this path, from 0.0 to 1.0
  5487. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5488. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5489. */
  5490. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5491. /**
  5492. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5493. * @param position the position of the point along this path, from 0.0 to 1.0
  5494. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5495. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5496. */
  5497. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5498. /**
  5499. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5500. * @param position the position of the point along this path, from 0.0 to 1.0
  5501. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5502. */
  5503. getDistanceAt(position: number): number;
  5504. /**
  5505. * Returns the array index of the previous point of an interpolated point along this path
  5506. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5507. * @returns the array index
  5508. */
  5509. getPreviousPointIndexAt(position: number): number;
  5510. /**
  5511. * 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)
  5512. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5513. * @returns the sub position
  5514. */
  5515. getSubPositionAt(position: number): number;
  5516. /**
  5517. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5518. * @param target the vector of which to get the closest position to
  5519. * @returns the position of the closest virtual point on this path to the target vector
  5520. */
  5521. getClosestPositionTo(target: Vector3): number;
  5522. /**
  5523. * Returns a sub path (slice) of this path
  5524. * @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
  5525. * @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
  5526. * @returns a sub path (slice) of this path
  5527. */
  5528. slice(start?: number, end?: number): Path3D;
  5529. /**
  5530. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5531. * @param path path which all values are copied into the curves points
  5532. * @param firstNormal which should be projected onto the curve
  5533. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5534. * @returns the same object updated.
  5535. */
  5536. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5537. private _compute;
  5538. private _getFirstNonNullVector;
  5539. private _getLastNonNullVector;
  5540. private _normalVector;
  5541. /**
  5542. * Updates the point at data for an interpolated point along this curve
  5543. * @param position the position of the point along this curve, from 0.0 to 1.0
  5544. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5545. * @returns the (updated) point at data
  5546. */
  5547. private _updatePointAtData;
  5548. /**
  5549. * Updates the point at data from the specified parameters
  5550. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5551. * @param point the interpolated point
  5552. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5553. */
  5554. private _setPointAtData;
  5555. /**
  5556. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5557. */
  5558. private _updateInterpolationMatrix;
  5559. }
  5560. /**
  5561. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5562. * A Curve3 is designed from a series of successive Vector3.
  5563. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5564. */
  5565. export class Curve3 {
  5566. private _points;
  5567. private _length;
  5568. /**
  5569. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5570. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5571. * @param v1 (Vector3) the control point
  5572. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5573. * @param nbPoints (integer) the wanted number of points in the curve
  5574. * @returns the created Curve3
  5575. */
  5576. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5577. /**
  5578. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5579. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5580. * @param v1 (Vector3) the first control point
  5581. * @param v2 (Vector3) the second control point
  5582. * @param v3 (Vector3) the end point of the Cubic Bezier
  5583. * @param nbPoints (integer) the wanted number of points in the curve
  5584. * @returns the created Curve3
  5585. */
  5586. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5587. /**
  5588. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5589. * @param p1 (Vector3) the origin point of the Hermite Spline
  5590. * @param t1 (Vector3) the tangent vector at the origin point
  5591. * @param p2 (Vector3) the end point of the Hermite Spline
  5592. * @param t2 (Vector3) the tangent vector at the end point
  5593. * @param nbPoints (integer) the wanted number of points in the curve
  5594. * @returns the created Curve3
  5595. */
  5596. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5597. /**
  5598. * Returns a Curve3 object along a CatmullRom Spline curve :
  5599. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5600. * @param nbPoints (integer) the wanted number of points between each curve control points
  5601. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5602. * @returns the created Curve3
  5603. */
  5604. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5605. /**
  5606. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5607. * A Curve3 is designed from a series of successive Vector3.
  5608. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5609. * @param points points which make up the curve
  5610. */
  5611. constructor(points: Vector3[]);
  5612. /**
  5613. * @returns the Curve3 stored array of successive Vector3
  5614. */
  5615. getPoints(): Vector3[];
  5616. /**
  5617. * @returns the computed length (float) of the curve.
  5618. */
  5619. length(): number;
  5620. /**
  5621. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5622. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5623. * curveA and curveB keep unchanged.
  5624. * @param curve the curve to continue from this curve
  5625. * @returns the newly constructed curve
  5626. */
  5627. continue(curve: DeepImmutable<Curve3>): Curve3;
  5628. private _computeLength;
  5629. }
  5630. }
  5631. declare module BABYLON {
  5632. /**
  5633. * This represents the main contract an easing function should follow.
  5634. * Easing functions are used throughout the animation system.
  5635. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5636. */
  5637. export interface IEasingFunction {
  5638. /**
  5639. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5640. * of the easing function.
  5641. * The link below provides some of the most common examples of easing functions.
  5642. * @see https://easings.net/
  5643. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5644. * @returns the corresponding value on the curve defined by the easing function
  5645. */
  5646. ease(gradient: number): number;
  5647. }
  5648. /**
  5649. * Base class used for every default easing function.
  5650. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5651. */
  5652. export class EasingFunction implements IEasingFunction {
  5653. /**
  5654. * Interpolation follows the mathematical formula associated with the easing function.
  5655. */
  5656. static readonly EASINGMODE_EASEIN: number;
  5657. /**
  5658. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5659. */
  5660. static readonly EASINGMODE_EASEOUT: number;
  5661. /**
  5662. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5663. */
  5664. static readonly EASINGMODE_EASEINOUT: number;
  5665. private _easingMode;
  5666. /**
  5667. * Sets the easing mode of the current function.
  5668. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5669. */
  5670. setEasingMode(easingMode: number): void;
  5671. /**
  5672. * Gets the current easing mode.
  5673. * @returns the easing mode
  5674. */
  5675. getEasingMode(): number;
  5676. /**
  5677. * @hidden
  5678. */
  5679. easeInCore(gradient: number): number;
  5680. /**
  5681. * Given an input gradient between 0 and 1, this returns the corresponding value
  5682. * of the easing function.
  5683. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5684. * @returns the corresponding value on the curve defined by the easing function
  5685. */
  5686. ease(gradient: number): number;
  5687. }
  5688. /**
  5689. * Easing function with a circle shape (see link below).
  5690. * @see https://easings.net/#easeInCirc
  5691. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5692. */
  5693. export class CircleEase extends EasingFunction implements IEasingFunction {
  5694. /** @hidden */
  5695. easeInCore(gradient: number): number;
  5696. }
  5697. /**
  5698. * Easing function with a ease back shape (see link below).
  5699. * @see https://easings.net/#easeInBack
  5700. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5701. */
  5702. export class BackEase extends EasingFunction implements IEasingFunction {
  5703. /** Defines the amplitude of the function */
  5704. amplitude: number;
  5705. /**
  5706. * Instantiates a back ease easing
  5707. * @see https://easings.net/#easeInBack
  5708. * @param amplitude Defines the amplitude of the function
  5709. */
  5710. constructor(
  5711. /** Defines the amplitude of the function */
  5712. amplitude?: number);
  5713. /** @hidden */
  5714. easeInCore(gradient: number): number;
  5715. }
  5716. /**
  5717. * Easing function with a bouncing shape (see link below).
  5718. * @see https://easings.net/#easeInBounce
  5719. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5720. */
  5721. export class BounceEase extends EasingFunction implements IEasingFunction {
  5722. /** Defines the number of bounces */
  5723. bounces: number;
  5724. /** Defines the amplitude of the bounce */
  5725. bounciness: number;
  5726. /**
  5727. * Instantiates a bounce easing
  5728. * @see https://easings.net/#easeInBounce
  5729. * @param bounces Defines the number of bounces
  5730. * @param bounciness Defines the amplitude of the bounce
  5731. */
  5732. constructor(
  5733. /** Defines the number of bounces */
  5734. bounces?: number,
  5735. /** Defines the amplitude of the bounce */
  5736. bounciness?: number);
  5737. /** @hidden */
  5738. easeInCore(gradient: number): number;
  5739. }
  5740. /**
  5741. * Easing function with a power of 3 shape (see link below).
  5742. * @see https://easings.net/#easeInCubic
  5743. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5744. */
  5745. export class CubicEase extends EasingFunction implements IEasingFunction {
  5746. /** @hidden */
  5747. easeInCore(gradient: number): number;
  5748. }
  5749. /**
  5750. * Easing function with an elastic shape (see link below).
  5751. * @see https://easings.net/#easeInElastic
  5752. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5753. */
  5754. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5755. /** Defines the number of oscillations*/
  5756. oscillations: number;
  5757. /** Defines the amplitude of the oscillations*/
  5758. springiness: number;
  5759. /**
  5760. * Instantiates an elastic easing function
  5761. * @see https://easings.net/#easeInElastic
  5762. * @param oscillations Defines the number of oscillations
  5763. * @param springiness Defines the amplitude of the oscillations
  5764. */
  5765. constructor(
  5766. /** Defines the number of oscillations*/
  5767. oscillations?: number,
  5768. /** Defines the amplitude of the oscillations*/
  5769. springiness?: number);
  5770. /** @hidden */
  5771. easeInCore(gradient: number): number;
  5772. }
  5773. /**
  5774. * Easing function with an exponential shape (see link below).
  5775. * @see https://easings.net/#easeInExpo
  5776. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5777. */
  5778. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5779. /** Defines the exponent of the function */
  5780. exponent: number;
  5781. /**
  5782. * Instantiates an exponential easing function
  5783. * @see https://easings.net/#easeInExpo
  5784. * @param exponent Defines the exponent of the function
  5785. */
  5786. constructor(
  5787. /** Defines the exponent of the function */
  5788. exponent?: number);
  5789. /** @hidden */
  5790. easeInCore(gradient: number): number;
  5791. }
  5792. /**
  5793. * Easing function with a power shape (see link below).
  5794. * @see https://easings.net/#easeInQuad
  5795. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5796. */
  5797. export class PowerEase extends EasingFunction implements IEasingFunction {
  5798. /** Defines the power of the function */
  5799. power: number;
  5800. /**
  5801. * Instantiates an power base easing function
  5802. * @see https://easings.net/#easeInQuad
  5803. * @param power Defines the power of the function
  5804. */
  5805. constructor(
  5806. /** Defines the power of the function */
  5807. power?: number);
  5808. /** @hidden */
  5809. easeInCore(gradient: number): number;
  5810. }
  5811. /**
  5812. * Easing function with a power of 2 shape (see link below).
  5813. * @see https://easings.net/#easeInQuad
  5814. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5815. */
  5816. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5817. /** @hidden */
  5818. easeInCore(gradient: number): number;
  5819. }
  5820. /**
  5821. * Easing function with a power of 4 shape (see link below).
  5822. * @see https://easings.net/#easeInQuart
  5823. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5824. */
  5825. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5826. /** @hidden */
  5827. easeInCore(gradient: number): number;
  5828. }
  5829. /**
  5830. * Easing function with a power of 5 shape (see link below).
  5831. * @see https://easings.net/#easeInQuint
  5832. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5833. */
  5834. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5835. /** @hidden */
  5836. easeInCore(gradient: number): number;
  5837. }
  5838. /**
  5839. * Easing function with a sin shape (see link below).
  5840. * @see https://easings.net/#easeInSine
  5841. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5842. */
  5843. export class SineEase extends EasingFunction implements IEasingFunction {
  5844. /** @hidden */
  5845. easeInCore(gradient: number): number;
  5846. }
  5847. /**
  5848. * Easing function with a bezier shape (see link below).
  5849. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5850. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5851. */
  5852. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5853. /** Defines the x component of the start tangent in the bezier curve */
  5854. x1: number;
  5855. /** Defines the y component of the start tangent in the bezier curve */
  5856. y1: number;
  5857. /** Defines the x component of the end tangent in the bezier curve */
  5858. x2: number;
  5859. /** Defines the y component of the end tangent in the bezier curve */
  5860. y2: number;
  5861. /**
  5862. * Instantiates a bezier function
  5863. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5864. * @param x1 Defines the x component of the start tangent in the bezier curve
  5865. * @param y1 Defines the y component of the start tangent in the bezier curve
  5866. * @param x2 Defines the x component of the end tangent in the bezier curve
  5867. * @param y2 Defines the y component of the end tangent in the bezier curve
  5868. */
  5869. constructor(
  5870. /** Defines the x component of the start tangent in the bezier curve */
  5871. x1?: number,
  5872. /** Defines the y component of the start tangent in the bezier curve */
  5873. y1?: number,
  5874. /** Defines the x component of the end tangent in the bezier curve */
  5875. x2?: number,
  5876. /** Defines the y component of the end tangent in the bezier curve */
  5877. y2?: number);
  5878. /** @hidden */
  5879. easeInCore(gradient: number): number;
  5880. }
  5881. }
  5882. declare module BABYLON {
  5883. /**
  5884. * Class used to hold a RBG color
  5885. */
  5886. export class Color3 {
  5887. /**
  5888. * Defines the red component (between 0 and 1, default is 0)
  5889. */
  5890. r: number;
  5891. /**
  5892. * Defines the green component (between 0 and 1, default is 0)
  5893. */
  5894. g: number;
  5895. /**
  5896. * Defines the blue component (between 0 and 1, default is 0)
  5897. */
  5898. b: number;
  5899. /**
  5900. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5901. * @param r defines the red component (between 0 and 1, default is 0)
  5902. * @param g defines the green component (between 0 and 1, default is 0)
  5903. * @param b defines the blue component (between 0 and 1, default is 0)
  5904. */
  5905. constructor(
  5906. /**
  5907. * Defines the red component (between 0 and 1, default is 0)
  5908. */
  5909. r?: number,
  5910. /**
  5911. * Defines the green component (between 0 and 1, default is 0)
  5912. */
  5913. g?: number,
  5914. /**
  5915. * Defines the blue component (between 0 and 1, default is 0)
  5916. */
  5917. b?: number);
  5918. /**
  5919. * Creates a string with the Color3 current values
  5920. * @returns the string representation of the Color3 object
  5921. */
  5922. toString(): string;
  5923. /**
  5924. * Returns the string "Color3"
  5925. * @returns "Color3"
  5926. */
  5927. getClassName(): string;
  5928. /**
  5929. * Compute the Color3 hash code
  5930. * @returns an unique number that can be used to hash Color3 objects
  5931. */
  5932. getHashCode(): number;
  5933. /**
  5934. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5935. * @param array defines the array where to store the r,g,b components
  5936. * @param index defines an optional index in the target array to define where to start storing values
  5937. * @returns the current Color3 object
  5938. */
  5939. toArray(array: FloatArray, index?: number): Color3;
  5940. /**
  5941. * Update the current color with values stored in an array from the starting index of the given array
  5942. * @param array defines the source array
  5943. * @param offset defines an offset in the source array
  5944. * @returns the current Color3 object
  5945. */
  5946. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5947. /**
  5948. * Returns a new Color4 object from the current Color3 and the given alpha
  5949. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5950. * @returns a new Color4 object
  5951. */
  5952. toColor4(alpha?: number): Color4;
  5953. /**
  5954. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5955. * @returns the new array
  5956. */
  5957. asArray(): number[];
  5958. /**
  5959. * Returns the luminance value
  5960. * @returns a float value
  5961. */
  5962. toLuminance(): number;
  5963. /**
  5964. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5965. * @param otherColor defines the second operand
  5966. * @returns the new Color3 object
  5967. */
  5968. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5969. /**
  5970. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5971. * @param otherColor defines the second operand
  5972. * @param result defines the Color3 object where to store the result
  5973. * @returns the current Color3
  5974. */
  5975. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5976. /**
  5977. * Determines equality between Color3 objects
  5978. * @param otherColor defines the second operand
  5979. * @returns true if the rgb values are equal to the given ones
  5980. */
  5981. equals(otherColor: DeepImmutable<Color3>): boolean;
  5982. /**
  5983. * Determines equality between the current Color3 object and a set of r,b,g values
  5984. * @param r defines the red component to check
  5985. * @param g defines the green component to check
  5986. * @param b defines the blue component to check
  5987. * @returns true if the rgb values are equal to the given ones
  5988. */
  5989. equalsFloats(r: number, g: number, b: number): boolean;
  5990. /**
  5991. * Multiplies in place each rgb value by scale
  5992. * @param scale defines the scaling factor
  5993. * @returns the updated Color3
  5994. */
  5995. scale(scale: number): Color3;
  5996. /**
  5997. * Multiplies the rgb values by scale and stores the result into "result"
  5998. * @param scale defines the scaling factor
  5999. * @param result defines the Color3 object where to store the result
  6000. * @returns the unmodified current Color3
  6001. */
  6002. scaleToRef(scale: number, result: Color3): Color3;
  6003. /**
  6004. * Scale the current Color3 values by a factor and add the result to a given Color3
  6005. * @param scale defines the scale factor
  6006. * @param result defines color to store the result into
  6007. * @returns the unmodified current Color3
  6008. */
  6009. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6010. /**
  6011. * Clamps the rgb values by the min and max values and stores the result into "result"
  6012. * @param min defines minimum clamping value (default is 0)
  6013. * @param max defines maximum clamping value (default is 1)
  6014. * @param result defines color to store the result into
  6015. * @returns the original Color3
  6016. */
  6017. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6018. /**
  6019. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6020. * @param otherColor defines the second operand
  6021. * @returns the new Color3
  6022. */
  6023. add(otherColor: DeepImmutable<Color3>): Color3;
  6024. /**
  6025. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6026. * @param otherColor defines the second operand
  6027. * @param result defines Color3 object to store the result into
  6028. * @returns the unmodified current Color3
  6029. */
  6030. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6031. /**
  6032. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6033. * @param otherColor defines the second operand
  6034. * @returns the new Color3
  6035. */
  6036. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6037. /**
  6038. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6039. * @param otherColor defines the second operand
  6040. * @param result defines Color3 object to store the result into
  6041. * @returns the unmodified current Color3
  6042. */
  6043. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6044. /**
  6045. * Copy the current object
  6046. * @returns a new Color3 copied the current one
  6047. */
  6048. clone(): Color3;
  6049. /**
  6050. * Copies the rgb values from the source in the current Color3
  6051. * @param source defines the source Color3 object
  6052. * @returns the updated Color3 object
  6053. */
  6054. copyFrom(source: DeepImmutable<Color3>): Color3;
  6055. /**
  6056. * Updates the Color3 rgb values from the given floats
  6057. * @param r defines the red component to read from
  6058. * @param g defines the green component to read from
  6059. * @param b defines the blue component to read from
  6060. * @returns the current Color3 object
  6061. */
  6062. copyFromFloats(r: number, g: number, b: number): Color3;
  6063. /**
  6064. * Updates the Color3 rgb values from the given floats
  6065. * @param r defines the red component to read from
  6066. * @param g defines the green component to read from
  6067. * @param b defines the blue component to read from
  6068. * @returns the current Color3 object
  6069. */
  6070. set(r: number, g: number, b: number): Color3;
  6071. /**
  6072. * Compute the Color3 hexadecimal code as a string
  6073. * @returns a string containing the hexadecimal representation of the Color3 object
  6074. */
  6075. toHexString(): string;
  6076. /**
  6077. * Computes a new Color3 converted from the current one to linear space
  6078. * @returns a new Color3 object
  6079. */
  6080. toLinearSpace(): Color3;
  6081. /**
  6082. * Converts current color in rgb space to HSV values
  6083. * @returns a new color3 representing the HSV values
  6084. */
  6085. toHSV(): Color3;
  6086. /**
  6087. * Converts current color in rgb space to HSV values
  6088. * @param result defines the Color3 where to store the HSV values
  6089. */
  6090. toHSVToRef(result: Color3): void;
  6091. /**
  6092. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6093. * @param convertedColor defines the Color3 object where to store the linear space version
  6094. * @returns the unmodified Color3
  6095. */
  6096. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6097. /**
  6098. * Computes a new Color3 converted from the current one to gamma space
  6099. * @returns a new Color3 object
  6100. */
  6101. toGammaSpace(): Color3;
  6102. /**
  6103. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6104. * @param convertedColor defines the Color3 object where to store the gamma space version
  6105. * @returns the unmodified Color3
  6106. */
  6107. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6108. private static _BlackReadOnly;
  6109. /**
  6110. * Convert Hue, saturation and value to a Color3 (RGB)
  6111. * @param hue defines the hue
  6112. * @param saturation defines the saturation
  6113. * @param value defines the value
  6114. * @param result defines the Color3 where to store the RGB values
  6115. */
  6116. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6117. /**
  6118. * Creates a new Color3 from the string containing valid hexadecimal values
  6119. * @param hex defines a string containing valid hexadecimal values
  6120. * @returns a new Color3 object
  6121. */
  6122. static FromHexString(hex: string): Color3;
  6123. /**
  6124. * Creates a new Color3 from the starting index of the given array
  6125. * @param array defines the source array
  6126. * @param offset defines an offset in the source array
  6127. * @returns a new Color3 object
  6128. */
  6129. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6130. /**
  6131. * Creates a new Color3 from the starting index element of the given array
  6132. * @param array defines the source array to read from
  6133. * @param offset defines the offset in the source array
  6134. * @param result defines the target Color3 object
  6135. */
  6136. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6137. /**
  6138. * Creates a new Color3 from integer values (< 256)
  6139. * @param r defines the red component to read from (value between 0 and 255)
  6140. * @param g defines the green component to read from (value between 0 and 255)
  6141. * @param b defines the blue component to read from (value between 0 and 255)
  6142. * @returns a new Color3 object
  6143. */
  6144. static FromInts(r: number, g: number, b: number): Color3;
  6145. /**
  6146. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6147. * @param start defines the start Color3 value
  6148. * @param end defines the end Color3 value
  6149. * @param amount defines the gradient value between start and end
  6150. * @returns a new Color3 object
  6151. */
  6152. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6153. /**
  6154. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6155. * @param left defines the start value
  6156. * @param right defines the end value
  6157. * @param amount defines the gradient factor
  6158. * @param result defines the Color3 object where to store the result
  6159. */
  6160. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6161. /**
  6162. * Returns a Color3 value containing a red color
  6163. * @returns a new Color3 object
  6164. */
  6165. static Red(): Color3;
  6166. /**
  6167. * Returns a Color3 value containing a green color
  6168. * @returns a new Color3 object
  6169. */
  6170. static Green(): Color3;
  6171. /**
  6172. * Returns a Color3 value containing a blue color
  6173. * @returns a new Color3 object
  6174. */
  6175. static Blue(): Color3;
  6176. /**
  6177. * Returns a Color3 value containing a black color
  6178. * @returns a new Color3 object
  6179. */
  6180. static Black(): Color3;
  6181. /**
  6182. * Gets a Color3 value containing a black color that must not be updated
  6183. */
  6184. static get BlackReadOnly(): DeepImmutable<Color3>;
  6185. /**
  6186. * Returns a Color3 value containing a white color
  6187. * @returns a new Color3 object
  6188. */
  6189. static White(): Color3;
  6190. /**
  6191. * Returns a Color3 value containing a purple color
  6192. * @returns a new Color3 object
  6193. */
  6194. static Purple(): Color3;
  6195. /**
  6196. * Returns a Color3 value containing a magenta color
  6197. * @returns a new Color3 object
  6198. */
  6199. static Magenta(): Color3;
  6200. /**
  6201. * Returns a Color3 value containing a yellow color
  6202. * @returns a new Color3 object
  6203. */
  6204. static Yellow(): Color3;
  6205. /**
  6206. * Returns a Color3 value containing a gray color
  6207. * @returns a new Color3 object
  6208. */
  6209. static Gray(): Color3;
  6210. /**
  6211. * Returns a Color3 value containing a teal color
  6212. * @returns a new Color3 object
  6213. */
  6214. static Teal(): Color3;
  6215. /**
  6216. * Returns a Color3 value containing a random color
  6217. * @returns a new Color3 object
  6218. */
  6219. static Random(): Color3;
  6220. }
  6221. /**
  6222. * Class used to hold a RBGA color
  6223. */
  6224. export class Color4 {
  6225. /**
  6226. * Defines the red component (between 0 and 1, default is 0)
  6227. */
  6228. r: number;
  6229. /**
  6230. * Defines the green component (between 0 and 1, default is 0)
  6231. */
  6232. g: number;
  6233. /**
  6234. * Defines the blue component (between 0 and 1, default is 0)
  6235. */
  6236. b: number;
  6237. /**
  6238. * Defines the alpha component (between 0 and 1, default is 1)
  6239. */
  6240. a: number;
  6241. /**
  6242. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6243. * @param r defines the red component (between 0 and 1, default is 0)
  6244. * @param g defines the green component (between 0 and 1, default is 0)
  6245. * @param b defines the blue component (between 0 and 1, default is 0)
  6246. * @param a defines the alpha component (between 0 and 1, default is 1)
  6247. */
  6248. constructor(
  6249. /**
  6250. * Defines the red component (between 0 and 1, default is 0)
  6251. */
  6252. r?: number,
  6253. /**
  6254. * Defines the green component (between 0 and 1, default is 0)
  6255. */
  6256. g?: number,
  6257. /**
  6258. * Defines the blue component (between 0 and 1, default is 0)
  6259. */
  6260. b?: number,
  6261. /**
  6262. * Defines the alpha component (between 0 and 1, default is 1)
  6263. */
  6264. a?: number);
  6265. /**
  6266. * Adds in place the given Color4 values to the current Color4 object
  6267. * @param right defines the second operand
  6268. * @returns the current updated Color4 object
  6269. */
  6270. addInPlace(right: DeepImmutable<Color4>): Color4;
  6271. /**
  6272. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6273. * @returns the new array
  6274. */
  6275. asArray(): number[];
  6276. /**
  6277. * Stores from the starting index in the given array the Color4 successive values
  6278. * @param array defines the array where to store the r,g,b components
  6279. * @param index defines an optional index in the target array to define where to start storing values
  6280. * @returns the current Color4 object
  6281. */
  6282. toArray(array: number[], index?: number): Color4;
  6283. /**
  6284. * Update the current color with values stored in an array from the starting index of the given array
  6285. * @param array defines the source array
  6286. * @param offset defines an offset in the source array
  6287. * @returns the current Color4 object
  6288. */
  6289. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6290. /**
  6291. * Determines equality between Color4 objects
  6292. * @param otherColor defines the second operand
  6293. * @returns true if the rgba values are equal to the given ones
  6294. */
  6295. equals(otherColor: DeepImmutable<Color4>): boolean;
  6296. /**
  6297. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6298. * @param right defines the second operand
  6299. * @returns a new Color4 object
  6300. */
  6301. add(right: DeepImmutable<Color4>): Color4;
  6302. /**
  6303. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6304. * @param right defines the second operand
  6305. * @returns a new Color4 object
  6306. */
  6307. subtract(right: DeepImmutable<Color4>): Color4;
  6308. /**
  6309. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6310. * @param right defines the second operand
  6311. * @param result defines the Color4 object where to store the result
  6312. * @returns the current Color4 object
  6313. */
  6314. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6315. /**
  6316. * Creates a new Color4 with the current Color4 values multiplied by scale
  6317. * @param scale defines the scaling factor to apply
  6318. * @returns a new Color4 object
  6319. */
  6320. scale(scale: number): Color4;
  6321. /**
  6322. * Multiplies the current Color4 values by scale and stores the result in "result"
  6323. * @param scale defines the scaling factor to apply
  6324. * @param result defines the Color4 object where to store the result
  6325. * @returns the current unmodified Color4
  6326. */
  6327. scaleToRef(scale: number, result: Color4): Color4;
  6328. /**
  6329. * Scale the current Color4 values by a factor and add the result to a given Color4
  6330. * @param scale defines the scale factor
  6331. * @param result defines the Color4 object where to store the result
  6332. * @returns the unmodified current Color4
  6333. */
  6334. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6335. /**
  6336. * Clamps the rgb values by the min and max values and stores the result into "result"
  6337. * @param min defines minimum clamping value (default is 0)
  6338. * @param max defines maximum clamping value (default is 1)
  6339. * @param result defines color to store the result into.
  6340. * @returns the cuurent Color4
  6341. */
  6342. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6343. /**
  6344. * Multipy an Color4 value by another and return a new Color4 object
  6345. * @param color defines the Color4 value to multiply by
  6346. * @returns a new Color4 object
  6347. */
  6348. multiply(color: Color4): Color4;
  6349. /**
  6350. * Multipy a Color4 value by another and push the result in a reference value
  6351. * @param color defines the Color4 value to multiply by
  6352. * @param result defines the Color4 to fill the result in
  6353. * @returns the result Color4
  6354. */
  6355. multiplyToRef(color: Color4, result: Color4): Color4;
  6356. /**
  6357. * Creates a string with the Color4 current values
  6358. * @returns the string representation of the Color4 object
  6359. */
  6360. toString(): string;
  6361. /**
  6362. * Returns the string "Color4"
  6363. * @returns "Color4"
  6364. */
  6365. getClassName(): string;
  6366. /**
  6367. * Compute the Color4 hash code
  6368. * @returns an unique number that can be used to hash Color4 objects
  6369. */
  6370. getHashCode(): number;
  6371. /**
  6372. * Creates a new Color4 copied from the current one
  6373. * @returns a new Color4 object
  6374. */
  6375. clone(): Color4;
  6376. /**
  6377. * Copies the given Color4 values into the current one
  6378. * @param source defines the source Color4 object
  6379. * @returns the current updated Color4 object
  6380. */
  6381. copyFrom(source: Color4): Color4;
  6382. /**
  6383. * Copies the given float values into the current one
  6384. * @param r defines the red component to read from
  6385. * @param g defines the green component to read from
  6386. * @param b defines the blue component to read from
  6387. * @param a defines the alpha component to read from
  6388. * @returns the current updated Color4 object
  6389. */
  6390. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6391. /**
  6392. * Copies the given float values into the current one
  6393. * @param r defines the red component to read from
  6394. * @param g defines the green component to read from
  6395. * @param b defines the blue component to read from
  6396. * @param a defines the alpha component to read from
  6397. * @returns the current updated Color4 object
  6398. */
  6399. set(r: number, g: number, b: number, a: number): Color4;
  6400. /**
  6401. * Compute the Color4 hexadecimal code as a string
  6402. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6403. * @returns a string containing the hexadecimal representation of the Color4 object
  6404. */
  6405. toHexString(returnAsColor3?: boolean): string;
  6406. /**
  6407. * Computes a new Color4 converted from the current one to linear space
  6408. * @returns a new Color4 object
  6409. */
  6410. toLinearSpace(): Color4;
  6411. /**
  6412. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6413. * @param convertedColor defines the Color4 object where to store the linear space version
  6414. * @returns the unmodified Color4
  6415. */
  6416. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6417. /**
  6418. * Computes a new Color4 converted from the current one to gamma space
  6419. * @returns a new Color4 object
  6420. */
  6421. toGammaSpace(): Color4;
  6422. /**
  6423. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6424. * @param convertedColor defines the Color4 object where to store the gamma space version
  6425. * @returns the unmodified Color4
  6426. */
  6427. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6428. /**
  6429. * Creates a new Color4 from the string containing valid hexadecimal values
  6430. * @param hex defines a string containing valid hexadecimal values
  6431. * @returns a new Color4 object
  6432. */
  6433. static FromHexString(hex: string): Color4;
  6434. /**
  6435. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6436. * @param left defines the start value
  6437. * @param right defines the end value
  6438. * @param amount defines the gradient factor
  6439. * @returns a new Color4 object
  6440. */
  6441. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6442. /**
  6443. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6444. * @param left defines the start value
  6445. * @param right defines the end value
  6446. * @param amount defines the gradient factor
  6447. * @param result defines the Color4 object where to store data
  6448. */
  6449. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6450. /**
  6451. * Creates a new Color4 from a Color3 and an alpha value
  6452. * @param color3 defines the source Color3 to read from
  6453. * @param alpha defines the alpha component (1.0 by default)
  6454. * @returns a new Color4 object
  6455. */
  6456. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6457. /**
  6458. * Creates a new Color4 from the starting index element of the given array
  6459. * @param array defines the source array to read from
  6460. * @param offset defines the offset in the source array
  6461. * @returns a new Color4 object
  6462. */
  6463. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6464. /**
  6465. * Creates a new Color4 from the starting index element of the given array
  6466. * @param array defines the source array to read from
  6467. * @param offset defines the offset in the source array
  6468. * @param result defines the target Color4 object
  6469. */
  6470. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6471. /**
  6472. * Creates a new Color3 from integer values (< 256)
  6473. * @param r defines the red component to read from (value between 0 and 255)
  6474. * @param g defines the green component to read from (value between 0 and 255)
  6475. * @param b defines the blue component to read from (value between 0 and 255)
  6476. * @param a defines the alpha component to read from (value between 0 and 255)
  6477. * @returns a new Color3 object
  6478. */
  6479. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6480. /**
  6481. * Check the content of a given array and convert it to an array containing RGBA data
  6482. * If the original array was already containing count * 4 values then it is returned directly
  6483. * @param colors defines the array to check
  6484. * @param count defines the number of RGBA data to expect
  6485. * @returns an array containing count * 4 values (RGBA)
  6486. */
  6487. static CheckColors4(colors: number[], count: number): number[];
  6488. }
  6489. /**
  6490. * @hidden
  6491. */
  6492. export class TmpColors {
  6493. static Color3: Color3[];
  6494. static Color4: Color4[];
  6495. }
  6496. }
  6497. declare module BABYLON {
  6498. /**
  6499. * Defines an interface which represents an animation key frame
  6500. */
  6501. export interface IAnimationKey {
  6502. /**
  6503. * Frame of the key frame
  6504. */
  6505. frame: number;
  6506. /**
  6507. * Value at the specifies key frame
  6508. */
  6509. value: any;
  6510. /**
  6511. * The input tangent for the cubic hermite spline
  6512. */
  6513. inTangent?: any;
  6514. /**
  6515. * The output tangent for the cubic hermite spline
  6516. */
  6517. outTangent?: any;
  6518. /**
  6519. * The animation interpolation type
  6520. */
  6521. interpolation?: AnimationKeyInterpolation;
  6522. }
  6523. /**
  6524. * Enum for the animation key frame interpolation type
  6525. */
  6526. export enum AnimationKeyInterpolation {
  6527. /**
  6528. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6529. */
  6530. STEP = 1
  6531. }
  6532. }
  6533. declare module BABYLON {
  6534. /**
  6535. * Represents the range of an animation
  6536. */
  6537. export class AnimationRange {
  6538. /**The name of the animation range**/
  6539. name: string;
  6540. /**The starting frame of the animation */
  6541. from: number;
  6542. /**The ending frame of the animation*/
  6543. to: number;
  6544. /**
  6545. * Initializes the range of an animation
  6546. * @param name The name of the animation range
  6547. * @param from The starting frame of the animation
  6548. * @param to The ending frame of the animation
  6549. */
  6550. constructor(
  6551. /**The name of the animation range**/
  6552. name: string,
  6553. /**The starting frame of the animation */
  6554. from: number,
  6555. /**The ending frame of the animation*/
  6556. to: number);
  6557. /**
  6558. * Makes a copy of the animation range
  6559. * @returns A copy of the animation range
  6560. */
  6561. clone(): AnimationRange;
  6562. }
  6563. }
  6564. declare module BABYLON {
  6565. /**
  6566. * Composed of a frame, and an action function
  6567. */
  6568. export class AnimationEvent {
  6569. /** The frame for which the event is triggered **/
  6570. frame: number;
  6571. /** The event to perform when triggered **/
  6572. action: (currentFrame: number) => void;
  6573. /** Specifies if the event should be triggered only once**/
  6574. onlyOnce?: boolean | undefined;
  6575. /**
  6576. * Specifies if the animation event is done
  6577. */
  6578. isDone: boolean;
  6579. /**
  6580. * Initializes the animation event
  6581. * @param frame The frame for which the event is triggered
  6582. * @param action The event to perform when triggered
  6583. * @param onlyOnce Specifies if the event should be triggered only once
  6584. */
  6585. constructor(
  6586. /** The frame for which the event is triggered **/
  6587. frame: number,
  6588. /** The event to perform when triggered **/
  6589. action: (currentFrame: number) => void,
  6590. /** Specifies if the event should be triggered only once**/
  6591. onlyOnce?: boolean | undefined);
  6592. /** @hidden */
  6593. _clone(): AnimationEvent;
  6594. }
  6595. }
  6596. declare module BABYLON {
  6597. /**
  6598. * Interface used to define a behavior
  6599. */
  6600. export interface Behavior<T> {
  6601. /** gets or sets behavior's name */
  6602. name: string;
  6603. /**
  6604. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6605. */
  6606. init(): void;
  6607. /**
  6608. * Called when the behavior is attached to a target
  6609. * @param target defines the target where the behavior is attached to
  6610. */
  6611. attach(target: T): void;
  6612. /**
  6613. * Called when the behavior is detached from its target
  6614. */
  6615. detach(): void;
  6616. }
  6617. /**
  6618. * Interface implemented by classes supporting behaviors
  6619. */
  6620. export interface IBehaviorAware<T> {
  6621. /**
  6622. * Attach a behavior
  6623. * @param behavior defines the behavior to attach
  6624. * @returns the current host
  6625. */
  6626. addBehavior(behavior: Behavior<T>): T;
  6627. /**
  6628. * Remove a behavior from the current object
  6629. * @param behavior defines the behavior to detach
  6630. * @returns the current host
  6631. */
  6632. removeBehavior(behavior: Behavior<T>): T;
  6633. /**
  6634. * Gets a behavior using its name to search
  6635. * @param name defines the name to search
  6636. * @returns the behavior or null if not found
  6637. */
  6638. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6639. }
  6640. }
  6641. declare module BABYLON {
  6642. /**
  6643. * Class used to store data that will be store in GPU memory
  6644. */
  6645. export class Buffer {
  6646. private _engine;
  6647. private _buffer;
  6648. /** @hidden */
  6649. _data: Nullable<DataArray>;
  6650. private _updatable;
  6651. private _instanced;
  6652. private _divisor;
  6653. private _isAlreadyOwned;
  6654. /**
  6655. * Gets the byte stride.
  6656. */
  6657. readonly byteStride: number;
  6658. /**
  6659. * Constructor
  6660. * @param engine the engine
  6661. * @param data the data to use for this buffer
  6662. * @param updatable whether the data is updatable
  6663. * @param stride the stride (optional)
  6664. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6665. * @param instanced whether the buffer is instanced (optional)
  6666. * @param useBytes set to true if the stride in in bytes (optional)
  6667. * @param divisor sets an optional divisor for instances (1 by default)
  6668. */
  6669. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6670. /**
  6671. * Create a new VertexBuffer based on the current buffer
  6672. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6673. * @param offset defines offset in the buffer (0 by default)
  6674. * @param size defines the size in floats of attributes (position is 3 for instance)
  6675. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6676. * @param instanced defines if the vertex buffer contains indexed data
  6677. * @param useBytes defines if the offset and stride are in bytes *
  6678. * @param divisor sets an optional divisor for instances (1 by default)
  6679. * @returns the new vertex buffer
  6680. */
  6681. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6682. /**
  6683. * Gets a boolean indicating if the Buffer is updatable?
  6684. * @returns true if the buffer is updatable
  6685. */
  6686. isUpdatable(): boolean;
  6687. /**
  6688. * Gets current buffer's data
  6689. * @returns a DataArray or null
  6690. */
  6691. getData(): Nullable<DataArray>;
  6692. /**
  6693. * Gets underlying native buffer
  6694. * @returns underlying native buffer
  6695. */
  6696. getBuffer(): Nullable<DataBuffer>;
  6697. /**
  6698. * Gets the stride in float32 units (i.e. byte stride / 4).
  6699. * May not be an integer if the byte stride is not divisible by 4.
  6700. * @returns the stride in float32 units
  6701. * @deprecated Please use byteStride instead.
  6702. */
  6703. getStrideSize(): number;
  6704. /**
  6705. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6706. * @param data defines the data to store
  6707. */
  6708. create(data?: Nullable<DataArray>): void;
  6709. /** @hidden */
  6710. _rebuild(): void;
  6711. /**
  6712. * Update current buffer data
  6713. * @param data defines the data to store
  6714. */
  6715. update(data: DataArray): void;
  6716. /**
  6717. * Updates the data directly.
  6718. * @param data the new data
  6719. * @param offset the new offset
  6720. * @param vertexCount the vertex count (optional)
  6721. * @param useBytes set to true if the offset is in bytes
  6722. */
  6723. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6724. /** @hidden */
  6725. _increaseReferences(): void;
  6726. /**
  6727. * Release all resources
  6728. */
  6729. dispose(): void;
  6730. }
  6731. /**
  6732. * Specialized buffer used to store vertex data
  6733. */
  6734. export class VertexBuffer {
  6735. /** @hidden */
  6736. _buffer: Buffer;
  6737. private _kind;
  6738. private _size;
  6739. private _ownsBuffer;
  6740. private _instanced;
  6741. private _instanceDivisor;
  6742. /**
  6743. * The byte type.
  6744. */
  6745. static readonly BYTE: number;
  6746. /**
  6747. * The unsigned byte type.
  6748. */
  6749. static readonly UNSIGNED_BYTE: number;
  6750. /**
  6751. * The short type.
  6752. */
  6753. static readonly SHORT: number;
  6754. /**
  6755. * The unsigned short type.
  6756. */
  6757. static readonly UNSIGNED_SHORT: number;
  6758. /**
  6759. * The integer type.
  6760. */
  6761. static readonly INT: number;
  6762. /**
  6763. * The unsigned integer type.
  6764. */
  6765. static readonly UNSIGNED_INT: number;
  6766. /**
  6767. * The float type.
  6768. */
  6769. static readonly FLOAT: number;
  6770. /**
  6771. * Gets or sets the instance divisor when in instanced mode
  6772. */
  6773. get instanceDivisor(): number;
  6774. set instanceDivisor(value: number);
  6775. /**
  6776. * Gets the byte stride.
  6777. */
  6778. readonly byteStride: number;
  6779. /**
  6780. * Gets the byte offset.
  6781. */
  6782. readonly byteOffset: number;
  6783. /**
  6784. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6785. */
  6786. readonly normalized: boolean;
  6787. /**
  6788. * Gets the data type of each component in the array.
  6789. */
  6790. readonly type: number;
  6791. /**
  6792. * Constructor
  6793. * @param engine the engine
  6794. * @param data the data to use for this vertex buffer
  6795. * @param kind the vertex buffer kind
  6796. * @param updatable whether the data is updatable
  6797. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6798. * @param stride the stride (optional)
  6799. * @param instanced whether the buffer is instanced (optional)
  6800. * @param offset the offset of the data (optional)
  6801. * @param size the number of components (optional)
  6802. * @param type the type of the component (optional)
  6803. * @param normalized whether the data contains normalized data (optional)
  6804. * @param useBytes set to true if stride and offset are in bytes (optional)
  6805. * @param divisor defines the instance divisor to use (1 by default)
  6806. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  6807. */
  6808. 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, takeBufferOwnership?: boolean);
  6809. /** @hidden */
  6810. _rebuild(): void;
  6811. /**
  6812. * Returns the kind of the VertexBuffer (string)
  6813. * @returns a string
  6814. */
  6815. getKind(): string;
  6816. /**
  6817. * Gets a boolean indicating if the VertexBuffer is updatable?
  6818. * @returns true if the buffer is updatable
  6819. */
  6820. isUpdatable(): boolean;
  6821. /**
  6822. * Gets current buffer's data
  6823. * @returns a DataArray or null
  6824. */
  6825. getData(): Nullable<DataArray>;
  6826. /**
  6827. * Gets underlying native buffer
  6828. * @returns underlying native buffer
  6829. */
  6830. getBuffer(): Nullable<DataBuffer>;
  6831. /**
  6832. * Gets the stride in float32 units (i.e. byte stride / 4).
  6833. * May not be an integer if the byte stride is not divisible by 4.
  6834. * @returns the stride in float32 units
  6835. * @deprecated Please use byteStride instead.
  6836. */
  6837. getStrideSize(): number;
  6838. /**
  6839. * Returns the offset as a multiple of the type byte length.
  6840. * @returns the offset in bytes
  6841. * @deprecated Please use byteOffset instead.
  6842. */
  6843. getOffset(): number;
  6844. /**
  6845. * Returns the number of components per vertex attribute (integer)
  6846. * @returns the size in float
  6847. */
  6848. getSize(): number;
  6849. /**
  6850. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6851. * @returns true if this buffer is instanced
  6852. */
  6853. getIsInstanced(): boolean;
  6854. /**
  6855. * Returns the instancing divisor, zero for non-instanced (integer).
  6856. * @returns a number
  6857. */
  6858. getInstanceDivisor(): number;
  6859. /**
  6860. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6861. * @param data defines the data to store
  6862. */
  6863. create(data?: DataArray): void;
  6864. /**
  6865. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6866. * This function will create a new buffer if the current one is not updatable
  6867. * @param data defines the data to store
  6868. */
  6869. update(data: DataArray): void;
  6870. /**
  6871. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6872. * Returns the directly updated WebGLBuffer.
  6873. * @param data the new data
  6874. * @param offset the new offset
  6875. * @param useBytes set to true if the offset is in bytes
  6876. */
  6877. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6878. /**
  6879. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6880. */
  6881. dispose(): void;
  6882. /**
  6883. * Enumerates each value of this vertex buffer as numbers.
  6884. * @param count the number of values to enumerate
  6885. * @param callback the callback function called for each value
  6886. */
  6887. forEach(count: number, callback: (value: number, index: number) => void): void;
  6888. /**
  6889. * Positions
  6890. */
  6891. static readonly PositionKind: string;
  6892. /**
  6893. * Normals
  6894. */
  6895. static readonly NormalKind: string;
  6896. /**
  6897. * Tangents
  6898. */
  6899. static readonly TangentKind: string;
  6900. /**
  6901. * Texture coordinates
  6902. */
  6903. static readonly UVKind: string;
  6904. /**
  6905. * Texture coordinates 2
  6906. */
  6907. static readonly UV2Kind: string;
  6908. /**
  6909. * Texture coordinates 3
  6910. */
  6911. static readonly UV3Kind: string;
  6912. /**
  6913. * Texture coordinates 4
  6914. */
  6915. static readonly UV4Kind: string;
  6916. /**
  6917. * Texture coordinates 5
  6918. */
  6919. static readonly UV5Kind: string;
  6920. /**
  6921. * Texture coordinates 6
  6922. */
  6923. static readonly UV6Kind: string;
  6924. /**
  6925. * Colors
  6926. */
  6927. static readonly ColorKind: string;
  6928. /**
  6929. * Matrix indices (for bones)
  6930. */
  6931. static readonly MatricesIndicesKind: string;
  6932. /**
  6933. * Matrix weights (for bones)
  6934. */
  6935. static readonly MatricesWeightsKind: string;
  6936. /**
  6937. * Additional matrix indices (for bones)
  6938. */
  6939. static readonly MatricesIndicesExtraKind: string;
  6940. /**
  6941. * Additional matrix weights (for bones)
  6942. */
  6943. static readonly MatricesWeightsExtraKind: string;
  6944. /**
  6945. * Deduces the stride given a kind.
  6946. * @param kind The kind string to deduce
  6947. * @returns The deduced stride
  6948. */
  6949. static DeduceStride(kind: string): number;
  6950. /**
  6951. * Gets the byte length of the given type.
  6952. * @param type the type
  6953. * @returns the number of bytes
  6954. */
  6955. static GetTypeByteLength(type: number): number;
  6956. /**
  6957. * Enumerates each value of the given parameters as numbers.
  6958. * @param data the data to enumerate
  6959. * @param byteOffset the byte offset of the data
  6960. * @param byteStride the byte stride of the data
  6961. * @param componentCount the number of components per element
  6962. * @param componentType the type of the component
  6963. * @param count the number of values to enumerate
  6964. * @param normalized whether the data is normalized
  6965. * @param callback the callback function called for each value
  6966. */
  6967. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6968. private static _GetFloatValue;
  6969. }
  6970. }
  6971. declare module BABYLON {
  6972. /**
  6973. * @hidden
  6974. */
  6975. export class IntersectionInfo {
  6976. bu: Nullable<number>;
  6977. bv: Nullable<number>;
  6978. distance: number;
  6979. faceId: number;
  6980. subMeshId: number;
  6981. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6982. }
  6983. }
  6984. declare module BABYLON {
  6985. /**
  6986. * Class used to store bounding sphere information
  6987. */
  6988. export class BoundingSphere {
  6989. /**
  6990. * Gets the center of the bounding sphere in local space
  6991. */
  6992. readonly center: Vector3;
  6993. /**
  6994. * Radius of the bounding sphere in local space
  6995. */
  6996. radius: number;
  6997. /**
  6998. * Gets the center of the bounding sphere in world space
  6999. */
  7000. readonly centerWorld: Vector3;
  7001. /**
  7002. * Radius of the bounding sphere in world space
  7003. */
  7004. radiusWorld: number;
  7005. /**
  7006. * Gets the minimum vector in local space
  7007. */
  7008. readonly minimum: Vector3;
  7009. /**
  7010. * Gets the maximum vector in local space
  7011. */
  7012. readonly maximum: Vector3;
  7013. private _worldMatrix;
  7014. private static readonly TmpVector3;
  7015. /**
  7016. * Creates a new bounding sphere
  7017. * @param min defines the minimum vector (in local space)
  7018. * @param max defines the maximum vector (in local space)
  7019. * @param worldMatrix defines the new world matrix
  7020. */
  7021. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7022. /**
  7023. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7024. * @param min defines the new minimum vector (in local space)
  7025. * @param max defines the new maximum vector (in local space)
  7026. * @param worldMatrix defines the new world matrix
  7027. */
  7028. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7029. /**
  7030. * Scale the current bounding sphere by applying a scale factor
  7031. * @param factor defines the scale factor to apply
  7032. * @returns the current bounding box
  7033. */
  7034. scale(factor: number): BoundingSphere;
  7035. /**
  7036. * Gets the world matrix of the bounding box
  7037. * @returns a matrix
  7038. */
  7039. getWorldMatrix(): DeepImmutable<Matrix>;
  7040. /** @hidden */
  7041. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7042. /**
  7043. * Tests if the bounding sphere is intersecting the frustum planes
  7044. * @param frustumPlanes defines the frustum planes to test
  7045. * @returns true if there is an intersection
  7046. */
  7047. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7048. /**
  7049. * Tests if the bounding sphere center is in between the frustum planes.
  7050. * Used for optimistic fast inclusion.
  7051. * @param frustumPlanes defines the frustum planes to test
  7052. * @returns true if the sphere center is in between the frustum planes
  7053. */
  7054. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7055. /**
  7056. * Tests if a point is inside the bounding sphere
  7057. * @param point defines the point to test
  7058. * @returns true if the point is inside the bounding sphere
  7059. */
  7060. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Checks if two sphere intersct
  7063. * @param sphere0 sphere 0
  7064. * @param sphere1 sphere 1
  7065. * @returns true if the speres intersect
  7066. */
  7067. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7068. }
  7069. }
  7070. declare module BABYLON {
  7071. /**
  7072. * Class used to store bounding box information
  7073. */
  7074. export class BoundingBox implements ICullable {
  7075. /**
  7076. * Gets the 8 vectors representing the bounding box in local space
  7077. */
  7078. readonly vectors: Vector3[];
  7079. /**
  7080. * Gets the center of the bounding box in local space
  7081. */
  7082. readonly center: Vector3;
  7083. /**
  7084. * Gets the center of the bounding box in world space
  7085. */
  7086. readonly centerWorld: Vector3;
  7087. /**
  7088. * Gets the extend size in local space
  7089. */
  7090. readonly extendSize: Vector3;
  7091. /**
  7092. * Gets the extend size in world space
  7093. */
  7094. readonly extendSizeWorld: Vector3;
  7095. /**
  7096. * Gets the OBB (object bounding box) directions
  7097. */
  7098. readonly directions: Vector3[];
  7099. /**
  7100. * Gets the 8 vectors representing the bounding box in world space
  7101. */
  7102. readonly vectorsWorld: Vector3[];
  7103. /**
  7104. * Gets the minimum vector in world space
  7105. */
  7106. readonly minimumWorld: Vector3;
  7107. /**
  7108. * Gets the maximum vector in world space
  7109. */
  7110. readonly maximumWorld: Vector3;
  7111. /**
  7112. * Gets the minimum vector in local space
  7113. */
  7114. readonly minimum: Vector3;
  7115. /**
  7116. * Gets the maximum vector in local space
  7117. */
  7118. readonly maximum: Vector3;
  7119. private _worldMatrix;
  7120. private static readonly TmpVector3;
  7121. /**
  7122. * @hidden
  7123. */
  7124. _tag: number;
  7125. /**
  7126. * Creates a new bounding box
  7127. * @param min defines the minimum vector (in local space)
  7128. * @param max defines the maximum vector (in local space)
  7129. * @param worldMatrix defines the new world matrix
  7130. */
  7131. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7132. /**
  7133. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7134. * @param min defines the new minimum vector (in local space)
  7135. * @param max defines the new maximum vector (in local space)
  7136. * @param worldMatrix defines the new world matrix
  7137. */
  7138. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7139. /**
  7140. * Scale the current bounding box by applying a scale factor
  7141. * @param factor defines the scale factor to apply
  7142. * @returns the current bounding box
  7143. */
  7144. scale(factor: number): BoundingBox;
  7145. /**
  7146. * Gets the world matrix of the bounding box
  7147. * @returns a matrix
  7148. */
  7149. getWorldMatrix(): DeepImmutable<Matrix>;
  7150. /** @hidden */
  7151. _update(world: DeepImmutable<Matrix>): void;
  7152. /**
  7153. * Tests if the bounding box is intersecting the frustum planes
  7154. * @param frustumPlanes defines the frustum planes to test
  7155. * @returns true if there is an intersection
  7156. */
  7157. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7158. /**
  7159. * Tests if the bounding box is entirely inside the frustum planes
  7160. * @param frustumPlanes defines the frustum planes to test
  7161. * @returns true if there is an inclusion
  7162. */
  7163. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7164. /**
  7165. * Tests if a point is inside the bounding box
  7166. * @param point defines the point to test
  7167. * @returns true if the point is inside the bounding box
  7168. */
  7169. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7170. /**
  7171. * Tests if the bounding box intersects with a bounding sphere
  7172. * @param sphere defines the sphere to test
  7173. * @returns true if there is an intersection
  7174. */
  7175. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7176. /**
  7177. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7178. * @param min defines the min vector to use
  7179. * @param max defines the max vector to use
  7180. * @returns true if there is an intersection
  7181. */
  7182. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7183. /**
  7184. * Tests if two bounding boxes are intersections
  7185. * @param box0 defines the first box to test
  7186. * @param box1 defines the second box to test
  7187. * @returns true if there is an intersection
  7188. */
  7189. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7190. /**
  7191. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7192. * @param minPoint defines the minimum vector of the bounding box
  7193. * @param maxPoint defines the maximum vector of the bounding box
  7194. * @param sphereCenter defines the sphere center
  7195. * @param sphereRadius defines the sphere radius
  7196. * @returns true if there is an intersection
  7197. */
  7198. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7199. /**
  7200. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7201. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7202. * @param frustumPlanes defines the frustum planes to test
  7203. * @return true if there is an inclusion
  7204. */
  7205. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7206. /**
  7207. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7208. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7209. * @param frustumPlanes defines the frustum planes to test
  7210. * @return true if there is an intersection
  7211. */
  7212. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7213. }
  7214. }
  7215. declare module BABYLON {
  7216. /** @hidden */
  7217. export class Collider {
  7218. /** Define if a collision was found */
  7219. collisionFound: boolean;
  7220. /**
  7221. * Define last intersection point in local space
  7222. */
  7223. intersectionPoint: Vector3;
  7224. /**
  7225. * Define last collided mesh
  7226. */
  7227. collidedMesh: Nullable<AbstractMesh>;
  7228. private _collisionPoint;
  7229. private _planeIntersectionPoint;
  7230. private _tempVector;
  7231. private _tempVector2;
  7232. private _tempVector3;
  7233. private _tempVector4;
  7234. private _edge;
  7235. private _baseToVertex;
  7236. private _destinationPoint;
  7237. private _slidePlaneNormal;
  7238. private _displacementVector;
  7239. /** @hidden */
  7240. _radius: Vector3;
  7241. /** @hidden */
  7242. _retry: number;
  7243. private _velocity;
  7244. private _basePoint;
  7245. private _epsilon;
  7246. /** @hidden */
  7247. _velocityWorldLength: number;
  7248. /** @hidden */
  7249. _basePointWorld: Vector3;
  7250. private _velocityWorld;
  7251. private _normalizedVelocity;
  7252. /** @hidden */
  7253. _initialVelocity: Vector3;
  7254. /** @hidden */
  7255. _initialPosition: Vector3;
  7256. private _nearestDistance;
  7257. private _collisionMask;
  7258. get collisionMask(): number;
  7259. set collisionMask(mask: number);
  7260. /**
  7261. * Gets the plane normal used to compute the sliding response (in local space)
  7262. */
  7263. get slidePlaneNormal(): Vector3;
  7264. /** @hidden */
  7265. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7266. /** @hidden */
  7267. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7268. /** @hidden */
  7269. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7270. /** @hidden */
  7271. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7272. /** @hidden */
  7273. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7274. /** @hidden */
  7275. _getResponse(pos: Vector3, vel: Vector3): void;
  7276. }
  7277. }
  7278. declare module BABYLON {
  7279. /**
  7280. * Interface for cullable objects
  7281. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7282. */
  7283. export interface ICullable {
  7284. /**
  7285. * Checks if the object or part of the object is in the frustum
  7286. * @param frustumPlanes Camera near/planes
  7287. * @returns true if the object is in frustum otherwise false
  7288. */
  7289. isInFrustum(frustumPlanes: Plane[]): boolean;
  7290. /**
  7291. * Checks if a cullable object (mesh...) is in the camera frustum
  7292. * Unlike isInFrustum this cheks the full bounding box
  7293. * @param frustumPlanes Camera near/planes
  7294. * @returns true if the object is in frustum otherwise false
  7295. */
  7296. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7297. }
  7298. /**
  7299. * Info for a bounding data of a mesh
  7300. */
  7301. export class BoundingInfo implements ICullable {
  7302. /**
  7303. * Bounding box for the mesh
  7304. */
  7305. readonly boundingBox: BoundingBox;
  7306. /**
  7307. * Bounding sphere for the mesh
  7308. */
  7309. readonly boundingSphere: BoundingSphere;
  7310. private _isLocked;
  7311. private static readonly TmpVector3;
  7312. /**
  7313. * Constructs bounding info
  7314. * @param minimum min vector of the bounding box/sphere
  7315. * @param maximum max vector of the bounding box/sphere
  7316. * @param worldMatrix defines the new world matrix
  7317. */
  7318. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7319. /**
  7320. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7321. * @param min defines the new minimum vector (in local space)
  7322. * @param max defines the new maximum vector (in local space)
  7323. * @param worldMatrix defines the new world matrix
  7324. */
  7325. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7326. /**
  7327. * min vector of the bounding box/sphere
  7328. */
  7329. get minimum(): Vector3;
  7330. /**
  7331. * max vector of the bounding box/sphere
  7332. */
  7333. get maximum(): Vector3;
  7334. /**
  7335. * If the info is locked and won't be updated to avoid perf overhead
  7336. */
  7337. get isLocked(): boolean;
  7338. set isLocked(value: boolean);
  7339. /**
  7340. * Updates the bounding sphere and box
  7341. * @param world world matrix to be used to update
  7342. */
  7343. update(world: DeepImmutable<Matrix>): void;
  7344. /**
  7345. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7346. * @param center New center of the bounding info
  7347. * @param extend New extend of the bounding info
  7348. * @returns the current bounding info
  7349. */
  7350. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7351. /**
  7352. * Scale the current bounding info by applying a scale factor
  7353. * @param factor defines the scale factor to apply
  7354. * @returns the current bounding info
  7355. */
  7356. scale(factor: number): BoundingInfo;
  7357. /**
  7358. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7359. * @param frustumPlanes defines the frustum to test
  7360. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7361. * @returns true if the bounding info is in the frustum planes
  7362. */
  7363. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7364. /**
  7365. * Gets the world distance between the min and max points of the bounding box
  7366. */
  7367. get diagonalLength(): number;
  7368. /**
  7369. * Checks if a cullable object (mesh...) is in the camera frustum
  7370. * Unlike isInFrustum this cheks the full bounding box
  7371. * @param frustumPlanes Camera near/planes
  7372. * @returns true if the object is in frustum otherwise false
  7373. */
  7374. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7375. /** @hidden */
  7376. _checkCollision(collider: Collider): boolean;
  7377. /**
  7378. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7379. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7380. * @param point the point to check intersection with
  7381. * @returns if the point intersects
  7382. */
  7383. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7384. /**
  7385. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7386. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7387. * @param boundingInfo the bounding info to check intersection with
  7388. * @param precise if the intersection should be done using OBB
  7389. * @returns if the bounding info intersects
  7390. */
  7391. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7392. }
  7393. }
  7394. declare module BABYLON {
  7395. /**
  7396. * Extracts minimum and maximum values from a list of indexed positions
  7397. * @param positions defines the positions to use
  7398. * @param indices defines the indices to the positions
  7399. * @param indexStart defines the start index
  7400. * @param indexCount defines the end index
  7401. * @param bias defines bias value to add to the result
  7402. * @return minimum and maximum values
  7403. */
  7404. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7405. minimum: Vector3;
  7406. maximum: Vector3;
  7407. };
  7408. /**
  7409. * Extracts minimum and maximum values from a list of positions
  7410. * @param positions defines the positions to use
  7411. * @param start defines the start index in the positions array
  7412. * @param count defines the number of positions to handle
  7413. * @param bias defines bias value to add to the result
  7414. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7415. * @return minimum and maximum values
  7416. */
  7417. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7418. minimum: Vector3;
  7419. maximum: Vector3;
  7420. };
  7421. }
  7422. declare module BABYLON {
  7423. /**
  7424. * Class used to manipulate GUIDs
  7425. */
  7426. export class GUID {
  7427. /**
  7428. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7429. * Be aware Math.random() could cause collisions, but:
  7430. * "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"
  7431. * @returns a pseudo random id
  7432. */
  7433. static RandomId(): string;
  7434. }
  7435. }
  7436. declare module BABYLON {
  7437. /**
  7438. * Base class of all the textures in babylon.
  7439. * It groups all the common properties the materials, post process, lights... might need
  7440. * in order to make a correct use of the texture.
  7441. */
  7442. export class BaseTexture extends ThinTexture implements IAnimatable {
  7443. /**
  7444. * Default anisotropic filtering level for the application.
  7445. * It is set to 4 as a good tradeoff between perf and quality.
  7446. */
  7447. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7448. /**
  7449. * Gets or sets the unique id of the texture
  7450. */
  7451. uniqueId: number;
  7452. /**
  7453. * Define the name of the texture.
  7454. */
  7455. name: string;
  7456. /**
  7457. * Gets or sets an object used to store user defined information.
  7458. */
  7459. metadata: any;
  7460. /**
  7461. * For internal use only. Please do not use.
  7462. */
  7463. reservedDataStore: any;
  7464. private _hasAlpha;
  7465. /**
  7466. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7467. */
  7468. set hasAlpha(value: boolean);
  7469. get hasAlpha(): boolean;
  7470. /**
  7471. * Defines if the alpha value should be determined via the rgb values.
  7472. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7473. */
  7474. getAlphaFromRGB: boolean;
  7475. /**
  7476. * Intensity or strength of the texture.
  7477. * It is commonly used by materials to fine tune the intensity of the texture
  7478. */
  7479. level: number;
  7480. /**
  7481. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7482. * This is part of the texture as textures usually maps to one uv set.
  7483. */
  7484. coordinatesIndex: number;
  7485. protected _coordinatesMode: number;
  7486. /**
  7487. * How a texture is mapped.
  7488. *
  7489. * | Value | Type | Description |
  7490. * | ----- | ----------------------------------- | ----------- |
  7491. * | 0 | EXPLICIT_MODE | |
  7492. * | 1 | SPHERICAL_MODE | |
  7493. * | 2 | PLANAR_MODE | |
  7494. * | 3 | CUBIC_MODE | |
  7495. * | 4 | PROJECTION_MODE | |
  7496. * | 5 | SKYBOX_MODE | |
  7497. * | 6 | INVCUBIC_MODE | |
  7498. * | 7 | EQUIRECTANGULAR_MODE | |
  7499. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7500. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7501. */
  7502. set coordinatesMode(value: number);
  7503. get coordinatesMode(): number;
  7504. /**
  7505. * | Value | Type | Description |
  7506. * | ----- | ------------------ | ----------- |
  7507. * | 0 | CLAMP_ADDRESSMODE | |
  7508. * | 1 | WRAP_ADDRESSMODE | |
  7509. * | 2 | MIRROR_ADDRESSMODE | |
  7510. */
  7511. get wrapU(): number;
  7512. set wrapU(value: number);
  7513. /**
  7514. * | Value | Type | Description |
  7515. * | ----- | ------------------ | ----------- |
  7516. * | 0 | CLAMP_ADDRESSMODE | |
  7517. * | 1 | WRAP_ADDRESSMODE | |
  7518. * | 2 | MIRROR_ADDRESSMODE | |
  7519. */
  7520. get wrapV(): number;
  7521. set wrapV(value: number);
  7522. /**
  7523. * | Value | Type | Description |
  7524. * | ----- | ------------------ | ----------- |
  7525. * | 0 | CLAMP_ADDRESSMODE | |
  7526. * | 1 | WRAP_ADDRESSMODE | |
  7527. * | 2 | MIRROR_ADDRESSMODE | |
  7528. */
  7529. wrapR: number;
  7530. /**
  7531. * With compliant hardware and browser (supporting anisotropic filtering)
  7532. * this defines the level of anisotropic filtering in the texture.
  7533. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7534. */
  7535. anisotropicFilteringLevel: number;
  7536. private _isCube;
  7537. /**
  7538. * Define if the texture is a cube texture or if false a 2d texture.
  7539. */
  7540. get isCube(): boolean;
  7541. set isCube(value: boolean);
  7542. /**
  7543. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7544. */
  7545. get is3D(): boolean;
  7546. set is3D(value: boolean);
  7547. /**
  7548. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7549. */
  7550. get is2DArray(): boolean;
  7551. set is2DArray(value: boolean);
  7552. private _gammaSpace;
  7553. /**
  7554. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7555. * HDR texture are usually stored in linear space.
  7556. * This only impacts the PBR and Background materials
  7557. */
  7558. get gammaSpace(): boolean;
  7559. set gammaSpace(gamma: boolean);
  7560. /**
  7561. * Gets or sets whether or not the texture contains RGBD data.
  7562. */
  7563. get isRGBD(): boolean;
  7564. set isRGBD(value: boolean);
  7565. /**
  7566. * Is Z inverted in the texture (useful in a cube texture).
  7567. */
  7568. invertZ: boolean;
  7569. /**
  7570. * Are mip maps generated for this texture or not.
  7571. */
  7572. get noMipmap(): boolean;
  7573. /**
  7574. * @hidden
  7575. */
  7576. lodLevelInAlpha: boolean;
  7577. /**
  7578. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7579. */
  7580. get lodGenerationOffset(): number;
  7581. set lodGenerationOffset(value: number);
  7582. /**
  7583. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7584. */
  7585. get lodGenerationScale(): number;
  7586. set lodGenerationScale(value: number);
  7587. /**
  7588. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7589. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7590. * average roughness values.
  7591. */
  7592. get linearSpecularLOD(): boolean;
  7593. set linearSpecularLOD(value: boolean);
  7594. /**
  7595. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7596. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7597. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7598. */
  7599. get irradianceTexture(): Nullable<BaseTexture>;
  7600. set irradianceTexture(value: Nullable<BaseTexture>);
  7601. /**
  7602. * Define if the texture is a render target.
  7603. */
  7604. isRenderTarget: boolean;
  7605. /**
  7606. * Define the unique id of the texture in the scene.
  7607. */
  7608. get uid(): string;
  7609. /** @hidden */
  7610. _prefiltered: boolean;
  7611. /**
  7612. * Return a string representation of the texture.
  7613. * @returns the texture as a string
  7614. */
  7615. toString(): string;
  7616. /**
  7617. * Get the class name of the texture.
  7618. * @returns "BaseTexture"
  7619. */
  7620. getClassName(): string;
  7621. /**
  7622. * Define the list of animation attached to the texture.
  7623. */
  7624. animations: Animation[];
  7625. /**
  7626. * An event triggered when the texture is disposed.
  7627. */
  7628. onDisposeObservable: Observable<BaseTexture>;
  7629. private _onDisposeObserver;
  7630. /**
  7631. * Callback triggered when the texture has been disposed.
  7632. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7633. */
  7634. set onDispose(callback: () => void);
  7635. protected _scene: Nullable<Scene>;
  7636. /** @hidden */
  7637. _texture: Nullable<InternalTexture>;
  7638. private _uid;
  7639. /**
  7640. * Define if the texture is preventinga material to render or not.
  7641. * If not and the texture is not ready, the engine will use a default black texture instead.
  7642. */
  7643. get isBlocking(): boolean;
  7644. /**
  7645. * Instantiates a new BaseTexture.
  7646. * Base class of all the textures in babylon.
  7647. * It groups all the common properties the materials, post process, lights... might need
  7648. * in order to make a correct use of the texture.
  7649. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7650. */
  7651. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7652. /**
  7653. * Get the scene the texture belongs to.
  7654. * @returns the scene or null if undefined
  7655. */
  7656. getScene(): Nullable<Scene>;
  7657. /** @hidden */
  7658. protected _getEngine(): Nullable<ThinEngine>;
  7659. /**
  7660. * Checks if the texture has the same transform matrix than another texture
  7661. * @param texture texture to check against
  7662. * @returns true if the transforms are the same, else false
  7663. */
  7664. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7665. /**
  7666. * Get the texture transform matrix used to offset tile the texture for istance.
  7667. * @returns the transformation matrix
  7668. */
  7669. getTextureMatrix(): Matrix;
  7670. /**
  7671. * Get the texture reflection matrix used to rotate/transform the reflection.
  7672. * @returns the reflection matrix
  7673. */
  7674. getReflectionTextureMatrix(): Matrix;
  7675. /**
  7676. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7677. * @returns true if ready or not blocking
  7678. */
  7679. isReadyOrNotBlocking(): boolean;
  7680. /**
  7681. * Scales the texture if is `canRescale()`
  7682. * @param ratio the resize factor we want to use to rescale
  7683. */
  7684. scale(ratio: number): void;
  7685. /**
  7686. * Get if the texture can rescale.
  7687. */
  7688. get canRescale(): boolean;
  7689. /** @hidden */
  7690. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  7691. /** @hidden */
  7692. _rebuild(): void;
  7693. /**
  7694. * Clones the texture.
  7695. * @returns the cloned texture
  7696. */
  7697. clone(): Nullable<BaseTexture>;
  7698. /**
  7699. * Get the texture underlying type (INT, FLOAT...)
  7700. */
  7701. get textureType(): number;
  7702. /**
  7703. * Get the texture underlying format (RGB, RGBA...)
  7704. */
  7705. get textureFormat(): number;
  7706. /**
  7707. * Indicates that textures need to be re-calculated for all materials
  7708. */
  7709. protected _markAllSubMeshesAsTexturesDirty(): void;
  7710. /**
  7711. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  7712. * This will returns an RGBA array buffer containing either in values (0-255) or
  7713. * float values (0-1) depending of the underlying buffer type.
  7714. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7715. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7716. * @param buffer defines a user defined buffer to fill with data (can be null)
  7717. * @returns The Array buffer containing the pixels data.
  7718. */
  7719. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  7720. /** @hidden */
  7721. get _lodTextureHigh(): Nullable<BaseTexture>;
  7722. /** @hidden */
  7723. get _lodTextureMid(): Nullable<BaseTexture>;
  7724. /** @hidden */
  7725. get _lodTextureLow(): Nullable<BaseTexture>;
  7726. /**
  7727. * Dispose the texture and release its associated resources.
  7728. */
  7729. dispose(): void;
  7730. /**
  7731. * Serialize the texture into a JSON representation that can be parsed later on.
  7732. * @returns the JSON representation of the texture
  7733. */
  7734. serialize(): any;
  7735. /**
  7736. * Helper function to be called back once a list of texture contains only ready textures.
  7737. * @param textures Define the list of textures to wait for
  7738. * @param callback Define the callback triggered once the entire list will be ready
  7739. */
  7740. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  7741. private static _isScene;
  7742. }
  7743. }
  7744. declare module BABYLON {
  7745. /** @hidden */
  7746. export class WebGLDataBuffer extends DataBuffer {
  7747. private _buffer;
  7748. constructor(resource: WebGLBuffer);
  7749. get underlyingResource(): any;
  7750. }
  7751. }
  7752. declare module BABYLON {
  7753. /** @hidden */
  7754. export class WebGLPipelineContext implements IPipelineContext {
  7755. engine: ThinEngine;
  7756. program: Nullable<WebGLProgram>;
  7757. context?: WebGLRenderingContext;
  7758. vertexShader?: WebGLShader;
  7759. fragmentShader?: WebGLShader;
  7760. isParallelCompiled: boolean;
  7761. onCompiled?: () => void;
  7762. transformFeedback?: WebGLTransformFeedback | null;
  7763. vertexCompilationError: Nullable<string>;
  7764. fragmentCompilationError: Nullable<string>;
  7765. programLinkError: Nullable<string>;
  7766. programValidationError: Nullable<string>;
  7767. get isAsync(): boolean;
  7768. get isReady(): boolean;
  7769. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7770. _getVertexShaderCode(): string | null;
  7771. _getFragmentShaderCode(): string | null;
  7772. }
  7773. }
  7774. declare module BABYLON {
  7775. interface ThinEngine {
  7776. /**
  7777. * Create an uniform buffer
  7778. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7779. * @param elements defines the content of the uniform buffer
  7780. * @returns the webGL uniform buffer
  7781. */
  7782. createUniformBuffer(elements: FloatArray): DataBuffer;
  7783. /**
  7784. * Create a dynamic uniform buffer
  7785. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7786. * @param elements defines the content of the uniform buffer
  7787. * @returns the webGL uniform buffer
  7788. */
  7789. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7790. /**
  7791. * Update an existing uniform buffer
  7792. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7793. * @param uniformBuffer defines the target uniform buffer
  7794. * @param elements defines the content to update
  7795. * @param offset defines the offset in the uniform buffer where update should start
  7796. * @param count defines the size of the data to update
  7797. */
  7798. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7799. /**
  7800. * Bind an uniform buffer to the current webGL context
  7801. * @param buffer defines the buffer to bind
  7802. */
  7803. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7804. /**
  7805. * Bind a buffer to the current webGL context at a given location
  7806. * @param buffer defines the buffer to bind
  7807. * @param location defines the index where to bind the buffer
  7808. */
  7809. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7810. /**
  7811. * Bind a specific block at a given index in a specific shader program
  7812. * @param pipelineContext defines the pipeline context to use
  7813. * @param blockName defines the block name
  7814. * @param index defines the index where to bind the block
  7815. */
  7816. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7817. }
  7818. }
  7819. declare module BABYLON {
  7820. /**
  7821. * Uniform buffer objects.
  7822. *
  7823. * Handles blocks of uniform on the GPU.
  7824. *
  7825. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7826. *
  7827. * For more information, please refer to :
  7828. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7829. */
  7830. export class UniformBuffer {
  7831. private _engine;
  7832. private _buffer;
  7833. private _data;
  7834. private _bufferData;
  7835. private _dynamic?;
  7836. private _uniformLocations;
  7837. private _uniformSizes;
  7838. private _uniformLocationPointer;
  7839. private _needSync;
  7840. private _noUBO;
  7841. private _currentEffect;
  7842. /** @hidden */
  7843. _alreadyBound: boolean;
  7844. private static _MAX_UNIFORM_SIZE;
  7845. private static _tempBuffer;
  7846. /**
  7847. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7848. * This is dynamic to allow compat with webgl 1 and 2.
  7849. * You will need to pass the name of the uniform as well as the value.
  7850. */
  7851. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7852. /**
  7853. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7854. * This is dynamic to allow compat with webgl 1 and 2.
  7855. * You will need to pass the name of the uniform as well as the value.
  7856. */
  7857. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7858. /**
  7859. * Lambda to Update a single float in a uniform buffer.
  7860. * This is dynamic to allow compat with webgl 1 and 2.
  7861. * You will need to pass the name of the uniform as well as the value.
  7862. */
  7863. updateFloat: (name: string, x: number) => void;
  7864. /**
  7865. * Lambda to Update a vec2 of float in a uniform buffer.
  7866. * This is dynamic to allow compat with webgl 1 and 2.
  7867. * You will need to pass the name of the uniform as well as the value.
  7868. */
  7869. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7870. /**
  7871. * Lambda to Update a vec3 of float in a uniform buffer.
  7872. * This is dynamic to allow compat with webgl 1 and 2.
  7873. * You will need to pass the name of the uniform as well as the value.
  7874. */
  7875. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7876. /**
  7877. * Lambda to Update a vec4 of float in a uniform buffer.
  7878. * This is dynamic to allow compat with webgl 1 and 2.
  7879. * You will need to pass the name of the uniform as well as the value.
  7880. */
  7881. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7882. /**
  7883. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7884. * This is dynamic to allow compat with webgl 1 and 2.
  7885. * You will need to pass the name of the uniform as well as the value.
  7886. */
  7887. updateMatrix: (name: string, mat: Matrix) => void;
  7888. /**
  7889. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7890. * This is dynamic to allow compat with webgl 1 and 2.
  7891. * You will need to pass the name of the uniform as well as the value.
  7892. */
  7893. updateVector3: (name: string, vector: Vector3) => void;
  7894. /**
  7895. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7896. * This is dynamic to allow compat with webgl 1 and 2.
  7897. * You will need to pass the name of the uniform as well as the value.
  7898. */
  7899. updateVector4: (name: string, vector: Vector4) => void;
  7900. /**
  7901. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7902. * This is dynamic to allow compat with webgl 1 and 2.
  7903. * You will need to pass the name of the uniform as well as the value.
  7904. */
  7905. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7906. /**
  7907. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7908. * This is dynamic to allow compat with webgl 1 and 2.
  7909. * You will need to pass the name of the uniform as well as the value.
  7910. */
  7911. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7912. /**
  7913. * Instantiates a new Uniform buffer objects.
  7914. *
  7915. * Handles blocks of uniform on the GPU.
  7916. *
  7917. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7918. *
  7919. * For more information, please refer to :
  7920. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7921. * @param engine Define the engine the buffer is associated with
  7922. * @param data Define the data contained in the buffer
  7923. * @param dynamic Define if the buffer is updatable
  7924. */
  7925. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7926. /**
  7927. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7928. * or just falling back on setUniformXXX calls.
  7929. */
  7930. get useUbo(): boolean;
  7931. /**
  7932. * Indicates if the WebGL underlying uniform buffer is in sync
  7933. * with the javascript cache data.
  7934. */
  7935. get isSync(): boolean;
  7936. /**
  7937. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7938. * Also, a dynamic UniformBuffer will disable cache verification and always
  7939. * update the underlying WebGL uniform buffer to the GPU.
  7940. * @returns if Dynamic, otherwise false
  7941. */
  7942. isDynamic(): boolean;
  7943. /**
  7944. * The data cache on JS side.
  7945. * @returns the underlying data as a float array
  7946. */
  7947. getData(): Float32Array;
  7948. /**
  7949. * The underlying WebGL Uniform buffer.
  7950. * @returns the webgl buffer
  7951. */
  7952. getBuffer(): Nullable<DataBuffer>;
  7953. /**
  7954. * std140 layout specifies how to align data within an UBO structure.
  7955. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7956. * for specs.
  7957. */
  7958. private _fillAlignment;
  7959. /**
  7960. * Adds an uniform in the buffer.
  7961. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7962. * for the layout to be correct !
  7963. * @param name Name of the uniform, as used in the uniform block in the shader.
  7964. * @param size Data size, or data directly.
  7965. */
  7966. addUniform(name: string, size: number | number[]): void;
  7967. /**
  7968. * Adds a Matrix 4x4 to the uniform buffer.
  7969. * @param name Name of the uniform, as used in the uniform block in the shader.
  7970. * @param mat A 4x4 matrix.
  7971. */
  7972. addMatrix(name: string, mat: Matrix): void;
  7973. /**
  7974. * Adds a vec2 to the uniform buffer.
  7975. * @param name Name of the uniform, as used in the uniform block in the shader.
  7976. * @param x Define the x component value of the vec2
  7977. * @param y Define the y component value of the vec2
  7978. */
  7979. addFloat2(name: string, x: number, y: number): void;
  7980. /**
  7981. * Adds a vec3 to the uniform buffer.
  7982. * @param name Name of the uniform, as used in the uniform block in the shader.
  7983. * @param x Define the x component value of the vec3
  7984. * @param y Define the y component value of the vec3
  7985. * @param z Define the z component value of the vec3
  7986. */
  7987. addFloat3(name: string, x: number, y: number, z: number): void;
  7988. /**
  7989. * Adds a vec3 to the uniform buffer.
  7990. * @param name Name of the uniform, as used in the uniform block in the shader.
  7991. * @param color Define the vec3 from a Color
  7992. */
  7993. addColor3(name: string, color: Color3): void;
  7994. /**
  7995. * Adds a vec4 to the uniform buffer.
  7996. * @param name Name of the uniform, as used in the uniform block in the shader.
  7997. * @param color Define the rgb components from a Color
  7998. * @param alpha Define the a component of the vec4
  7999. */
  8000. addColor4(name: string, color: Color3, alpha: number): void;
  8001. /**
  8002. * Adds a vec3 to the uniform buffer.
  8003. * @param name Name of the uniform, as used in the uniform block in the shader.
  8004. * @param vector Define the vec3 components from a Vector
  8005. */
  8006. addVector3(name: string, vector: Vector3): void;
  8007. /**
  8008. * Adds a Matrix 3x3 to the uniform buffer.
  8009. * @param name Name of the uniform, as used in the uniform block in the shader.
  8010. */
  8011. addMatrix3x3(name: string): void;
  8012. /**
  8013. * Adds a Matrix 2x2 to the uniform buffer.
  8014. * @param name Name of the uniform, as used in the uniform block in the shader.
  8015. */
  8016. addMatrix2x2(name: string): void;
  8017. /**
  8018. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8019. */
  8020. create(): void;
  8021. /** @hidden */
  8022. _rebuild(): void;
  8023. /**
  8024. * Updates the WebGL Uniform Buffer on the GPU.
  8025. * If the `dynamic` flag is set to true, no cache comparison is done.
  8026. * Otherwise, the buffer will be updated only if the cache differs.
  8027. */
  8028. update(): void;
  8029. /**
  8030. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8031. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8032. * @param data Define the flattened data
  8033. * @param size Define the size of the data.
  8034. */
  8035. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8036. private _valueCache;
  8037. private _cacheMatrix;
  8038. private _updateMatrix3x3ForUniform;
  8039. private _updateMatrix3x3ForEffect;
  8040. private _updateMatrix2x2ForEffect;
  8041. private _updateMatrix2x2ForUniform;
  8042. private _updateFloatForEffect;
  8043. private _updateFloatForUniform;
  8044. private _updateFloat2ForEffect;
  8045. private _updateFloat2ForUniform;
  8046. private _updateFloat3ForEffect;
  8047. private _updateFloat3ForUniform;
  8048. private _updateFloat4ForEffect;
  8049. private _updateFloat4ForUniform;
  8050. private _updateMatrixForEffect;
  8051. private _updateMatrixForUniform;
  8052. private _updateVector3ForEffect;
  8053. private _updateVector3ForUniform;
  8054. private _updateVector4ForEffect;
  8055. private _updateVector4ForUniform;
  8056. private _updateColor3ForEffect;
  8057. private _updateColor3ForUniform;
  8058. private _updateColor4ForEffect;
  8059. private _updateColor4ForUniform;
  8060. /**
  8061. * Sets a sampler uniform on the effect.
  8062. * @param name Define the name of the sampler.
  8063. * @param texture Define the texture to set in the sampler
  8064. */
  8065. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8066. /**
  8067. * Directly updates the value of the uniform in the cache AND on the GPU.
  8068. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8069. * @param data Define the flattened data
  8070. */
  8071. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8072. /**
  8073. * Binds this uniform buffer to an effect.
  8074. * @param effect Define the effect to bind the buffer to
  8075. * @param name Name of the uniform block in the shader.
  8076. */
  8077. bindToEffect(effect: Effect, name: string): void;
  8078. /**
  8079. * Disposes the uniform buffer.
  8080. */
  8081. dispose(): void;
  8082. }
  8083. }
  8084. declare module BABYLON {
  8085. /**
  8086. * Manages the defines for the Material
  8087. */
  8088. export class MaterialDefines {
  8089. /** @hidden */
  8090. protected _keys: string[];
  8091. private _isDirty;
  8092. /** @hidden */
  8093. _renderId: number;
  8094. /** @hidden */
  8095. _areLightsDirty: boolean;
  8096. /** @hidden */
  8097. _areLightsDisposed: boolean;
  8098. /** @hidden */
  8099. _areAttributesDirty: boolean;
  8100. /** @hidden */
  8101. _areTexturesDirty: boolean;
  8102. /** @hidden */
  8103. _areFresnelDirty: boolean;
  8104. /** @hidden */
  8105. _areMiscDirty: boolean;
  8106. /** @hidden */
  8107. _arePrePassDirty: boolean;
  8108. /** @hidden */
  8109. _areImageProcessingDirty: boolean;
  8110. /** @hidden */
  8111. _normals: boolean;
  8112. /** @hidden */
  8113. _uvs: boolean;
  8114. /** @hidden */
  8115. _needNormals: boolean;
  8116. /** @hidden */
  8117. _needUVs: boolean;
  8118. [id: string]: any;
  8119. /**
  8120. * Specifies if the material needs to be re-calculated
  8121. */
  8122. get isDirty(): boolean;
  8123. /**
  8124. * Marks the material to indicate that it has been re-calculated
  8125. */
  8126. markAsProcessed(): void;
  8127. /**
  8128. * Marks the material to indicate that it needs to be re-calculated
  8129. */
  8130. markAsUnprocessed(): void;
  8131. /**
  8132. * Marks the material to indicate all of its defines need to be re-calculated
  8133. */
  8134. markAllAsDirty(): void;
  8135. /**
  8136. * Marks the material to indicate that image processing needs to be re-calculated
  8137. */
  8138. markAsImageProcessingDirty(): void;
  8139. /**
  8140. * Marks the material to indicate the lights need to be re-calculated
  8141. * @param disposed Defines whether the light is dirty due to dispose or not
  8142. */
  8143. markAsLightDirty(disposed?: boolean): void;
  8144. /**
  8145. * Marks the attribute state as changed
  8146. */
  8147. markAsAttributesDirty(): void;
  8148. /**
  8149. * Marks the texture state as changed
  8150. */
  8151. markAsTexturesDirty(): void;
  8152. /**
  8153. * Marks the fresnel state as changed
  8154. */
  8155. markAsFresnelDirty(): void;
  8156. /**
  8157. * Marks the misc state as changed
  8158. */
  8159. markAsMiscDirty(): void;
  8160. /**
  8161. * Marks the prepass state as changed
  8162. */
  8163. markAsPrePassDirty(): void;
  8164. /**
  8165. * Rebuilds the material defines
  8166. */
  8167. rebuild(): void;
  8168. /**
  8169. * Specifies if two material defines are equal
  8170. * @param other - A material define instance to compare to
  8171. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8172. */
  8173. isEqual(other: MaterialDefines): boolean;
  8174. /**
  8175. * Clones this instance's defines to another instance
  8176. * @param other - material defines to clone values to
  8177. */
  8178. cloneTo(other: MaterialDefines): void;
  8179. /**
  8180. * Resets the material define values
  8181. */
  8182. reset(): void;
  8183. /**
  8184. * Converts the material define values to a string
  8185. * @returns - String of material define information
  8186. */
  8187. toString(): string;
  8188. }
  8189. }
  8190. declare module BABYLON {
  8191. /**
  8192. * Enum that determines the text-wrapping mode to use.
  8193. */
  8194. export enum InspectableType {
  8195. /**
  8196. * Checkbox for booleans
  8197. */
  8198. Checkbox = 0,
  8199. /**
  8200. * Sliders for numbers
  8201. */
  8202. Slider = 1,
  8203. /**
  8204. * Vector3
  8205. */
  8206. Vector3 = 2,
  8207. /**
  8208. * Quaternions
  8209. */
  8210. Quaternion = 3,
  8211. /**
  8212. * Color3
  8213. */
  8214. Color3 = 4,
  8215. /**
  8216. * String
  8217. */
  8218. String = 5
  8219. }
  8220. /**
  8221. * Interface used to define custom inspectable properties.
  8222. * This interface is used by the inspector to display custom property grids
  8223. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8224. */
  8225. export interface IInspectable {
  8226. /**
  8227. * Gets the label to display
  8228. */
  8229. label: string;
  8230. /**
  8231. * Gets the name of the property to edit
  8232. */
  8233. propertyName: string;
  8234. /**
  8235. * Gets the type of the editor to use
  8236. */
  8237. type: InspectableType;
  8238. /**
  8239. * Gets the minimum value of the property when using in "slider" mode
  8240. */
  8241. min?: number;
  8242. /**
  8243. * Gets the maximum value of the property when using in "slider" mode
  8244. */
  8245. max?: number;
  8246. /**
  8247. * Gets the setp to use when using in "slider" mode
  8248. */
  8249. step?: number;
  8250. }
  8251. }
  8252. declare module BABYLON {
  8253. /**
  8254. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8255. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8256. * 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.
  8257. */
  8258. export abstract class Light extends Node {
  8259. /**
  8260. * Falloff Default: light is falling off following the material specification:
  8261. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8262. */
  8263. static readonly FALLOFF_DEFAULT: number;
  8264. /**
  8265. * Falloff Physical: light is falling off following the inverse squared distance law.
  8266. */
  8267. static readonly FALLOFF_PHYSICAL: number;
  8268. /**
  8269. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8270. * to enhance interoperability with other engines.
  8271. */
  8272. static readonly FALLOFF_GLTF: number;
  8273. /**
  8274. * Falloff Standard: light is falling off like in the standard material
  8275. * to enhance interoperability with other materials.
  8276. */
  8277. static readonly FALLOFF_STANDARD: number;
  8278. /**
  8279. * If every light affecting the material is in this lightmapMode,
  8280. * material.lightmapTexture adds or multiplies
  8281. * (depends on material.useLightmapAsShadowmap)
  8282. * after every other light calculations.
  8283. */
  8284. static readonly LIGHTMAP_DEFAULT: number;
  8285. /**
  8286. * material.lightmapTexture as only diffuse lighting from this light
  8287. * adds only specular lighting from this light
  8288. * adds dynamic shadows
  8289. */
  8290. static readonly LIGHTMAP_SPECULAR: number;
  8291. /**
  8292. * material.lightmapTexture as only lighting
  8293. * no light calculation from this light
  8294. * only adds dynamic shadows from this light
  8295. */
  8296. static readonly LIGHTMAP_SHADOWSONLY: number;
  8297. /**
  8298. * Each light type uses the default quantity according to its type:
  8299. * point/spot lights use luminous intensity
  8300. * directional lights use illuminance
  8301. */
  8302. static readonly INTENSITYMODE_AUTOMATIC: number;
  8303. /**
  8304. * lumen (lm)
  8305. */
  8306. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8307. /**
  8308. * candela (lm/sr)
  8309. */
  8310. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8311. /**
  8312. * lux (lm/m^2)
  8313. */
  8314. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8315. /**
  8316. * nit (cd/m^2)
  8317. */
  8318. static readonly INTENSITYMODE_LUMINANCE: number;
  8319. /**
  8320. * Light type const id of the point light.
  8321. */
  8322. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8323. /**
  8324. * Light type const id of the directional light.
  8325. */
  8326. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8327. /**
  8328. * Light type const id of the spot light.
  8329. */
  8330. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8331. /**
  8332. * Light type const id of the hemispheric light.
  8333. */
  8334. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8335. /**
  8336. * Diffuse gives the basic color to an object.
  8337. */
  8338. diffuse: Color3;
  8339. /**
  8340. * Specular produces a highlight color on an object.
  8341. * Note: This is note affecting PBR materials.
  8342. */
  8343. specular: Color3;
  8344. /**
  8345. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8346. * falling off base on range or angle.
  8347. * This can be set to any values in Light.FALLOFF_x.
  8348. *
  8349. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8350. * other types of materials.
  8351. */
  8352. falloffType: number;
  8353. /**
  8354. * Strength of the light.
  8355. * Note: By default it is define in the framework own unit.
  8356. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8357. */
  8358. intensity: number;
  8359. private _range;
  8360. protected _inverseSquaredRange: number;
  8361. /**
  8362. * Defines how far from the source the light is impacting in scene units.
  8363. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8364. */
  8365. get range(): number;
  8366. /**
  8367. * Defines how far from the source the light is impacting in scene units.
  8368. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8369. */
  8370. set range(value: number);
  8371. /**
  8372. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8373. * of light.
  8374. */
  8375. private _photometricScale;
  8376. private _intensityMode;
  8377. /**
  8378. * Gets the photometric scale used to interpret the intensity.
  8379. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8380. */
  8381. get intensityMode(): number;
  8382. /**
  8383. * Sets the photometric scale used to interpret the intensity.
  8384. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8385. */
  8386. set intensityMode(value: number);
  8387. private _radius;
  8388. /**
  8389. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8390. */
  8391. get radius(): number;
  8392. /**
  8393. * sets the light radius used by PBR Materials to simulate soft area lights.
  8394. */
  8395. set radius(value: number);
  8396. private _renderPriority;
  8397. /**
  8398. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8399. * exceeding the number allowed of the materials.
  8400. */
  8401. renderPriority: number;
  8402. private _shadowEnabled;
  8403. /**
  8404. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8405. * the current shadow generator.
  8406. */
  8407. get shadowEnabled(): boolean;
  8408. /**
  8409. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8410. * the current shadow generator.
  8411. */
  8412. set shadowEnabled(value: boolean);
  8413. private _includedOnlyMeshes;
  8414. /**
  8415. * Gets the only meshes impacted by this light.
  8416. */
  8417. get includedOnlyMeshes(): AbstractMesh[];
  8418. /**
  8419. * Sets the only meshes impacted by this light.
  8420. */
  8421. set includedOnlyMeshes(value: AbstractMesh[]);
  8422. private _excludedMeshes;
  8423. /**
  8424. * Gets the meshes not impacted by this light.
  8425. */
  8426. get excludedMeshes(): AbstractMesh[];
  8427. /**
  8428. * Sets the meshes not impacted by this light.
  8429. */
  8430. set excludedMeshes(value: AbstractMesh[]);
  8431. private _excludeWithLayerMask;
  8432. /**
  8433. * Gets the layer id use to find what meshes are not impacted by the light.
  8434. * Inactive if 0
  8435. */
  8436. get excludeWithLayerMask(): number;
  8437. /**
  8438. * Sets the layer id use to find what meshes are not impacted by the light.
  8439. * Inactive if 0
  8440. */
  8441. set excludeWithLayerMask(value: number);
  8442. private _includeOnlyWithLayerMask;
  8443. /**
  8444. * Gets the layer id use to find what meshes are impacted by the light.
  8445. * Inactive if 0
  8446. */
  8447. get includeOnlyWithLayerMask(): number;
  8448. /**
  8449. * Sets the layer id use to find what meshes are impacted by the light.
  8450. * Inactive if 0
  8451. */
  8452. set includeOnlyWithLayerMask(value: number);
  8453. private _lightmapMode;
  8454. /**
  8455. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8456. */
  8457. get lightmapMode(): number;
  8458. /**
  8459. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8460. */
  8461. set lightmapMode(value: number);
  8462. /**
  8463. * Shadow generator associted to the light.
  8464. * @hidden Internal use only.
  8465. */
  8466. _shadowGenerator: Nullable<IShadowGenerator>;
  8467. /**
  8468. * @hidden Internal use only.
  8469. */
  8470. _excludedMeshesIds: string[];
  8471. /**
  8472. * @hidden Internal use only.
  8473. */
  8474. _includedOnlyMeshesIds: string[];
  8475. /**
  8476. * The current light unifom buffer.
  8477. * @hidden Internal use only.
  8478. */
  8479. _uniformBuffer: UniformBuffer;
  8480. /** @hidden */
  8481. _renderId: number;
  8482. /**
  8483. * Creates a Light object in the scene.
  8484. * Documentation : https://doc.babylonjs.com/babylon101/lights
  8485. * @param name The firendly name of the light
  8486. * @param scene The scene the light belongs too
  8487. */
  8488. constructor(name: string, scene: Scene);
  8489. protected abstract _buildUniformLayout(): void;
  8490. /**
  8491. * Sets the passed Effect "effect" with the Light information.
  8492. * @param effect The effect to update
  8493. * @param lightIndex The index of the light in the effect to update
  8494. * @returns The light
  8495. */
  8496. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  8497. /**
  8498. * Sets the passed Effect "effect" with the Light textures.
  8499. * @param effect The effect to update
  8500. * @param lightIndex The index of the light in the effect to update
  8501. * @returns The light
  8502. */
  8503. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  8504. /**
  8505. * Binds the lights information from the scene to the effect for the given mesh.
  8506. * @param lightIndex Light index
  8507. * @param scene The scene where the light belongs to
  8508. * @param effect The effect we are binding the data to
  8509. * @param useSpecular Defines if specular is supported
  8510. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8511. */
  8512. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  8513. /**
  8514. * Sets the passed Effect "effect" with the Light information.
  8515. * @param effect The effect to update
  8516. * @param lightDataUniformName The uniform used to store light data (position or direction)
  8517. * @returns The light
  8518. */
  8519. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  8520. /**
  8521. * Returns the string "Light".
  8522. * @returns the class name
  8523. */
  8524. getClassName(): string;
  8525. /** @hidden */
  8526. readonly _isLight: boolean;
  8527. /**
  8528. * Converts the light information to a readable string for debug purpose.
  8529. * @param fullDetails Supports for multiple levels of logging within scene loading
  8530. * @returns the human readable light info
  8531. */
  8532. toString(fullDetails?: boolean): string;
  8533. /** @hidden */
  8534. protected _syncParentEnabledState(): void;
  8535. /**
  8536. * Set the enabled state of this node.
  8537. * @param value - the new enabled state
  8538. */
  8539. setEnabled(value: boolean): void;
  8540. /**
  8541. * Returns the Light associated shadow generator if any.
  8542. * @return the associated shadow generator.
  8543. */
  8544. getShadowGenerator(): Nullable<IShadowGenerator>;
  8545. /**
  8546. * Returns a Vector3, the absolute light position in the World.
  8547. * @returns the world space position of the light
  8548. */
  8549. getAbsolutePosition(): Vector3;
  8550. /**
  8551. * Specifies if the light will affect the passed mesh.
  8552. * @param mesh The mesh to test against the light
  8553. * @return true the mesh is affected otherwise, false.
  8554. */
  8555. canAffectMesh(mesh: AbstractMesh): boolean;
  8556. /**
  8557. * Sort function to order lights for rendering.
  8558. * @param a First Light object to compare to second.
  8559. * @param b Second Light object to compare first.
  8560. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  8561. */
  8562. static CompareLightsPriority(a: Light, b: Light): number;
  8563. /**
  8564. * Releases resources associated with this node.
  8565. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8566. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8567. */
  8568. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8569. /**
  8570. * Returns the light type ID (integer).
  8571. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8572. */
  8573. getTypeID(): number;
  8574. /**
  8575. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  8576. * @returns the scaled intensity in intensity mode unit
  8577. */
  8578. getScaledIntensity(): number;
  8579. /**
  8580. * Returns a new Light object, named "name", from the current one.
  8581. * @param name The name of the cloned light
  8582. * @param newParent The parent of this light, if it has one
  8583. * @returns the new created light
  8584. */
  8585. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  8586. /**
  8587. * Serializes the current light into a Serialization object.
  8588. * @returns the serialized object.
  8589. */
  8590. serialize(): any;
  8591. /**
  8592. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  8593. * This new light is named "name" and added to the passed scene.
  8594. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  8595. * @param name The friendly name of the light
  8596. * @param scene The scene the new light will belong to
  8597. * @returns the constructor function
  8598. */
  8599. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  8600. /**
  8601. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  8602. * @param parsedLight The JSON representation of the light
  8603. * @param scene The scene to create the parsed light in
  8604. * @returns the created light after parsing
  8605. */
  8606. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  8607. private _hookArrayForExcluded;
  8608. private _hookArrayForIncludedOnly;
  8609. private _resyncMeshes;
  8610. /**
  8611. * Forces the meshes to update their light related information in their rendering used effects
  8612. * @hidden Internal Use Only
  8613. */
  8614. _markMeshesAsLightDirty(): void;
  8615. /**
  8616. * Recomputes the cached photometric scale if needed.
  8617. */
  8618. private _computePhotometricScale;
  8619. /**
  8620. * Returns the Photometric Scale according to the light type and intensity mode.
  8621. */
  8622. private _getPhotometricScale;
  8623. /**
  8624. * Reorder the light in the scene according to their defined priority.
  8625. * @hidden Internal Use Only
  8626. */
  8627. _reorderLightsInScene(): void;
  8628. /**
  8629. * Prepares the list of defines specific to the light type.
  8630. * @param defines the list of defines
  8631. * @param lightIndex defines the index of the light for the effect
  8632. */
  8633. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  8634. }
  8635. }
  8636. declare module BABYLON {
  8637. /** Defines supported spaces */
  8638. export enum Space {
  8639. /** Local (object) space */
  8640. LOCAL = 0,
  8641. /** World space */
  8642. WORLD = 1,
  8643. /** Bone space */
  8644. BONE = 2
  8645. }
  8646. /** Defines the 3 main axes */
  8647. export class Axis {
  8648. /** X axis */
  8649. static X: Vector3;
  8650. /** Y axis */
  8651. static Y: Vector3;
  8652. /** Z axis */
  8653. static Z: Vector3;
  8654. }
  8655. /**
  8656. * Defines cartesian components.
  8657. */
  8658. export enum Coordinate {
  8659. /** X axis */
  8660. X = 0,
  8661. /** Y axis */
  8662. Y = 1,
  8663. /** Z axis */
  8664. Z = 2
  8665. }
  8666. }
  8667. declare module BABYLON {
  8668. /**
  8669. * Interface describing all the common properties and methods a shadow light needs to implement.
  8670. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8671. * as well as binding the different shadow properties to the effects.
  8672. */
  8673. export interface IShadowLight extends Light {
  8674. /**
  8675. * The light id in the scene (used in scene.findLighById for instance)
  8676. */
  8677. id: string;
  8678. /**
  8679. * The position the shdow will be casted from.
  8680. */
  8681. position: Vector3;
  8682. /**
  8683. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8684. */
  8685. direction: Vector3;
  8686. /**
  8687. * The transformed position. Position of the light in world space taking parenting in account.
  8688. */
  8689. transformedPosition: Vector3;
  8690. /**
  8691. * The transformed direction. Direction of the light in world space taking parenting in account.
  8692. */
  8693. transformedDirection: Vector3;
  8694. /**
  8695. * The friendly name of the light in the scene.
  8696. */
  8697. name: string;
  8698. /**
  8699. * Defines the shadow projection clipping minimum z value.
  8700. */
  8701. shadowMinZ: number;
  8702. /**
  8703. * Defines the shadow projection clipping maximum z value.
  8704. */
  8705. shadowMaxZ: number;
  8706. /**
  8707. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8708. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8709. */
  8710. computeTransformedInformation(): boolean;
  8711. /**
  8712. * Gets the scene the light belongs to.
  8713. * @returns The scene
  8714. */
  8715. getScene(): Scene;
  8716. /**
  8717. * Callback defining a custom Projection Matrix Builder.
  8718. * This can be used to override the default projection matrix computation.
  8719. */
  8720. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8721. /**
  8722. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8723. * @param matrix The materix to updated with the projection information
  8724. * @param viewMatrix The transform matrix of the light
  8725. * @param renderList The list of mesh to render in the map
  8726. * @returns The current light
  8727. */
  8728. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8729. /**
  8730. * Gets the current depth scale used in ESM.
  8731. * @returns The scale
  8732. */
  8733. getDepthScale(): number;
  8734. /**
  8735. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8736. * @returns true if a cube texture needs to be use
  8737. */
  8738. needCube(): boolean;
  8739. /**
  8740. * Detects if the projection matrix requires to be recomputed this frame.
  8741. * @returns true if it requires to be recomputed otherwise, false.
  8742. */
  8743. needProjectionMatrixCompute(): boolean;
  8744. /**
  8745. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8746. */
  8747. forceProjectionMatrixCompute(): void;
  8748. /**
  8749. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8750. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8751. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8752. */
  8753. getShadowDirection(faceIndex?: number): Vector3;
  8754. /**
  8755. * Gets the minZ used for shadow according to both the scene and the light.
  8756. * @param activeCamera The camera we are returning the min for
  8757. * @returns the depth min z
  8758. */
  8759. getDepthMinZ(activeCamera: Camera): number;
  8760. /**
  8761. * Gets the maxZ used for shadow according to both the scene and the light.
  8762. * @param activeCamera The camera we are returning the max for
  8763. * @returns the depth max z
  8764. */
  8765. getDepthMaxZ(activeCamera: Camera): number;
  8766. }
  8767. /**
  8768. * Base implementation IShadowLight
  8769. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8770. */
  8771. export abstract class ShadowLight extends Light implements IShadowLight {
  8772. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8773. protected _position: Vector3;
  8774. protected _setPosition(value: Vector3): void;
  8775. /**
  8776. * Sets the position the shadow will be casted from. Also use as the light position for both
  8777. * point and spot lights.
  8778. */
  8779. get position(): Vector3;
  8780. /**
  8781. * Sets the position the shadow will be casted from. Also use as the light position for both
  8782. * point and spot lights.
  8783. */
  8784. set position(value: Vector3);
  8785. protected _direction: Vector3;
  8786. protected _setDirection(value: Vector3): void;
  8787. /**
  8788. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8789. * Also use as the light direction on spot and directional lights.
  8790. */
  8791. get direction(): Vector3;
  8792. /**
  8793. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8794. * Also use as the light direction on spot and directional lights.
  8795. */
  8796. set direction(value: Vector3);
  8797. protected _shadowMinZ: number;
  8798. /**
  8799. * Gets the shadow projection clipping minimum z value.
  8800. */
  8801. get shadowMinZ(): number;
  8802. /**
  8803. * Sets the shadow projection clipping minimum z value.
  8804. */
  8805. set shadowMinZ(value: number);
  8806. protected _shadowMaxZ: number;
  8807. /**
  8808. * Sets the shadow projection clipping maximum z value.
  8809. */
  8810. get shadowMaxZ(): number;
  8811. /**
  8812. * Gets the shadow projection clipping maximum z value.
  8813. */
  8814. set shadowMaxZ(value: number);
  8815. /**
  8816. * Callback defining a custom Projection Matrix Builder.
  8817. * This can be used to override the default projection matrix computation.
  8818. */
  8819. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8820. /**
  8821. * The transformed position. Position of the light in world space taking parenting in account.
  8822. */
  8823. transformedPosition: Vector3;
  8824. /**
  8825. * The transformed direction. Direction of the light in world space taking parenting in account.
  8826. */
  8827. transformedDirection: Vector3;
  8828. private _needProjectionMatrixCompute;
  8829. /**
  8830. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8831. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8832. */
  8833. computeTransformedInformation(): boolean;
  8834. /**
  8835. * Return the depth scale used for the shadow map.
  8836. * @returns the depth scale.
  8837. */
  8838. getDepthScale(): number;
  8839. /**
  8840. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8841. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8842. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8843. */
  8844. getShadowDirection(faceIndex?: number): Vector3;
  8845. /**
  8846. * Returns the ShadowLight absolute position in the World.
  8847. * @returns the position vector in world space
  8848. */
  8849. getAbsolutePosition(): Vector3;
  8850. /**
  8851. * Sets the ShadowLight direction toward the passed target.
  8852. * @param target The point to target in local space
  8853. * @returns the updated ShadowLight direction
  8854. */
  8855. setDirectionToTarget(target: Vector3): Vector3;
  8856. /**
  8857. * Returns the light rotation in euler definition.
  8858. * @returns the x y z rotation in local space.
  8859. */
  8860. getRotation(): Vector3;
  8861. /**
  8862. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8863. * @returns true if a cube texture needs to be use
  8864. */
  8865. needCube(): boolean;
  8866. /**
  8867. * Detects if the projection matrix requires to be recomputed this frame.
  8868. * @returns true if it requires to be recomputed otherwise, false.
  8869. */
  8870. needProjectionMatrixCompute(): boolean;
  8871. /**
  8872. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8873. */
  8874. forceProjectionMatrixCompute(): void;
  8875. /** @hidden */
  8876. _initCache(): void;
  8877. /** @hidden */
  8878. _isSynchronized(): boolean;
  8879. /**
  8880. * Computes the world matrix of the node
  8881. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8882. * @returns the world matrix
  8883. */
  8884. computeWorldMatrix(force?: boolean): Matrix;
  8885. /**
  8886. * Gets the minZ used for shadow according to both the scene and the light.
  8887. * @param activeCamera The camera we are returning the min for
  8888. * @returns the depth min z
  8889. */
  8890. getDepthMinZ(activeCamera: Camera): number;
  8891. /**
  8892. * Gets the maxZ used for shadow according to both the scene and the light.
  8893. * @param activeCamera The camera we are returning the max for
  8894. * @returns the depth max z
  8895. */
  8896. getDepthMaxZ(activeCamera: Camera): number;
  8897. /**
  8898. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8899. * @param matrix The materix to updated with the projection information
  8900. * @param viewMatrix The transform matrix of the light
  8901. * @param renderList The list of mesh to render in the map
  8902. * @returns The current light
  8903. */
  8904. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8905. }
  8906. }
  8907. declare module BABYLON {
  8908. /**
  8909. * Configuration needed for prepass-capable materials
  8910. */
  8911. export class PrePassConfiguration {
  8912. /**
  8913. * Previous world matrices of meshes carrying this material
  8914. * Used for computing velocity
  8915. */
  8916. previousWorldMatrices: {
  8917. [index: number]: Matrix;
  8918. };
  8919. /**
  8920. * Previous view project matrix
  8921. * Used for computing velocity
  8922. */
  8923. previousViewProjection: Matrix;
  8924. /**
  8925. * Previous bones of meshes carrying this material
  8926. * Used for computing velocity
  8927. */
  8928. previousBones: {
  8929. [index: number]: Float32Array;
  8930. };
  8931. /**
  8932. * Add the required uniforms to the current list.
  8933. * @param uniforms defines the current uniform list.
  8934. */
  8935. static AddUniforms(uniforms: string[]): void;
  8936. /**
  8937. * Add the required samplers to the current list.
  8938. * @param samplers defines the current sampler list.
  8939. */
  8940. static AddSamplers(samplers: string[]): void;
  8941. /**
  8942. * Binds the material data.
  8943. * @param effect defines the effect to update
  8944. * @param scene defines the scene the material belongs to.
  8945. * @param mesh The mesh
  8946. * @param world World matrix of this mesh
  8947. * @param isFrozen Is the material frozen
  8948. */
  8949. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  8950. }
  8951. }
  8952. declare module BABYLON {
  8953. /**
  8954. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8955. * This is the base of the follow, arc rotate cameras and Free camera
  8956. * @see https://doc.babylonjs.com/features/cameras
  8957. */
  8958. export class TargetCamera extends Camera {
  8959. private static _RigCamTransformMatrix;
  8960. private static _TargetTransformMatrix;
  8961. private static _TargetFocalPoint;
  8962. private _tmpUpVector;
  8963. private _tmpTargetVector;
  8964. /**
  8965. * Define the current direction the camera is moving to
  8966. */
  8967. cameraDirection: Vector3;
  8968. /**
  8969. * Define the current rotation the camera is rotating to
  8970. */
  8971. cameraRotation: Vector2;
  8972. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  8973. ignoreParentScaling: boolean;
  8974. /**
  8975. * When set, the up vector of the camera will be updated by the rotation of the camera
  8976. */
  8977. updateUpVectorFromRotation: boolean;
  8978. private _tmpQuaternion;
  8979. /**
  8980. * Define the current rotation of the camera
  8981. */
  8982. rotation: Vector3;
  8983. /**
  8984. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8985. */
  8986. rotationQuaternion: Quaternion;
  8987. /**
  8988. * Define the current speed of the camera
  8989. */
  8990. speed: number;
  8991. /**
  8992. * Add constraint to the camera to prevent it to move freely in all directions and
  8993. * around all axis.
  8994. */
  8995. noRotationConstraint: boolean;
  8996. /**
  8997. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8998. * panning
  8999. */
  9000. invertRotation: boolean;
  9001. /**
  9002. * Speed multiplier for inverse camera panning
  9003. */
  9004. inverseRotationSpeed: number;
  9005. /**
  9006. * Define the current target of the camera as an object or a position.
  9007. */
  9008. lockedTarget: any;
  9009. /** @hidden */
  9010. _currentTarget: Vector3;
  9011. /** @hidden */
  9012. _initialFocalDistance: number;
  9013. /** @hidden */
  9014. _viewMatrix: Matrix;
  9015. /** @hidden */
  9016. _camMatrix: Matrix;
  9017. /** @hidden */
  9018. _cameraTransformMatrix: Matrix;
  9019. /** @hidden */
  9020. _cameraRotationMatrix: Matrix;
  9021. /** @hidden */
  9022. _referencePoint: Vector3;
  9023. /** @hidden */
  9024. _transformedReferencePoint: Vector3;
  9025. /** @hidden */
  9026. _reset: () => void;
  9027. private _defaultUp;
  9028. /**
  9029. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9030. * This is the base of the follow, arc rotate cameras and Free camera
  9031. * @see https://doc.babylonjs.com/features/cameras
  9032. * @param name Defines the name of the camera in the scene
  9033. * @param position Defines the start position of the camera in the scene
  9034. * @param scene Defines the scene the camera belongs to
  9035. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9036. */
  9037. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9038. /**
  9039. * Gets the position in front of the camera at a given distance.
  9040. * @param distance The distance from the camera we want the position to be
  9041. * @returns the position
  9042. */
  9043. getFrontPosition(distance: number): Vector3;
  9044. /** @hidden */
  9045. _getLockedTargetPosition(): Nullable<Vector3>;
  9046. private _storedPosition;
  9047. private _storedRotation;
  9048. private _storedRotationQuaternion;
  9049. /**
  9050. * Store current camera state of the camera (fov, position, rotation, etc..)
  9051. * @returns the camera
  9052. */
  9053. storeState(): Camera;
  9054. /**
  9055. * Restored camera state. You must call storeState() first
  9056. * @returns whether it was successful or not
  9057. * @hidden
  9058. */
  9059. _restoreStateValues(): boolean;
  9060. /** @hidden */
  9061. _initCache(): void;
  9062. /** @hidden */
  9063. _updateCache(ignoreParentClass?: boolean): void;
  9064. /** @hidden */
  9065. _isSynchronizedViewMatrix(): boolean;
  9066. /** @hidden */
  9067. _computeLocalCameraSpeed(): number;
  9068. /**
  9069. * Defines the target the camera should look at.
  9070. * @param target Defines the new target as a Vector or a mesh
  9071. */
  9072. setTarget(target: Vector3): void;
  9073. /**
  9074. * Defines the target point of the camera.
  9075. * The camera looks towards it form the radius distance.
  9076. */
  9077. get target(): Vector3;
  9078. set target(value: Vector3);
  9079. /**
  9080. * Return the current target position of the camera. This value is expressed in local space.
  9081. * @returns the target position
  9082. */
  9083. getTarget(): Vector3;
  9084. /** @hidden */
  9085. _decideIfNeedsToMove(): boolean;
  9086. /** @hidden */
  9087. _updatePosition(): void;
  9088. /** @hidden */
  9089. _checkInputs(): void;
  9090. protected _updateCameraRotationMatrix(): void;
  9091. /**
  9092. * 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)
  9093. * @returns the current camera
  9094. */
  9095. private _rotateUpVectorWithCameraRotationMatrix;
  9096. private _cachedRotationZ;
  9097. private _cachedQuaternionRotationZ;
  9098. /** @hidden */
  9099. _getViewMatrix(): Matrix;
  9100. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9101. /**
  9102. * @hidden
  9103. */
  9104. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9105. /**
  9106. * @hidden
  9107. */
  9108. _updateRigCameras(): void;
  9109. private _getRigCamPositionAndTarget;
  9110. /**
  9111. * Gets the current object class name.
  9112. * @return the class name
  9113. */
  9114. getClassName(): string;
  9115. }
  9116. }
  9117. declare module BABYLON {
  9118. /**
  9119. * @ignore
  9120. * This is a list of all the different input types that are available in the application.
  9121. * Fo instance: ArcRotateCameraGamepadInput...
  9122. */
  9123. export var CameraInputTypes: {};
  9124. /**
  9125. * This is the contract to implement in order to create a new input class.
  9126. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9127. */
  9128. export interface ICameraInput<TCamera extends Camera> {
  9129. /**
  9130. * Defines the camera the input is attached to.
  9131. */
  9132. camera: Nullable<TCamera>;
  9133. /**
  9134. * Gets the class name of the current intput.
  9135. * @returns the class name
  9136. */
  9137. getClassName(): string;
  9138. /**
  9139. * Get the friendly name associated with the input class.
  9140. * @returns the input friendly name
  9141. */
  9142. getSimpleName(): string;
  9143. /**
  9144. * Attach the input controls to a specific dom element to get the input from.
  9145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9146. */
  9147. attachControl(noPreventDefault?: boolean): void;
  9148. /**
  9149. * Detach the current controls from the specified dom element.
  9150. */
  9151. detachControl(): void;
  9152. /**
  9153. * Update the current camera state depending on the inputs that have been used this frame.
  9154. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9155. */
  9156. checkInputs?: () => void;
  9157. }
  9158. /**
  9159. * Represents a map of input types to input instance or input index to input instance.
  9160. */
  9161. export interface CameraInputsMap<TCamera extends Camera> {
  9162. /**
  9163. * Accessor to the input by input type.
  9164. */
  9165. [name: string]: ICameraInput<TCamera>;
  9166. /**
  9167. * Accessor to the input by input index.
  9168. */
  9169. [idx: number]: ICameraInput<TCamera>;
  9170. }
  9171. /**
  9172. * This represents the input manager used within a camera.
  9173. * It helps dealing with all the different kind of input attached to a camera.
  9174. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9175. */
  9176. export class CameraInputsManager<TCamera extends Camera> {
  9177. /**
  9178. * Defines the list of inputs attahed to the camera.
  9179. */
  9180. attached: CameraInputsMap<TCamera>;
  9181. /**
  9182. * Defines the dom element the camera is collecting inputs from.
  9183. * This is null if the controls have not been attached.
  9184. */
  9185. attachedToElement: boolean;
  9186. /**
  9187. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9188. */
  9189. noPreventDefault: boolean;
  9190. /**
  9191. * Defined the camera the input manager belongs to.
  9192. */
  9193. camera: TCamera;
  9194. /**
  9195. * Update the current camera state depending on the inputs that have been used this frame.
  9196. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9197. */
  9198. checkInputs: () => void;
  9199. /**
  9200. * Instantiate a new Camera Input Manager.
  9201. * @param camera Defines the camera the input manager blongs to
  9202. */
  9203. constructor(camera: TCamera);
  9204. /**
  9205. * Add an input method to a camera
  9206. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9207. * @param input camera input method
  9208. */
  9209. add(input: ICameraInput<TCamera>): void;
  9210. /**
  9211. * Remove a specific input method from a camera
  9212. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9213. * @param inputToRemove camera input method
  9214. */
  9215. remove(inputToRemove: ICameraInput<TCamera>): void;
  9216. /**
  9217. * Remove a specific input type from a camera
  9218. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9219. * @param inputType the type of the input to remove
  9220. */
  9221. removeByType(inputType: string): void;
  9222. private _addCheckInputs;
  9223. /**
  9224. * Attach the input controls to the currently attached dom element to listen the events from.
  9225. * @param input Defines the input to attach
  9226. */
  9227. attachInput(input: ICameraInput<TCamera>): void;
  9228. /**
  9229. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9230. * @param element Defines the dom element to collect the events from
  9231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9232. */
  9233. attachElement(noPreventDefault?: boolean): void;
  9234. /**
  9235. * Detach the current manager inputs controls from a specific dom element.
  9236. * @param element Defines the dom element to collect the events from
  9237. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9238. */
  9239. detachElement(disconnect?: boolean): void;
  9240. /**
  9241. * Rebuild the dynamic inputCheck function from the current list of
  9242. * defined inputs in the manager.
  9243. */
  9244. rebuildInputCheck(): void;
  9245. /**
  9246. * Remove all attached input methods from a camera
  9247. */
  9248. clear(): void;
  9249. /**
  9250. * Serialize the current input manager attached to a camera.
  9251. * This ensures than once parsed,
  9252. * the input associated to the camera will be identical to the current ones
  9253. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9254. */
  9255. serialize(serializedCamera: any): void;
  9256. /**
  9257. * Parses an input manager serialized JSON to restore the previous list of inputs
  9258. * and states associated to a camera.
  9259. * @param parsedCamera Defines the JSON to parse
  9260. */
  9261. parse(parsedCamera: any): void;
  9262. }
  9263. }
  9264. declare module BABYLON {
  9265. /**
  9266. * Gather the list of keyboard event types as constants.
  9267. */
  9268. export class KeyboardEventTypes {
  9269. /**
  9270. * The keydown event is fired when a key becomes active (pressed).
  9271. */
  9272. static readonly KEYDOWN: number;
  9273. /**
  9274. * The keyup event is fired when a key has been released.
  9275. */
  9276. static readonly KEYUP: number;
  9277. }
  9278. /**
  9279. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9280. */
  9281. export class KeyboardInfo {
  9282. /**
  9283. * Defines the type of event (KeyboardEventTypes)
  9284. */
  9285. type: number;
  9286. /**
  9287. * Defines the related dom event
  9288. */
  9289. event: KeyboardEvent;
  9290. /**
  9291. * Instantiates a new keyboard info.
  9292. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9293. * @param type Defines the type of event (KeyboardEventTypes)
  9294. * @param event Defines the related dom event
  9295. */
  9296. constructor(
  9297. /**
  9298. * Defines the type of event (KeyboardEventTypes)
  9299. */
  9300. type: number,
  9301. /**
  9302. * Defines the related dom event
  9303. */
  9304. event: KeyboardEvent);
  9305. }
  9306. /**
  9307. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9308. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9309. */
  9310. export class KeyboardInfoPre extends KeyboardInfo {
  9311. /**
  9312. * Defines the type of event (KeyboardEventTypes)
  9313. */
  9314. type: number;
  9315. /**
  9316. * Defines the related dom event
  9317. */
  9318. event: KeyboardEvent;
  9319. /**
  9320. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9321. */
  9322. skipOnPointerObservable: boolean;
  9323. /**
  9324. * Instantiates a new keyboard pre info.
  9325. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9326. * @param type Defines the type of event (KeyboardEventTypes)
  9327. * @param event Defines the related dom event
  9328. */
  9329. constructor(
  9330. /**
  9331. * Defines the type of event (KeyboardEventTypes)
  9332. */
  9333. type: number,
  9334. /**
  9335. * Defines the related dom event
  9336. */
  9337. event: KeyboardEvent);
  9338. }
  9339. }
  9340. declare module BABYLON {
  9341. /**
  9342. * Manage the keyboard inputs to control the movement of a free camera.
  9343. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9344. */
  9345. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9346. /**
  9347. * Defines the camera the input is attached to.
  9348. */
  9349. camera: FreeCamera;
  9350. /**
  9351. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9352. */
  9353. keysUp: number[];
  9354. /**
  9355. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9356. */
  9357. keysUpward: number[];
  9358. /**
  9359. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9360. */
  9361. keysDown: number[];
  9362. /**
  9363. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9364. */
  9365. keysDownward: number[];
  9366. /**
  9367. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9368. */
  9369. keysLeft: number[];
  9370. /**
  9371. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9372. */
  9373. keysRight: number[];
  9374. private _keys;
  9375. private _onCanvasBlurObserver;
  9376. private _onKeyboardObserver;
  9377. private _engine;
  9378. private _scene;
  9379. /**
  9380. * Attach the input controls to a specific dom element to get the input from.
  9381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9382. */
  9383. attachControl(noPreventDefault?: boolean): void;
  9384. /**
  9385. * Detach the current controls from the specified dom element.
  9386. */
  9387. detachControl(): void;
  9388. /**
  9389. * Update the current camera state depending on the inputs that have been used this frame.
  9390. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9391. */
  9392. checkInputs(): void;
  9393. /**
  9394. * Gets the class name of the current intput.
  9395. * @returns the class name
  9396. */
  9397. getClassName(): string;
  9398. /** @hidden */
  9399. _onLostFocus(): void;
  9400. /**
  9401. * Get the friendly name associated with the input class.
  9402. * @returns the input friendly name
  9403. */
  9404. getSimpleName(): string;
  9405. }
  9406. }
  9407. declare module BABYLON {
  9408. /**
  9409. * Interface used to define Action
  9410. */
  9411. export interface IAction {
  9412. /**
  9413. * Trigger for the action
  9414. */
  9415. trigger: number;
  9416. /** Options of the trigger */
  9417. triggerOptions: any;
  9418. /**
  9419. * Gets the trigger parameters
  9420. * @returns the trigger parameters
  9421. */
  9422. getTriggerParameter(): any;
  9423. /**
  9424. * Internal only - executes current action event
  9425. * @hidden
  9426. */
  9427. _executeCurrent(evt?: ActionEvent): void;
  9428. /**
  9429. * Serialize placeholder for child classes
  9430. * @param parent of child
  9431. * @returns the serialized object
  9432. */
  9433. serialize(parent: any): any;
  9434. /**
  9435. * Internal only
  9436. * @hidden
  9437. */
  9438. _prepare(): void;
  9439. /**
  9440. * Internal only - manager for action
  9441. * @hidden
  9442. */
  9443. _actionManager: Nullable<AbstractActionManager>;
  9444. /**
  9445. * Adds action to chain of actions, may be a DoNothingAction
  9446. * @param action defines the next action to execute
  9447. * @returns The action passed in
  9448. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9449. */
  9450. then(action: IAction): IAction;
  9451. }
  9452. /**
  9453. * The action to be carried out following a trigger
  9454. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9455. */
  9456. export class Action implements IAction {
  9457. /** the trigger, with or without parameters, for the action */
  9458. triggerOptions: any;
  9459. /**
  9460. * Trigger for the action
  9461. */
  9462. trigger: number;
  9463. /**
  9464. * Internal only - manager for action
  9465. * @hidden
  9466. */
  9467. _actionManager: ActionManager;
  9468. private _nextActiveAction;
  9469. private _child;
  9470. private _condition?;
  9471. private _triggerParameter;
  9472. /**
  9473. * An event triggered prior to action being executed.
  9474. */
  9475. onBeforeExecuteObservable: Observable<Action>;
  9476. /**
  9477. * Creates a new Action
  9478. * @param triggerOptions the trigger, with or without parameters, for the action
  9479. * @param condition an optional determinant of action
  9480. */
  9481. constructor(
  9482. /** the trigger, with or without parameters, for the action */
  9483. triggerOptions: any, condition?: Condition);
  9484. /**
  9485. * Internal only
  9486. * @hidden
  9487. */
  9488. _prepare(): void;
  9489. /**
  9490. * Gets the trigger parameters
  9491. * @returns the trigger parameters
  9492. */
  9493. getTriggerParameter(): any;
  9494. /**
  9495. * Internal only - executes current action event
  9496. * @hidden
  9497. */
  9498. _executeCurrent(evt?: ActionEvent): void;
  9499. /**
  9500. * Execute placeholder for child classes
  9501. * @param evt optional action event
  9502. */
  9503. execute(evt?: ActionEvent): void;
  9504. /**
  9505. * Skips to next active action
  9506. */
  9507. skipToNextActiveAction(): void;
  9508. /**
  9509. * Adds action to chain of actions, may be a DoNothingAction
  9510. * @param action defines the next action to execute
  9511. * @returns The action passed in
  9512. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9513. */
  9514. then(action: Action): Action;
  9515. /**
  9516. * Internal only
  9517. * @hidden
  9518. */
  9519. _getProperty(propertyPath: string): string;
  9520. /**
  9521. * Internal only
  9522. * @hidden
  9523. */
  9524. _getEffectiveTarget(target: any, propertyPath: string): any;
  9525. /**
  9526. * Serialize placeholder for child classes
  9527. * @param parent of child
  9528. * @returns the serialized object
  9529. */
  9530. serialize(parent: any): any;
  9531. /**
  9532. * Internal only called by serialize
  9533. * @hidden
  9534. */
  9535. protected _serialize(serializedAction: any, parent?: any): any;
  9536. /**
  9537. * Internal only
  9538. * @hidden
  9539. */
  9540. static _SerializeValueAsString: (value: any) => string;
  9541. /**
  9542. * Internal only
  9543. * @hidden
  9544. */
  9545. static _GetTargetProperty: (target: Scene | Node) => {
  9546. name: string;
  9547. targetType: string;
  9548. value: string;
  9549. };
  9550. }
  9551. }
  9552. declare module BABYLON {
  9553. /**
  9554. * A Condition applied to an Action
  9555. */
  9556. export class Condition {
  9557. /**
  9558. * Internal only - manager for action
  9559. * @hidden
  9560. */
  9561. _actionManager: ActionManager;
  9562. /**
  9563. * Internal only
  9564. * @hidden
  9565. */
  9566. _evaluationId: number;
  9567. /**
  9568. * Internal only
  9569. * @hidden
  9570. */
  9571. _currentResult: boolean;
  9572. /**
  9573. * Creates a new Condition
  9574. * @param actionManager the manager of the action the condition is applied to
  9575. */
  9576. constructor(actionManager: ActionManager);
  9577. /**
  9578. * Check if the current condition is valid
  9579. * @returns a boolean
  9580. */
  9581. isValid(): boolean;
  9582. /**
  9583. * Internal only
  9584. * @hidden
  9585. */
  9586. _getProperty(propertyPath: string): string;
  9587. /**
  9588. * Internal only
  9589. * @hidden
  9590. */
  9591. _getEffectiveTarget(target: any, propertyPath: string): any;
  9592. /**
  9593. * Serialize placeholder for child classes
  9594. * @returns the serialized object
  9595. */
  9596. serialize(): any;
  9597. /**
  9598. * Internal only
  9599. * @hidden
  9600. */
  9601. protected _serialize(serializedCondition: any): any;
  9602. }
  9603. /**
  9604. * Defines specific conditional operators as extensions of Condition
  9605. */
  9606. export class ValueCondition extends Condition {
  9607. /** path to specify the property of the target the conditional operator uses */
  9608. propertyPath: string;
  9609. /** the value compared by the conditional operator against the current value of the property */
  9610. value: any;
  9611. /** the conditional operator, default ValueCondition.IsEqual */
  9612. operator: number;
  9613. /**
  9614. * Internal only
  9615. * @hidden
  9616. */
  9617. private static _IsEqual;
  9618. /**
  9619. * Internal only
  9620. * @hidden
  9621. */
  9622. private static _IsDifferent;
  9623. /**
  9624. * Internal only
  9625. * @hidden
  9626. */
  9627. private static _IsGreater;
  9628. /**
  9629. * Internal only
  9630. * @hidden
  9631. */
  9632. private static _IsLesser;
  9633. /**
  9634. * returns the number for IsEqual
  9635. */
  9636. static get IsEqual(): number;
  9637. /**
  9638. * Returns the number for IsDifferent
  9639. */
  9640. static get IsDifferent(): number;
  9641. /**
  9642. * Returns the number for IsGreater
  9643. */
  9644. static get IsGreater(): number;
  9645. /**
  9646. * Returns the number for IsLesser
  9647. */
  9648. static get IsLesser(): number;
  9649. /**
  9650. * Internal only The action manager for the condition
  9651. * @hidden
  9652. */
  9653. _actionManager: ActionManager;
  9654. /**
  9655. * Internal only
  9656. * @hidden
  9657. */
  9658. private _target;
  9659. /**
  9660. * Internal only
  9661. * @hidden
  9662. */
  9663. private _effectiveTarget;
  9664. /**
  9665. * Internal only
  9666. * @hidden
  9667. */
  9668. private _property;
  9669. /**
  9670. * Creates a new ValueCondition
  9671. * @param actionManager manager for the action the condition applies to
  9672. * @param target for the action
  9673. * @param propertyPath path to specify the property of the target the conditional operator uses
  9674. * @param value the value compared by the conditional operator against the current value of the property
  9675. * @param operator the conditional operator, default ValueCondition.IsEqual
  9676. */
  9677. constructor(actionManager: ActionManager, target: any,
  9678. /** path to specify the property of the target the conditional operator uses */
  9679. propertyPath: string,
  9680. /** the value compared by the conditional operator against the current value of the property */
  9681. value: any,
  9682. /** the conditional operator, default ValueCondition.IsEqual */
  9683. operator?: number);
  9684. /**
  9685. * Compares the given value with the property value for the specified conditional operator
  9686. * @returns the result of the comparison
  9687. */
  9688. isValid(): boolean;
  9689. /**
  9690. * Serialize the ValueCondition into a JSON compatible object
  9691. * @returns serialization object
  9692. */
  9693. serialize(): any;
  9694. /**
  9695. * Gets the name of the conditional operator for the ValueCondition
  9696. * @param operator the conditional operator
  9697. * @returns the name
  9698. */
  9699. static GetOperatorName(operator: number): string;
  9700. }
  9701. /**
  9702. * Defines a predicate condition as an extension of Condition
  9703. */
  9704. export class PredicateCondition extends Condition {
  9705. /** defines the predicate function used to validate the condition */
  9706. predicate: () => boolean;
  9707. /**
  9708. * Internal only - manager for action
  9709. * @hidden
  9710. */
  9711. _actionManager: ActionManager;
  9712. /**
  9713. * Creates a new PredicateCondition
  9714. * @param actionManager manager for the action the condition applies to
  9715. * @param predicate defines the predicate function used to validate the condition
  9716. */
  9717. constructor(actionManager: ActionManager,
  9718. /** defines the predicate function used to validate the condition */
  9719. predicate: () => boolean);
  9720. /**
  9721. * @returns the validity of the predicate condition
  9722. */
  9723. isValid(): boolean;
  9724. }
  9725. /**
  9726. * Defines a state condition as an extension of Condition
  9727. */
  9728. export class StateCondition extends Condition {
  9729. /** Value to compare with target state */
  9730. value: string;
  9731. /**
  9732. * Internal only - manager for action
  9733. * @hidden
  9734. */
  9735. _actionManager: ActionManager;
  9736. /**
  9737. * Internal only
  9738. * @hidden
  9739. */
  9740. private _target;
  9741. /**
  9742. * Creates a new StateCondition
  9743. * @param actionManager manager for the action the condition applies to
  9744. * @param target of the condition
  9745. * @param value to compare with target state
  9746. */
  9747. constructor(actionManager: ActionManager, target: any,
  9748. /** Value to compare with target state */
  9749. value: string);
  9750. /**
  9751. * Gets a boolean indicating if the current condition is met
  9752. * @returns the validity of the state
  9753. */
  9754. isValid(): boolean;
  9755. /**
  9756. * Serialize the StateCondition into a JSON compatible object
  9757. * @returns serialization object
  9758. */
  9759. serialize(): any;
  9760. }
  9761. }
  9762. declare module BABYLON {
  9763. /**
  9764. * This defines an action responsible to toggle a boolean once triggered.
  9765. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9766. */
  9767. export class SwitchBooleanAction extends Action {
  9768. /**
  9769. * The path to the boolean property in the target object
  9770. */
  9771. propertyPath: string;
  9772. private _target;
  9773. private _effectiveTarget;
  9774. private _property;
  9775. /**
  9776. * Instantiate the action
  9777. * @param triggerOptions defines the trigger options
  9778. * @param target defines the object containing the boolean
  9779. * @param propertyPath defines the path to the boolean property in the target object
  9780. * @param condition defines the trigger related conditions
  9781. */
  9782. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9783. /** @hidden */
  9784. _prepare(): void;
  9785. /**
  9786. * Execute the action toggle the boolean value.
  9787. */
  9788. execute(): void;
  9789. /**
  9790. * Serializes the actions and its related information.
  9791. * @param parent defines the object to serialize in
  9792. * @returns the serialized object
  9793. */
  9794. serialize(parent: any): any;
  9795. }
  9796. /**
  9797. * This defines an action responsible to set a the state field of the target
  9798. * to a desired value once triggered.
  9799. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9800. */
  9801. export class SetStateAction extends Action {
  9802. /**
  9803. * The value to store in the state field.
  9804. */
  9805. value: string;
  9806. private _target;
  9807. /**
  9808. * Instantiate the action
  9809. * @param triggerOptions defines the trigger options
  9810. * @param target defines the object containing the state property
  9811. * @param value defines the value to store in the state field
  9812. * @param condition defines the trigger related conditions
  9813. */
  9814. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9815. /**
  9816. * Execute the action and store the value on the target state property.
  9817. */
  9818. execute(): void;
  9819. /**
  9820. * Serializes the actions and its related information.
  9821. * @param parent defines the object to serialize in
  9822. * @returns the serialized object
  9823. */
  9824. serialize(parent: any): any;
  9825. }
  9826. /**
  9827. * This defines an action responsible to set a property of the target
  9828. * to a desired value once triggered.
  9829. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9830. */
  9831. export class SetValueAction extends Action {
  9832. /**
  9833. * The path of the property to set in the target.
  9834. */
  9835. propertyPath: string;
  9836. /**
  9837. * The value to set in the property
  9838. */
  9839. value: any;
  9840. private _target;
  9841. private _effectiveTarget;
  9842. private _property;
  9843. /**
  9844. * Instantiate the action
  9845. * @param triggerOptions defines the trigger options
  9846. * @param target defines the object containing the property
  9847. * @param propertyPath defines the path of the property to set in the target
  9848. * @param value defines the value to set in the property
  9849. * @param condition defines the trigger related conditions
  9850. */
  9851. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9852. /** @hidden */
  9853. _prepare(): void;
  9854. /**
  9855. * Execute the action and set the targetted property to the desired value.
  9856. */
  9857. execute(): void;
  9858. /**
  9859. * Serializes the actions and its related information.
  9860. * @param parent defines the object to serialize in
  9861. * @returns the serialized object
  9862. */
  9863. serialize(parent: any): any;
  9864. }
  9865. /**
  9866. * This defines an action responsible to increment the target value
  9867. * to a desired value once triggered.
  9868. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9869. */
  9870. export class IncrementValueAction extends Action {
  9871. /**
  9872. * The path of the property to increment in the target.
  9873. */
  9874. propertyPath: string;
  9875. /**
  9876. * The value we should increment the property by.
  9877. */
  9878. value: any;
  9879. private _target;
  9880. private _effectiveTarget;
  9881. private _property;
  9882. /**
  9883. * Instantiate the action
  9884. * @param triggerOptions defines the trigger options
  9885. * @param target defines the object containing the property
  9886. * @param propertyPath defines the path of the property to increment in the target
  9887. * @param value defines the value value we should increment the property by
  9888. * @param condition defines the trigger related conditions
  9889. */
  9890. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9891. /** @hidden */
  9892. _prepare(): void;
  9893. /**
  9894. * Execute the action and increment the target of the value amount.
  9895. */
  9896. execute(): void;
  9897. /**
  9898. * Serializes the actions and its related information.
  9899. * @param parent defines the object to serialize in
  9900. * @returns the serialized object
  9901. */
  9902. serialize(parent: any): any;
  9903. }
  9904. /**
  9905. * This defines an action responsible to start an animation once triggered.
  9906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9907. */
  9908. export class PlayAnimationAction extends Action {
  9909. /**
  9910. * Where the animation should start (animation frame)
  9911. */
  9912. from: number;
  9913. /**
  9914. * Where the animation should stop (animation frame)
  9915. */
  9916. to: number;
  9917. /**
  9918. * Define if the animation should loop or stop after the first play.
  9919. */
  9920. loop?: boolean;
  9921. private _target;
  9922. /**
  9923. * Instantiate the action
  9924. * @param triggerOptions defines the trigger options
  9925. * @param target defines the target animation or animation name
  9926. * @param from defines from where the animation should start (animation frame)
  9927. * @param end defines where the animation should stop (animation frame)
  9928. * @param loop defines if the animation should loop or stop after the first play
  9929. * @param condition defines the trigger related conditions
  9930. */
  9931. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9932. /** @hidden */
  9933. _prepare(): void;
  9934. /**
  9935. * Execute the action and play the animation.
  9936. */
  9937. execute(): void;
  9938. /**
  9939. * Serializes the actions and its related information.
  9940. * @param parent defines the object to serialize in
  9941. * @returns the serialized object
  9942. */
  9943. serialize(parent: any): any;
  9944. }
  9945. /**
  9946. * This defines an action responsible to stop an animation once triggered.
  9947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9948. */
  9949. export class StopAnimationAction extends Action {
  9950. private _target;
  9951. /**
  9952. * Instantiate the action
  9953. * @param triggerOptions defines the trigger options
  9954. * @param target defines the target animation or animation name
  9955. * @param condition defines the trigger related conditions
  9956. */
  9957. constructor(triggerOptions: any, target: any, condition?: Condition);
  9958. /** @hidden */
  9959. _prepare(): void;
  9960. /**
  9961. * Execute the action and stop the animation.
  9962. */
  9963. execute(): void;
  9964. /**
  9965. * Serializes the actions and its related information.
  9966. * @param parent defines the object to serialize in
  9967. * @returns the serialized object
  9968. */
  9969. serialize(parent: any): any;
  9970. }
  9971. /**
  9972. * This defines an action responsible that does nothing once triggered.
  9973. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9974. */
  9975. export class DoNothingAction extends Action {
  9976. /**
  9977. * Instantiate the action
  9978. * @param triggerOptions defines the trigger options
  9979. * @param condition defines the trigger related conditions
  9980. */
  9981. constructor(triggerOptions?: any, condition?: Condition);
  9982. /**
  9983. * Execute the action and do nothing.
  9984. */
  9985. execute(): void;
  9986. /**
  9987. * Serializes the actions and its related information.
  9988. * @param parent defines the object to serialize in
  9989. * @returns the serialized object
  9990. */
  9991. serialize(parent: any): any;
  9992. }
  9993. /**
  9994. * This defines an action responsible to trigger several actions once triggered.
  9995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9996. */
  9997. export class CombineAction extends Action {
  9998. /**
  9999. * The list of aggregated animations to run.
  10000. */
  10001. children: Action[];
  10002. /**
  10003. * Instantiate the action
  10004. * @param triggerOptions defines the trigger options
  10005. * @param children defines the list of aggregated animations to run
  10006. * @param condition defines the trigger related conditions
  10007. */
  10008. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10009. /** @hidden */
  10010. _prepare(): void;
  10011. /**
  10012. * Execute the action and executes all the aggregated actions.
  10013. */
  10014. execute(evt: ActionEvent): void;
  10015. /**
  10016. * Serializes the actions and its related information.
  10017. * @param parent defines the object to serialize in
  10018. * @returns the serialized object
  10019. */
  10020. serialize(parent: any): any;
  10021. }
  10022. /**
  10023. * This defines an action responsible to run code (external event) once triggered.
  10024. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10025. */
  10026. export class ExecuteCodeAction extends Action {
  10027. /**
  10028. * The callback function to run.
  10029. */
  10030. func: (evt: ActionEvent) => void;
  10031. /**
  10032. * Instantiate the action
  10033. * @param triggerOptions defines the trigger options
  10034. * @param func defines the callback function to run
  10035. * @param condition defines the trigger related conditions
  10036. */
  10037. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10038. /**
  10039. * Execute the action and run the attached code.
  10040. */
  10041. execute(evt: ActionEvent): void;
  10042. }
  10043. /**
  10044. * This defines an action responsible to set the parent property of the target once triggered.
  10045. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10046. */
  10047. export class SetParentAction extends Action {
  10048. private _parent;
  10049. private _target;
  10050. /**
  10051. * Instantiate the action
  10052. * @param triggerOptions defines the trigger options
  10053. * @param target defines the target containing the parent property
  10054. * @param parent defines from where the animation should start (animation frame)
  10055. * @param condition defines the trigger related conditions
  10056. */
  10057. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10058. /** @hidden */
  10059. _prepare(): void;
  10060. /**
  10061. * Execute the action and set the parent property.
  10062. */
  10063. execute(): void;
  10064. /**
  10065. * Serializes the actions and its related information.
  10066. * @param parent defines the object to serialize in
  10067. * @returns the serialized object
  10068. */
  10069. serialize(parent: any): any;
  10070. }
  10071. }
  10072. declare module BABYLON {
  10073. /**
  10074. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10075. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10076. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10077. */
  10078. export class ActionManager extends AbstractActionManager {
  10079. /**
  10080. * Nothing
  10081. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10082. */
  10083. static readonly NothingTrigger: number;
  10084. /**
  10085. * On pick
  10086. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10087. */
  10088. static readonly OnPickTrigger: number;
  10089. /**
  10090. * On left pick
  10091. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10092. */
  10093. static readonly OnLeftPickTrigger: number;
  10094. /**
  10095. * On right pick
  10096. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10097. */
  10098. static readonly OnRightPickTrigger: number;
  10099. /**
  10100. * On center pick
  10101. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10102. */
  10103. static readonly OnCenterPickTrigger: number;
  10104. /**
  10105. * On pick down
  10106. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10107. */
  10108. static readonly OnPickDownTrigger: number;
  10109. /**
  10110. * On double pick
  10111. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10112. */
  10113. static readonly OnDoublePickTrigger: number;
  10114. /**
  10115. * On pick up
  10116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10117. */
  10118. static readonly OnPickUpTrigger: number;
  10119. /**
  10120. * On pick out.
  10121. * This trigger will only be raised if you also declared a OnPickDown
  10122. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10123. */
  10124. static readonly OnPickOutTrigger: number;
  10125. /**
  10126. * On long press
  10127. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10128. */
  10129. static readonly OnLongPressTrigger: number;
  10130. /**
  10131. * On pointer over
  10132. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10133. */
  10134. static readonly OnPointerOverTrigger: number;
  10135. /**
  10136. * On pointer out
  10137. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10138. */
  10139. static readonly OnPointerOutTrigger: number;
  10140. /**
  10141. * On every frame
  10142. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10143. */
  10144. static readonly OnEveryFrameTrigger: number;
  10145. /**
  10146. * On intersection enter
  10147. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10148. */
  10149. static readonly OnIntersectionEnterTrigger: number;
  10150. /**
  10151. * On intersection exit
  10152. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10153. */
  10154. static readonly OnIntersectionExitTrigger: number;
  10155. /**
  10156. * On key down
  10157. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10158. */
  10159. static readonly OnKeyDownTrigger: number;
  10160. /**
  10161. * On key up
  10162. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10163. */
  10164. static readonly OnKeyUpTrigger: number;
  10165. private _scene;
  10166. /**
  10167. * Creates a new action manager
  10168. * @param scene defines the hosting scene
  10169. */
  10170. constructor(scene: Scene);
  10171. /**
  10172. * Releases all associated resources
  10173. */
  10174. dispose(): void;
  10175. /**
  10176. * Gets hosting scene
  10177. * @returns the hosting scene
  10178. */
  10179. getScene(): Scene;
  10180. /**
  10181. * Does this action manager handles actions of any of the given triggers
  10182. * @param triggers defines the triggers to be tested
  10183. * @return a boolean indicating whether one (or more) of the triggers is handled
  10184. */
  10185. hasSpecificTriggers(triggers: number[]): boolean;
  10186. /**
  10187. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10188. * speed.
  10189. * @param triggerA defines the trigger to be tested
  10190. * @param triggerB defines the trigger to be tested
  10191. * @return a boolean indicating whether one (or more) of the triggers is handled
  10192. */
  10193. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10194. /**
  10195. * Does this action manager handles actions of a given trigger
  10196. * @param trigger defines the trigger to be tested
  10197. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10198. * @return whether the trigger is handled
  10199. */
  10200. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10201. /**
  10202. * Does this action manager has pointer triggers
  10203. */
  10204. get hasPointerTriggers(): boolean;
  10205. /**
  10206. * Does this action manager has pick triggers
  10207. */
  10208. get hasPickTriggers(): boolean;
  10209. /**
  10210. * Registers an action to this action manager
  10211. * @param action defines the action to be registered
  10212. * @return the action amended (prepared) after registration
  10213. */
  10214. registerAction(action: IAction): Nullable<IAction>;
  10215. /**
  10216. * Unregisters an action to this action manager
  10217. * @param action defines the action to be unregistered
  10218. * @return a boolean indicating whether the action has been unregistered
  10219. */
  10220. unregisterAction(action: IAction): Boolean;
  10221. /**
  10222. * Process a specific trigger
  10223. * @param trigger defines the trigger to process
  10224. * @param evt defines the event details to be processed
  10225. */
  10226. processTrigger(trigger: number, evt?: IActionEvent): void;
  10227. /** @hidden */
  10228. _getEffectiveTarget(target: any, propertyPath: string): any;
  10229. /** @hidden */
  10230. _getProperty(propertyPath: string): string;
  10231. /**
  10232. * Serialize this manager to a JSON object
  10233. * @param name defines the property name to store this manager
  10234. * @returns a JSON representation of this manager
  10235. */
  10236. serialize(name: string): any;
  10237. /**
  10238. * Creates a new ActionManager from a JSON data
  10239. * @param parsedActions defines the JSON data to read from
  10240. * @param object defines the hosting mesh
  10241. * @param scene defines the hosting scene
  10242. */
  10243. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10244. /**
  10245. * Get a trigger name by index
  10246. * @param trigger defines the trigger index
  10247. * @returns a trigger name
  10248. */
  10249. static GetTriggerName(trigger: number): string;
  10250. }
  10251. }
  10252. declare module BABYLON {
  10253. /**
  10254. * Class representing a ray with position and direction
  10255. */
  10256. export class Ray {
  10257. /** origin point */
  10258. origin: Vector3;
  10259. /** direction */
  10260. direction: Vector3;
  10261. /** length of the ray */
  10262. length: number;
  10263. private static readonly _TmpVector3;
  10264. private _tmpRay;
  10265. /**
  10266. * Creates a new ray
  10267. * @param origin origin point
  10268. * @param direction direction
  10269. * @param length length of the ray
  10270. */
  10271. constructor(
  10272. /** origin point */
  10273. origin: Vector3,
  10274. /** direction */
  10275. direction: Vector3,
  10276. /** length of the ray */
  10277. length?: number);
  10278. /**
  10279. * Checks if the ray intersects a box
  10280. * This does not account for the ray lenght by design to improve perfs.
  10281. * @param minimum bound of the box
  10282. * @param maximum bound of the box
  10283. * @param intersectionTreshold extra extend to be added to the box in all direction
  10284. * @returns if the box was hit
  10285. */
  10286. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10287. /**
  10288. * Checks if the ray intersects a box
  10289. * This does not account for the ray lenght by design to improve perfs.
  10290. * @param box the bounding box to check
  10291. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10292. * @returns if the box was hit
  10293. */
  10294. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10295. /**
  10296. * If the ray hits a sphere
  10297. * @param sphere the bounding sphere to check
  10298. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10299. * @returns true if it hits the sphere
  10300. */
  10301. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10302. /**
  10303. * If the ray hits a triange
  10304. * @param vertex0 triangle vertex
  10305. * @param vertex1 triangle vertex
  10306. * @param vertex2 triangle vertex
  10307. * @returns intersection information if hit
  10308. */
  10309. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10310. /**
  10311. * Checks if ray intersects a plane
  10312. * @param plane the plane to check
  10313. * @returns the distance away it was hit
  10314. */
  10315. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10316. /**
  10317. * Calculate the intercept of a ray on a given axis
  10318. * @param axis to check 'x' | 'y' | 'z'
  10319. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10320. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10321. */
  10322. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10323. /**
  10324. * Checks if ray intersects a mesh
  10325. * @param mesh the mesh to check
  10326. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10327. * @returns picking info of the intersecton
  10328. */
  10329. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10330. /**
  10331. * Checks if ray intersects a mesh
  10332. * @param meshes the meshes to check
  10333. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10334. * @param results array to store result in
  10335. * @returns Array of picking infos
  10336. */
  10337. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10338. private _comparePickingInfo;
  10339. private static smallnum;
  10340. private static rayl;
  10341. /**
  10342. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10343. * @param sega the first point of the segment to test the intersection against
  10344. * @param segb the second point of the segment to test the intersection against
  10345. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10346. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10347. */
  10348. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10349. /**
  10350. * Update the ray from viewport position
  10351. * @param x position
  10352. * @param y y position
  10353. * @param viewportWidth viewport width
  10354. * @param viewportHeight viewport height
  10355. * @param world world matrix
  10356. * @param view view matrix
  10357. * @param projection projection matrix
  10358. * @returns this ray updated
  10359. */
  10360. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10361. /**
  10362. * Creates a ray with origin and direction of 0,0,0
  10363. * @returns the new ray
  10364. */
  10365. static Zero(): Ray;
  10366. /**
  10367. * Creates a new ray from screen space and viewport
  10368. * @param x position
  10369. * @param y y position
  10370. * @param viewportWidth viewport width
  10371. * @param viewportHeight viewport height
  10372. * @param world world matrix
  10373. * @param view view matrix
  10374. * @param projection projection matrix
  10375. * @returns new ray
  10376. */
  10377. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10378. /**
  10379. * 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
  10380. * transformed to the given world matrix.
  10381. * @param origin The origin point
  10382. * @param end The end point
  10383. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10384. * @returns the new ray
  10385. */
  10386. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10387. /**
  10388. * Transforms a ray by a matrix
  10389. * @param ray ray to transform
  10390. * @param matrix matrix to apply
  10391. * @returns the resulting new ray
  10392. */
  10393. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10394. /**
  10395. * Transforms a ray by a matrix
  10396. * @param ray ray to transform
  10397. * @param matrix matrix to apply
  10398. * @param result ray to store result in
  10399. */
  10400. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10401. /**
  10402. * Unproject a ray from screen space to object space
  10403. * @param sourceX defines the screen space x coordinate to use
  10404. * @param sourceY defines the screen space y coordinate to use
  10405. * @param viewportWidth defines the current width of the viewport
  10406. * @param viewportHeight defines the current height of the viewport
  10407. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10408. * @param view defines the view matrix to use
  10409. * @param projection defines the projection matrix to use
  10410. */
  10411. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10412. }
  10413. /**
  10414. * Type used to define predicate used to select faces when a mesh intersection is detected
  10415. */
  10416. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10417. interface Scene {
  10418. /** @hidden */
  10419. _tempPickingRay: Nullable<Ray>;
  10420. /** @hidden */
  10421. _cachedRayForTransform: Ray;
  10422. /** @hidden */
  10423. _pickWithRayInverseMatrix: Matrix;
  10424. /** @hidden */
  10425. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10426. /** @hidden */
  10427. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10428. /** @hidden */
  10429. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10430. }
  10431. }
  10432. declare module BABYLON {
  10433. /**
  10434. * Groups all the scene component constants in one place to ease maintenance.
  10435. * @hidden
  10436. */
  10437. export class SceneComponentConstants {
  10438. static readonly NAME_EFFECTLAYER: string;
  10439. static readonly NAME_LAYER: string;
  10440. static readonly NAME_LENSFLARESYSTEM: string;
  10441. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10442. static readonly NAME_PARTICLESYSTEM: string;
  10443. static readonly NAME_GAMEPAD: string;
  10444. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10445. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10446. static readonly NAME_PREPASSRENDERER: string;
  10447. static readonly NAME_DEPTHRENDERER: string;
  10448. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10449. static readonly NAME_SPRITE: string;
  10450. static readonly NAME_SUBSURFACE: string;
  10451. static readonly NAME_OUTLINERENDERER: string;
  10452. static readonly NAME_PROCEDURALTEXTURE: string;
  10453. static readonly NAME_SHADOWGENERATOR: string;
  10454. static readonly NAME_OCTREE: string;
  10455. static readonly NAME_PHYSICSENGINE: string;
  10456. static readonly NAME_AUDIO: string;
  10457. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10458. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10459. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10460. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10461. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10462. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10463. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10464. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10465. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10466. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10467. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10468. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10469. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10470. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10471. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10472. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10473. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10474. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10475. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10476. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10477. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10478. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10479. static readonly STEP_AFTERRENDER_AUDIO: number;
  10480. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10481. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10482. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10483. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10484. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10485. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10486. static readonly STEP_POINTERMOVE_SPRITE: number;
  10487. static readonly STEP_POINTERDOWN_SPRITE: number;
  10488. static readonly STEP_POINTERUP_SPRITE: number;
  10489. }
  10490. /**
  10491. * This represents a scene component.
  10492. *
  10493. * This is used to decouple the dependency the scene is having on the different workloads like
  10494. * layers, post processes...
  10495. */
  10496. export interface ISceneComponent {
  10497. /**
  10498. * The name of the component. Each component must have a unique name.
  10499. */
  10500. name: string;
  10501. /**
  10502. * The scene the component belongs to.
  10503. */
  10504. scene: Scene;
  10505. /**
  10506. * Register the component to one instance of a scene.
  10507. */
  10508. register(): void;
  10509. /**
  10510. * Rebuilds the elements related to this component in case of
  10511. * context lost for instance.
  10512. */
  10513. rebuild(): void;
  10514. /**
  10515. * Disposes the component and the associated ressources.
  10516. */
  10517. dispose(): void;
  10518. }
  10519. /**
  10520. * This represents a SERIALIZABLE scene component.
  10521. *
  10522. * This extends Scene Component to add Serialization methods on top.
  10523. */
  10524. export interface ISceneSerializableComponent extends ISceneComponent {
  10525. /**
  10526. * Adds all the elements from the container to the scene
  10527. * @param container the container holding the elements
  10528. */
  10529. addFromContainer(container: AbstractScene): void;
  10530. /**
  10531. * Removes all the elements in the container from the scene
  10532. * @param container contains the elements to remove
  10533. * @param dispose if the removed element should be disposed (default: false)
  10534. */
  10535. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10536. /**
  10537. * Serializes the component data to the specified json object
  10538. * @param serializationObject The object to serialize to
  10539. */
  10540. serialize(serializationObject: any): void;
  10541. }
  10542. /**
  10543. * Strong typing of a Mesh related stage step action
  10544. */
  10545. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10546. /**
  10547. * Strong typing of a Evaluate Sub Mesh related stage step action
  10548. */
  10549. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10550. /**
  10551. * Strong typing of a pre active Mesh related stage step action
  10552. */
  10553. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10554. /**
  10555. * Strong typing of a Camera related stage step action
  10556. */
  10557. export type CameraStageAction = (camera: Camera) => void;
  10558. /**
  10559. * Strong typing of a Camera Frame buffer related stage step action
  10560. */
  10561. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10562. /**
  10563. * Strong typing of a Render Target related stage step action
  10564. */
  10565. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10566. /**
  10567. * Strong typing of a RenderingGroup related stage step action
  10568. */
  10569. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10570. /**
  10571. * Strong typing of a Mesh Render related stage step action
  10572. */
  10573. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10574. /**
  10575. * Strong typing of a simple stage step action
  10576. */
  10577. export type SimpleStageAction = () => void;
  10578. /**
  10579. * Strong typing of a render target action.
  10580. */
  10581. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10582. /**
  10583. * Strong typing of a pointer move action.
  10584. */
  10585. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10586. /**
  10587. * Strong typing of a pointer up/down action.
  10588. */
  10589. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10590. /**
  10591. * Representation of a stage in the scene (Basically a list of ordered steps)
  10592. * @hidden
  10593. */
  10594. export class Stage<T extends Function> extends Array<{
  10595. index: number;
  10596. component: ISceneComponent;
  10597. action: T;
  10598. }> {
  10599. /**
  10600. * Hide ctor from the rest of the world.
  10601. * @param items The items to add.
  10602. */
  10603. private constructor();
  10604. /**
  10605. * Creates a new Stage.
  10606. * @returns A new instance of a Stage
  10607. */
  10608. static Create<T extends Function>(): Stage<T>;
  10609. /**
  10610. * Registers a step in an ordered way in the targeted stage.
  10611. * @param index Defines the position to register the step in
  10612. * @param component Defines the component attached to the step
  10613. * @param action Defines the action to launch during the step
  10614. */
  10615. registerStep(index: number, component: ISceneComponent, action: T): void;
  10616. /**
  10617. * Clears all the steps from the stage.
  10618. */
  10619. clear(): void;
  10620. }
  10621. }
  10622. declare module BABYLON {
  10623. interface Scene {
  10624. /** @hidden */
  10625. _pointerOverSprite: Nullable<Sprite>;
  10626. /** @hidden */
  10627. _pickedDownSprite: Nullable<Sprite>;
  10628. /** @hidden */
  10629. _tempSpritePickingRay: Nullable<Ray>;
  10630. /**
  10631. * All of the sprite managers added to this scene
  10632. * @see https://doc.babylonjs.com/babylon101/sprites
  10633. */
  10634. spriteManagers: Array<ISpriteManager>;
  10635. /**
  10636. * An event triggered when sprites rendering is about to start
  10637. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10638. */
  10639. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10640. /**
  10641. * An event triggered when sprites rendering is done
  10642. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10643. */
  10644. onAfterSpritesRenderingObservable: Observable<Scene>;
  10645. /** @hidden */
  10646. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10647. /** Launch a ray to try to pick a sprite in the scene
  10648. * @param x position on screen
  10649. * @param y position on screen
  10650. * @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
  10651. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10652. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10653. * @returns a PickingInfo
  10654. */
  10655. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10656. /** Use the given ray to pick a sprite in the scene
  10657. * @param ray The ray (in world space) to use to pick meshes
  10658. * @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
  10659. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10660. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10661. * @returns a PickingInfo
  10662. */
  10663. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10664. /** @hidden */
  10665. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10666. /** Launch a ray to try to pick sprites in the scene
  10667. * @param x position on screen
  10668. * @param y position on screen
  10669. * @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
  10670. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10671. * @returns a PickingInfo array
  10672. */
  10673. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10674. /** Use the given ray to pick sprites in the scene
  10675. * @param ray The ray (in world space) to use to pick meshes
  10676. * @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
  10677. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10678. * @returns a PickingInfo array
  10679. */
  10680. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10681. /**
  10682. * Force the sprite under the pointer
  10683. * @param sprite defines the sprite to use
  10684. */
  10685. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10686. /**
  10687. * Gets the sprite under the pointer
  10688. * @returns a Sprite or null if no sprite is under the pointer
  10689. */
  10690. getPointerOverSprite(): Nullable<Sprite>;
  10691. }
  10692. /**
  10693. * Defines the sprite scene component responsible to manage sprites
  10694. * in a given scene.
  10695. */
  10696. export class SpriteSceneComponent implements ISceneComponent {
  10697. /**
  10698. * The component name helpfull to identify the component in the list of scene components.
  10699. */
  10700. readonly name: string;
  10701. /**
  10702. * The scene the component belongs to.
  10703. */
  10704. scene: Scene;
  10705. /** @hidden */
  10706. private _spritePredicate;
  10707. /**
  10708. * Creates a new instance of the component for the given scene
  10709. * @param scene Defines the scene to register the component in
  10710. */
  10711. constructor(scene: Scene);
  10712. /**
  10713. * Registers the component in a given scene
  10714. */
  10715. register(): void;
  10716. /**
  10717. * Rebuilds the elements related to this component in case of
  10718. * context lost for instance.
  10719. */
  10720. rebuild(): void;
  10721. /**
  10722. * Disposes the component and the associated ressources.
  10723. */
  10724. dispose(): void;
  10725. private _pickSpriteButKeepRay;
  10726. private _pointerMove;
  10727. private _pointerDown;
  10728. private _pointerUp;
  10729. }
  10730. }
  10731. declare module BABYLON {
  10732. /**
  10733. * Class used to provide helper for timing
  10734. */
  10735. export class TimingTools {
  10736. /**
  10737. * Polyfill for setImmediate
  10738. * @param action defines the action to execute after the current execution block
  10739. */
  10740. static SetImmediate(action: () => void): void;
  10741. }
  10742. }
  10743. declare module BABYLON {
  10744. /**
  10745. * Class used to enable instatition of objects by class name
  10746. */
  10747. export class InstantiationTools {
  10748. /**
  10749. * Use this object to register external classes like custom textures or material
  10750. * to allow the laoders to instantiate them
  10751. */
  10752. static RegisteredExternalClasses: {
  10753. [key: string]: Object;
  10754. };
  10755. /**
  10756. * Tries to instantiate a new object from a given class name
  10757. * @param className defines the class name to instantiate
  10758. * @returns the new object or null if the system was not able to do the instantiation
  10759. */
  10760. static Instantiate(className: string): any;
  10761. }
  10762. }
  10763. declare module BABYLON {
  10764. /**
  10765. * Class used to host copy specific utilities
  10766. */
  10767. export class CopyTools {
  10768. /**
  10769. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  10770. * @param texture defines the texture to read pixels from
  10771. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  10772. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  10773. * @returns The base64 encoded string or null
  10774. */
  10775. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  10776. }
  10777. }
  10778. declare module BABYLON {
  10779. /**
  10780. * Define options used to create a depth texture
  10781. */
  10782. export class DepthTextureCreationOptions {
  10783. /** Specifies whether or not a stencil should be allocated in the texture */
  10784. generateStencil?: boolean;
  10785. /** Specifies whether or not bilinear filtering is enable on the texture */
  10786. bilinearFiltering?: boolean;
  10787. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10788. comparisonFunction?: number;
  10789. /** Specifies if the created texture is a cube texture */
  10790. isCube?: boolean;
  10791. }
  10792. }
  10793. declare module BABYLON {
  10794. interface ThinEngine {
  10795. /**
  10796. * Creates a depth stencil cube texture.
  10797. * This is only available in WebGL 2.
  10798. * @param size The size of face edge in the cube texture.
  10799. * @param options The options defining the cube texture.
  10800. * @returns The cube texture
  10801. */
  10802. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  10803. /**
  10804. * Creates a cube texture
  10805. * @param rootUrl defines the url where the files to load is located
  10806. * @param scene defines the current scene
  10807. * @param files defines the list of files to load (1 per face)
  10808. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10809. * @param onLoad defines an optional callback raised when the texture is loaded
  10810. * @param onError defines an optional callback raised if there is an issue to load the texture
  10811. * @param format defines the format of the data
  10812. * @param forcedExtension defines the extension to use to pick the right loader
  10813. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10814. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10815. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10816. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  10817. * @param loaderOptions options to be passed to the loader
  10818. * @returns the cube texture as an InternalTexture
  10819. */
  10820. 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;
  10821. /**
  10822. * Creates a cube texture
  10823. * @param rootUrl defines the url where the files to load is located
  10824. * @param scene defines the current scene
  10825. * @param files defines the list of files to load (1 per face)
  10826. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10827. * @param onLoad defines an optional callback raised when the texture is loaded
  10828. * @param onError defines an optional callback raised if there is an issue to load the texture
  10829. * @param format defines the format of the data
  10830. * @param forcedExtension defines the extension to use to pick the right loader
  10831. * @returns the cube texture as an InternalTexture
  10832. */
  10833. 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;
  10834. /**
  10835. * Creates a cube texture
  10836. * @param rootUrl defines the url where the files to load is located
  10837. * @param scene defines the current scene
  10838. * @param files defines the list of files to load (1 per face)
  10839. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10840. * @param onLoad defines an optional callback raised when the texture is loaded
  10841. * @param onError defines an optional callback raised if there is an issue to load the texture
  10842. * @param format defines the format of the data
  10843. * @param forcedExtension defines the extension to use to pick the right loader
  10844. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10845. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10846. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10847. * @returns the cube texture as an InternalTexture
  10848. */
  10849. 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;
  10850. /** @hidden */
  10851. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  10852. /** @hidden */
  10853. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  10854. /** @hidden */
  10855. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  10856. /** @hidden */
  10857. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  10858. /**
  10859. * @hidden
  10860. */
  10861. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  10862. }
  10863. }
  10864. declare module BABYLON {
  10865. /**
  10866. * Class for creating a cube texture
  10867. */
  10868. export class CubeTexture extends BaseTexture {
  10869. private _delayedOnLoad;
  10870. /**
  10871. * Observable triggered once the texture has been loaded.
  10872. */
  10873. onLoadObservable: Observable<CubeTexture>;
  10874. /**
  10875. * The url of the texture
  10876. */
  10877. url: string;
  10878. /**
  10879. * Gets or sets the center of the bounding box associated with the cube texture.
  10880. * It must define where the camera used to render the texture was set
  10881. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  10882. */
  10883. boundingBoxPosition: Vector3;
  10884. private _boundingBoxSize;
  10885. /**
  10886. * Gets or sets the size of the bounding box associated with the cube texture
  10887. * When defined, the cubemap will switch to local mode
  10888. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  10889. * @example https://www.babylonjs-playground.com/#RNASML
  10890. */
  10891. set boundingBoxSize(value: Vector3);
  10892. /**
  10893. * Returns the bounding box size
  10894. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  10895. */
  10896. get boundingBoxSize(): Vector3;
  10897. protected _rotationY: number;
  10898. /**
  10899. * Sets texture matrix rotation angle around Y axis in radians.
  10900. */
  10901. set rotationY(value: number);
  10902. /**
  10903. * Gets texture matrix rotation angle around Y axis radians.
  10904. */
  10905. get rotationY(): number;
  10906. /**
  10907. * Are mip maps generated for this texture or not.
  10908. */
  10909. get noMipmap(): boolean;
  10910. private _noMipmap;
  10911. private _files;
  10912. protected _forcedExtension: Nullable<string>;
  10913. private _extensions;
  10914. private _textureMatrix;
  10915. private _format;
  10916. private _createPolynomials;
  10917. private _loaderOptions;
  10918. /**
  10919. * Creates a cube texture from an array of image urls
  10920. * @param files defines an array of image urls
  10921. * @param scene defines the hosting scene
  10922. * @param noMipmap specifies if mip maps are not used
  10923. * @returns a cube texture
  10924. */
  10925. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  10926. /**
  10927. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  10928. * @param url defines the url of the prefiltered texture
  10929. * @param scene defines the scene the texture is attached to
  10930. * @param forcedExtension defines the extension of the file if different from the url
  10931. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  10932. * @return the prefiltered texture
  10933. */
  10934. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  10935. /**
  10936. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  10937. * as prefiltered data.
  10938. * @param rootUrl defines the url of the texture or the root name of the six images
  10939. * @param null defines the scene or engine the texture is attached to
  10940. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  10941. * @param noMipmap defines if mipmaps should be created or not
  10942. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  10943. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  10944. * @param onError defines a callback triggered in case of error during load
  10945. * @param format defines the internal format to use for the texture once loaded
  10946. * @param prefiltered defines whether or not the texture is created from prefiltered data
  10947. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  10948. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  10949. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10950. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10951. * @param loaderOptions options to be passed to the loader
  10952. * @return the cube texture
  10953. */
  10954. 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);
  10955. /**
  10956. * Get the current class name of the texture useful for serialization or dynamic coding.
  10957. * @returns "CubeTexture"
  10958. */
  10959. getClassName(): string;
  10960. /**
  10961. * Update the url (and optional buffer) of this texture if url was null during construction.
  10962. * @param url the url of the texture
  10963. * @param forcedExtension defines the extension to use
  10964. * @param onLoad callback called when the texture is loaded (defaults to null)
  10965. * @param prefiltered Defines whether the updated texture is prefiltered or not
  10966. */
  10967. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  10968. /**
  10969. * Delays loading of the cube texture
  10970. * @param forcedExtension defines the extension to use
  10971. */
  10972. delayLoad(forcedExtension?: string): void;
  10973. /**
  10974. * Returns the reflection texture matrix
  10975. * @returns the reflection texture matrix
  10976. */
  10977. getReflectionTextureMatrix(): Matrix;
  10978. /**
  10979. * Sets the reflection texture matrix
  10980. * @param value Reflection texture matrix
  10981. */
  10982. setReflectionTextureMatrix(value: Matrix): void;
  10983. /**
  10984. * Parses text to create a cube texture
  10985. * @param parsedTexture define the serialized text to read from
  10986. * @param scene defines the hosting scene
  10987. * @param rootUrl defines the root url of the cube texture
  10988. * @returns a cube texture
  10989. */
  10990. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  10991. /**
  10992. * Makes a clone, or deep copy, of the cube texture
  10993. * @returns a new cube texture
  10994. */
  10995. clone(): CubeTexture;
  10996. }
  10997. }
  10998. declare module BABYLON {
  10999. /**
  11000. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11001. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11002. * 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;
  11003. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11004. */
  11005. export class ColorCurves {
  11006. private _dirty;
  11007. private _tempColor;
  11008. private _globalCurve;
  11009. private _highlightsCurve;
  11010. private _midtonesCurve;
  11011. private _shadowsCurve;
  11012. private _positiveCurve;
  11013. private _negativeCurve;
  11014. private _globalHue;
  11015. private _globalDensity;
  11016. private _globalSaturation;
  11017. private _globalExposure;
  11018. /**
  11019. * Gets the global Hue value.
  11020. * 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).
  11021. */
  11022. get globalHue(): number;
  11023. /**
  11024. * Sets the global Hue value.
  11025. * 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).
  11026. */
  11027. set globalHue(value: number);
  11028. /**
  11029. * Gets the global Density value.
  11030. * 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.
  11031. * Values less than zero provide a filter of opposite hue.
  11032. */
  11033. get globalDensity(): number;
  11034. /**
  11035. * Sets the global Density value.
  11036. * 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.
  11037. * Values less than zero provide a filter of opposite hue.
  11038. */
  11039. set globalDensity(value: number);
  11040. /**
  11041. * Gets the global Saturation value.
  11042. * 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.
  11043. */
  11044. get globalSaturation(): number;
  11045. /**
  11046. * Sets the global Saturation value.
  11047. * 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.
  11048. */
  11049. set globalSaturation(value: number);
  11050. /**
  11051. * Gets the global Exposure value.
  11052. * 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.
  11053. */
  11054. get globalExposure(): number;
  11055. /**
  11056. * Sets the global Exposure value.
  11057. * 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.
  11058. */
  11059. set globalExposure(value: number);
  11060. private _highlightsHue;
  11061. private _highlightsDensity;
  11062. private _highlightsSaturation;
  11063. private _highlightsExposure;
  11064. /**
  11065. * Gets the highlights Hue value.
  11066. * 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).
  11067. */
  11068. get highlightsHue(): number;
  11069. /**
  11070. * Sets the highlights Hue value.
  11071. * 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).
  11072. */
  11073. set highlightsHue(value: number);
  11074. /**
  11075. * Gets the highlights Density value.
  11076. * 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.
  11077. * Values less than zero provide a filter of opposite hue.
  11078. */
  11079. get highlightsDensity(): number;
  11080. /**
  11081. * Sets the highlights Density value.
  11082. * 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.
  11083. * Values less than zero provide a filter of opposite hue.
  11084. */
  11085. set highlightsDensity(value: number);
  11086. /**
  11087. * Gets the highlights Saturation value.
  11088. * 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.
  11089. */
  11090. get highlightsSaturation(): number;
  11091. /**
  11092. * Sets the highlights Saturation value.
  11093. * 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.
  11094. */
  11095. set highlightsSaturation(value: number);
  11096. /**
  11097. * Gets the highlights Exposure value.
  11098. * 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.
  11099. */
  11100. get highlightsExposure(): number;
  11101. /**
  11102. * Sets the highlights Exposure value.
  11103. * 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.
  11104. */
  11105. set highlightsExposure(value: number);
  11106. private _midtonesHue;
  11107. private _midtonesDensity;
  11108. private _midtonesSaturation;
  11109. private _midtonesExposure;
  11110. /**
  11111. * Gets the midtones Hue value.
  11112. * 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).
  11113. */
  11114. get midtonesHue(): number;
  11115. /**
  11116. * Sets the midtones Hue value.
  11117. * 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).
  11118. */
  11119. set midtonesHue(value: number);
  11120. /**
  11121. * Gets the midtones Density value.
  11122. * 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.
  11123. * Values less than zero provide a filter of opposite hue.
  11124. */
  11125. get midtonesDensity(): number;
  11126. /**
  11127. * Sets the midtones Density value.
  11128. * 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.
  11129. * Values less than zero provide a filter of opposite hue.
  11130. */
  11131. set midtonesDensity(value: number);
  11132. /**
  11133. * Gets the midtones Saturation value.
  11134. * 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.
  11135. */
  11136. get midtonesSaturation(): number;
  11137. /**
  11138. * Sets the midtones Saturation value.
  11139. * 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.
  11140. */
  11141. set midtonesSaturation(value: number);
  11142. /**
  11143. * Gets the midtones Exposure value.
  11144. * 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.
  11145. */
  11146. get midtonesExposure(): number;
  11147. /**
  11148. * Sets the midtones Exposure value.
  11149. * 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.
  11150. */
  11151. set midtonesExposure(value: number);
  11152. private _shadowsHue;
  11153. private _shadowsDensity;
  11154. private _shadowsSaturation;
  11155. private _shadowsExposure;
  11156. /**
  11157. * Gets the shadows Hue value.
  11158. * 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).
  11159. */
  11160. get shadowsHue(): number;
  11161. /**
  11162. * Sets the shadows Hue value.
  11163. * 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).
  11164. */
  11165. set shadowsHue(value: number);
  11166. /**
  11167. * Gets the shadows Density value.
  11168. * 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.
  11169. * Values less than zero provide a filter of opposite hue.
  11170. */
  11171. get shadowsDensity(): number;
  11172. /**
  11173. * Sets the shadows Density value.
  11174. * 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.
  11175. * Values less than zero provide a filter of opposite hue.
  11176. */
  11177. set shadowsDensity(value: number);
  11178. /**
  11179. * Gets the shadows Saturation value.
  11180. * 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.
  11181. */
  11182. get shadowsSaturation(): number;
  11183. /**
  11184. * Sets the shadows Saturation value.
  11185. * 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.
  11186. */
  11187. set shadowsSaturation(value: number);
  11188. /**
  11189. * Gets the shadows Exposure value.
  11190. * 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.
  11191. */
  11192. get shadowsExposure(): number;
  11193. /**
  11194. * Sets the shadows Exposure value.
  11195. * 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.
  11196. */
  11197. set shadowsExposure(value: number);
  11198. /**
  11199. * Returns the class name
  11200. * @returns The class name
  11201. */
  11202. getClassName(): string;
  11203. /**
  11204. * Binds the color curves to the shader.
  11205. * @param colorCurves The color curve to bind
  11206. * @param effect The effect to bind to
  11207. * @param positiveUniform The positive uniform shader parameter
  11208. * @param neutralUniform The neutral uniform shader parameter
  11209. * @param negativeUniform The negative uniform shader parameter
  11210. */
  11211. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11212. /**
  11213. * Prepare the list of uniforms associated with the ColorCurves effects.
  11214. * @param uniformsList The list of uniforms used in the effect
  11215. */
  11216. static PrepareUniforms(uniformsList: string[]): void;
  11217. /**
  11218. * Returns color grading data based on a hue, density, saturation and exposure value.
  11219. * @param filterHue The hue of the color filter.
  11220. * @param filterDensity The density of the color filter.
  11221. * @param saturation The saturation.
  11222. * @param exposure The exposure.
  11223. * @param result The result data container.
  11224. */
  11225. private getColorGradingDataToRef;
  11226. /**
  11227. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11228. * @param value The input slider value in range [-100,100].
  11229. * @returns Adjusted value.
  11230. */
  11231. private static applyColorGradingSliderNonlinear;
  11232. /**
  11233. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11234. * @param hue The hue (H) input.
  11235. * @param saturation The saturation (S) input.
  11236. * @param brightness The brightness (B) input.
  11237. * @result An RGBA color represented as Vector4.
  11238. */
  11239. private static fromHSBToRef;
  11240. /**
  11241. * Returns a value clamped between min and max
  11242. * @param value The value to clamp
  11243. * @param min The minimum of value
  11244. * @param max The maximum of value
  11245. * @returns The clamped value.
  11246. */
  11247. private static clamp;
  11248. /**
  11249. * Clones the current color curve instance.
  11250. * @return The cloned curves
  11251. */
  11252. clone(): ColorCurves;
  11253. /**
  11254. * Serializes the current color curve instance to a json representation.
  11255. * @return a JSON representation
  11256. */
  11257. serialize(): any;
  11258. /**
  11259. * Parses the color curve from a json representation.
  11260. * @param source the JSON source to parse
  11261. * @return The parsed curves
  11262. */
  11263. static Parse(source: any): ColorCurves;
  11264. }
  11265. }
  11266. declare module BABYLON {
  11267. /**
  11268. * Interface to follow in your material defines to integrate easily the
  11269. * Image proccessing functions.
  11270. * @hidden
  11271. */
  11272. export interface IImageProcessingConfigurationDefines {
  11273. IMAGEPROCESSING: boolean;
  11274. VIGNETTE: boolean;
  11275. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11276. VIGNETTEBLENDMODEOPAQUE: boolean;
  11277. TONEMAPPING: boolean;
  11278. TONEMAPPING_ACES: boolean;
  11279. CONTRAST: boolean;
  11280. EXPOSURE: boolean;
  11281. COLORCURVES: boolean;
  11282. COLORGRADING: boolean;
  11283. COLORGRADING3D: boolean;
  11284. SAMPLER3DGREENDEPTH: boolean;
  11285. SAMPLER3DBGRMAP: boolean;
  11286. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11287. }
  11288. /**
  11289. * @hidden
  11290. */
  11291. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11292. IMAGEPROCESSING: boolean;
  11293. VIGNETTE: boolean;
  11294. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11295. VIGNETTEBLENDMODEOPAQUE: boolean;
  11296. TONEMAPPING: boolean;
  11297. TONEMAPPING_ACES: boolean;
  11298. CONTRAST: boolean;
  11299. COLORCURVES: boolean;
  11300. COLORGRADING: boolean;
  11301. COLORGRADING3D: boolean;
  11302. SAMPLER3DGREENDEPTH: boolean;
  11303. SAMPLER3DBGRMAP: boolean;
  11304. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11305. EXPOSURE: boolean;
  11306. constructor();
  11307. }
  11308. /**
  11309. * This groups together the common properties used for image processing either in direct forward pass
  11310. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11311. * or not.
  11312. */
  11313. export class ImageProcessingConfiguration {
  11314. /**
  11315. * Default tone mapping applied in BabylonJS.
  11316. */
  11317. static readonly TONEMAPPING_STANDARD: number;
  11318. /**
  11319. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11320. * to other engines rendering to increase portability.
  11321. */
  11322. static readonly TONEMAPPING_ACES: number;
  11323. /**
  11324. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11325. */
  11326. colorCurves: Nullable<ColorCurves>;
  11327. private _colorCurvesEnabled;
  11328. /**
  11329. * Gets wether the color curves effect is enabled.
  11330. */
  11331. get colorCurvesEnabled(): boolean;
  11332. /**
  11333. * Sets wether the color curves effect is enabled.
  11334. */
  11335. set colorCurvesEnabled(value: boolean);
  11336. private _colorGradingTexture;
  11337. /**
  11338. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11339. */
  11340. get colorGradingTexture(): Nullable<BaseTexture>;
  11341. /**
  11342. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11343. */
  11344. set colorGradingTexture(value: Nullable<BaseTexture>);
  11345. private _colorGradingEnabled;
  11346. /**
  11347. * Gets wether the color grading effect is enabled.
  11348. */
  11349. get colorGradingEnabled(): boolean;
  11350. /**
  11351. * Sets wether the color grading effect is enabled.
  11352. */
  11353. set colorGradingEnabled(value: boolean);
  11354. private _colorGradingWithGreenDepth;
  11355. /**
  11356. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11357. */
  11358. get colorGradingWithGreenDepth(): boolean;
  11359. /**
  11360. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11361. */
  11362. set colorGradingWithGreenDepth(value: boolean);
  11363. private _colorGradingBGR;
  11364. /**
  11365. * Gets wether the color grading texture contains BGR values.
  11366. */
  11367. get colorGradingBGR(): boolean;
  11368. /**
  11369. * Sets wether the color grading texture contains BGR values.
  11370. */
  11371. set colorGradingBGR(value: boolean);
  11372. /** @hidden */
  11373. _exposure: number;
  11374. /**
  11375. * Gets the Exposure used in the effect.
  11376. */
  11377. get exposure(): number;
  11378. /**
  11379. * Sets the Exposure used in the effect.
  11380. */
  11381. set exposure(value: number);
  11382. private _toneMappingEnabled;
  11383. /**
  11384. * Gets wether the tone mapping effect is enabled.
  11385. */
  11386. get toneMappingEnabled(): boolean;
  11387. /**
  11388. * Sets wether the tone mapping effect is enabled.
  11389. */
  11390. set toneMappingEnabled(value: boolean);
  11391. private _toneMappingType;
  11392. /**
  11393. * Gets the type of tone mapping effect.
  11394. */
  11395. get toneMappingType(): number;
  11396. /**
  11397. * Sets the type of tone mapping effect used in BabylonJS.
  11398. */
  11399. set toneMappingType(value: number);
  11400. protected _contrast: number;
  11401. /**
  11402. * Gets the contrast used in the effect.
  11403. */
  11404. get contrast(): number;
  11405. /**
  11406. * Sets the contrast used in the effect.
  11407. */
  11408. set contrast(value: number);
  11409. /**
  11410. * Vignette stretch size.
  11411. */
  11412. vignetteStretch: number;
  11413. /**
  11414. * Vignette centre X Offset.
  11415. */
  11416. vignetteCentreX: number;
  11417. /**
  11418. * Vignette centre Y Offset.
  11419. */
  11420. vignetteCentreY: number;
  11421. /**
  11422. * Vignette weight or intensity of the vignette effect.
  11423. */
  11424. vignetteWeight: number;
  11425. /**
  11426. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  11427. * if vignetteEnabled is set to true.
  11428. */
  11429. vignetteColor: Color4;
  11430. /**
  11431. * Camera field of view used by the Vignette effect.
  11432. */
  11433. vignetteCameraFov: number;
  11434. private _vignetteBlendMode;
  11435. /**
  11436. * Gets the vignette blend mode allowing different kind of effect.
  11437. */
  11438. get vignetteBlendMode(): number;
  11439. /**
  11440. * Sets the vignette blend mode allowing different kind of effect.
  11441. */
  11442. set vignetteBlendMode(value: number);
  11443. private _vignetteEnabled;
  11444. /**
  11445. * Gets wether the vignette effect is enabled.
  11446. */
  11447. get vignetteEnabled(): boolean;
  11448. /**
  11449. * Sets wether the vignette effect is enabled.
  11450. */
  11451. set vignetteEnabled(value: boolean);
  11452. private _applyByPostProcess;
  11453. /**
  11454. * Gets wether the image processing is applied through a post process or not.
  11455. */
  11456. get applyByPostProcess(): boolean;
  11457. /**
  11458. * Sets wether the image processing is applied through a post process or not.
  11459. */
  11460. set applyByPostProcess(value: boolean);
  11461. private _isEnabled;
  11462. /**
  11463. * Gets wether the image processing is enabled or not.
  11464. */
  11465. get isEnabled(): boolean;
  11466. /**
  11467. * Sets wether the image processing is enabled or not.
  11468. */
  11469. set isEnabled(value: boolean);
  11470. /**
  11471. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  11472. */
  11473. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  11474. /**
  11475. * Method called each time the image processing information changes requires to recompile the effect.
  11476. */
  11477. protected _updateParameters(): void;
  11478. /**
  11479. * Gets the current class name.
  11480. * @return "ImageProcessingConfiguration"
  11481. */
  11482. getClassName(): string;
  11483. /**
  11484. * Prepare the list of uniforms associated with the Image Processing effects.
  11485. * @param uniforms The list of uniforms used in the effect
  11486. * @param defines the list of defines currently in use
  11487. */
  11488. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  11489. /**
  11490. * Prepare the list of samplers associated with the Image Processing effects.
  11491. * @param samplersList The list of uniforms used in the effect
  11492. * @param defines the list of defines currently in use
  11493. */
  11494. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  11495. /**
  11496. * Prepare the list of defines associated to the shader.
  11497. * @param defines the list of defines to complete
  11498. * @param forPostProcess Define if we are currently in post process mode or not
  11499. */
  11500. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  11501. /**
  11502. * Returns true if all the image processing information are ready.
  11503. * @returns True if ready, otherwise, false
  11504. */
  11505. isReady(): boolean;
  11506. /**
  11507. * Binds the image processing to the shader.
  11508. * @param effect The effect to bind to
  11509. * @param overrideAspectRatio Override the aspect ratio of the effect
  11510. */
  11511. bind(effect: Effect, overrideAspectRatio?: number): void;
  11512. /**
  11513. * Clones the current image processing instance.
  11514. * @return The cloned image processing
  11515. */
  11516. clone(): ImageProcessingConfiguration;
  11517. /**
  11518. * Serializes the current image processing instance to a json representation.
  11519. * @return a JSON representation
  11520. */
  11521. serialize(): any;
  11522. /**
  11523. * Parses the image processing from a json representation.
  11524. * @param source the JSON source to parse
  11525. * @return The parsed image processing
  11526. */
  11527. static Parse(source: any): ImageProcessingConfiguration;
  11528. private static _VIGNETTEMODE_MULTIPLY;
  11529. private static _VIGNETTEMODE_OPAQUE;
  11530. /**
  11531. * Used to apply the vignette as a mix with the pixel color.
  11532. */
  11533. static get VIGNETTEMODE_MULTIPLY(): number;
  11534. /**
  11535. * Used to apply the vignette as a replacement of the pixel color.
  11536. */
  11537. static get VIGNETTEMODE_OPAQUE(): number;
  11538. }
  11539. }
  11540. declare module BABYLON {
  11541. /** @hidden */
  11542. export var postprocessVertexShader: {
  11543. name: string;
  11544. shader: string;
  11545. };
  11546. }
  11547. declare module BABYLON {
  11548. /**
  11549. * Type used to define a render target texture size (either with a number or with a rect width and height)
  11550. */
  11551. export type RenderTargetTextureSize = number | {
  11552. width: number;
  11553. height: number;
  11554. layers?: number;
  11555. };
  11556. interface ThinEngine {
  11557. /**
  11558. * Creates a new render target texture
  11559. * @param size defines the size of the texture
  11560. * @param options defines the options used to create the texture
  11561. * @returns a new render target texture stored in an InternalTexture
  11562. */
  11563. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11564. /**
  11565. * Creates a depth stencil texture.
  11566. * This is only available in WebGL 2 or with the depth texture extension available.
  11567. * @param size The size of face edge in the texture.
  11568. * @param options The options defining the texture.
  11569. * @returns The texture
  11570. */
  11571. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11572. /** @hidden */
  11573. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11574. }
  11575. }
  11576. declare module BABYLON {
  11577. /**
  11578. * Defines the kind of connection point for node based material
  11579. */
  11580. export enum NodeMaterialBlockConnectionPointTypes {
  11581. /** Float */
  11582. Float = 1,
  11583. /** Int */
  11584. Int = 2,
  11585. /** Vector2 */
  11586. Vector2 = 4,
  11587. /** Vector3 */
  11588. Vector3 = 8,
  11589. /** Vector4 */
  11590. Vector4 = 16,
  11591. /** Color3 */
  11592. Color3 = 32,
  11593. /** Color4 */
  11594. Color4 = 64,
  11595. /** Matrix */
  11596. Matrix = 128,
  11597. /** Custom object */
  11598. Object = 256,
  11599. /** Detect type based on connection */
  11600. AutoDetect = 1024,
  11601. /** Output type that will be defined by input type */
  11602. BasedOnInput = 2048
  11603. }
  11604. }
  11605. declare module BABYLON {
  11606. /**
  11607. * Enum used to define the target of a block
  11608. */
  11609. export enum NodeMaterialBlockTargets {
  11610. /** Vertex shader */
  11611. Vertex = 1,
  11612. /** Fragment shader */
  11613. Fragment = 2,
  11614. /** Neutral */
  11615. Neutral = 4,
  11616. /** Vertex and Fragment */
  11617. VertexAndFragment = 3
  11618. }
  11619. }
  11620. declare module BABYLON {
  11621. /**
  11622. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  11623. */
  11624. export enum NodeMaterialBlockConnectionPointMode {
  11625. /** Value is an uniform */
  11626. Uniform = 0,
  11627. /** Value is a mesh attribute */
  11628. Attribute = 1,
  11629. /** Value is a varying between vertex and fragment shaders */
  11630. Varying = 2,
  11631. /** Mode is undefined */
  11632. Undefined = 3
  11633. }
  11634. }
  11635. declare module BABYLON {
  11636. /**
  11637. * Enum used to define system values e.g. values automatically provided by the system
  11638. */
  11639. export enum NodeMaterialSystemValues {
  11640. /** World */
  11641. World = 1,
  11642. /** View */
  11643. View = 2,
  11644. /** Projection */
  11645. Projection = 3,
  11646. /** ViewProjection */
  11647. ViewProjection = 4,
  11648. /** WorldView */
  11649. WorldView = 5,
  11650. /** WorldViewProjection */
  11651. WorldViewProjection = 6,
  11652. /** CameraPosition */
  11653. CameraPosition = 7,
  11654. /** Fog Color */
  11655. FogColor = 8,
  11656. /** Delta time */
  11657. DeltaTime = 9
  11658. }
  11659. }
  11660. declare module BABYLON {
  11661. /**
  11662. * Represents a camera frustum
  11663. */
  11664. export class Frustum {
  11665. /**
  11666. * Gets the planes representing the frustum
  11667. * @param transform matrix to be applied to the returned planes
  11668. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  11669. */
  11670. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  11671. /**
  11672. * Gets the near frustum plane transformed by the transform matrix
  11673. * @param transform transformation matrix to be applied to the resulting frustum plane
  11674. * @param frustumPlane the resuling frustum plane
  11675. */
  11676. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11677. /**
  11678. * Gets the far frustum plane transformed by the transform matrix
  11679. * @param transform transformation matrix to be applied to the resulting frustum plane
  11680. * @param frustumPlane the resuling frustum plane
  11681. */
  11682. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11683. /**
  11684. * Gets the left frustum plane transformed by the transform matrix
  11685. * @param transform transformation matrix to be applied to the resulting frustum plane
  11686. * @param frustumPlane the resuling frustum plane
  11687. */
  11688. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11689. /**
  11690. * Gets the right frustum plane transformed by the transform matrix
  11691. * @param transform transformation matrix to be applied to the resulting frustum plane
  11692. * @param frustumPlane the resuling frustum plane
  11693. */
  11694. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11695. /**
  11696. * Gets the top frustum plane transformed by the transform matrix
  11697. * @param transform transformation matrix to be applied to the resulting frustum plane
  11698. * @param frustumPlane the resuling frustum plane
  11699. */
  11700. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11701. /**
  11702. * Gets the bottom frustum plane transformed by the transform matrix
  11703. * @param transform transformation matrix to be applied to the resulting frustum plane
  11704. * @param frustumPlane the resuling frustum plane
  11705. */
  11706. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11707. /**
  11708. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  11709. * @param transform transformation matrix to be applied to the resulting frustum planes
  11710. * @param frustumPlanes the resuling frustum planes
  11711. */
  11712. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  11713. }
  11714. }
  11715. declare module BABYLON {
  11716. /**
  11717. * Contains position and normal vectors for a vertex
  11718. */
  11719. export class PositionNormalVertex {
  11720. /** the position of the vertex (defaut: 0,0,0) */
  11721. position: Vector3;
  11722. /** the normal of the vertex (defaut: 0,1,0) */
  11723. normal: Vector3;
  11724. /**
  11725. * Creates a PositionNormalVertex
  11726. * @param position the position of the vertex (defaut: 0,0,0)
  11727. * @param normal the normal of the vertex (defaut: 0,1,0)
  11728. */
  11729. constructor(
  11730. /** the position of the vertex (defaut: 0,0,0) */
  11731. position?: Vector3,
  11732. /** the normal of the vertex (defaut: 0,1,0) */
  11733. normal?: Vector3);
  11734. /**
  11735. * Clones the PositionNormalVertex
  11736. * @returns the cloned PositionNormalVertex
  11737. */
  11738. clone(): PositionNormalVertex;
  11739. }
  11740. /**
  11741. * Contains position, normal and uv vectors for a vertex
  11742. */
  11743. export class PositionNormalTextureVertex {
  11744. /** the position of the vertex (defaut: 0,0,0) */
  11745. position: Vector3;
  11746. /** the normal of the vertex (defaut: 0,1,0) */
  11747. normal: Vector3;
  11748. /** the uv of the vertex (default: 0,0) */
  11749. uv: Vector2;
  11750. /**
  11751. * Creates a PositionNormalTextureVertex
  11752. * @param position the position of the vertex (defaut: 0,0,0)
  11753. * @param normal the normal of the vertex (defaut: 0,1,0)
  11754. * @param uv the uv of the vertex (default: 0,0)
  11755. */
  11756. constructor(
  11757. /** the position of the vertex (defaut: 0,0,0) */
  11758. position?: Vector3,
  11759. /** the normal of the vertex (defaut: 0,1,0) */
  11760. normal?: Vector3,
  11761. /** the uv of the vertex (default: 0,0) */
  11762. uv?: Vector2);
  11763. /**
  11764. * Clones the PositionNormalTextureVertex
  11765. * @returns the cloned PositionNormalTextureVertex
  11766. */
  11767. clone(): PositionNormalTextureVertex;
  11768. }
  11769. }
  11770. declare module BABYLON {
  11771. /**
  11772. * Enum defining the type of animations supported by InputBlock
  11773. */
  11774. export enum AnimatedInputBlockTypes {
  11775. /** No animation */
  11776. None = 0,
  11777. /** Time based animation. Will only work for floats */
  11778. Time = 1
  11779. }
  11780. }
  11781. declare module BABYLON {
  11782. /**
  11783. * Block used to expose an input value
  11784. */
  11785. export class InputBlock extends NodeMaterialBlock {
  11786. private _mode;
  11787. private _associatedVariableName;
  11788. private _storedValue;
  11789. private _valueCallback;
  11790. private _type;
  11791. private _animationType;
  11792. /** Gets or set a value used to limit the range of float values */
  11793. min: number;
  11794. /** Gets or set a value used to limit the range of float values */
  11795. max: number;
  11796. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  11797. isBoolean: boolean;
  11798. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  11799. matrixMode: number;
  11800. /** @hidden */
  11801. _systemValue: Nullable<NodeMaterialSystemValues>;
  11802. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  11803. isConstant: boolean;
  11804. /** Gets or sets the group to use to display this block in the Inspector */
  11805. groupInInspector: string;
  11806. /** Gets an observable raised when the value is changed */
  11807. onValueChangedObservable: Observable<InputBlock>;
  11808. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  11809. convertToGammaSpace: boolean;
  11810. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  11811. convertToLinearSpace: boolean;
  11812. /**
  11813. * Gets or sets the connection point type (default is float)
  11814. */
  11815. get type(): NodeMaterialBlockConnectionPointTypes;
  11816. /**
  11817. * Creates a new InputBlock
  11818. * @param name defines the block name
  11819. * @param target defines the target of that block (Vertex by default)
  11820. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  11821. */
  11822. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  11823. /**
  11824. * Validates if a name is a reserve word.
  11825. * @param newName the new name to be given to the node.
  11826. * @returns false if the name is a reserve word, else true.
  11827. */
  11828. validateBlockName(newName: string): boolean;
  11829. /**
  11830. * Gets the output component
  11831. */
  11832. get output(): NodeMaterialConnectionPoint;
  11833. /**
  11834. * Set the source of this connection point to a vertex attribute
  11835. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  11836. * @returns the current connection point
  11837. */
  11838. setAsAttribute(attributeName?: string): InputBlock;
  11839. /**
  11840. * Set the source of this connection point to a system value
  11841. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  11842. * @returns the current connection point
  11843. */
  11844. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  11845. /**
  11846. * Gets or sets the value of that point.
  11847. * Please note that this value will be ignored if valueCallback is defined
  11848. */
  11849. get value(): any;
  11850. set value(value: any);
  11851. /**
  11852. * Gets or sets a callback used to get the value of that point.
  11853. * Please note that setting this value will force the connection point to ignore the value property
  11854. */
  11855. get valueCallback(): () => any;
  11856. set valueCallback(value: () => any);
  11857. /**
  11858. * Gets or sets the associated variable name in the shader
  11859. */
  11860. get associatedVariableName(): string;
  11861. set associatedVariableName(value: string);
  11862. /** Gets or sets the type of animation applied to the input */
  11863. get animationType(): AnimatedInputBlockTypes;
  11864. set animationType(value: AnimatedInputBlockTypes);
  11865. /**
  11866. * Gets a boolean indicating that this connection point not defined yet
  11867. */
  11868. get isUndefined(): boolean;
  11869. /**
  11870. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  11871. * In this case the connection point name must be the name of the uniform to use.
  11872. * Can only be set on inputs
  11873. */
  11874. get isUniform(): boolean;
  11875. set isUniform(value: boolean);
  11876. /**
  11877. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  11878. * In this case the connection point name must be the name of the attribute to use
  11879. * Can only be set on inputs
  11880. */
  11881. get isAttribute(): boolean;
  11882. set isAttribute(value: boolean);
  11883. /**
  11884. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  11885. * Can only be set on exit points
  11886. */
  11887. get isVarying(): boolean;
  11888. set isVarying(value: boolean);
  11889. /**
  11890. * Gets a boolean indicating that the current connection point is a system value
  11891. */
  11892. get isSystemValue(): boolean;
  11893. /**
  11894. * Gets or sets the current well known value or null if not defined as a system value
  11895. */
  11896. get systemValue(): Nullable<NodeMaterialSystemValues>;
  11897. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  11898. /**
  11899. * Gets the current class name
  11900. * @returns the class name
  11901. */
  11902. getClassName(): string;
  11903. /**
  11904. * Animate the input if animationType !== None
  11905. * @param scene defines the rendering scene
  11906. */
  11907. animate(scene: Scene): void;
  11908. private _emitDefine;
  11909. initialize(state: NodeMaterialBuildState): void;
  11910. /**
  11911. * Set the input block to its default value (based on its type)
  11912. */
  11913. setDefaultValue(): void;
  11914. private _emitConstant;
  11915. /** @hidden */
  11916. get _noContextSwitch(): boolean;
  11917. private _emit;
  11918. /** @hidden */
  11919. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  11920. /** @hidden */
  11921. _transmit(effect: Effect, scene: Scene): void;
  11922. protected _buildBlock(state: NodeMaterialBuildState): void;
  11923. protected _dumpPropertiesCode(): string;
  11924. dispose(): void;
  11925. serialize(): any;
  11926. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  11927. }
  11928. }
  11929. declare module BABYLON {
  11930. /**
  11931. * Enum used to define the compatibility state between two connection points
  11932. */
  11933. export enum NodeMaterialConnectionPointCompatibilityStates {
  11934. /** Points are compatibles */
  11935. Compatible = 0,
  11936. /** Points are incompatible because of their types */
  11937. TypeIncompatible = 1,
  11938. /** Points are incompatible because of their targets (vertex vs fragment) */
  11939. TargetIncompatible = 2
  11940. }
  11941. /**
  11942. * Defines the direction of a connection point
  11943. */
  11944. export enum NodeMaterialConnectionPointDirection {
  11945. /** Input */
  11946. Input = 0,
  11947. /** Output */
  11948. Output = 1
  11949. }
  11950. /**
  11951. * Defines a connection point for a block
  11952. */
  11953. export class NodeMaterialConnectionPoint {
  11954. /**
  11955. * Checks if two types are equivalent
  11956. * @param type1 type 1 to check
  11957. * @param type2 type 2 to check
  11958. * @returns true if both types are equivalent, else false
  11959. */
  11960. static AreEquivalentTypes(type1: number, type2: number): boolean;
  11961. /** @hidden */
  11962. _ownerBlock: NodeMaterialBlock;
  11963. /** @hidden */
  11964. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  11965. private _endpoints;
  11966. private _associatedVariableName;
  11967. private _direction;
  11968. /** @hidden */
  11969. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  11970. /** @hidden */
  11971. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  11972. /** @hidden */
  11973. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  11974. private _type;
  11975. /** @hidden */
  11976. _enforceAssociatedVariableName: boolean;
  11977. /** Gets the direction of the point */
  11978. get direction(): NodeMaterialConnectionPointDirection;
  11979. /** Indicates that this connection point needs dual validation before being connected to another point */
  11980. needDualDirectionValidation: boolean;
  11981. /**
  11982. * Gets or sets the additional types supported by this connection point
  11983. */
  11984. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  11985. /**
  11986. * Gets or sets the additional types excluded by this connection point
  11987. */
  11988. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  11989. /**
  11990. * Observable triggered when this point is connected
  11991. */
  11992. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  11993. /**
  11994. * Gets or sets the associated variable name in the shader
  11995. */
  11996. get associatedVariableName(): string;
  11997. set associatedVariableName(value: string);
  11998. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  11999. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12000. /**
  12001. * Gets or sets the connection point type (default is float)
  12002. */
  12003. get type(): NodeMaterialBlockConnectionPointTypes;
  12004. set type(value: NodeMaterialBlockConnectionPointTypes);
  12005. /**
  12006. * Gets or sets the connection point name
  12007. */
  12008. name: string;
  12009. /**
  12010. * Gets or sets the connection point name
  12011. */
  12012. displayName: string;
  12013. /**
  12014. * Gets or sets a boolean indicating that this connection point can be omitted
  12015. */
  12016. isOptional: boolean;
  12017. /**
  12018. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12019. */
  12020. isExposedOnFrame: boolean;
  12021. /**
  12022. * Gets or sets number indicating the position that the port is exposed to on a frame
  12023. */
  12024. exposedPortPosition: number;
  12025. /**
  12026. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12027. */
  12028. define: string;
  12029. /** @hidden */
  12030. _prioritizeVertex: boolean;
  12031. private _target;
  12032. /** Gets or sets the target of that connection point */
  12033. get target(): NodeMaterialBlockTargets;
  12034. set target(value: NodeMaterialBlockTargets);
  12035. /**
  12036. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12037. */
  12038. get isConnected(): boolean;
  12039. /**
  12040. * Gets a boolean indicating that the current point is connected to an input block
  12041. */
  12042. get isConnectedToInputBlock(): boolean;
  12043. /**
  12044. * Gets a the connected input block (if any)
  12045. */
  12046. get connectInputBlock(): Nullable<InputBlock>;
  12047. /** Get the other side of the connection (if any) */
  12048. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12049. /** Get the block that owns this connection point */
  12050. get ownerBlock(): NodeMaterialBlock;
  12051. /** Get the block connected on the other side of this connection (if any) */
  12052. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12053. /** Get the block connected on the endpoints of this connection (if any) */
  12054. get connectedBlocks(): Array<NodeMaterialBlock>;
  12055. /** Gets the list of connected endpoints */
  12056. get endpoints(): NodeMaterialConnectionPoint[];
  12057. /** Gets a boolean indicating if that output point is connected to at least one input */
  12058. get hasEndpoints(): boolean;
  12059. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12060. get isConnectedInVertexShader(): boolean;
  12061. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12062. get isConnectedInFragmentShader(): boolean;
  12063. /**
  12064. * Creates a block suitable to be used as an input for this input point.
  12065. * If null is returned, a block based on the point type will be created.
  12066. * @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
  12067. */
  12068. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12069. /**
  12070. * Creates a new connection point
  12071. * @param name defines the connection point name
  12072. * @param ownerBlock defines the block hosting this connection point
  12073. * @param direction defines the direction of the connection point
  12074. */
  12075. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12076. /**
  12077. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12078. * @returns the class name
  12079. */
  12080. getClassName(): string;
  12081. /**
  12082. * Gets a boolean indicating if the current point can be connected to another point
  12083. * @param connectionPoint defines the other connection point
  12084. * @returns a boolean
  12085. */
  12086. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12087. /**
  12088. * Gets a number indicating if the current point can be connected to another point
  12089. * @param connectionPoint defines the other connection point
  12090. * @returns a number defining the compatibility state
  12091. */
  12092. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12093. /**
  12094. * Connect this point to another connection point
  12095. * @param connectionPoint defines the other connection point
  12096. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12097. * @returns the current connection point
  12098. */
  12099. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12100. /**
  12101. * Disconnect this point from one of his endpoint
  12102. * @param endpoint defines the other connection point
  12103. * @returns the current connection point
  12104. */
  12105. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12106. /**
  12107. * Serializes this point in a JSON representation
  12108. * @param isInput defines if the connection point is an input (default is true)
  12109. * @returns the serialized point object
  12110. */
  12111. serialize(isInput?: boolean): any;
  12112. /**
  12113. * Release resources
  12114. */
  12115. dispose(): void;
  12116. }
  12117. }
  12118. declare module BABYLON {
  12119. /**
  12120. * Enum used to define the material modes
  12121. */
  12122. export enum NodeMaterialModes {
  12123. /** Regular material */
  12124. Material = 0,
  12125. /** For post process */
  12126. PostProcess = 1,
  12127. /** For particle system */
  12128. Particle = 2,
  12129. /** For procedural texture */
  12130. ProceduralTexture = 3
  12131. }
  12132. }
  12133. declare module BABYLON {
  12134. /** @hidden */
  12135. export var helperFunctions: {
  12136. name: string;
  12137. shader: string;
  12138. };
  12139. }
  12140. declare module BABYLON {
  12141. /**
  12142. * Block used to read a texture from a sampler
  12143. */
  12144. export class TextureBlock extends NodeMaterialBlock {
  12145. private _defineName;
  12146. private _linearDefineName;
  12147. private _gammaDefineName;
  12148. private _tempTextureRead;
  12149. private _samplerName;
  12150. private _transformedUVName;
  12151. private _textureTransformName;
  12152. private _textureInfoName;
  12153. private _mainUVName;
  12154. private _mainUVDefineName;
  12155. private _fragmentOnly;
  12156. /**
  12157. * Gets or sets the texture associated with the node
  12158. */
  12159. texture: Nullable<Texture>;
  12160. /**
  12161. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12162. */
  12163. convertToGammaSpace: boolean;
  12164. /**
  12165. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12166. */
  12167. convertToLinearSpace: boolean;
  12168. /**
  12169. * Create a new TextureBlock
  12170. * @param name defines the block name
  12171. */
  12172. constructor(name: string, fragmentOnly?: boolean);
  12173. /**
  12174. * Gets the current class name
  12175. * @returns the class name
  12176. */
  12177. getClassName(): string;
  12178. /**
  12179. * Gets the uv input component
  12180. */
  12181. get uv(): NodeMaterialConnectionPoint;
  12182. /**
  12183. * Gets the rgba output component
  12184. */
  12185. get rgba(): NodeMaterialConnectionPoint;
  12186. /**
  12187. * Gets the rgb output component
  12188. */
  12189. get rgb(): NodeMaterialConnectionPoint;
  12190. /**
  12191. * Gets the r output component
  12192. */
  12193. get r(): NodeMaterialConnectionPoint;
  12194. /**
  12195. * Gets the g output component
  12196. */
  12197. get g(): NodeMaterialConnectionPoint;
  12198. /**
  12199. * Gets the b output component
  12200. */
  12201. get b(): NodeMaterialConnectionPoint;
  12202. /**
  12203. * Gets the a output component
  12204. */
  12205. get a(): NodeMaterialConnectionPoint;
  12206. get target(): NodeMaterialBlockTargets;
  12207. autoConfigure(material: NodeMaterial): void;
  12208. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12209. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12210. isReady(): boolean;
  12211. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12212. private get _isMixed();
  12213. private _injectVertexCode;
  12214. private _writeTextureRead;
  12215. private _writeOutput;
  12216. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12217. protected _dumpPropertiesCode(): string;
  12218. serialize(): any;
  12219. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12220. }
  12221. }
  12222. declare module BABYLON {
  12223. /** @hidden */
  12224. export var reflectionFunction: {
  12225. name: string;
  12226. shader: string;
  12227. };
  12228. }
  12229. declare module BABYLON {
  12230. /**
  12231. * Base block used to read a reflection texture from a sampler
  12232. */
  12233. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12234. /** @hidden */
  12235. _define3DName: string;
  12236. /** @hidden */
  12237. _defineCubicName: string;
  12238. /** @hidden */
  12239. _defineExplicitName: string;
  12240. /** @hidden */
  12241. _defineProjectionName: string;
  12242. /** @hidden */
  12243. _defineLocalCubicName: string;
  12244. /** @hidden */
  12245. _defineSphericalName: string;
  12246. /** @hidden */
  12247. _definePlanarName: string;
  12248. /** @hidden */
  12249. _defineEquirectangularName: string;
  12250. /** @hidden */
  12251. _defineMirroredEquirectangularFixedName: string;
  12252. /** @hidden */
  12253. _defineEquirectangularFixedName: string;
  12254. /** @hidden */
  12255. _defineSkyboxName: string;
  12256. /** @hidden */
  12257. _defineOppositeZ: string;
  12258. /** @hidden */
  12259. _cubeSamplerName: string;
  12260. /** @hidden */
  12261. _2DSamplerName: string;
  12262. protected _positionUVWName: string;
  12263. protected _directionWName: string;
  12264. protected _reflectionVectorName: string;
  12265. /** @hidden */
  12266. _reflectionCoordsName: string;
  12267. /** @hidden */
  12268. _reflectionMatrixName: string;
  12269. protected _reflectionColorName: string;
  12270. /**
  12271. * Gets or sets the texture associated with the node
  12272. */
  12273. texture: Nullable<BaseTexture>;
  12274. /**
  12275. * Create a new ReflectionTextureBaseBlock
  12276. * @param name defines the block name
  12277. */
  12278. constructor(name: string);
  12279. /**
  12280. * Gets the current class name
  12281. * @returns the class name
  12282. */
  12283. getClassName(): string;
  12284. /**
  12285. * Gets the world position input component
  12286. */
  12287. abstract get position(): NodeMaterialConnectionPoint;
  12288. /**
  12289. * Gets the world position input component
  12290. */
  12291. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12292. /**
  12293. * Gets the world normal input component
  12294. */
  12295. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12296. /**
  12297. * Gets the world input component
  12298. */
  12299. abstract get world(): NodeMaterialConnectionPoint;
  12300. /**
  12301. * Gets the camera (or eye) position component
  12302. */
  12303. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12304. /**
  12305. * Gets the view input component
  12306. */
  12307. abstract get view(): NodeMaterialConnectionPoint;
  12308. protected _getTexture(): Nullable<BaseTexture>;
  12309. autoConfigure(material: NodeMaterial): void;
  12310. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12311. isReady(): boolean;
  12312. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12313. /**
  12314. * Gets the code to inject in the vertex shader
  12315. * @param state current state of the node material building
  12316. * @returns the shader code
  12317. */
  12318. handleVertexSide(state: NodeMaterialBuildState): string;
  12319. /**
  12320. * Handles the inits for the fragment code path
  12321. * @param state node material build state
  12322. */
  12323. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12324. /**
  12325. * Generates the reflection coords code for the fragment code path
  12326. * @param worldNormalVarName name of the world normal variable
  12327. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12328. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12329. * @returns the shader code
  12330. */
  12331. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12332. /**
  12333. * Generates the reflection color code for the fragment code path
  12334. * @param lodVarName name of the lod variable
  12335. * @param swizzleLookupTexture swizzle to use for the final color variable
  12336. * @returns the shader code
  12337. */
  12338. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12339. /**
  12340. * Generates the code corresponding to the connected output points
  12341. * @param state node material build state
  12342. * @param varName name of the variable to output
  12343. * @returns the shader code
  12344. */
  12345. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12346. protected _buildBlock(state: NodeMaterialBuildState): this;
  12347. protected _dumpPropertiesCode(): string;
  12348. serialize(): any;
  12349. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12350. }
  12351. }
  12352. declare module BABYLON {
  12353. /**
  12354. * Defines a connection point to be used for points with a custom object type
  12355. */
  12356. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12357. private _blockType;
  12358. private _blockName;
  12359. private _nameForCheking?;
  12360. /**
  12361. * Creates a new connection point
  12362. * @param name defines the connection point name
  12363. * @param ownerBlock defines the block hosting this connection point
  12364. * @param direction defines the direction of the connection point
  12365. */
  12366. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12367. /**
  12368. * Gets a number indicating if the current point can be connected to another point
  12369. * @param connectionPoint defines the other connection point
  12370. * @returns a number defining the compatibility state
  12371. */
  12372. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12373. /**
  12374. * Creates a block suitable to be used as an input for this input point.
  12375. * If null is returned, a block based on the point type will be created.
  12376. * @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
  12377. */
  12378. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12379. }
  12380. }
  12381. declare module BABYLON {
  12382. /**
  12383. * Enum defining the type of properties that can be edited in the property pages in the NME
  12384. */
  12385. export enum PropertyTypeForEdition {
  12386. /** property is a boolean */
  12387. Boolean = 0,
  12388. /** property is a float */
  12389. Float = 1,
  12390. /** property is a Vector2 */
  12391. Vector2 = 2,
  12392. /** property is a list of values */
  12393. List = 3
  12394. }
  12395. /**
  12396. * Interface that defines an option in a variable of type list
  12397. */
  12398. export interface IEditablePropertyListOption {
  12399. /** label of the option */
  12400. "label": string;
  12401. /** value of the option */
  12402. "value": number;
  12403. }
  12404. /**
  12405. * Interface that defines the options available for an editable property
  12406. */
  12407. export interface IEditablePropertyOption {
  12408. /** min value */
  12409. "min"?: number;
  12410. /** max value */
  12411. "max"?: number;
  12412. /** notifiers: indicates which actions to take when the property is changed */
  12413. "notifiers"?: {
  12414. /** the material should be rebuilt */
  12415. "rebuild"?: boolean;
  12416. /** the preview should be updated */
  12417. "update"?: boolean;
  12418. };
  12419. /** list of the options for a variable of type list */
  12420. "options"?: IEditablePropertyListOption[];
  12421. }
  12422. /**
  12423. * Interface that describes an editable property
  12424. */
  12425. export interface IPropertyDescriptionForEdition {
  12426. /** name of the property */
  12427. "propertyName": string;
  12428. /** display name of the property */
  12429. "displayName": string;
  12430. /** type of the property */
  12431. "type": PropertyTypeForEdition;
  12432. /** group of the property - all properties with the same group value will be displayed in a specific section */
  12433. "groupName": string;
  12434. /** options for the property */
  12435. "options": IEditablePropertyOption;
  12436. }
  12437. /**
  12438. * Decorator that flags a property in a node material block as being editable
  12439. */
  12440. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  12441. }
  12442. declare module BABYLON {
  12443. /**
  12444. * Block used to implement the refraction part of the sub surface module of the PBR material
  12445. */
  12446. export class RefractionBlock extends NodeMaterialBlock {
  12447. /** @hidden */
  12448. _define3DName: string;
  12449. /** @hidden */
  12450. _refractionMatrixName: string;
  12451. /** @hidden */
  12452. _defineLODRefractionAlpha: string;
  12453. /** @hidden */
  12454. _defineLinearSpecularRefraction: string;
  12455. /** @hidden */
  12456. _defineOppositeZ: string;
  12457. /** @hidden */
  12458. _cubeSamplerName: string;
  12459. /** @hidden */
  12460. _2DSamplerName: string;
  12461. /** @hidden */
  12462. _vRefractionMicrosurfaceInfosName: string;
  12463. /** @hidden */
  12464. _vRefractionInfosName: string;
  12465. private _scene;
  12466. /**
  12467. * The properties below are set by the main PBR block prior to calling methods of this class.
  12468. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  12469. * It's less burden on the user side in the editor part.
  12470. */
  12471. /** @hidden */
  12472. viewConnectionPoint: NodeMaterialConnectionPoint;
  12473. /** @hidden */
  12474. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  12475. /**
  12476. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  12477. * Materials half opaque for instance using refraction could benefit from this control.
  12478. */
  12479. linkRefractionWithTransparency: boolean;
  12480. /**
  12481. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  12482. */
  12483. invertRefractionY: boolean;
  12484. /**
  12485. * Gets or sets the texture associated with the node
  12486. */
  12487. texture: Nullable<BaseTexture>;
  12488. /**
  12489. * Create a new RefractionBlock
  12490. * @param name defines the block name
  12491. */
  12492. constructor(name: string);
  12493. /**
  12494. * Gets the current class name
  12495. * @returns the class name
  12496. */
  12497. getClassName(): string;
  12498. /**
  12499. * Gets the intensity input component
  12500. */
  12501. get intensity(): NodeMaterialConnectionPoint;
  12502. /**
  12503. * Gets the tint at distance input component
  12504. */
  12505. get tintAtDistance(): NodeMaterialConnectionPoint;
  12506. /**
  12507. * Gets the view input component
  12508. */
  12509. get view(): NodeMaterialConnectionPoint;
  12510. /**
  12511. * Gets the refraction object output component
  12512. */
  12513. get refraction(): NodeMaterialConnectionPoint;
  12514. /**
  12515. * Returns true if the block has a texture
  12516. */
  12517. get hasTexture(): boolean;
  12518. protected _getTexture(): Nullable<BaseTexture>;
  12519. autoConfigure(material: NodeMaterial): void;
  12520. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12521. isReady(): boolean;
  12522. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  12523. /**
  12524. * Gets the main code of the block (fragment side)
  12525. * @param state current state of the node material building
  12526. * @returns the shader code
  12527. */
  12528. getCode(state: NodeMaterialBuildState): string;
  12529. protected _buildBlock(state: NodeMaterialBuildState): this;
  12530. protected _dumpPropertiesCode(): string;
  12531. serialize(): any;
  12532. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12533. }
  12534. }
  12535. declare module BABYLON {
  12536. /**
  12537. * Base block used as input for post process
  12538. */
  12539. export class CurrentScreenBlock extends NodeMaterialBlock {
  12540. private _samplerName;
  12541. private _linearDefineName;
  12542. private _gammaDefineName;
  12543. private _mainUVName;
  12544. private _tempTextureRead;
  12545. /**
  12546. * Gets or sets the texture associated with the node
  12547. */
  12548. texture: Nullable<BaseTexture>;
  12549. /**
  12550. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12551. */
  12552. convertToGammaSpace: boolean;
  12553. /**
  12554. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12555. */
  12556. convertToLinearSpace: boolean;
  12557. /**
  12558. * Create a new CurrentScreenBlock
  12559. * @param name defines the block name
  12560. */
  12561. constructor(name: string);
  12562. /**
  12563. * Gets the current class name
  12564. * @returns the class name
  12565. */
  12566. getClassName(): string;
  12567. /**
  12568. * Gets the uv input component
  12569. */
  12570. get uv(): NodeMaterialConnectionPoint;
  12571. /**
  12572. * Gets the rgba output component
  12573. */
  12574. get rgba(): NodeMaterialConnectionPoint;
  12575. /**
  12576. * Gets the rgb output component
  12577. */
  12578. get rgb(): NodeMaterialConnectionPoint;
  12579. /**
  12580. * Gets the r output component
  12581. */
  12582. get r(): NodeMaterialConnectionPoint;
  12583. /**
  12584. * Gets the g output component
  12585. */
  12586. get g(): NodeMaterialConnectionPoint;
  12587. /**
  12588. * Gets the b output component
  12589. */
  12590. get b(): NodeMaterialConnectionPoint;
  12591. /**
  12592. * Gets the a output component
  12593. */
  12594. get a(): NodeMaterialConnectionPoint;
  12595. /**
  12596. * Initialize the block and prepare the context for build
  12597. * @param state defines the state that will be used for the build
  12598. */
  12599. initialize(state: NodeMaterialBuildState): void;
  12600. get target(): NodeMaterialBlockTargets;
  12601. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12602. isReady(): boolean;
  12603. private _injectVertexCode;
  12604. private _writeTextureRead;
  12605. private _writeOutput;
  12606. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12607. serialize(): any;
  12608. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12609. }
  12610. }
  12611. declare module BABYLON {
  12612. /**
  12613. * Base block used for the particle texture
  12614. */
  12615. export class ParticleTextureBlock extends NodeMaterialBlock {
  12616. private _samplerName;
  12617. private _linearDefineName;
  12618. private _gammaDefineName;
  12619. private _tempTextureRead;
  12620. /**
  12621. * Gets or sets the texture associated with the node
  12622. */
  12623. texture: Nullable<BaseTexture>;
  12624. /**
  12625. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12626. */
  12627. convertToGammaSpace: boolean;
  12628. /**
  12629. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12630. */
  12631. convertToLinearSpace: boolean;
  12632. /**
  12633. * Create a new ParticleTextureBlock
  12634. * @param name defines the block name
  12635. */
  12636. constructor(name: string);
  12637. /**
  12638. * Gets the current class name
  12639. * @returns the class name
  12640. */
  12641. getClassName(): string;
  12642. /**
  12643. * Gets the uv input component
  12644. */
  12645. get uv(): NodeMaterialConnectionPoint;
  12646. /**
  12647. * Gets the rgba output component
  12648. */
  12649. get rgba(): NodeMaterialConnectionPoint;
  12650. /**
  12651. * Gets the rgb output component
  12652. */
  12653. get rgb(): NodeMaterialConnectionPoint;
  12654. /**
  12655. * Gets the r output component
  12656. */
  12657. get r(): NodeMaterialConnectionPoint;
  12658. /**
  12659. * Gets the g output component
  12660. */
  12661. get g(): NodeMaterialConnectionPoint;
  12662. /**
  12663. * Gets the b output component
  12664. */
  12665. get b(): NodeMaterialConnectionPoint;
  12666. /**
  12667. * Gets the a output component
  12668. */
  12669. get a(): NodeMaterialConnectionPoint;
  12670. /**
  12671. * Initialize the block and prepare the context for build
  12672. * @param state defines the state that will be used for the build
  12673. */
  12674. initialize(state: NodeMaterialBuildState): void;
  12675. autoConfigure(material: NodeMaterial): void;
  12676. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12677. isReady(): boolean;
  12678. private _writeOutput;
  12679. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12680. serialize(): any;
  12681. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12682. }
  12683. }
  12684. declare module BABYLON {
  12685. /**
  12686. * Class used to store shared data between 2 NodeMaterialBuildState
  12687. */
  12688. export class NodeMaterialBuildStateSharedData {
  12689. /**
  12690. * Gets the list of emitted varyings
  12691. */
  12692. temps: string[];
  12693. /**
  12694. * Gets the list of emitted varyings
  12695. */
  12696. varyings: string[];
  12697. /**
  12698. * Gets the varying declaration string
  12699. */
  12700. varyingDeclaration: string;
  12701. /**
  12702. * Input blocks
  12703. */
  12704. inputBlocks: InputBlock[];
  12705. /**
  12706. * Input blocks
  12707. */
  12708. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  12709. /**
  12710. * Bindable blocks (Blocks that need to set data to the effect)
  12711. */
  12712. bindableBlocks: NodeMaterialBlock[];
  12713. /**
  12714. * List of blocks that can provide a compilation fallback
  12715. */
  12716. blocksWithFallbacks: NodeMaterialBlock[];
  12717. /**
  12718. * List of blocks that can provide a define update
  12719. */
  12720. blocksWithDefines: NodeMaterialBlock[];
  12721. /**
  12722. * List of blocks that can provide a repeatable content
  12723. */
  12724. repeatableContentBlocks: NodeMaterialBlock[];
  12725. /**
  12726. * List of blocks that can provide a dynamic list of uniforms
  12727. */
  12728. dynamicUniformBlocks: NodeMaterialBlock[];
  12729. /**
  12730. * List of blocks that can block the isReady function for the material
  12731. */
  12732. blockingBlocks: NodeMaterialBlock[];
  12733. /**
  12734. * Gets the list of animated inputs
  12735. */
  12736. animatedInputs: InputBlock[];
  12737. /**
  12738. * Build Id used to avoid multiple recompilations
  12739. */
  12740. buildId: number;
  12741. /** List of emitted variables */
  12742. variableNames: {
  12743. [key: string]: number;
  12744. };
  12745. /** List of emitted defines */
  12746. defineNames: {
  12747. [key: string]: number;
  12748. };
  12749. /** Should emit comments? */
  12750. emitComments: boolean;
  12751. /** Emit build activity */
  12752. verbose: boolean;
  12753. /** Gets or sets the hosting scene */
  12754. scene: Scene;
  12755. /**
  12756. * Gets the compilation hints emitted at compilation time
  12757. */
  12758. hints: {
  12759. needWorldViewMatrix: boolean;
  12760. needWorldViewProjectionMatrix: boolean;
  12761. needAlphaBlending: boolean;
  12762. needAlphaTesting: boolean;
  12763. };
  12764. /**
  12765. * List of compilation checks
  12766. */
  12767. checks: {
  12768. emitVertex: boolean;
  12769. emitFragment: boolean;
  12770. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  12771. };
  12772. /**
  12773. * Is vertex program allowed to be empty?
  12774. */
  12775. allowEmptyVertexProgram: boolean;
  12776. /** Creates a new shared data */
  12777. constructor();
  12778. /**
  12779. * Emits console errors and exceptions if there is a failing check
  12780. */
  12781. emitErrors(): void;
  12782. }
  12783. }
  12784. declare module BABYLON {
  12785. /**
  12786. * Class used to store node based material build state
  12787. */
  12788. export class NodeMaterialBuildState {
  12789. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  12790. supportUniformBuffers: boolean;
  12791. /**
  12792. * Gets the list of emitted attributes
  12793. */
  12794. attributes: string[];
  12795. /**
  12796. * Gets the list of emitted uniforms
  12797. */
  12798. uniforms: string[];
  12799. /**
  12800. * Gets the list of emitted constants
  12801. */
  12802. constants: string[];
  12803. /**
  12804. * Gets the list of emitted samplers
  12805. */
  12806. samplers: string[];
  12807. /**
  12808. * Gets the list of emitted functions
  12809. */
  12810. functions: {
  12811. [key: string]: string;
  12812. };
  12813. /**
  12814. * Gets the list of emitted extensions
  12815. */
  12816. extensions: {
  12817. [key: string]: string;
  12818. };
  12819. /**
  12820. * Gets the target of the compilation state
  12821. */
  12822. target: NodeMaterialBlockTargets;
  12823. /**
  12824. * Gets the list of emitted counters
  12825. */
  12826. counters: {
  12827. [key: string]: number;
  12828. };
  12829. /**
  12830. * Shared data between multiple NodeMaterialBuildState instances
  12831. */
  12832. sharedData: NodeMaterialBuildStateSharedData;
  12833. /** @hidden */
  12834. _vertexState: NodeMaterialBuildState;
  12835. /** @hidden */
  12836. _attributeDeclaration: string;
  12837. /** @hidden */
  12838. _uniformDeclaration: string;
  12839. /** @hidden */
  12840. _constantDeclaration: string;
  12841. /** @hidden */
  12842. _samplerDeclaration: string;
  12843. /** @hidden */
  12844. _varyingTransfer: string;
  12845. /** @hidden */
  12846. _injectAtEnd: string;
  12847. private _repeatableContentAnchorIndex;
  12848. /** @hidden */
  12849. _builtCompilationString: string;
  12850. /**
  12851. * Gets the emitted compilation strings
  12852. */
  12853. compilationString: string;
  12854. /**
  12855. * Finalize the compilation strings
  12856. * @param state defines the current compilation state
  12857. */
  12858. finalize(state: NodeMaterialBuildState): void;
  12859. /** @hidden */
  12860. get _repeatableContentAnchor(): string;
  12861. /** @hidden */
  12862. _getFreeVariableName(prefix: string): string;
  12863. /** @hidden */
  12864. _getFreeDefineName(prefix: string): string;
  12865. /** @hidden */
  12866. _excludeVariableName(name: string): void;
  12867. /** @hidden */
  12868. _emit2DSampler(name: string): void;
  12869. /** @hidden */
  12870. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  12871. /** @hidden */
  12872. _emitExtension(name: string, extension: string, define?: string): void;
  12873. /** @hidden */
  12874. _emitFunction(name: string, code: string, comments: string): void;
  12875. /** @hidden */
  12876. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  12877. replaceStrings?: {
  12878. search: RegExp;
  12879. replace: string;
  12880. }[];
  12881. repeatKey?: string;
  12882. }): string;
  12883. /** @hidden */
  12884. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  12885. repeatKey?: string;
  12886. removeAttributes?: boolean;
  12887. removeUniforms?: boolean;
  12888. removeVaryings?: boolean;
  12889. removeIfDef?: boolean;
  12890. replaceStrings?: {
  12891. search: RegExp;
  12892. replace: string;
  12893. }[];
  12894. }, storeKey?: string): void;
  12895. /** @hidden */
  12896. _registerTempVariable(name: string): boolean;
  12897. /** @hidden */
  12898. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  12899. /** @hidden */
  12900. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  12901. /** @hidden */
  12902. _emitFloat(value: number): string;
  12903. }
  12904. }
  12905. declare module BABYLON {
  12906. /**
  12907. * Helper class used to generate session unique ID
  12908. */
  12909. export class UniqueIdGenerator {
  12910. private static _UniqueIdCounter;
  12911. /**
  12912. * Gets an unique (relatively to the current scene) Id
  12913. */
  12914. static get UniqueId(): number;
  12915. }
  12916. }
  12917. declare module BABYLON {
  12918. /**
  12919. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  12920. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  12921. */
  12922. export class EffectFallbacks implements IEffectFallbacks {
  12923. private _defines;
  12924. private _currentRank;
  12925. private _maxRank;
  12926. private _mesh;
  12927. /**
  12928. * Removes the fallback from the bound mesh.
  12929. */
  12930. unBindMesh(): void;
  12931. /**
  12932. * Adds a fallback on the specified property.
  12933. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12934. * @param define The name of the define in the shader
  12935. */
  12936. addFallback(rank: number, define: string): void;
  12937. /**
  12938. * Sets the mesh to use CPU skinning when needing to fallback.
  12939. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  12940. * @param mesh The mesh to use the fallbacks.
  12941. */
  12942. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  12943. /**
  12944. * Checks to see if more fallbacks are still availible.
  12945. */
  12946. get hasMoreFallbacks(): boolean;
  12947. /**
  12948. * Removes the defines that should be removed when falling back.
  12949. * @param currentDefines defines the current define statements for the shader.
  12950. * @param effect defines the current effect we try to compile
  12951. * @returns The resulting defines with defines of the current rank removed.
  12952. */
  12953. reduce(currentDefines: string, effect: Effect): string;
  12954. }
  12955. }
  12956. declare module BABYLON {
  12957. /**
  12958. * Defines a block that can be used inside a node based material
  12959. */
  12960. export class NodeMaterialBlock {
  12961. private _buildId;
  12962. private _buildTarget;
  12963. private _target;
  12964. private _isFinalMerger;
  12965. private _isInput;
  12966. private _name;
  12967. protected _isUnique: boolean;
  12968. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  12969. inputsAreExclusive: boolean;
  12970. /** @hidden */
  12971. _codeVariableName: string;
  12972. /** @hidden */
  12973. _inputs: NodeMaterialConnectionPoint[];
  12974. /** @hidden */
  12975. _outputs: NodeMaterialConnectionPoint[];
  12976. /** @hidden */
  12977. _preparationId: number;
  12978. /**
  12979. * Gets the name of the block
  12980. */
  12981. get name(): string;
  12982. /**
  12983. * Sets the name of the block. Will check if the name is valid.
  12984. */
  12985. set name(newName: string);
  12986. /**
  12987. * Gets or sets the unique id of the node
  12988. */
  12989. uniqueId: number;
  12990. /**
  12991. * Gets or sets the comments associated with this block
  12992. */
  12993. comments: string;
  12994. /**
  12995. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  12996. */
  12997. get isUnique(): boolean;
  12998. /**
  12999. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13000. */
  13001. get isFinalMerger(): boolean;
  13002. /**
  13003. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13004. */
  13005. get isInput(): boolean;
  13006. /**
  13007. * Gets or sets the build Id
  13008. */
  13009. get buildId(): number;
  13010. set buildId(value: number);
  13011. /**
  13012. * Gets or sets the target of the block
  13013. */
  13014. get target(): NodeMaterialBlockTargets;
  13015. set target(value: NodeMaterialBlockTargets);
  13016. /**
  13017. * Gets the list of input points
  13018. */
  13019. get inputs(): NodeMaterialConnectionPoint[];
  13020. /** Gets the list of output points */
  13021. get outputs(): NodeMaterialConnectionPoint[];
  13022. /**
  13023. * Find an input by its name
  13024. * @param name defines the name of the input to look for
  13025. * @returns the input or null if not found
  13026. */
  13027. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13028. /**
  13029. * Find an output by its name
  13030. * @param name defines the name of the outputto look for
  13031. * @returns the output or null if not found
  13032. */
  13033. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13034. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13035. visibleInInspector: boolean;
  13036. /**
  13037. * Creates a new NodeMaterialBlock
  13038. * @param name defines the block name
  13039. * @param target defines the target of that block (Vertex by default)
  13040. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13041. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13042. */
  13043. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13044. /**
  13045. * Initialize the block and prepare the context for build
  13046. * @param state defines the state that will be used for the build
  13047. */
  13048. initialize(state: NodeMaterialBuildState): void;
  13049. /**
  13050. * Bind data to effect. Will only be called for blocks with isBindable === true
  13051. * @param effect defines the effect to bind data to
  13052. * @param nodeMaterial defines the hosting NodeMaterial
  13053. * @param mesh defines the mesh that will be rendered
  13054. * @param subMesh defines the submesh that will be rendered
  13055. */
  13056. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13057. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13058. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13059. protected _writeFloat(value: number): string;
  13060. /**
  13061. * Gets the current class name e.g. "NodeMaterialBlock"
  13062. * @returns the class name
  13063. */
  13064. getClassName(): string;
  13065. /**
  13066. * Register a new input. Must be called inside a block constructor
  13067. * @param name defines the connection point name
  13068. * @param type defines the connection point type
  13069. * @param isOptional defines a boolean indicating that this input can be omitted
  13070. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13071. * @param point an already created connection point. If not provided, create a new one
  13072. * @returns the current block
  13073. */
  13074. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13075. /**
  13076. * Register a new output. Must be called inside a block constructor
  13077. * @param name defines the connection point name
  13078. * @param type defines the connection point type
  13079. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13080. * @param point an already created connection point. If not provided, create a new one
  13081. * @returns the current block
  13082. */
  13083. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13084. /**
  13085. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13086. * @param forOutput defines an optional connection point to check compatibility with
  13087. * @returns the first available input or null
  13088. */
  13089. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13090. /**
  13091. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13092. * @param forBlock defines an optional block to check compatibility with
  13093. * @returns the first available input or null
  13094. */
  13095. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13096. /**
  13097. * Gets the sibling of the given output
  13098. * @param current defines the current output
  13099. * @returns the next output in the list or null
  13100. */
  13101. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13102. /**
  13103. * Connect current block with another block
  13104. * @param other defines the block to connect with
  13105. * @param options define the various options to help pick the right connections
  13106. * @returns the current block
  13107. */
  13108. connectTo(other: NodeMaterialBlock, options?: {
  13109. input?: string;
  13110. output?: string;
  13111. outputSwizzle?: string;
  13112. }): this | undefined;
  13113. protected _buildBlock(state: NodeMaterialBuildState): void;
  13114. /**
  13115. * Add uniforms, samplers and uniform buffers at compilation time
  13116. * @param state defines the state to update
  13117. * @param nodeMaterial defines the node material requesting the update
  13118. * @param defines defines the material defines to update
  13119. * @param uniformBuffers defines the list of uniform buffer names
  13120. */
  13121. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13122. /**
  13123. * Add potential fallbacks if shader compilation fails
  13124. * @param mesh defines the mesh to be rendered
  13125. * @param fallbacks defines the current prioritized list of fallbacks
  13126. */
  13127. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13128. /**
  13129. * Initialize defines for shader compilation
  13130. * @param mesh defines the mesh to be rendered
  13131. * @param nodeMaterial defines the node material requesting the update
  13132. * @param defines defines the material defines to update
  13133. * @param useInstances specifies that instances should be used
  13134. */
  13135. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13136. /**
  13137. * Update defines for shader compilation
  13138. * @param mesh defines the mesh to be rendered
  13139. * @param nodeMaterial defines the node material requesting the update
  13140. * @param defines defines the material defines to update
  13141. * @param useInstances specifies that instances should be used
  13142. * @param subMesh defines which submesh to render
  13143. */
  13144. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13145. /**
  13146. * Lets the block try to connect some inputs automatically
  13147. * @param material defines the hosting NodeMaterial
  13148. */
  13149. autoConfigure(material: NodeMaterial): void;
  13150. /**
  13151. * Function called when a block is declared as repeatable content generator
  13152. * @param vertexShaderState defines the current compilation state for the vertex shader
  13153. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13154. * @param mesh defines the mesh to be rendered
  13155. * @param defines defines the material defines to update
  13156. */
  13157. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13158. /**
  13159. * Checks if the block is ready
  13160. * @param mesh defines the mesh to be rendered
  13161. * @param nodeMaterial defines the node material requesting the update
  13162. * @param defines defines the material defines to update
  13163. * @param useInstances specifies that instances should be used
  13164. * @returns true if the block is ready
  13165. */
  13166. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13167. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13168. private _processBuild;
  13169. /**
  13170. * Validates the new name for the block node.
  13171. * @param newName the new name to be given to the node.
  13172. * @returns false if the name is a reserve word, else true.
  13173. */
  13174. validateBlockName(newName: string): boolean;
  13175. /**
  13176. * Compile the current node and generate the shader code
  13177. * @param state defines the current compilation state (uniforms, samplers, current string)
  13178. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13179. * @returns true if already built
  13180. */
  13181. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13182. protected _inputRename(name: string): string;
  13183. protected _outputRename(name: string): string;
  13184. protected _dumpPropertiesCode(): string;
  13185. /** @hidden */
  13186. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13187. /** @hidden */
  13188. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13189. /**
  13190. * Clone the current block to a new identical block
  13191. * @param scene defines the hosting scene
  13192. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13193. * @returns a copy of the current block
  13194. */
  13195. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13196. /**
  13197. * Serializes this block in a JSON representation
  13198. * @returns the serialized block object
  13199. */
  13200. serialize(): any;
  13201. /** @hidden */
  13202. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13203. private _deserializePortDisplayNamesAndExposedOnFrame;
  13204. /**
  13205. * Release resources
  13206. */
  13207. dispose(): void;
  13208. }
  13209. }
  13210. declare module BABYLON {
  13211. /**
  13212. * Base class of materials working in push mode in babylon JS
  13213. * @hidden
  13214. */
  13215. export class PushMaterial extends Material {
  13216. protected _activeEffect: Effect;
  13217. protected _normalMatrix: Matrix;
  13218. constructor(name: string, scene: Scene);
  13219. getEffect(): Effect;
  13220. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13221. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13222. /**
  13223. * Binds the given world matrix to the active effect
  13224. *
  13225. * @param world the matrix to bind
  13226. */
  13227. bindOnlyWorldMatrix(world: Matrix): void;
  13228. /**
  13229. * Binds the given normal matrix to the active effect
  13230. *
  13231. * @param normalMatrix the matrix to bind
  13232. */
  13233. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13234. bind(world: Matrix, mesh?: Mesh): void;
  13235. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13236. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13237. }
  13238. }
  13239. declare module BABYLON {
  13240. /**
  13241. * Root class for all node material optimizers
  13242. */
  13243. export class NodeMaterialOptimizer {
  13244. /**
  13245. * Function used to optimize a NodeMaterial graph
  13246. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13247. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13248. */
  13249. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13250. }
  13251. }
  13252. declare module BABYLON {
  13253. /**
  13254. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13255. */
  13256. export class TransformBlock extends NodeMaterialBlock {
  13257. /**
  13258. * Defines the value to use to complement W value to transform it to a Vector4
  13259. */
  13260. complementW: number;
  13261. /**
  13262. * Defines the value to use to complement z value to transform it to a Vector4
  13263. */
  13264. complementZ: number;
  13265. /**
  13266. * Creates a new TransformBlock
  13267. * @param name defines the block name
  13268. */
  13269. constructor(name: string);
  13270. /**
  13271. * Gets the current class name
  13272. * @returns the class name
  13273. */
  13274. getClassName(): string;
  13275. /**
  13276. * Gets the vector input
  13277. */
  13278. get vector(): NodeMaterialConnectionPoint;
  13279. /**
  13280. * Gets the output component
  13281. */
  13282. get output(): NodeMaterialConnectionPoint;
  13283. /**
  13284. * Gets the xyz output component
  13285. */
  13286. get xyz(): NodeMaterialConnectionPoint;
  13287. /**
  13288. * Gets the matrix transform input
  13289. */
  13290. get transform(): NodeMaterialConnectionPoint;
  13291. protected _buildBlock(state: NodeMaterialBuildState): this;
  13292. /**
  13293. * Update defines for shader compilation
  13294. * @param mesh defines the mesh to be rendered
  13295. * @param nodeMaterial defines the node material requesting the update
  13296. * @param defines defines the material defines to update
  13297. * @param useInstances specifies that instances should be used
  13298. * @param subMesh defines which submesh to render
  13299. */
  13300. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13301. serialize(): any;
  13302. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13303. protected _dumpPropertiesCode(): string;
  13304. }
  13305. }
  13306. declare module BABYLON {
  13307. /**
  13308. * Block used to output the vertex position
  13309. */
  13310. export class VertexOutputBlock extends NodeMaterialBlock {
  13311. /**
  13312. * Creates a new VertexOutputBlock
  13313. * @param name defines the block name
  13314. */
  13315. constructor(name: string);
  13316. /**
  13317. * Gets the current class name
  13318. * @returns the class name
  13319. */
  13320. getClassName(): string;
  13321. /**
  13322. * Gets the vector input component
  13323. */
  13324. get vector(): NodeMaterialConnectionPoint;
  13325. protected _buildBlock(state: NodeMaterialBuildState): this;
  13326. }
  13327. }
  13328. declare module BABYLON {
  13329. /**
  13330. * Block used to output the final color
  13331. */
  13332. export class FragmentOutputBlock extends NodeMaterialBlock {
  13333. /**
  13334. * Create a new FragmentOutputBlock
  13335. * @param name defines the block name
  13336. */
  13337. constructor(name: string);
  13338. /**
  13339. * Gets the current class name
  13340. * @returns the class name
  13341. */
  13342. getClassName(): string;
  13343. /**
  13344. * Gets the rgba input component
  13345. */
  13346. get rgba(): NodeMaterialConnectionPoint;
  13347. /**
  13348. * Gets the rgb input component
  13349. */
  13350. get rgb(): NodeMaterialConnectionPoint;
  13351. /**
  13352. * Gets the a input component
  13353. */
  13354. get a(): NodeMaterialConnectionPoint;
  13355. protected _buildBlock(state: NodeMaterialBuildState): this;
  13356. }
  13357. }
  13358. declare module BABYLON {
  13359. /**
  13360. * Block used for the particle ramp gradient section
  13361. */
  13362. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13363. /**
  13364. * Create a new ParticleRampGradientBlock
  13365. * @param name defines the block name
  13366. */
  13367. constructor(name: string);
  13368. /**
  13369. * Gets the current class name
  13370. * @returns the class name
  13371. */
  13372. getClassName(): string;
  13373. /**
  13374. * Gets the color input component
  13375. */
  13376. get color(): NodeMaterialConnectionPoint;
  13377. /**
  13378. * Gets the rampColor output component
  13379. */
  13380. get rampColor(): NodeMaterialConnectionPoint;
  13381. /**
  13382. * Initialize the block and prepare the context for build
  13383. * @param state defines the state that will be used for the build
  13384. */
  13385. initialize(state: NodeMaterialBuildState): void;
  13386. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13387. }
  13388. }
  13389. declare module BABYLON {
  13390. /**
  13391. * Block used for the particle blend multiply section
  13392. */
  13393. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13394. /**
  13395. * Create a new ParticleBlendMultiplyBlock
  13396. * @param name defines the block name
  13397. */
  13398. constructor(name: string);
  13399. /**
  13400. * Gets the current class name
  13401. * @returns the class name
  13402. */
  13403. getClassName(): string;
  13404. /**
  13405. * Gets the color input component
  13406. */
  13407. get color(): NodeMaterialConnectionPoint;
  13408. /**
  13409. * Gets the alphaTexture input component
  13410. */
  13411. get alphaTexture(): NodeMaterialConnectionPoint;
  13412. /**
  13413. * Gets the alphaColor input component
  13414. */
  13415. get alphaColor(): NodeMaterialConnectionPoint;
  13416. /**
  13417. * Gets the blendColor output component
  13418. */
  13419. get blendColor(): NodeMaterialConnectionPoint;
  13420. /**
  13421. * Initialize the block and prepare the context for build
  13422. * @param state defines the state that will be used for the build
  13423. */
  13424. initialize(state: NodeMaterialBuildState): void;
  13425. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13426. }
  13427. }
  13428. declare module BABYLON {
  13429. /**
  13430. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  13431. */
  13432. export class VectorMergerBlock extends NodeMaterialBlock {
  13433. /**
  13434. * Create a new VectorMergerBlock
  13435. * @param name defines the block name
  13436. */
  13437. constructor(name: string);
  13438. /**
  13439. * Gets the current class name
  13440. * @returns the class name
  13441. */
  13442. getClassName(): string;
  13443. /**
  13444. * Gets the xyz component (input)
  13445. */
  13446. get xyzIn(): NodeMaterialConnectionPoint;
  13447. /**
  13448. * Gets the xy component (input)
  13449. */
  13450. get xyIn(): NodeMaterialConnectionPoint;
  13451. /**
  13452. * Gets the x component (input)
  13453. */
  13454. get x(): NodeMaterialConnectionPoint;
  13455. /**
  13456. * Gets the y component (input)
  13457. */
  13458. get y(): NodeMaterialConnectionPoint;
  13459. /**
  13460. * Gets the z component (input)
  13461. */
  13462. get z(): NodeMaterialConnectionPoint;
  13463. /**
  13464. * Gets the w component (input)
  13465. */
  13466. get w(): NodeMaterialConnectionPoint;
  13467. /**
  13468. * Gets the xyzw component (output)
  13469. */
  13470. get xyzw(): NodeMaterialConnectionPoint;
  13471. /**
  13472. * Gets the xyz component (output)
  13473. */
  13474. get xyzOut(): NodeMaterialConnectionPoint;
  13475. /**
  13476. * Gets the xy component (output)
  13477. */
  13478. get xyOut(): NodeMaterialConnectionPoint;
  13479. /**
  13480. * Gets the xy component (output)
  13481. * @deprecated Please use xyOut instead.
  13482. */
  13483. get xy(): NodeMaterialConnectionPoint;
  13484. /**
  13485. * Gets the xyz component (output)
  13486. * @deprecated Please use xyzOut instead.
  13487. */
  13488. get xyz(): NodeMaterialConnectionPoint;
  13489. protected _buildBlock(state: NodeMaterialBuildState): this;
  13490. }
  13491. }
  13492. declare module BABYLON {
  13493. /**
  13494. * Block used to remap a float from a range to a new one
  13495. */
  13496. export class RemapBlock extends NodeMaterialBlock {
  13497. /**
  13498. * Gets or sets the source range
  13499. */
  13500. sourceRange: Vector2;
  13501. /**
  13502. * Gets or sets the target range
  13503. */
  13504. targetRange: Vector2;
  13505. /**
  13506. * Creates a new RemapBlock
  13507. * @param name defines the block name
  13508. */
  13509. constructor(name: string);
  13510. /**
  13511. * Gets the current class name
  13512. * @returns the class name
  13513. */
  13514. getClassName(): string;
  13515. /**
  13516. * Gets the input component
  13517. */
  13518. get input(): NodeMaterialConnectionPoint;
  13519. /**
  13520. * Gets the source min input component
  13521. */
  13522. get sourceMin(): NodeMaterialConnectionPoint;
  13523. /**
  13524. * Gets the source max input component
  13525. */
  13526. get sourceMax(): NodeMaterialConnectionPoint;
  13527. /**
  13528. * Gets the target min input component
  13529. */
  13530. get targetMin(): NodeMaterialConnectionPoint;
  13531. /**
  13532. * Gets the target max input component
  13533. */
  13534. get targetMax(): NodeMaterialConnectionPoint;
  13535. /**
  13536. * Gets the output component
  13537. */
  13538. get output(): NodeMaterialConnectionPoint;
  13539. protected _buildBlock(state: NodeMaterialBuildState): this;
  13540. protected _dumpPropertiesCode(): string;
  13541. serialize(): any;
  13542. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13543. }
  13544. }
  13545. declare module BABYLON {
  13546. /**
  13547. * Block used to multiply 2 values
  13548. */
  13549. export class MultiplyBlock extends NodeMaterialBlock {
  13550. /**
  13551. * Creates a new MultiplyBlock
  13552. * @param name defines the block name
  13553. */
  13554. constructor(name: string);
  13555. /**
  13556. * Gets the current class name
  13557. * @returns the class name
  13558. */
  13559. getClassName(): string;
  13560. /**
  13561. * Gets the left operand input component
  13562. */
  13563. get left(): NodeMaterialConnectionPoint;
  13564. /**
  13565. * Gets the right operand input component
  13566. */
  13567. get right(): NodeMaterialConnectionPoint;
  13568. /**
  13569. * Gets the output component
  13570. */
  13571. get output(): NodeMaterialConnectionPoint;
  13572. protected _buildBlock(state: NodeMaterialBuildState): this;
  13573. }
  13574. }
  13575. declare module BABYLON {
  13576. /** Interface used by value gradients (color, factor, ...) */
  13577. export interface IValueGradient {
  13578. /**
  13579. * Gets or sets the gradient value (between 0 and 1)
  13580. */
  13581. gradient: number;
  13582. }
  13583. /** Class used to store color4 gradient */
  13584. export class ColorGradient implements IValueGradient {
  13585. /**
  13586. * Gets or sets the gradient value (between 0 and 1)
  13587. */
  13588. gradient: number;
  13589. /**
  13590. * Gets or sets first associated color
  13591. */
  13592. color1: Color4;
  13593. /**
  13594. * Gets or sets second associated color
  13595. */
  13596. color2?: Color4 | undefined;
  13597. /**
  13598. * Creates a new color4 gradient
  13599. * @param gradient gets or sets the gradient value (between 0 and 1)
  13600. * @param color1 gets or sets first associated color
  13601. * @param color2 gets or sets first second color
  13602. */
  13603. constructor(
  13604. /**
  13605. * Gets or sets the gradient value (between 0 and 1)
  13606. */
  13607. gradient: number,
  13608. /**
  13609. * Gets or sets first associated color
  13610. */
  13611. color1: Color4,
  13612. /**
  13613. * Gets or sets second associated color
  13614. */
  13615. color2?: Color4 | undefined);
  13616. /**
  13617. * Will get a color picked randomly between color1 and color2.
  13618. * If color2 is undefined then color1 will be used
  13619. * @param result defines the target Color4 to store the result in
  13620. */
  13621. getColorToRef(result: Color4): void;
  13622. }
  13623. /** Class used to store color 3 gradient */
  13624. export class Color3Gradient implements IValueGradient {
  13625. /**
  13626. * Gets or sets the gradient value (between 0 and 1)
  13627. */
  13628. gradient: number;
  13629. /**
  13630. * Gets or sets the associated color
  13631. */
  13632. color: Color3;
  13633. /**
  13634. * Creates a new color3 gradient
  13635. * @param gradient gets or sets the gradient value (between 0 and 1)
  13636. * @param color gets or sets associated color
  13637. */
  13638. constructor(
  13639. /**
  13640. * Gets or sets the gradient value (between 0 and 1)
  13641. */
  13642. gradient: number,
  13643. /**
  13644. * Gets or sets the associated color
  13645. */
  13646. color: Color3);
  13647. }
  13648. /** Class used to store factor gradient */
  13649. export class FactorGradient implements IValueGradient {
  13650. /**
  13651. * Gets or sets the gradient value (between 0 and 1)
  13652. */
  13653. gradient: number;
  13654. /**
  13655. * Gets or sets first associated factor
  13656. */
  13657. factor1: number;
  13658. /**
  13659. * Gets or sets second associated factor
  13660. */
  13661. factor2?: number | undefined;
  13662. /**
  13663. * Creates a new factor gradient
  13664. * @param gradient gets or sets the gradient value (between 0 and 1)
  13665. * @param factor1 gets or sets first associated factor
  13666. * @param factor2 gets or sets second associated factor
  13667. */
  13668. constructor(
  13669. /**
  13670. * Gets or sets the gradient value (between 0 and 1)
  13671. */
  13672. gradient: number,
  13673. /**
  13674. * Gets or sets first associated factor
  13675. */
  13676. factor1: number,
  13677. /**
  13678. * Gets or sets second associated factor
  13679. */
  13680. factor2?: number | undefined);
  13681. /**
  13682. * Will get a number picked randomly between factor1 and factor2.
  13683. * If factor2 is undefined then factor1 will be used
  13684. * @returns the picked number
  13685. */
  13686. getFactor(): number;
  13687. }
  13688. /**
  13689. * Helper used to simplify some generic gradient tasks
  13690. */
  13691. export class GradientHelper {
  13692. /**
  13693. * Gets the current gradient from an array of IValueGradient
  13694. * @param ratio defines the current ratio to get
  13695. * @param gradients defines the array of IValueGradient
  13696. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  13697. */
  13698. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  13699. }
  13700. }
  13701. declare module BABYLON {
  13702. interface ThinEngine {
  13703. /**
  13704. * Creates a raw texture
  13705. * @param data defines the data to store in the texture
  13706. * @param width defines the width of the texture
  13707. * @param height defines the height of the texture
  13708. * @param format defines the format of the data
  13709. * @param generateMipMaps defines if the engine should generate the mip levels
  13710. * @param invertY defines if data must be stored with Y axis inverted
  13711. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  13712. * @param compression defines the compression used (null by default)
  13713. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13714. * @returns the raw texture inside an InternalTexture
  13715. */
  13716. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  13717. /**
  13718. * Update a raw texture
  13719. * @param texture defines the texture to update
  13720. * @param data defines the data to store in the texture
  13721. * @param format defines the format of the data
  13722. * @param invertY defines if data must be stored with Y axis inverted
  13723. */
  13724. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13725. /**
  13726. * Update a raw texture
  13727. * @param texture defines the texture to update
  13728. * @param data defines the data to store in the texture
  13729. * @param format defines the format of the data
  13730. * @param invertY defines if data must be stored with Y axis inverted
  13731. * @param compression defines the compression used (null by default)
  13732. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13733. */
  13734. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  13735. /**
  13736. * Creates a new raw cube texture
  13737. * @param data defines the array of data to use to create each face
  13738. * @param size defines the size of the textures
  13739. * @param format defines the format of the data
  13740. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13741. * @param generateMipMaps defines if the engine should generate the mip levels
  13742. * @param invertY defines if data must be stored with Y axis inverted
  13743. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13744. * @param compression defines the compression used (null by default)
  13745. * @returns the cube texture as an InternalTexture
  13746. */
  13747. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  13748. /**
  13749. * Update a raw cube texture
  13750. * @param texture defines the texture to udpdate
  13751. * @param data defines the data to store
  13752. * @param format defines the data format
  13753. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13754. * @param invertY defines if data must be stored with Y axis inverted
  13755. */
  13756. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  13757. /**
  13758. * Update a raw cube texture
  13759. * @param texture defines the texture to udpdate
  13760. * @param data defines the data to store
  13761. * @param format defines the data format
  13762. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13763. * @param invertY defines if data must be stored with Y axis inverted
  13764. * @param compression defines the compression used (null by default)
  13765. */
  13766. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  13767. /**
  13768. * Update a raw cube texture
  13769. * @param texture defines the texture to udpdate
  13770. * @param data defines the data to store
  13771. * @param format defines the data format
  13772. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13773. * @param invertY defines if data must be stored with Y axis inverted
  13774. * @param compression defines the compression used (null by default)
  13775. * @param level defines which level of the texture to update
  13776. */
  13777. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  13778. /**
  13779. * Creates a new raw cube texture from a specified url
  13780. * @param url defines the url where the data is located
  13781. * @param scene defines the current scene
  13782. * @param size defines the size of the textures
  13783. * @param format defines the format of the data
  13784. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13785. * @param noMipmap defines if the engine should avoid generating the mip levels
  13786. * @param callback defines a callback used to extract texture data from loaded data
  13787. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  13788. * @param onLoad defines a callback called when texture is loaded
  13789. * @param onError defines a callback called if there is an error
  13790. * @returns the cube texture as an InternalTexture
  13791. */
  13792. 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;
  13793. /**
  13794. * Creates a new raw cube texture from a specified url
  13795. * @param url defines the url where the data is located
  13796. * @param scene defines the current scene
  13797. * @param size defines the size of the textures
  13798. * @param format defines the format of the data
  13799. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13800. * @param noMipmap defines if the engine should avoid generating the mip levels
  13801. * @param callback defines a callback used to extract texture data from loaded data
  13802. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  13803. * @param onLoad defines a callback called when texture is loaded
  13804. * @param onError defines a callback called if there is an error
  13805. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13806. * @param invertY defines if data must be stored with Y axis inverted
  13807. * @returns the cube texture as an InternalTexture
  13808. */
  13809. 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;
  13810. /**
  13811. * Creates a new raw 3D texture
  13812. * @param data defines the data used to create the texture
  13813. * @param width defines the width of the texture
  13814. * @param height defines the height of the texture
  13815. * @param depth defines the depth of the texture
  13816. * @param format defines the format of the texture
  13817. * @param generateMipMaps defines if the engine must generate mip levels
  13818. * @param invertY defines if data must be stored with Y axis inverted
  13819. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13820. * @param compression defines the compressed used (can be null)
  13821. * @param textureType defines the compressed used (can be null)
  13822. * @returns a new raw 3D texture (stored in an InternalTexture)
  13823. */
  13824. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13825. /**
  13826. * Update a raw 3D texture
  13827. * @param texture defines the texture to update
  13828. * @param data defines the data to store
  13829. * @param format defines the data format
  13830. * @param invertY defines if data must be stored with Y axis inverted
  13831. */
  13832. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13833. /**
  13834. * Update a raw 3D texture
  13835. * @param texture defines the texture to update
  13836. * @param data defines the data to store
  13837. * @param format defines the data format
  13838. * @param invertY defines if data must be stored with Y axis inverted
  13839. * @param compression defines the used compression (can be null)
  13840. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13841. */
  13842. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13843. /**
  13844. * Creates a new raw 2D array texture
  13845. * @param data defines the data used to create the texture
  13846. * @param width defines the width of the texture
  13847. * @param height defines the height of the texture
  13848. * @param depth defines the number of layers of the texture
  13849. * @param format defines the format of the texture
  13850. * @param generateMipMaps defines if the engine must generate mip levels
  13851. * @param invertY defines if data must be stored with Y axis inverted
  13852. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13853. * @param compression defines the compressed used (can be null)
  13854. * @param textureType defines the compressed used (can be null)
  13855. * @returns a new raw 2D array texture (stored in an InternalTexture)
  13856. */
  13857. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13858. /**
  13859. * Update a raw 2D array texture
  13860. * @param texture defines the texture to update
  13861. * @param data defines the data to store
  13862. * @param format defines the data format
  13863. * @param invertY defines if data must be stored with Y axis inverted
  13864. */
  13865. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13866. /**
  13867. * Update a raw 2D array texture
  13868. * @param texture defines the texture to update
  13869. * @param data defines the data to store
  13870. * @param format defines the data format
  13871. * @param invertY defines if data must be stored with Y axis inverted
  13872. * @param compression defines the used compression (can be null)
  13873. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13874. */
  13875. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13876. }
  13877. }
  13878. declare module BABYLON {
  13879. /**
  13880. * Raw texture can help creating a texture directly from an array of data.
  13881. * This can be super useful if you either get the data from an uncompressed source or
  13882. * if you wish to create your texture pixel by pixel.
  13883. */
  13884. export class RawTexture extends Texture {
  13885. /**
  13886. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13887. */
  13888. format: number;
  13889. /**
  13890. * Instantiates a new RawTexture.
  13891. * Raw texture can help creating a texture directly from an array of data.
  13892. * This can be super useful if you either get the data from an uncompressed source or
  13893. * if you wish to create your texture pixel by pixel.
  13894. * @param data define the array of data to use to create the texture
  13895. * @param width define the width of the texture
  13896. * @param height define the height of the texture
  13897. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13898. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13899. * @param generateMipMaps define whether mip maps should be generated or not
  13900. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13901. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13902. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13903. */
  13904. constructor(data: ArrayBufferView, width: number, height: number,
  13905. /**
  13906. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13907. */
  13908. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13909. /**
  13910. * Updates the texture underlying data.
  13911. * @param data Define the new data of the texture
  13912. */
  13913. update(data: ArrayBufferView): void;
  13914. /**
  13915. * Creates a luminance texture from some data.
  13916. * @param data Define the texture data
  13917. * @param width Define the width of the texture
  13918. * @param height Define the height of the texture
  13919. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13920. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13921. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13922. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13923. * @returns the luminance texture
  13924. */
  13925. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13926. /**
  13927. * Creates a luminance alpha texture from some data.
  13928. * @param data Define the texture data
  13929. * @param width Define the width of the texture
  13930. * @param height Define the height of the texture
  13931. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13932. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13933. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13934. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13935. * @returns the luminance alpha texture
  13936. */
  13937. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13938. /**
  13939. * Creates an alpha texture from some data.
  13940. * @param data Define the texture data
  13941. * @param width Define the width of the texture
  13942. * @param height Define the height of the texture
  13943. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13944. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13945. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13946. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13947. * @returns the alpha texture
  13948. */
  13949. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13950. /**
  13951. * Creates a RGB texture from some data.
  13952. * @param data Define the texture data
  13953. * @param width Define the width of the texture
  13954. * @param height Define the height of the texture
  13955. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13956. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13957. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13958. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13959. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13960. * @returns the RGB alpha texture
  13961. */
  13962. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13963. /**
  13964. * Creates a RGBA texture from some data.
  13965. * @param data Define the texture data
  13966. * @param width Define the width of the texture
  13967. * @param height Define the height of the texture
  13968. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13969. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13970. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13971. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13972. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13973. * @returns the RGBA texture
  13974. */
  13975. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13976. /**
  13977. * Creates a R texture from some data.
  13978. * @param data Define the texture data
  13979. * @param width Define the width of the texture
  13980. * @param height Define the height of the texture
  13981. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13982. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13983. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13984. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13985. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13986. * @returns the R texture
  13987. */
  13988. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13989. }
  13990. }
  13991. declare module BABYLON {
  13992. interface ThinEngine {
  13993. /**
  13994. * Update a dynamic index buffer
  13995. * @param indexBuffer defines the target index buffer
  13996. * @param indices defines the data to update
  13997. * @param offset defines the offset in the target index buffer where update should start
  13998. */
  13999. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14000. /**
  14001. * Updates a dynamic vertex buffer.
  14002. * @param vertexBuffer the vertex buffer to update
  14003. * @param data the data used to update the vertex buffer
  14004. * @param byteOffset the byte offset of the data
  14005. * @param byteLength the byte length of the data
  14006. */
  14007. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14008. }
  14009. }
  14010. declare module BABYLON {
  14011. interface AbstractScene {
  14012. /**
  14013. * The list of procedural textures added to the scene
  14014. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14015. */
  14016. proceduralTextures: Array<ProceduralTexture>;
  14017. }
  14018. /**
  14019. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14020. * in a given scene.
  14021. */
  14022. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14023. /**
  14024. * The component name helpfull to identify the component in the list of scene components.
  14025. */
  14026. readonly name: string;
  14027. /**
  14028. * The scene the component belongs to.
  14029. */
  14030. scene: Scene;
  14031. /**
  14032. * Creates a new instance of the component for the given scene
  14033. * @param scene Defines the scene to register the component in
  14034. */
  14035. constructor(scene: Scene);
  14036. /**
  14037. * Registers the component in a given scene
  14038. */
  14039. register(): void;
  14040. /**
  14041. * Rebuilds the elements related to this component in case of
  14042. * context lost for instance.
  14043. */
  14044. rebuild(): void;
  14045. /**
  14046. * Disposes the component and the associated ressources.
  14047. */
  14048. dispose(): void;
  14049. private _beforeClear;
  14050. }
  14051. }
  14052. declare module BABYLON {
  14053. interface ThinEngine {
  14054. /**
  14055. * Creates a new render target cube texture
  14056. * @param size defines the size of the texture
  14057. * @param options defines the options used to create the texture
  14058. * @returns a new render target cube texture stored in an InternalTexture
  14059. */
  14060. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14061. }
  14062. }
  14063. declare module BABYLON {
  14064. /** @hidden */
  14065. export var proceduralVertexShader: {
  14066. name: string;
  14067. shader: string;
  14068. };
  14069. }
  14070. declare module BABYLON {
  14071. /**
  14072. * 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.
  14073. * This is the base class of any Procedural texture and contains most of the shareable code.
  14074. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14075. */
  14076. export class ProceduralTexture extends Texture {
  14077. /**
  14078. * Define if the texture is enabled or not (disabled texture will not render)
  14079. */
  14080. isEnabled: boolean;
  14081. /**
  14082. * Define if the texture must be cleared before rendering (default is true)
  14083. */
  14084. autoClear: boolean;
  14085. /**
  14086. * Callback called when the texture is generated
  14087. */
  14088. onGenerated: () => void;
  14089. /**
  14090. * Event raised when the texture is generated
  14091. */
  14092. onGeneratedObservable: Observable<ProceduralTexture>;
  14093. /**
  14094. * Event raised before the texture is generated
  14095. */
  14096. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14097. /**
  14098. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14099. */
  14100. nodeMaterialSource: Nullable<NodeMaterial>;
  14101. /** @hidden */
  14102. _generateMipMaps: boolean;
  14103. /** @hidden **/
  14104. _effect: Effect;
  14105. /** @hidden */
  14106. _textures: {
  14107. [key: string]: Texture;
  14108. };
  14109. /** @hidden */
  14110. protected _fallbackTexture: Nullable<Texture>;
  14111. private _size;
  14112. private _currentRefreshId;
  14113. private _frameId;
  14114. private _refreshRate;
  14115. private _vertexBuffers;
  14116. private _indexBuffer;
  14117. private _uniforms;
  14118. private _samplers;
  14119. private _fragment;
  14120. private _floats;
  14121. private _ints;
  14122. private _floatsArrays;
  14123. private _colors3;
  14124. private _colors4;
  14125. private _vectors2;
  14126. private _vectors3;
  14127. private _matrices;
  14128. private _fallbackTextureUsed;
  14129. private _fullEngine;
  14130. private _cachedDefines;
  14131. private _contentUpdateId;
  14132. private _contentData;
  14133. /**
  14134. * Instantiates a new procedural texture.
  14135. * 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.
  14136. * This is the base class of any Procedural texture and contains most of the shareable code.
  14137. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14138. * @param name Define the name of the texture
  14139. * @param size Define the size of the texture to create
  14140. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14141. * @param scene Define the scene the texture belongs to
  14142. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14143. * @param generateMipMaps Define if the texture should creates mip maps or not
  14144. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14145. * @param textureType The FBO internal texture type
  14146. */
  14147. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14148. /**
  14149. * The effect that is created when initializing the post process.
  14150. * @returns The created effect corresponding the the postprocess.
  14151. */
  14152. getEffect(): Effect;
  14153. /**
  14154. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14155. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14156. */
  14157. getContent(): Nullable<ArrayBufferView>;
  14158. private _createIndexBuffer;
  14159. /** @hidden */
  14160. _rebuild(): void;
  14161. /**
  14162. * Resets the texture in order to recreate its associated resources.
  14163. * This can be called in case of context loss
  14164. */
  14165. reset(): void;
  14166. protected _getDefines(): string;
  14167. /**
  14168. * Is the texture ready to be used ? (rendered at least once)
  14169. * @returns true if ready, otherwise, false.
  14170. */
  14171. isReady(): boolean;
  14172. /**
  14173. * Resets the refresh counter of the texture and start bak from scratch.
  14174. * Could be useful to regenerate the texture if it is setup to render only once.
  14175. */
  14176. resetRefreshCounter(): void;
  14177. /**
  14178. * Set the fragment shader to use in order to render the texture.
  14179. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14180. */
  14181. setFragment(fragment: any): void;
  14182. /**
  14183. * Define the refresh rate of the texture or the rendering frequency.
  14184. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14185. */
  14186. get refreshRate(): number;
  14187. set refreshRate(value: number);
  14188. /** @hidden */
  14189. _shouldRender(): boolean;
  14190. /**
  14191. * Get the size the texture is rendering at.
  14192. * @returns the size (on cube texture it is always squared)
  14193. */
  14194. getRenderSize(): RenderTargetTextureSize;
  14195. /**
  14196. * Resize the texture to new value.
  14197. * @param size Define the new size the texture should have
  14198. * @param generateMipMaps Define whether the new texture should create mip maps
  14199. */
  14200. resize(size: number, generateMipMaps: boolean): void;
  14201. private _checkUniform;
  14202. /**
  14203. * Set a texture in the shader program used to render.
  14204. * @param name Define the name of the uniform samplers as defined in the shader
  14205. * @param texture Define the texture to bind to this sampler
  14206. * @return the texture itself allowing "fluent" like uniform updates
  14207. */
  14208. setTexture(name: string, texture: Texture): ProceduralTexture;
  14209. /**
  14210. * Set a float in the shader.
  14211. * @param name Define the name of the uniform as defined in the shader
  14212. * @param value Define the value to give to the uniform
  14213. * @return the texture itself allowing "fluent" like uniform updates
  14214. */
  14215. setFloat(name: string, value: number): ProceduralTexture;
  14216. /**
  14217. * Set a int in the shader.
  14218. * @param name Define the name of the uniform as defined in the shader
  14219. * @param value Define the value to give to the uniform
  14220. * @return the texture itself allowing "fluent" like uniform updates
  14221. */
  14222. setInt(name: string, value: number): ProceduralTexture;
  14223. /**
  14224. * Set an array of floats in the shader.
  14225. * @param name Define the name of the uniform as defined in the shader
  14226. * @param value Define the value to give to the uniform
  14227. * @return the texture itself allowing "fluent" like uniform updates
  14228. */
  14229. setFloats(name: string, value: number[]): ProceduralTexture;
  14230. /**
  14231. * Set a vec3 in the shader from a Color3.
  14232. * @param name Define the name of the uniform as defined in the shader
  14233. * @param value Define the value to give to the uniform
  14234. * @return the texture itself allowing "fluent" like uniform updates
  14235. */
  14236. setColor3(name: string, value: Color3): ProceduralTexture;
  14237. /**
  14238. * Set a vec4 in the shader from a Color4.
  14239. * @param name Define the name of the uniform as defined in the shader
  14240. * @param value Define the value to give to the uniform
  14241. * @return the texture itself allowing "fluent" like uniform updates
  14242. */
  14243. setColor4(name: string, value: Color4): ProceduralTexture;
  14244. /**
  14245. * Set a vec2 in the shader from a Vector2.
  14246. * @param name Define the name of the uniform as defined in the shader
  14247. * @param value Define the value to give to the uniform
  14248. * @return the texture itself allowing "fluent" like uniform updates
  14249. */
  14250. setVector2(name: string, value: Vector2): ProceduralTexture;
  14251. /**
  14252. * Set a vec3 in the shader from a Vector3.
  14253. * @param name Define the name of the uniform as defined in the shader
  14254. * @param value Define the value to give to the uniform
  14255. * @return the texture itself allowing "fluent" like uniform updates
  14256. */
  14257. setVector3(name: string, value: Vector3): ProceduralTexture;
  14258. /**
  14259. * Set a mat4 in the shader from a MAtrix.
  14260. * @param name Define the name of the uniform as defined in the shader
  14261. * @param value Define the value to give to the uniform
  14262. * @return the texture itself allowing "fluent" like uniform updates
  14263. */
  14264. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14265. /**
  14266. * Render the texture to its associated render target.
  14267. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14268. */
  14269. render(useCameraPostProcess?: boolean): void;
  14270. /**
  14271. * Clone the texture.
  14272. * @returns the cloned texture
  14273. */
  14274. clone(): ProceduralTexture;
  14275. /**
  14276. * Dispose the texture and release its asoociated resources.
  14277. */
  14278. dispose(): void;
  14279. }
  14280. }
  14281. declare module BABYLON {
  14282. /**
  14283. * This represents the base class for particle system in Babylon.
  14284. * 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.
  14285. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14286. * @example https://doc.babylonjs.com/babylon101/particles
  14287. */
  14288. export class BaseParticleSystem {
  14289. /**
  14290. * Source color is added to the destination color without alpha affecting the result
  14291. */
  14292. static BLENDMODE_ONEONE: number;
  14293. /**
  14294. * Blend current color and particle color using particle’s alpha
  14295. */
  14296. static BLENDMODE_STANDARD: number;
  14297. /**
  14298. * Add current color and particle color multiplied by particle’s alpha
  14299. */
  14300. static BLENDMODE_ADD: number;
  14301. /**
  14302. * Multiply current color with particle color
  14303. */
  14304. static BLENDMODE_MULTIPLY: number;
  14305. /**
  14306. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14307. */
  14308. static BLENDMODE_MULTIPLYADD: number;
  14309. /**
  14310. * List of animations used by the particle system.
  14311. */
  14312. animations: Animation[];
  14313. /**
  14314. * Gets or sets the unique id of the particle system
  14315. */
  14316. uniqueId: number;
  14317. /**
  14318. * The id of the Particle system.
  14319. */
  14320. id: string;
  14321. /**
  14322. * The friendly name of the Particle system.
  14323. */
  14324. name: string;
  14325. /**
  14326. * Snippet ID if the particle system was created from the snippet server
  14327. */
  14328. snippetId: string;
  14329. /**
  14330. * The rendering group used by the Particle system to chose when to render.
  14331. */
  14332. renderingGroupId: number;
  14333. /**
  14334. * The emitter represents the Mesh or position we are attaching the particle system to.
  14335. */
  14336. emitter: Nullable<AbstractMesh | Vector3>;
  14337. /**
  14338. * The maximum number of particles to emit per frame
  14339. */
  14340. emitRate: number;
  14341. /**
  14342. * If you want to launch only a few particles at once, that can be done, as well.
  14343. */
  14344. manualEmitCount: number;
  14345. /**
  14346. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14347. */
  14348. updateSpeed: number;
  14349. /**
  14350. * The amount of time the particle system is running (depends of the overall update speed).
  14351. */
  14352. targetStopDuration: number;
  14353. /**
  14354. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14355. */
  14356. disposeOnStop: boolean;
  14357. /**
  14358. * Minimum power of emitting particles.
  14359. */
  14360. minEmitPower: number;
  14361. /**
  14362. * Maximum power of emitting particles.
  14363. */
  14364. maxEmitPower: number;
  14365. /**
  14366. * Minimum life time of emitting particles.
  14367. */
  14368. minLifeTime: number;
  14369. /**
  14370. * Maximum life time of emitting particles.
  14371. */
  14372. maxLifeTime: number;
  14373. /**
  14374. * Minimum Size of emitting particles.
  14375. */
  14376. minSize: number;
  14377. /**
  14378. * Maximum Size of emitting particles.
  14379. */
  14380. maxSize: number;
  14381. /**
  14382. * Minimum scale of emitting particles on X axis.
  14383. */
  14384. minScaleX: number;
  14385. /**
  14386. * Maximum scale of emitting particles on X axis.
  14387. */
  14388. maxScaleX: number;
  14389. /**
  14390. * Minimum scale of emitting particles on Y axis.
  14391. */
  14392. minScaleY: number;
  14393. /**
  14394. * Maximum scale of emitting particles on Y axis.
  14395. */
  14396. maxScaleY: number;
  14397. /**
  14398. * Gets or sets the minimal initial rotation in radians.
  14399. */
  14400. minInitialRotation: number;
  14401. /**
  14402. * Gets or sets the maximal initial rotation in radians.
  14403. */
  14404. maxInitialRotation: number;
  14405. /**
  14406. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14407. */
  14408. minAngularSpeed: number;
  14409. /**
  14410. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14411. */
  14412. maxAngularSpeed: number;
  14413. /**
  14414. * The texture used to render each particle. (this can be a spritesheet)
  14415. */
  14416. particleTexture: Nullable<BaseTexture>;
  14417. /**
  14418. * The layer mask we are rendering the particles through.
  14419. */
  14420. layerMask: number;
  14421. /**
  14422. * This can help using your own shader to render the particle system.
  14423. * The according effect will be created
  14424. */
  14425. customShader: any;
  14426. /**
  14427. * By default particle system starts as soon as they are created. This prevents the
  14428. * automatic start to happen and let you decide when to start emitting particles.
  14429. */
  14430. preventAutoStart: boolean;
  14431. private _noiseTexture;
  14432. /**
  14433. * Gets or sets a texture used to add random noise to particle positions
  14434. */
  14435. get noiseTexture(): Nullable<ProceduralTexture>;
  14436. set noiseTexture(value: Nullable<ProceduralTexture>);
  14437. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14438. noiseStrength: Vector3;
  14439. /**
  14440. * Callback triggered when the particle animation is ending.
  14441. */
  14442. onAnimationEnd: Nullable<() => void>;
  14443. /**
  14444. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14445. */
  14446. blendMode: number;
  14447. /**
  14448. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14449. * to override the particles.
  14450. */
  14451. forceDepthWrite: boolean;
  14452. /** 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 */
  14453. preWarmCycles: number;
  14454. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14455. preWarmStepOffset: number;
  14456. /**
  14457. * 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)
  14458. */
  14459. spriteCellChangeSpeed: number;
  14460. /**
  14461. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14462. */
  14463. startSpriteCellID: number;
  14464. /**
  14465. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14466. */
  14467. endSpriteCellID: number;
  14468. /**
  14469. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14470. */
  14471. spriteCellWidth: number;
  14472. /**
  14473. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14474. */
  14475. spriteCellHeight: number;
  14476. /**
  14477. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14478. */
  14479. spriteRandomStartCell: boolean;
  14480. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14481. translationPivot: Vector2;
  14482. /** @hidden */
  14483. protected _isAnimationSheetEnabled: boolean;
  14484. /**
  14485. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14486. */
  14487. beginAnimationOnStart: boolean;
  14488. /**
  14489. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14490. */
  14491. beginAnimationFrom: number;
  14492. /**
  14493. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14494. */
  14495. beginAnimationTo: number;
  14496. /**
  14497. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14498. */
  14499. beginAnimationLoop: boolean;
  14500. /**
  14501. * Gets or sets a world offset applied to all particles
  14502. */
  14503. worldOffset: Vector3;
  14504. /**
  14505. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14506. */
  14507. get isAnimationSheetEnabled(): boolean;
  14508. set isAnimationSheetEnabled(value: boolean);
  14509. /**
  14510. * Get hosting scene
  14511. * @returns the scene
  14512. */
  14513. getScene(): Nullable<Scene>;
  14514. /**
  14515. * You can use gravity if you want to give an orientation to your particles.
  14516. */
  14517. gravity: Vector3;
  14518. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14519. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14520. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14521. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14522. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14523. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14524. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14525. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14526. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14527. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14528. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14529. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14530. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14531. /**
  14532. * Defines the delay in milliseconds before starting the system (0 by default)
  14533. */
  14534. startDelay: number;
  14535. /**
  14536. * Gets the current list of drag gradients.
  14537. * You must use addDragGradient and removeDragGradient to udpate this list
  14538. * @returns the list of drag gradients
  14539. */
  14540. getDragGradients(): Nullable<Array<FactorGradient>>;
  14541. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14542. limitVelocityDamping: number;
  14543. /**
  14544. * Gets the current list of limit velocity gradients.
  14545. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14546. * @returns the list of limit velocity gradients
  14547. */
  14548. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14549. /**
  14550. * Gets the current list of color gradients.
  14551. * You must use addColorGradient and removeColorGradient to udpate this list
  14552. * @returns the list of color gradients
  14553. */
  14554. getColorGradients(): Nullable<Array<ColorGradient>>;
  14555. /**
  14556. * Gets the current list of size gradients.
  14557. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14558. * @returns the list of size gradients
  14559. */
  14560. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14561. /**
  14562. * Gets the current list of color remap gradients.
  14563. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14564. * @returns the list of color remap gradients
  14565. */
  14566. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14567. /**
  14568. * Gets the current list of alpha remap gradients.
  14569. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14570. * @returns the list of alpha remap gradients
  14571. */
  14572. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14573. /**
  14574. * Gets the current list of life time gradients.
  14575. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14576. * @returns the list of life time gradients
  14577. */
  14578. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14579. /**
  14580. * Gets the current list of angular speed gradients.
  14581. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14582. * @returns the list of angular speed gradients
  14583. */
  14584. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14585. /**
  14586. * Gets the current list of velocity gradients.
  14587. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14588. * @returns the list of velocity gradients
  14589. */
  14590. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14591. /**
  14592. * Gets the current list of start size gradients.
  14593. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14594. * @returns the list of start size gradients
  14595. */
  14596. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14597. /**
  14598. * Gets the current list of emit rate gradients.
  14599. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14600. * @returns the list of emit rate gradients
  14601. */
  14602. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14603. /**
  14604. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14605. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14606. */
  14607. get direction1(): Vector3;
  14608. set direction1(value: Vector3);
  14609. /**
  14610. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14611. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14612. */
  14613. get direction2(): Vector3;
  14614. set direction2(value: Vector3);
  14615. /**
  14616. * 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.
  14617. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14618. */
  14619. get minEmitBox(): Vector3;
  14620. set minEmitBox(value: Vector3);
  14621. /**
  14622. * 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.
  14623. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14624. */
  14625. get maxEmitBox(): Vector3;
  14626. set maxEmitBox(value: Vector3);
  14627. /**
  14628. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14629. */
  14630. color1: Color4;
  14631. /**
  14632. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14633. */
  14634. color2: Color4;
  14635. /**
  14636. * Color the particle will have at the end of its lifetime
  14637. */
  14638. colorDead: Color4;
  14639. /**
  14640. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14641. */
  14642. textureMask: Color4;
  14643. /**
  14644. * The particle emitter type defines the emitter used by the particle system.
  14645. * It can be for example box, sphere, or cone...
  14646. */
  14647. particleEmitterType: IParticleEmitterType;
  14648. /** @hidden */
  14649. _isSubEmitter: boolean;
  14650. /**
  14651. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14652. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14653. */
  14654. billboardMode: number;
  14655. protected _isBillboardBased: boolean;
  14656. /**
  14657. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14658. */
  14659. get isBillboardBased(): boolean;
  14660. set isBillboardBased(value: boolean);
  14661. /**
  14662. * The scene the particle system belongs to.
  14663. */
  14664. protected _scene: Nullable<Scene>;
  14665. /**
  14666. * The engine the particle system belongs to.
  14667. */
  14668. protected _engine: ThinEngine;
  14669. /**
  14670. * Local cache of defines for image processing.
  14671. */
  14672. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14673. /**
  14674. * Default configuration related to image processing available in the standard Material.
  14675. */
  14676. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  14677. /**
  14678. * Gets the image processing configuration used either in this material.
  14679. */
  14680. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  14681. /**
  14682. * Sets the Default image processing configuration used either in the this material.
  14683. *
  14684. * If sets to null, the scene one is in use.
  14685. */
  14686. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  14687. /**
  14688. * Attaches a new image processing configuration to the Standard Material.
  14689. * @param configuration
  14690. */
  14691. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14692. /** @hidden */
  14693. protected _reset(): void;
  14694. /** @hidden */
  14695. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14696. /**
  14697. * Instantiates a particle system.
  14698. * 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.
  14699. * @param name The name of the particle system
  14700. */
  14701. constructor(name: string);
  14702. /**
  14703. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14704. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14705. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14706. * @returns the emitter
  14707. */
  14708. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14709. /**
  14710. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14711. * @param radius The radius of the hemisphere to emit from
  14712. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14713. * @returns the emitter
  14714. */
  14715. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14716. /**
  14717. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14718. * @param radius The radius of the sphere to emit from
  14719. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14720. * @returns the emitter
  14721. */
  14722. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14723. /**
  14724. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14725. * @param radius The radius of the sphere to emit from
  14726. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14727. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14728. * @returns the emitter
  14729. */
  14730. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14731. /**
  14732. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14733. * @param radius The radius of the emission cylinder
  14734. * @param height The height of the emission cylinder
  14735. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14736. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14737. * @returns the emitter
  14738. */
  14739. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14740. /**
  14741. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14742. * @param radius The radius of the cylinder to emit from
  14743. * @param height The height of the emission cylinder
  14744. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14745. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14746. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14747. * @returns the emitter
  14748. */
  14749. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14750. /**
  14751. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14752. * @param radius The radius of the cone to emit from
  14753. * @param angle The base angle of the cone
  14754. * @returns the emitter
  14755. */
  14756. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14757. /**
  14758. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14759. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14760. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14761. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14762. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14763. * @returns the emitter
  14764. */
  14765. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14766. }
  14767. }
  14768. declare module BABYLON {
  14769. /**
  14770. * Type of sub emitter
  14771. */
  14772. export enum SubEmitterType {
  14773. /**
  14774. * Attached to the particle over it's lifetime
  14775. */
  14776. ATTACHED = 0,
  14777. /**
  14778. * Created when the particle dies
  14779. */
  14780. END = 1
  14781. }
  14782. /**
  14783. * Sub emitter class used to emit particles from an existing particle
  14784. */
  14785. export class SubEmitter {
  14786. /**
  14787. * the particle system to be used by the sub emitter
  14788. */
  14789. particleSystem: ParticleSystem;
  14790. /**
  14791. * Type of the submitter (Default: END)
  14792. */
  14793. type: SubEmitterType;
  14794. /**
  14795. * 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)
  14796. * Note: This only is supported when using an emitter of type Mesh
  14797. */
  14798. inheritDirection: boolean;
  14799. /**
  14800. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14801. */
  14802. inheritedVelocityAmount: number;
  14803. /**
  14804. * Creates a sub emitter
  14805. * @param particleSystem the particle system to be used by the sub emitter
  14806. */
  14807. constructor(
  14808. /**
  14809. * the particle system to be used by the sub emitter
  14810. */
  14811. particleSystem: ParticleSystem);
  14812. /**
  14813. * Clones the sub emitter
  14814. * @returns the cloned sub emitter
  14815. */
  14816. clone(): SubEmitter;
  14817. /**
  14818. * Serialize current object to a JSON object
  14819. * @returns the serialized object
  14820. */
  14821. serialize(): any;
  14822. /** @hidden */
  14823. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  14824. /**
  14825. * Creates a new SubEmitter from a serialized JSON version
  14826. * @param serializationObject defines the JSON object to read from
  14827. * @param sceneOrEngine defines the hosting scene or the hosting engine
  14828. * @param rootUrl defines the rootUrl for data loading
  14829. * @returns a new SubEmitter
  14830. */
  14831. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  14832. /** Release associated resources */
  14833. dispose(): void;
  14834. }
  14835. }
  14836. declare module BABYLON {
  14837. /** @hidden */
  14838. export var clipPlaneFragmentDeclaration: {
  14839. name: string;
  14840. shader: string;
  14841. };
  14842. }
  14843. declare module BABYLON {
  14844. /** @hidden */
  14845. export var imageProcessingDeclaration: {
  14846. name: string;
  14847. shader: string;
  14848. };
  14849. }
  14850. declare module BABYLON {
  14851. /** @hidden */
  14852. export var imageProcessingFunctions: {
  14853. name: string;
  14854. shader: string;
  14855. };
  14856. }
  14857. declare module BABYLON {
  14858. /** @hidden */
  14859. export var clipPlaneFragment: {
  14860. name: string;
  14861. shader: string;
  14862. };
  14863. }
  14864. declare module BABYLON {
  14865. /** @hidden */
  14866. export var particlesPixelShader: {
  14867. name: string;
  14868. shader: string;
  14869. };
  14870. }
  14871. declare module BABYLON {
  14872. /** @hidden */
  14873. export var clipPlaneVertexDeclaration: {
  14874. name: string;
  14875. shader: string;
  14876. };
  14877. }
  14878. declare module BABYLON {
  14879. /** @hidden */
  14880. export var clipPlaneVertex: {
  14881. name: string;
  14882. shader: string;
  14883. };
  14884. }
  14885. declare module BABYLON {
  14886. /** @hidden */
  14887. export var particlesVertexShader: {
  14888. name: string;
  14889. shader: string;
  14890. };
  14891. }
  14892. declare module BABYLON {
  14893. /**
  14894. * Interface used to define entities containing multiple clip planes
  14895. */
  14896. export interface IClipPlanesHolder {
  14897. /**
  14898. * Gets or sets the active clipplane 1
  14899. */
  14900. clipPlane: Nullable<Plane>;
  14901. /**
  14902. * Gets or sets the active clipplane 2
  14903. */
  14904. clipPlane2: Nullable<Plane>;
  14905. /**
  14906. * Gets or sets the active clipplane 3
  14907. */
  14908. clipPlane3: Nullable<Plane>;
  14909. /**
  14910. * Gets or sets the active clipplane 4
  14911. */
  14912. clipPlane4: Nullable<Plane>;
  14913. /**
  14914. * Gets or sets the active clipplane 5
  14915. */
  14916. clipPlane5: Nullable<Plane>;
  14917. /**
  14918. * Gets or sets the active clipplane 6
  14919. */
  14920. clipPlane6: Nullable<Plane>;
  14921. }
  14922. }
  14923. declare module BABYLON {
  14924. /**
  14925. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  14926. *
  14927. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  14928. *
  14929. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14930. */
  14931. export class ThinMaterialHelper {
  14932. /**
  14933. * Binds the clip plane information from the holder to the effect.
  14934. * @param effect The effect we are binding the data to
  14935. * @param holder The entity containing the clip plane information
  14936. */
  14937. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  14938. }
  14939. }
  14940. declare module BABYLON {
  14941. interface ThinEngine {
  14942. /**
  14943. * Sets alpha constants used by some alpha blending modes
  14944. * @param r defines the red component
  14945. * @param g defines the green component
  14946. * @param b defines the blue component
  14947. * @param a defines the alpha component
  14948. */
  14949. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  14950. /**
  14951. * Sets the current alpha mode
  14952. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  14953. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  14954. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  14955. */
  14956. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  14957. /**
  14958. * Gets the current alpha mode
  14959. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  14960. * @returns the current alpha mode
  14961. */
  14962. getAlphaMode(): number;
  14963. /**
  14964. * Sets the current alpha equation
  14965. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  14966. */
  14967. setAlphaEquation(equation: number): void;
  14968. /**
  14969. * Gets the current alpha equation.
  14970. * @returns the current alpha equation
  14971. */
  14972. getAlphaEquation(): number;
  14973. }
  14974. }
  14975. declare module BABYLON {
  14976. /**
  14977. * This represents a particle system in Babylon.
  14978. * 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.
  14979. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14980. * @example https://doc.babylonjs.com/babylon101/particles
  14981. */
  14982. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14983. /**
  14984. * Billboard mode will only apply to Y axis
  14985. */
  14986. static readonly BILLBOARDMODE_Y: number;
  14987. /**
  14988. * Billboard mode will apply to all axes
  14989. */
  14990. static readonly BILLBOARDMODE_ALL: number;
  14991. /**
  14992. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14993. */
  14994. static readonly BILLBOARDMODE_STRETCHED: number;
  14995. /**
  14996. * This function can be defined to provide custom update for active particles.
  14997. * This function will be called instead of regular update (age, position, color, etc.).
  14998. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14999. */
  15000. updateFunction: (particles: Particle[]) => void;
  15001. private _emitterWorldMatrix;
  15002. /**
  15003. * This function can be defined to specify initial direction for every new particle.
  15004. * It by default use the emitterType defined function
  15005. */
  15006. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15007. /**
  15008. * This function can be defined to specify initial position for every new particle.
  15009. * It by default use the emitterType defined function
  15010. */
  15011. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15012. /**
  15013. * @hidden
  15014. */
  15015. _inheritedVelocityOffset: Vector3;
  15016. /**
  15017. * An event triggered when the system is disposed
  15018. */
  15019. onDisposeObservable: Observable<IParticleSystem>;
  15020. /**
  15021. * An event triggered when the system is stopped
  15022. */
  15023. onStoppedObservable: Observable<IParticleSystem>;
  15024. private _onDisposeObserver;
  15025. /**
  15026. * Sets a callback that will be triggered when the system is disposed
  15027. */
  15028. set onDispose(callback: () => void);
  15029. private _particles;
  15030. private _epsilon;
  15031. private _capacity;
  15032. private _stockParticles;
  15033. private _newPartsExcess;
  15034. private _vertexData;
  15035. private _vertexBuffer;
  15036. private _vertexBuffers;
  15037. private _spriteBuffer;
  15038. private _indexBuffer;
  15039. private _effect;
  15040. private _customEffect;
  15041. private _cachedDefines;
  15042. private _scaledColorStep;
  15043. private _colorDiff;
  15044. private _scaledDirection;
  15045. private _scaledGravity;
  15046. private _currentRenderId;
  15047. private _alive;
  15048. private _useInstancing;
  15049. private _vertexArrayObject;
  15050. private _started;
  15051. private _stopped;
  15052. private _actualFrame;
  15053. private _scaledUpdateSpeed;
  15054. private _vertexBufferSize;
  15055. /** @hidden */
  15056. _currentEmitRateGradient: Nullable<FactorGradient>;
  15057. /** @hidden */
  15058. _currentEmitRate1: number;
  15059. /** @hidden */
  15060. _currentEmitRate2: number;
  15061. /** @hidden */
  15062. _currentStartSizeGradient: Nullable<FactorGradient>;
  15063. /** @hidden */
  15064. _currentStartSize1: number;
  15065. /** @hidden */
  15066. _currentStartSize2: number;
  15067. private readonly _rawTextureWidth;
  15068. private _rampGradientsTexture;
  15069. private _useRampGradients;
  15070. /** Gets or sets a matrix to use to compute projection */
  15071. defaultProjectionMatrix: Matrix;
  15072. /** Gets or sets a matrix to use to compute view */
  15073. defaultViewMatrix: Matrix;
  15074. /** Gets or sets a boolean indicating that ramp gradients must be used
  15075. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15076. */
  15077. get useRampGradients(): boolean;
  15078. set useRampGradients(value: boolean);
  15079. /**
  15080. * 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.
  15081. * 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: [])
  15082. */
  15083. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15084. private _subEmitters;
  15085. /**
  15086. * @hidden
  15087. * If the particle systems emitter should be disposed when the particle system is disposed
  15088. */
  15089. _disposeEmitterOnDispose: boolean;
  15090. /**
  15091. * The current active Sub-systems, this property is used by the root particle system only.
  15092. */
  15093. activeSubSystems: Array<ParticleSystem>;
  15094. /**
  15095. * Specifies if the particles are updated in emitter local space or world space
  15096. */
  15097. isLocal: boolean;
  15098. private _rootParticleSystem;
  15099. /**
  15100. * Gets the current list of active particles
  15101. */
  15102. get particles(): Particle[];
  15103. /**
  15104. * Gets the number of particles active at the same time.
  15105. * @returns The number of active particles.
  15106. */
  15107. getActiveCount(): number;
  15108. /**
  15109. * Returns the string "ParticleSystem"
  15110. * @returns a string containing the class name
  15111. */
  15112. getClassName(): string;
  15113. /**
  15114. * Gets a boolean indicating that the system is stopping
  15115. * @returns true if the system is currently stopping
  15116. */
  15117. isStopping(): boolean;
  15118. /**
  15119. * Gets the custom effect used to render the particles
  15120. * @param blendMode Blend mode for which the effect should be retrieved
  15121. * @returns The effect
  15122. */
  15123. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15124. /**
  15125. * Sets the custom effect used to render the particles
  15126. * @param effect The effect to set
  15127. * @param blendMode Blend mode for which the effect should be set
  15128. */
  15129. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15130. /** @hidden */
  15131. private _onBeforeDrawParticlesObservable;
  15132. /**
  15133. * Observable that will be called just before the particles are drawn
  15134. */
  15135. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15136. /**
  15137. * Gets the name of the particle vertex shader
  15138. */
  15139. get vertexShaderName(): string;
  15140. /**
  15141. * Instantiates a particle system.
  15142. * 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.
  15143. * @param name The name of the particle system
  15144. * @param capacity The max number of particles alive at the same time
  15145. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15146. * @param customEffect a custom effect used to change the way particles are rendered by default
  15147. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15148. * @param epsilon Offset used to render the particles
  15149. */
  15150. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15151. private _addFactorGradient;
  15152. private _removeFactorGradient;
  15153. /**
  15154. * Adds a new life time gradient
  15155. * @param gradient defines the gradient to use (between 0 and 1)
  15156. * @param factor defines the life time factor to affect to the specified gradient
  15157. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15158. * @returns the current particle system
  15159. */
  15160. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15161. /**
  15162. * Remove a specific life time gradient
  15163. * @param gradient defines the gradient to remove
  15164. * @returns the current particle system
  15165. */
  15166. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15167. /**
  15168. * Adds a new size gradient
  15169. * @param gradient defines the gradient to use (between 0 and 1)
  15170. * @param factor defines the size factor to affect to the specified gradient
  15171. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15172. * @returns the current particle system
  15173. */
  15174. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15175. /**
  15176. * Remove a specific size gradient
  15177. * @param gradient defines the gradient to remove
  15178. * @returns the current particle system
  15179. */
  15180. removeSizeGradient(gradient: number): IParticleSystem;
  15181. /**
  15182. * Adds a new color remap gradient
  15183. * @param gradient defines the gradient to use (between 0 and 1)
  15184. * @param min defines the color remap minimal range
  15185. * @param max defines the color remap maximal range
  15186. * @returns the current particle system
  15187. */
  15188. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15189. /**
  15190. * Remove a specific color remap gradient
  15191. * @param gradient defines the gradient to remove
  15192. * @returns the current particle system
  15193. */
  15194. removeColorRemapGradient(gradient: number): IParticleSystem;
  15195. /**
  15196. * Adds a new alpha remap gradient
  15197. * @param gradient defines the gradient to use (between 0 and 1)
  15198. * @param min defines the alpha remap minimal range
  15199. * @param max defines the alpha remap maximal range
  15200. * @returns the current particle system
  15201. */
  15202. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15203. /**
  15204. * Remove a specific alpha remap gradient
  15205. * @param gradient defines the gradient to remove
  15206. * @returns the current particle system
  15207. */
  15208. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15209. /**
  15210. * Adds a new angular speed gradient
  15211. * @param gradient defines the gradient to use (between 0 and 1)
  15212. * @param factor defines the angular speed to affect to the specified gradient
  15213. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15214. * @returns the current particle system
  15215. */
  15216. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15217. /**
  15218. * Remove a specific angular speed gradient
  15219. * @param gradient defines the gradient to remove
  15220. * @returns the current particle system
  15221. */
  15222. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15223. /**
  15224. * Adds a new velocity gradient
  15225. * @param gradient defines the gradient to use (between 0 and 1)
  15226. * @param factor defines the velocity to affect to the specified gradient
  15227. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15228. * @returns the current particle system
  15229. */
  15230. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15231. /**
  15232. * Remove a specific velocity gradient
  15233. * @param gradient defines the gradient to remove
  15234. * @returns the current particle system
  15235. */
  15236. removeVelocityGradient(gradient: number): IParticleSystem;
  15237. /**
  15238. * Adds a new limit velocity gradient
  15239. * @param gradient defines the gradient to use (between 0 and 1)
  15240. * @param factor defines the limit velocity value to affect to the specified gradient
  15241. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15242. * @returns the current particle system
  15243. */
  15244. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15245. /**
  15246. * Remove a specific limit velocity gradient
  15247. * @param gradient defines the gradient to remove
  15248. * @returns the current particle system
  15249. */
  15250. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15251. /**
  15252. * Adds a new drag gradient
  15253. * @param gradient defines the gradient to use (between 0 and 1)
  15254. * @param factor defines the drag value to affect to the specified gradient
  15255. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15256. * @returns the current particle system
  15257. */
  15258. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15259. /**
  15260. * Remove a specific drag gradient
  15261. * @param gradient defines the gradient to remove
  15262. * @returns the current particle system
  15263. */
  15264. removeDragGradient(gradient: number): IParticleSystem;
  15265. /**
  15266. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15267. * @param gradient defines the gradient to use (between 0 and 1)
  15268. * @param factor defines the emit rate value to affect to the specified gradient
  15269. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15270. * @returns the current particle system
  15271. */
  15272. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15273. /**
  15274. * Remove a specific emit rate gradient
  15275. * @param gradient defines the gradient to remove
  15276. * @returns the current particle system
  15277. */
  15278. removeEmitRateGradient(gradient: number): IParticleSystem;
  15279. /**
  15280. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15281. * @param gradient defines the gradient to use (between 0 and 1)
  15282. * @param factor defines the start size value to affect to the specified gradient
  15283. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15284. * @returns the current particle system
  15285. */
  15286. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15287. /**
  15288. * Remove a specific start size gradient
  15289. * @param gradient defines the gradient to remove
  15290. * @returns the current particle system
  15291. */
  15292. removeStartSizeGradient(gradient: number): IParticleSystem;
  15293. private _createRampGradientTexture;
  15294. /**
  15295. * Gets the current list of ramp gradients.
  15296. * You must use addRampGradient and removeRampGradient to udpate this list
  15297. * @returns the list of ramp gradients
  15298. */
  15299. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15300. /** Force the system to rebuild all gradients that need to be resync */
  15301. forceRefreshGradients(): void;
  15302. private _syncRampGradientTexture;
  15303. /**
  15304. * Adds a new ramp gradient used to remap particle colors
  15305. * @param gradient defines the gradient to use (between 0 and 1)
  15306. * @param color defines the color to affect to the specified gradient
  15307. * @returns the current particle system
  15308. */
  15309. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15310. /**
  15311. * Remove a specific ramp gradient
  15312. * @param gradient defines the gradient to remove
  15313. * @returns the current particle system
  15314. */
  15315. removeRampGradient(gradient: number): ParticleSystem;
  15316. /**
  15317. * Adds a new color gradient
  15318. * @param gradient defines the gradient to use (between 0 and 1)
  15319. * @param color1 defines the color to affect to the specified gradient
  15320. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15321. * @returns this particle system
  15322. */
  15323. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15324. /**
  15325. * Remove a specific color gradient
  15326. * @param gradient defines the gradient to remove
  15327. * @returns this particle system
  15328. */
  15329. removeColorGradient(gradient: number): IParticleSystem;
  15330. private _fetchR;
  15331. protected _reset(): void;
  15332. private _resetEffect;
  15333. private _createVertexBuffers;
  15334. private _createIndexBuffer;
  15335. /**
  15336. * Gets the maximum number of particles active at the same time.
  15337. * @returns The max number of active particles.
  15338. */
  15339. getCapacity(): number;
  15340. /**
  15341. * Gets whether there are still active particles in the system.
  15342. * @returns True if it is alive, otherwise false.
  15343. */
  15344. isAlive(): boolean;
  15345. /**
  15346. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15347. * @returns True if it has been started, otherwise false.
  15348. */
  15349. isStarted(): boolean;
  15350. private _prepareSubEmitterInternalArray;
  15351. /**
  15352. * Starts the particle system and begins to emit
  15353. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15354. */
  15355. start(delay?: number): void;
  15356. /**
  15357. * Stops the particle system.
  15358. * @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.
  15359. */
  15360. stop(stopSubEmitters?: boolean): void;
  15361. /**
  15362. * Remove all active particles
  15363. */
  15364. reset(): void;
  15365. /**
  15366. * @hidden (for internal use only)
  15367. */
  15368. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15369. /**
  15370. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15371. * Its lifetime will start back at 0.
  15372. */
  15373. recycleParticle: (particle: Particle) => void;
  15374. private _stopSubEmitters;
  15375. private _createParticle;
  15376. private _removeFromRoot;
  15377. private _emitFromParticle;
  15378. private _update;
  15379. /** @hidden */
  15380. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15381. /** @hidden */
  15382. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15383. /**
  15384. * Fill the defines array according to the current settings of the particle system
  15385. * @param defines Array to be updated
  15386. * @param blendMode blend mode to take into account when updating the array
  15387. */
  15388. fillDefines(defines: Array<string>, blendMode: number): void;
  15389. /**
  15390. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15391. * @param uniforms Uniforms array to fill
  15392. * @param attributes Attributes array to fill
  15393. * @param samplers Samplers array to fill
  15394. */
  15395. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15396. /** @hidden */
  15397. private _getEffect;
  15398. /**
  15399. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15400. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15401. */
  15402. animate(preWarmOnly?: boolean): void;
  15403. private _appendParticleVertices;
  15404. /**
  15405. * Rebuilds the particle system.
  15406. */
  15407. rebuild(): void;
  15408. /**
  15409. * Is this system ready to be used/rendered
  15410. * @return true if the system is ready
  15411. */
  15412. isReady(): boolean;
  15413. private _render;
  15414. /**
  15415. * Renders the particle system in its current state.
  15416. * @returns the current number of particles
  15417. */
  15418. render(): number;
  15419. /**
  15420. * Disposes the particle system and free the associated resources
  15421. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15422. */
  15423. dispose(disposeTexture?: boolean): void;
  15424. /**
  15425. * Clones the particle system.
  15426. * @param name The name of the cloned object
  15427. * @param newEmitter The new emitter to use
  15428. * @returns the cloned particle system
  15429. */
  15430. clone(name: string, newEmitter: any): ParticleSystem;
  15431. /**
  15432. * Serializes the particle system to a JSON object
  15433. * @param serializeTexture defines if the texture must be serialized as well
  15434. * @returns the JSON object
  15435. */
  15436. serialize(serializeTexture?: boolean): any;
  15437. /** @hidden */
  15438. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  15439. /** @hidden */
  15440. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  15441. /**
  15442. * Parses a JSON object to create a particle system.
  15443. * @param parsedParticleSystem The JSON object to parse
  15444. * @param sceneOrEngine The scene or the engine to create the particle system in
  15445. * @param rootUrl The root url to use to load external dependencies like texture
  15446. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15447. * @returns the Parsed particle system
  15448. */
  15449. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15450. }
  15451. }
  15452. declare module BABYLON {
  15453. /**
  15454. * A particle represents one of the element emitted by a particle system.
  15455. * This is mainly define by its coordinates, direction, velocity and age.
  15456. */
  15457. export class Particle {
  15458. /**
  15459. * The particle system the particle belongs to.
  15460. */
  15461. particleSystem: ParticleSystem;
  15462. private static _Count;
  15463. /**
  15464. * Unique ID of the particle
  15465. */
  15466. id: number;
  15467. /**
  15468. * The world position of the particle in the scene.
  15469. */
  15470. position: Vector3;
  15471. /**
  15472. * The world direction of the particle in the scene.
  15473. */
  15474. direction: Vector3;
  15475. /**
  15476. * The color of the particle.
  15477. */
  15478. color: Color4;
  15479. /**
  15480. * The color change of the particle per step.
  15481. */
  15482. colorStep: Color4;
  15483. /**
  15484. * Defines how long will the life of the particle be.
  15485. */
  15486. lifeTime: number;
  15487. /**
  15488. * The current age of the particle.
  15489. */
  15490. age: number;
  15491. /**
  15492. * The current size of the particle.
  15493. */
  15494. size: number;
  15495. /**
  15496. * The current scale of the particle.
  15497. */
  15498. scale: Vector2;
  15499. /**
  15500. * The current angle of the particle.
  15501. */
  15502. angle: number;
  15503. /**
  15504. * Defines how fast is the angle changing.
  15505. */
  15506. angularSpeed: number;
  15507. /**
  15508. * Defines the cell index used by the particle to be rendered from a sprite.
  15509. */
  15510. cellIndex: number;
  15511. /**
  15512. * The information required to support color remapping
  15513. */
  15514. remapData: Vector4;
  15515. /** @hidden */
  15516. _randomCellOffset?: number;
  15517. /** @hidden */
  15518. _initialDirection: Nullable<Vector3>;
  15519. /** @hidden */
  15520. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15521. /** @hidden */
  15522. _initialStartSpriteCellID: number;
  15523. /** @hidden */
  15524. _initialEndSpriteCellID: number;
  15525. /** @hidden */
  15526. _currentColorGradient: Nullable<ColorGradient>;
  15527. /** @hidden */
  15528. _currentColor1: Color4;
  15529. /** @hidden */
  15530. _currentColor2: Color4;
  15531. /** @hidden */
  15532. _currentSizeGradient: Nullable<FactorGradient>;
  15533. /** @hidden */
  15534. _currentSize1: number;
  15535. /** @hidden */
  15536. _currentSize2: number;
  15537. /** @hidden */
  15538. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15539. /** @hidden */
  15540. _currentAngularSpeed1: number;
  15541. /** @hidden */
  15542. _currentAngularSpeed2: number;
  15543. /** @hidden */
  15544. _currentVelocityGradient: Nullable<FactorGradient>;
  15545. /** @hidden */
  15546. _currentVelocity1: number;
  15547. /** @hidden */
  15548. _currentVelocity2: number;
  15549. /** @hidden */
  15550. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15551. /** @hidden */
  15552. _currentLimitVelocity1: number;
  15553. /** @hidden */
  15554. _currentLimitVelocity2: number;
  15555. /** @hidden */
  15556. _currentDragGradient: Nullable<FactorGradient>;
  15557. /** @hidden */
  15558. _currentDrag1: number;
  15559. /** @hidden */
  15560. _currentDrag2: number;
  15561. /** @hidden */
  15562. _randomNoiseCoordinates1: Vector3;
  15563. /** @hidden */
  15564. _randomNoiseCoordinates2: Vector3;
  15565. /** @hidden */
  15566. _localPosition?: Vector3;
  15567. /**
  15568. * Creates a new instance Particle
  15569. * @param particleSystem the particle system the particle belongs to
  15570. */
  15571. constructor(
  15572. /**
  15573. * The particle system the particle belongs to.
  15574. */
  15575. particleSystem: ParticleSystem);
  15576. private updateCellInfoFromSystem;
  15577. /**
  15578. * Defines how the sprite cell index is updated for the particle
  15579. */
  15580. updateCellIndex(): void;
  15581. /** @hidden */
  15582. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15583. /** @hidden */
  15584. _inheritParticleInfoToSubEmitters(): void;
  15585. /** @hidden */
  15586. _reset(): void;
  15587. /**
  15588. * Copy the properties of particle to another one.
  15589. * @param other the particle to copy the information to.
  15590. */
  15591. copyTo(other: Particle): void;
  15592. }
  15593. }
  15594. declare module BABYLON {
  15595. /**
  15596. * Particle emitter represents a volume emitting particles.
  15597. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15598. */
  15599. export interface IParticleEmitterType {
  15600. /**
  15601. * Called by the particle System when the direction is computed for the created particle.
  15602. * @param worldMatrix is the world matrix of the particle system
  15603. * @param directionToUpdate is the direction vector to update with the result
  15604. * @param particle is the particle we are computed the direction for
  15605. * @param isLocal defines if the direction should be set in local space
  15606. */
  15607. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15608. /**
  15609. * Called by the particle System when the position is computed for the created particle.
  15610. * @param worldMatrix is the world matrix of the particle system
  15611. * @param positionToUpdate is the position vector to update with the result
  15612. * @param particle is the particle we are computed the position for
  15613. * @param isLocal defines if the position should be set in local space
  15614. */
  15615. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15616. /**
  15617. * Clones the current emitter and returns a copy of it
  15618. * @returns the new emitter
  15619. */
  15620. clone(): IParticleEmitterType;
  15621. /**
  15622. * Called by the GPUParticleSystem to setup the update shader
  15623. * @param effect defines the update shader
  15624. */
  15625. applyToShader(effect: Effect): void;
  15626. /**
  15627. * Returns a string to use to update the GPU particles update shader
  15628. * @returns the effect defines string
  15629. */
  15630. getEffectDefines(): string;
  15631. /**
  15632. * Returns a string representing the class name
  15633. * @returns a string containing the class name
  15634. */
  15635. getClassName(): string;
  15636. /**
  15637. * Serializes the particle system to a JSON object.
  15638. * @returns the JSON object
  15639. */
  15640. serialize(): any;
  15641. /**
  15642. * Parse properties from a JSON object
  15643. * @param serializationObject defines the JSON object
  15644. * @param scene defines the hosting scene
  15645. */
  15646. parse(serializationObject: any, scene: Nullable<Scene>): void;
  15647. }
  15648. }
  15649. declare module BABYLON {
  15650. /**
  15651. * Particle emitter emitting particles from the inside of a box.
  15652. * It emits the particles randomly between 2 given directions.
  15653. */
  15654. export class BoxParticleEmitter implements IParticleEmitterType {
  15655. /**
  15656. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15657. */
  15658. direction1: Vector3;
  15659. /**
  15660. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15661. */
  15662. direction2: Vector3;
  15663. /**
  15664. * 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.
  15665. */
  15666. minEmitBox: Vector3;
  15667. /**
  15668. * 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.
  15669. */
  15670. maxEmitBox: Vector3;
  15671. /**
  15672. * Creates a new instance BoxParticleEmitter
  15673. */
  15674. constructor();
  15675. /**
  15676. * Called by the particle System when the direction is computed for the created particle.
  15677. * @param worldMatrix is the world matrix of the particle system
  15678. * @param directionToUpdate is the direction vector to update with the result
  15679. * @param particle is the particle we are computed the direction for
  15680. * @param isLocal defines if the direction should be set in local space
  15681. */
  15682. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15683. /**
  15684. * Called by the particle System when the position is computed for the created particle.
  15685. * @param worldMatrix is the world matrix of the particle system
  15686. * @param positionToUpdate is the position vector to update with the result
  15687. * @param particle is the particle we are computed the position for
  15688. * @param isLocal defines if the position should be set in local space
  15689. */
  15690. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15691. /**
  15692. * Clones the current emitter and returns a copy of it
  15693. * @returns the new emitter
  15694. */
  15695. clone(): BoxParticleEmitter;
  15696. /**
  15697. * Called by the GPUParticleSystem to setup the update shader
  15698. * @param effect defines the update shader
  15699. */
  15700. applyToShader(effect: Effect): void;
  15701. /**
  15702. * Returns a string to use to update the GPU particles update shader
  15703. * @returns a string containng the defines string
  15704. */
  15705. getEffectDefines(): string;
  15706. /**
  15707. * Returns the string "BoxParticleEmitter"
  15708. * @returns a string containing the class name
  15709. */
  15710. getClassName(): string;
  15711. /**
  15712. * Serializes the particle system to a JSON object.
  15713. * @returns the JSON object
  15714. */
  15715. serialize(): any;
  15716. /**
  15717. * Parse properties from a JSON object
  15718. * @param serializationObject defines the JSON object
  15719. */
  15720. parse(serializationObject: any): void;
  15721. }
  15722. }
  15723. declare module BABYLON {
  15724. /**
  15725. * Particle emitter emitting particles from the inside of a cone.
  15726. * It emits the particles alongside the cone volume from the base to the particle.
  15727. * The emission direction might be randomized.
  15728. */
  15729. export class ConeParticleEmitter implements IParticleEmitterType {
  15730. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15731. directionRandomizer: number;
  15732. private _radius;
  15733. private _angle;
  15734. private _height;
  15735. /**
  15736. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15737. */
  15738. radiusRange: number;
  15739. /**
  15740. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15741. */
  15742. heightRange: number;
  15743. /**
  15744. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15745. */
  15746. emitFromSpawnPointOnly: boolean;
  15747. /**
  15748. * Gets or sets the radius of the emission cone
  15749. */
  15750. get radius(): number;
  15751. set radius(value: number);
  15752. /**
  15753. * Gets or sets the angle of the emission cone
  15754. */
  15755. get angle(): number;
  15756. set angle(value: number);
  15757. private _buildHeight;
  15758. /**
  15759. * Creates a new instance ConeParticleEmitter
  15760. * @param radius the radius of the emission cone (1 by default)
  15761. * @param angle the cone base angle (PI by default)
  15762. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15763. */
  15764. constructor(radius?: number, angle?: number,
  15765. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15766. directionRandomizer?: number);
  15767. /**
  15768. * Called by the particle System when the direction is computed for the created particle.
  15769. * @param worldMatrix is the world matrix of the particle system
  15770. * @param directionToUpdate is the direction vector to update with the result
  15771. * @param particle is the particle we are computed the direction for
  15772. * @param isLocal defines if the direction should be set in local space
  15773. */
  15774. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15775. /**
  15776. * Called by the particle System when the position is computed for the created particle.
  15777. * @param worldMatrix is the world matrix of the particle system
  15778. * @param positionToUpdate is the position vector to update with the result
  15779. * @param particle is the particle we are computed the position for
  15780. * @param isLocal defines if the position should be set in local space
  15781. */
  15782. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15783. /**
  15784. * Clones the current emitter and returns a copy of it
  15785. * @returns the new emitter
  15786. */
  15787. clone(): ConeParticleEmitter;
  15788. /**
  15789. * Called by the GPUParticleSystem to setup the update shader
  15790. * @param effect defines the update shader
  15791. */
  15792. applyToShader(effect: Effect): void;
  15793. /**
  15794. * Returns a string to use to update the GPU particles update shader
  15795. * @returns a string containng the defines string
  15796. */
  15797. getEffectDefines(): string;
  15798. /**
  15799. * Returns the string "ConeParticleEmitter"
  15800. * @returns a string containing the class name
  15801. */
  15802. getClassName(): string;
  15803. /**
  15804. * Serializes the particle system to a JSON object.
  15805. * @returns the JSON object
  15806. */
  15807. serialize(): any;
  15808. /**
  15809. * Parse properties from a JSON object
  15810. * @param serializationObject defines the JSON object
  15811. */
  15812. parse(serializationObject: any): void;
  15813. }
  15814. }
  15815. declare module BABYLON {
  15816. /**
  15817. * Particle emitter emitting particles from the inside of a cylinder.
  15818. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15819. */
  15820. export class CylinderParticleEmitter implements IParticleEmitterType {
  15821. /**
  15822. * The radius of the emission cylinder.
  15823. */
  15824. radius: number;
  15825. /**
  15826. * The height of the emission cylinder.
  15827. */
  15828. height: number;
  15829. /**
  15830. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15831. */
  15832. radiusRange: number;
  15833. /**
  15834. * How much to randomize the particle direction [0-1].
  15835. */
  15836. directionRandomizer: number;
  15837. /**
  15838. * Creates a new instance CylinderParticleEmitter
  15839. * @param radius the radius of the emission cylinder (1 by default)
  15840. * @param height the height of the emission cylinder (1 by default)
  15841. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15842. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15843. */
  15844. constructor(
  15845. /**
  15846. * The radius of the emission cylinder.
  15847. */
  15848. radius?: number,
  15849. /**
  15850. * The height of the emission cylinder.
  15851. */
  15852. height?: number,
  15853. /**
  15854. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15855. */
  15856. radiusRange?: number,
  15857. /**
  15858. * How much to randomize the particle direction [0-1].
  15859. */
  15860. directionRandomizer?: number);
  15861. /**
  15862. * Called by the particle System when the direction is computed for the created particle.
  15863. * @param worldMatrix is the world matrix of the particle system
  15864. * @param directionToUpdate is the direction vector to update with the result
  15865. * @param particle is the particle we are computed the direction for
  15866. * @param isLocal defines if the direction should be set in local space
  15867. */
  15868. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15869. /**
  15870. * Called by the particle System when the position is computed for the created particle.
  15871. * @param worldMatrix is the world matrix of the particle system
  15872. * @param positionToUpdate is the position vector to update with the result
  15873. * @param particle is the particle we are computed the position for
  15874. * @param isLocal defines if the position should be set in local space
  15875. */
  15876. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15877. /**
  15878. * Clones the current emitter and returns a copy of it
  15879. * @returns the new emitter
  15880. */
  15881. clone(): CylinderParticleEmitter;
  15882. /**
  15883. * Called by the GPUParticleSystem to setup the update shader
  15884. * @param effect defines the update shader
  15885. */
  15886. applyToShader(effect: Effect): void;
  15887. /**
  15888. * Returns a string to use to update the GPU particles update shader
  15889. * @returns a string containng the defines string
  15890. */
  15891. getEffectDefines(): string;
  15892. /**
  15893. * Returns the string "CylinderParticleEmitter"
  15894. * @returns a string containing the class name
  15895. */
  15896. getClassName(): string;
  15897. /**
  15898. * Serializes the particle system to a JSON object.
  15899. * @returns the JSON object
  15900. */
  15901. serialize(): any;
  15902. /**
  15903. * Parse properties from a JSON object
  15904. * @param serializationObject defines the JSON object
  15905. */
  15906. parse(serializationObject: any): void;
  15907. }
  15908. /**
  15909. * Particle emitter emitting particles from the inside of a cylinder.
  15910. * It emits the particles randomly between two vectors.
  15911. */
  15912. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15913. /**
  15914. * The min limit of the emission direction.
  15915. */
  15916. direction1: Vector3;
  15917. /**
  15918. * The max limit of the emission direction.
  15919. */
  15920. direction2: Vector3;
  15921. /**
  15922. * Creates a new instance CylinderDirectedParticleEmitter
  15923. * @param radius the radius of the emission cylinder (1 by default)
  15924. * @param height the height of the emission cylinder (1 by default)
  15925. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15926. * @param direction1 the min limit of the emission direction (up vector by default)
  15927. * @param direction2 the max limit of the emission direction (up vector by default)
  15928. */
  15929. constructor(radius?: number, height?: number, radiusRange?: number,
  15930. /**
  15931. * The min limit of the emission direction.
  15932. */
  15933. direction1?: Vector3,
  15934. /**
  15935. * The max limit of the emission direction.
  15936. */
  15937. direction2?: Vector3);
  15938. /**
  15939. * Called by the particle System when the direction is computed for the created particle.
  15940. * @param worldMatrix is the world matrix of the particle system
  15941. * @param directionToUpdate is the direction vector to update with the result
  15942. * @param particle is the particle we are computed the direction for
  15943. */
  15944. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15945. /**
  15946. * Clones the current emitter and returns a copy of it
  15947. * @returns the new emitter
  15948. */
  15949. clone(): CylinderDirectedParticleEmitter;
  15950. /**
  15951. * Called by the GPUParticleSystem to setup the update shader
  15952. * @param effect defines the update shader
  15953. */
  15954. applyToShader(effect: Effect): void;
  15955. /**
  15956. * Returns a string to use to update the GPU particles update shader
  15957. * @returns a string containng the defines string
  15958. */
  15959. getEffectDefines(): string;
  15960. /**
  15961. * Returns the string "CylinderDirectedParticleEmitter"
  15962. * @returns a string containing the class name
  15963. */
  15964. getClassName(): string;
  15965. /**
  15966. * Serializes the particle system to a JSON object.
  15967. * @returns the JSON object
  15968. */
  15969. serialize(): any;
  15970. /**
  15971. * Parse properties from a JSON object
  15972. * @param serializationObject defines the JSON object
  15973. */
  15974. parse(serializationObject: any): void;
  15975. }
  15976. }
  15977. declare module BABYLON {
  15978. /**
  15979. * Particle emitter emitting particles from the inside of a hemisphere.
  15980. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15981. */
  15982. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15983. /**
  15984. * The radius of the emission hemisphere.
  15985. */
  15986. radius: number;
  15987. /**
  15988. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15989. */
  15990. radiusRange: number;
  15991. /**
  15992. * How much to randomize the particle direction [0-1].
  15993. */
  15994. directionRandomizer: number;
  15995. /**
  15996. * Creates a new instance HemisphericParticleEmitter
  15997. * @param radius the radius of the emission hemisphere (1 by default)
  15998. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15999. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16000. */
  16001. constructor(
  16002. /**
  16003. * The radius of the emission hemisphere.
  16004. */
  16005. radius?: number,
  16006. /**
  16007. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16008. */
  16009. radiusRange?: number,
  16010. /**
  16011. * How much to randomize the particle direction [0-1].
  16012. */
  16013. directionRandomizer?: number);
  16014. /**
  16015. * Called by the particle System when the direction is computed for the created particle.
  16016. * @param worldMatrix is the world matrix of the particle system
  16017. * @param directionToUpdate is the direction vector to update with the result
  16018. * @param particle is the particle we are computed the direction for
  16019. * @param isLocal defines if the direction should be set in local space
  16020. */
  16021. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16022. /**
  16023. * Called by the particle System when the position is computed for the created particle.
  16024. * @param worldMatrix is the world matrix of the particle system
  16025. * @param positionToUpdate is the position vector to update with the result
  16026. * @param particle is the particle we are computed the position for
  16027. * @param isLocal defines if the position should be set in local space
  16028. */
  16029. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16030. /**
  16031. * Clones the current emitter and returns a copy of it
  16032. * @returns the new emitter
  16033. */
  16034. clone(): HemisphericParticleEmitter;
  16035. /**
  16036. * Called by the GPUParticleSystem to setup the update shader
  16037. * @param effect defines the update shader
  16038. */
  16039. applyToShader(effect: Effect): void;
  16040. /**
  16041. * Returns a string to use to update the GPU particles update shader
  16042. * @returns a string containng the defines string
  16043. */
  16044. getEffectDefines(): string;
  16045. /**
  16046. * Returns the string "HemisphericParticleEmitter"
  16047. * @returns a string containing the class name
  16048. */
  16049. getClassName(): string;
  16050. /**
  16051. * Serializes the particle system to a JSON object.
  16052. * @returns the JSON object
  16053. */
  16054. serialize(): any;
  16055. /**
  16056. * Parse properties from a JSON object
  16057. * @param serializationObject defines the JSON object
  16058. */
  16059. parse(serializationObject: any): void;
  16060. }
  16061. }
  16062. declare module BABYLON {
  16063. /**
  16064. * Particle emitter emitting particles from a point.
  16065. * It emits the particles randomly between 2 given directions.
  16066. */
  16067. export class PointParticleEmitter implements IParticleEmitterType {
  16068. /**
  16069. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16070. */
  16071. direction1: Vector3;
  16072. /**
  16073. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16074. */
  16075. direction2: Vector3;
  16076. /**
  16077. * Creates a new instance PointParticleEmitter
  16078. */
  16079. constructor();
  16080. /**
  16081. * Called by the particle System when the direction is computed for the created particle.
  16082. * @param worldMatrix is the world matrix of the particle system
  16083. * @param directionToUpdate is the direction vector to update with the result
  16084. * @param particle is the particle we are computed the direction for
  16085. * @param isLocal defines if the direction should be set in local space
  16086. */
  16087. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16088. /**
  16089. * Called by the particle System when the position is computed for the created particle.
  16090. * @param worldMatrix is the world matrix of the particle system
  16091. * @param positionToUpdate is the position vector to update with the result
  16092. * @param particle is the particle we are computed the position for
  16093. * @param isLocal defines if the position should be set in local space
  16094. */
  16095. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16096. /**
  16097. * Clones the current emitter and returns a copy of it
  16098. * @returns the new emitter
  16099. */
  16100. clone(): PointParticleEmitter;
  16101. /**
  16102. * Called by the GPUParticleSystem to setup the update shader
  16103. * @param effect defines the update shader
  16104. */
  16105. applyToShader(effect: Effect): void;
  16106. /**
  16107. * Returns a string to use to update the GPU particles update shader
  16108. * @returns a string containng the defines string
  16109. */
  16110. getEffectDefines(): string;
  16111. /**
  16112. * Returns the string "PointParticleEmitter"
  16113. * @returns a string containing the class name
  16114. */
  16115. getClassName(): string;
  16116. /**
  16117. * Serializes the particle system to a JSON object.
  16118. * @returns the JSON object
  16119. */
  16120. serialize(): any;
  16121. /**
  16122. * Parse properties from a JSON object
  16123. * @param serializationObject defines the JSON object
  16124. */
  16125. parse(serializationObject: any): void;
  16126. }
  16127. }
  16128. declare module BABYLON {
  16129. /**
  16130. * Particle emitter emitting particles from the inside of a sphere.
  16131. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16132. */
  16133. export class SphereParticleEmitter implements IParticleEmitterType {
  16134. /**
  16135. * The radius of the emission sphere.
  16136. */
  16137. radius: number;
  16138. /**
  16139. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16140. */
  16141. radiusRange: number;
  16142. /**
  16143. * How much to randomize the particle direction [0-1].
  16144. */
  16145. directionRandomizer: number;
  16146. /**
  16147. * Creates a new instance SphereParticleEmitter
  16148. * @param radius the radius of the emission sphere (1 by default)
  16149. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16150. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16151. */
  16152. constructor(
  16153. /**
  16154. * The radius of the emission sphere.
  16155. */
  16156. radius?: number,
  16157. /**
  16158. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16159. */
  16160. radiusRange?: number,
  16161. /**
  16162. * How much to randomize the particle direction [0-1].
  16163. */
  16164. directionRandomizer?: number);
  16165. /**
  16166. * Called by the particle System when the direction is computed for the created particle.
  16167. * @param worldMatrix is the world matrix of the particle system
  16168. * @param directionToUpdate is the direction vector to update with the result
  16169. * @param particle is the particle we are computed the direction for
  16170. * @param isLocal defines if the direction should be set in local space
  16171. */
  16172. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16173. /**
  16174. * Called by the particle System when the position is computed for the created particle.
  16175. * @param worldMatrix is the world matrix of the particle system
  16176. * @param positionToUpdate is the position vector to update with the result
  16177. * @param particle is the particle we are computed the position for
  16178. * @param isLocal defines if the position should be set in local space
  16179. */
  16180. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16181. /**
  16182. * Clones the current emitter and returns a copy of it
  16183. * @returns the new emitter
  16184. */
  16185. clone(): SphereParticleEmitter;
  16186. /**
  16187. * Called by the GPUParticleSystem to setup the update shader
  16188. * @param effect defines the update shader
  16189. */
  16190. applyToShader(effect: Effect): void;
  16191. /**
  16192. * Returns a string to use to update the GPU particles update shader
  16193. * @returns a string containng the defines string
  16194. */
  16195. getEffectDefines(): string;
  16196. /**
  16197. * Returns the string "SphereParticleEmitter"
  16198. * @returns a string containing the class name
  16199. */
  16200. getClassName(): string;
  16201. /**
  16202. * Serializes the particle system to a JSON object.
  16203. * @returns the JSON object
  16204. */
  16205. serialize(): any;
  16206. /**
  16207. * Parse properties from a JSON object
  16208. * @param serializationObject defines the JSON object
  16209. */
  16210. parse(serializationObject: any): void;
  16211. }
  16212. /**
  16213. * Particle emitter emitting particles from the inside of a sphere.
  16214. * It emits the particles randomly between two vectors.
  16215. */
  16216. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16217. /**
  16218. * The min limit of the emission direction.
  16219. */
  16220. direction1: Vector3;
  16221. /**
  16222. * The max limit of the emission direction.
  16223. */
  16224. direction2: Vector3;
  16225. /**
  16226. * Creates a new instance SphereDirectedParticleEmitter
  16227. * @param radius the radius of the emission sphere (1 by default)
  16228. * @param direction1 the min limit of the emission direction (up vector by default)
  16229. * @param direction2 the max limit of the emission direction (up vector by default)
  16230. */
  16231. constructor(radius?: number,
  16232. /**
  16233. * The min limit of the emission direction.
  16234. */
  16235. direction1?: Vector3,
  16236. /**
  16237. * The max limit of the emission direction.
  16238. */
  16239. direction2?: Vector3);
  16240. /**
  16241. * Called by the particle System when the direction is computed for the created particle.
  16242. * @param worldMatrix is the world matrix of the particle system
  16243. * @param directionToUpdate is the direction vector to update with the result
  16244. * @param particle is the particle we are computed the direction for
  16245. */
  16246. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16247. /**
  16248. * Clones the current emitter and returns a copy of it
  16249. * @returns the new emitter
  16250. */
  16251. clone(): SphereDirectedParticleEmitter;
  16252. /**
  16253. * Called by the GPUParticleSystem to setup the update shader
  16254. * @param effect defines the update shader
  16255. */
  16256. applyToShader(effect: Effect): void;
  16257. /**
  16258. * Returns a string to use to update the GPU particles update shader
  16259. * @returns a string containng the defines string
  16260. */
  16261. getEffectDefines(): string;
  16262. /**
  16263. * Returns the string "SphereDirectedParticleEmitter"
  16264. * @returns a string containing the class name
  16265. */
  16266. getClassName(): string;
  16267. /**
  16268. * Serializes the particle system to a JSON object.
  16269. * @returns the JSON object
  16270. */
  16271. serialize(): any;
  16272. /**
  16273. * Parse properties from a JSON object
  16274. * @param serializationObject defines the JSON object
  16275. */
  16276. parse(serializationObject: any): void;
  16277. }
  16278. }
  16279. declare module BABYLON {
  16280. /**
  16281. * Particle emitter emitting particles from a custom list of positions.
  16282. */
  16283. export class CustomParticleEmitter implements IParticleEmitterType {
  16284. /**
  16285. * Gets or sets the position generator that will create the inital position of each particle.
  16286. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16287. */
  16288. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16289. /**
  16290. * Gets or sets the destination generator that will create the final destination of each particle.
  16291. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16292. */
  16293. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16294. /**
  16295. * Creates a new instance CustomParticleEmitter
  16296. */
  16297. constructor();
  16298. /**
  16299. * Called by the particle System when the direction is computed for the created particle.
  16300. * @param worldMatrix is the world matrix of the particle system
  16301. * @param directionToUpdate is the direction vector to update with the result
  16302. * @param particle is the particle we are computed the direction for
  16303. * @param isLocal defines if the direction should be set in local space
  16304. */
  16305. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16306. /**
  16307. * Called by the particle System when the position is computed for the created particle.
  16308. * @param worldMatrix is the world matrix of the particle system
  16309. * @param positionToUpdate is the position vector to update with the result
  16310. * @param particle is the particle we are computed the position for
  16311. * @param isLocal defines if the position should be set in local space
  16312. */
  16313. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16314. /**
  16315. * Clones the current emitter and returns a copy of it
  16316. * @returns the new emitter
  16317. */
  16318. clone(): CustomParticleEmitter;
  16319. /**
  16320. * Called by the GPUParticleSystem to setup the update shader
  16321. * @param effect defines the update shader
  16322. */
  16323. applyToShader(effect: Effect): void;
  16324. /**
  16325. * Returns a string to use to update the GPU particles update shader
  16326. * @returns a string containng the defines string
  16327. */
  16328. getEffectDefines(): string;
  16329. /**
  16330. * Returns the string "PointParticleEmitter"
  16331. * @returns a string containing the class name
  16332. */
  16333. getClassName(): string;
  16334. /**
  16335. * Serializes the particle system to a JSON object.
  16336. * @returns the JSON object
  16337. */
  16338. serialize(): any;
  16339. /**
  16340. * Parse properties from a JSON object
  16341. * @param serializationObject defines the JSON object
  16342. */
  16343. parse(serializationObject: any): void;
  16344. }
  16345. }
  16346. declare module BABYLON {
  16347. /**
  16348. * Particle emitter emitting particles from the inside of a box.
  16349. * It emits the particles randomly between 2 given directions.
  16350. */
  16351. export class MeshParticleEmitter implements IParticleEmitterType {
  16352. private _indices;
  16353. private _positions;
  16354. private _normals;
  16355. private _storedNormal;
  16356. private _mesh;
  16357. /**
  16358. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16359. */
  16360. direction1: Vector3;
  16361. /**
  16362. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16363. */
  16364. direction2: Vector3;
  16365. /**
  16366. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16367. */
  16368. useMeshNormalsForDirection: boolean;
  16369. /** Defines the mesh to use as source */
  16370. get mesh(): Nullable<AbstractMesh>;
  16371. set mesh(value: Nullable<AbstractMesh>);
  16372. /**
  16373. * Creates a new instance MeshParticleEmitter
  16374. * @param mesh defines the mesh to use as source
  16375. */
  16376. constructor(mesh?: Nullable<AbstractMesh>);
  16377. /**
  16378. * Called by the particle System when the direction is computed for the created particle.
  16379. * @param worldMatrix is the world matrix of the particle system
  16380. * @param directionToUpdate is the direction vector to update with the result
  16381. * @param particle is the particle we are computed the direction for
  16382. * @param isLocal defines if the direction should be set in local space
  16383. */
  16384. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16385. /**
  16386. * Called by the particle System when the position is computed for the created particle.
  16387. * @param worldMatrix is the world matrix of the particle system
  16388. * @param positionToUpdate is the position vector to update with the result
  16389. * @param particle is the particle we are computed the position for
  16390. * @param isLocal defines if the position should be set in local space
  16391. */
  16392. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16393. /**
  16394. * Clones the current emitter and returns a copy of it
  16395. * @returns the new emitter
  16396. */
  16397. clone(): MeshParticleEmitter;
  16398. /**
  16399. * Called by the GPUParticleSystem to setup the update shader
  16400. * @param effect defines the update shader
  16401. */
  16402. applyToShader(effect: Effect): void;
  16403. /**
  16404. * Returns a string to use to update the GPU particles update shader
  16405. * @returns a string containng the defines string
  16406. */
  16407. getEffectDefines(): string;
  16408. /**
  16409. * Returns the string "BoxParticleEmitter"
  16410. * @returns a string containing the class name
  16411. */
  16412. getClassName(): string;
  16413. /**
  16414. * Serializes the particle system to a JSON object.
  16415. * @returns the JSON object
  16416. */
  16417. serialize(): any;
  16418. /**
  16419. * Parse properties from a JSON object
  16420. * @param serializationObject defines the JSON object
  16421. * @param scene defines the hosting scene
  16422. */
  16423. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16424. }
  16425. }
  16426. declare module BABYLON {
  16427. /**
  16428. * Interface representing a particle system in Babylon.js.
  16429. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16430. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16431. */
  16432. export interface IParticleSystem {
  16433. /**
  16434. * List of animations used by the particle system.
  16435. */
  16436. animations: Animation[];
  16437. /**
  16438. * The id of the Particle system.
  16439. */
  16440. id: string;
  16441. /**
  16442. * The name of the Particle system.
  16443. */
  16444. name: string;
  16445. /**
  16446. * The emitter represents the Mesh or position we are attaching the particle system to.
  16447. */
  16448. emitter: Nullable<AbstractMesh | Vector3>;
  16449. /**
  16450. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16451. */
  16452. isBillboardBased: boolean;
  16453. /**
  16454. * The rendering group used by the Particle system to chose when to render.
  16455. */
  16456. renderingGroupId: number;
  16457. /**
  16458. * The layer mask we are rendering the particles through.
  16459. */
  16460. layerMask: number;
  16461. /**
  16462. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16463. */
  16464. updateSpeed: number;
  16465. /**
  16466. * The amount of time the particle system is running (depends of the overall update speed).
  16467. */
  16468. targetStopDuration: number;
  16469. /**
  16470. * The texture used to render each particle. (this can be a spritesheet)
  16471. */
  16472. particleTexture: Nullable<BaseTexture>;
  16473. /**
  16474. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16475. */
  16476. blendMode: number;
  16477. /**
  16478. * Minimum life time of emitting particles.
  16479. */
  16480. minLifeTime: number;
  16481. /**
  16482. * Maximum life time of emitting particles.
  16483. */
  16484. maxLifeTime: number;
  16485. /**
  16486. * Minimum Size of emitting particles.
  16487. */
  16488. minSize: number;
  16489. /**
  16490. * Maximum Size of emitting particles.
  16491. */
  16492. maxSize: number;
  16493. /**
  16494. * Minimum scale of emitting particles on X axis.
  16495. */
  16496. minScaleX: number;
  16497. /**
  16498. * Maximum scale of emitting particles on X axis.
  16499. */
  16500. maxScaleX: number;
  16501. /**
  16502. * Minimum scale of emitting particles on Y axis.
  16503. */
  16504. minScaleY: number;
  16505. /**
  16506. * Maximum scale of emitting particles on Y axis.
  16507. */
  16508. maxScaleY: number;
  16509. /**
  16510. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16511. */
  16512. color1: Color4;
  16513. /**
  16514. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16515. */
  16516. color2: Color4;
  16517. /**
  16518. * Color the particle will have at the end of its lifetime.
  16519. */
  16520. colorDead: Color4;
  16521. /**
  16522. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16523. */
  16524. emitRate: number;
  16525. /**
  16526. * You can use gravity if you want to give an orientation to your particles.
  16527. */
  16528. gravity: Vector3;
  16529. /**
  16530. * Minimum power of emitting particles.
  16531. */
  16532. minEmitPower: number;
  16533. /**
  16534. * Maximum power of emitting particles.
  16535. */
  16536. maxEmitPower: number;
  16537. /**
  16538. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16539. */
  16540. minAngularSpeed: number;
  16541. /**
  16542. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16543. */
  16544. maxAngularSpeed: number;
  16545. /**
  16546. * Gets or sets the minimal initial rotation in radians.
  16547. */
  16548. minInitialRotation: number;
  16549. /**
  16550. * Gets or sets the maximal initial rotation in radians.
  16551. */
  16552. maxInitialRotation: number;
  16553. /**
  16554. * The particle emitter type defines the emitter used by the particle system.
  16555. * It can be for example box, sphere, or cone...
  16556. */
  16557. particleEmitterType: Nullable<IParticleEmitterType>;
  16558. /**
  16559. * Defines the delay in milliseconds before starting the system (0 by default)
  16560. */
  16561. startDelay: number;
  16562. /**
  16563. * 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
  16564. */
  16565. preWarmCycles: number;
  16566. /**
  16567. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16568. */
  16569. preWarmStepOffset: number;
  16570. /**
  16571. * 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)
  16572. */
  16573. spriteCellChangeSpeed: number;
  16574. /**
  16575. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16576. */
  16577. startSpriteCellID: number;
  16578. /**
  16579. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16580. */
  16581. endSpriteCellID: number;
  16582. /**
  16583. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16584. */
  16585. spriteCellWidth: number;
  16586. /**
  16587. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16588. */
  16589. spriteCellHeight: number;
  16590. /**
  16591. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16592. */
  16593. spriteRandomStartCell: boolean;
  16594. /**
  16595. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16596. */
  16597. isAnimationSheetEnabled: boolean;
  16598. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16599. translationPivot: Vector2;
  16600. /**
  16601. * Gets or sets a texture used to add random noise to particle positions
  16602. */
  16603. noiseTexture: Nullable<BaseTexture>;
  16604. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16605. noiseStrength: Vector3;
  16606. /**
  16607. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16608. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16609. */
  16610. billboardMode: number;
  16611. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16612. limitVelocityDamping: number;
  16613. /**
  16614. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16615. */
  16616. beginAnimationOnStart: boolean;
  16617. /**
  16618. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16619. */
  16620. beginAnimationFrom: number;
  16621. /**
  16622. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16623. */
  16624. beginAnimationTo: number;
  16625. /**
  16626. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16627. */
  16628. beginAnimationLoop: boolean;
  16629. /**
  16630. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16631. */
  16632. disposeOnStop: boolean;
  16633. /**
  16634. * Specifies if the particles are updated in emitter local space or world space
  16635. */
  16636. isLocal: boolean;
  16637. /** Snippet ID if the particle system was created from the snippet server */
  16638. snippetId: string;
  16639. /** Gets or sets a matrix to use to compute projection */
  16640. defaultProjectionMatrix: Matrix;
  16641. /**
  16642. * Gets the maximum number of particles active at the same time.
  16643. * @returns The max number of active particles.
  16644. */
  16645. getCapacity(): number;
  16646. /**
  16647. * Gets the number of particles active at the same time.
  16648. * @returns The number of active particles.
  16649. */
  16650. getActiveCount(): number;
  16651. /**
  16652. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16653. * @returns True if it has been started, otherwise false.
  16654. */
  16655. isStarted(): boolean;
  16656. /**
  16657. * Animates the particle system for this frame.
  16658. */
  16659. animate(): void;
  16660. /**
  16661. * Renders the particle system in its current state.
  16662. * @returns the current number of particles
  16663. */
  16664. render(): number;
  16665. /**
  16666. * Dispose the particle system and frees its associated resources.
  16667. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16668. */
  16669. dispose(disposeTexture?: boolean): void;
  16670. /**
  16671. * An event triggered when the system is disposed
  16672. */
  16673. onDisposeObservable: Observable<IParticleSystem>;
  16674. /**
  16675. * An event triggered when the system is stopped
  16676. */
  16677. onStoppedObservable: Observable<IParticleSystem>;
  16678. /**
  16679. * Clones the particle system.
  16680. * @param name The name of the cloned object
  16681. * @param newEmitter The new emitter to use
  16682. * @returns the cloned particle system
  16683. */
  16684. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16685. /**
  16686. * Serializes the particle system to a JSON object
  16687. * @param serializeTexture defines if the texture must be serialized as well
  16688. * @returns the JSON object
  16689. */
  16690. serialize(serializeTexture: boolean): any;
  16691. /**
  16692. * Rebuild the particle system
  16693. */
  16694. rebuild(): void;
  16695. /** Force the system to rebuild all gradients that need to be resync */
  16696. forceRefreshGradients(): void;
  16697. /**
  16698. * Starts the particle system and begins to emit
  16699. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16700. */
  16701. start(delay?: number): void;
  16702. /**
  16703. * Stops the particle system.
  16704. */
  16705. stop(): void;
  16706. /**
  16707. * Remove all active particles
  16708. */
  16709. reset(): void;
  16710. /**
  16711. * Gets a boolean indicating that the system is stopping
  16712. * @returns true if the system is currently stopping
  16713. */
  16714. isStopping(): boolean;
  16715. /**
  16716. * Is this system ready to be used/rendered
  16717. * @return true if the system is ready
  16718. */
  16719. isReady(): boolean;
  16720. /**
  16721. * Returns the string "ParticleSystem"
  16722. * @returns a string containing the class name
  16723. */
  16724. getClassName(): string;
  16725. /**
  16726. * Gets the custom effect used to render the particles
  16727. * @param blendMode Blend mode for which the effect should be retrieved
  16728. * @returns The effect
  16729. */
  16730. getCustomEffect(blendMode: number): Nullable<Effect>;
  16731. /**
  16732. * Sets the custom effect used to render the particles
  16733. * @param effect The effect to set
  16734. * @param blendMode Blend mode for which the effect should be set
  16735. */
  16736. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  16737. /**
  16738. * Fill the defines array according to the current settings of the particle system
  16739. * @param defines Array to be updated
  16740. * @param blendMode blend mode to take into account when updating the array
  16741. */
  16742. fillDefines(defines: Array<string>, blendMode: number): void;
  16743. /**
  16744. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16745. * @param uniforms Uniforms array to fill
  16746. * @param attributes Attributes array to fill
  16747. * @param samplers Samplers array to fill
  16748. */
  16749. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16750. /**
  16751. * Observable that will be called just before the particles are drawn
  16752. */
  16753. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  16754. /**
  16755. * Gets the name of the particle vertex shader
  16756. */
  16757. vertexShaderName: string;
  16758. /**
  16759. * Adds a new color gradient
  16760. * @param gradient defines the gradient to use (between 0 and 1)
  16761. * @param color1 defines the color to affect to the specified gradient
  16762. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16763. * @returns the current particle system
  16764. */
  16765. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16766. /**
  16767. * Remove a specific color gradient
  16768. * @param gradient defines the gradient to remove
  16769. * @returns the current particle system
  16770. */
  16771. removeColorGradient(gradient: number): IParticleSystem;
  16772. /**
  16773. * Adds a new size gradient
  16774. * @param gradient defines the gradient to use (between 0 and 1)
  16775. * @param factor defines the size factor to affect to the specified gradient
  16776. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16777. * @returns the current particle system
  16778. */
  16779. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16780. /**
  16781. * Remove a specific size gradient
  16782. * @param gradient defines the gradient to remove
  16783. * @returns the current particle system
  16784. */
  16785. removeSizeGradient(gradient: number): IParticleSystem;
  16786. /**
  16787. * Gets the current list of color gradients.
  16788. * You must use addColorGradient and removeColorGradient to udpate this list
  16789. * @returns the list of color gradients
  16790. */
  16791. getColorGradients(): Nullable<Array<ColorGradient>>;
  16792. /**
  16793. * Gets the current list of size gradients.
  16794. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16795. * @returns the list of size gradients
  16796. */
  16797. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16798. /**
  16799. * Gets the current list of angular speed gradients.
  16800. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16801. * @returns the list of angular speed gradients
  16802. */
  16803. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16804. /**
  16805. * Adds a new angular speed gradient
  16806. * @param gradient defines the gradient to use (between 0 and 1)
  16807. * @param factor defines the angular speed to affect to the specified gradient
  16808. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16809. * @returns the current particle system
  16810. */
  16811. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16812. /**
  16813. * Remove a specific angular speed gradient
  16814. * @param gradient defines the gradient to remove
  16815. * @returns the current particle system
  16816. */
  16817. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16818. /**
  16819. * Gets the current list of velocity gradients.
  16820. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16821. * @returns the list of velocity gradients
  16822. */
  16823. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16824. /**
  16825. * Adds a new velocity gradient
  16826. * @param gradient defines the gradient to use (between 0 and 1)
  16827. * @param factor defines the velocity to affect to the specified gradient
  16828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16829. * @returns the current particle system
  16830. */
  16831. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16832. /**
  16833. * Remove a specific velocity gradient
  16834. * @param gradient defines the gradient to remove
  16835. * @returns the current particle system
  16836. */
  16837. removeVelocityGradient(gradient: number): IParticleSystem;
  16838. /**
  16839. * Gets the current list of limit velocity gradients.
  16840. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16841. * @returns the list of limit velocity gradients
  16842. */
  16843. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16844. /**
  16845. * Adds a new limit velocity gradient
  16846. * @param gradient defines the gradient to use (between 0 and 1)
  16847. * @param factor defines the limit velocity to affect to the specified gradient
  16848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16849. * @returns the current particle system
  16850. */
  16851. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16852. /**
  16853. * Remove a specific limit velocity gradient
  16854. * @param gradient defines the gradient to remove
  16855. * @returns the current particle system
  16856. */
  16857. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16858. /**
  16859. * Adds a new drag gradient
  16860. * @param gradient defines the gradient to use (between 0 and 1)
  16861. * @param factor defines the drag to affect to the specified gradient
  16862. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16863. * @returns the current particle system
  16864. */
  16865. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16866. /**
  16867. * Remove a specific drag gradient
  16868. * @param gradient defines the gradient to remove
  16869. * @returns the current particle system
  16870. */
  16871. removeDragGradient(gradient: number): IParticleSystem;
  16872. /**
  16873. * Gets the current list of drag gradients.
  16874. * You must use addDragGradient and removeDragGradient to udpate this list
  16875. * @returns the list of drag gradients
  16876. */
  16877. getDragGradients(): Nullable<Array<FactorGradient>>;
  16878. /**
  16879. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16880. * @param gradient defines the gradient to use (between 0 and 1)
  16881. * @param factor defines the emit rate to affect to the specified gradient
  16882. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16883. * @returns the current particle system
  16884. */
  16885. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16886. /**
  16887. * Remove a specific emit rate gradient
  16888. * @param gradient defines the gradient to remove
  16889. * @returns the current particle system
  16890. */
  16891. removeEmitRateGradient(gradient: number): IParticleSystem;
  16892. /**
  16893. * Gets the current list of emit rate gradients.
  16894. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16895. * @returns the list of emit rate gradients
  16896. */
  16897. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16898. /**
  16899. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16900. * @param gradient defines the gradient to use (between 0 and 1)
  16901. * @param factor defines the start size to affect to the specified gradient
  16902. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16903. * @returns the current particle system
  16904. */
  16905. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16906. /**
  16907. * Remove a specific start size gradient
  16908. * @param gradient defines the gradient to remove
  16909. * @returns the current particle system
  16910. */
  16911. removeStartSizeGradient(gradient: number): IParticleSystem;
  16912. /**
  16913. * Gets the current list of start size gradients.
  16914. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16915. * @returns the list of start size gradients
  16916. */
  16917. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16918. /**
  16919. * Adds a new life time gradient
  16920. * @param gradient defines the gradient to use (between 0 and 1)
  16921. * @param factor defines the life time factor to affect to the specified gradient
  16922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16923. * @returns the current particle system
  16924. */
  16925. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16926. /**
  16927. * Remove a specific life time gradient
  16928. * @param gradient defines the gradient to remove
  16929. * @returns the current particle system
  16930. */
  16931. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16932. /**
  16933. * Gets the current list of life time gradients.
  16934. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16935. * @returns the list of life time gradients
  16936. */
  16937. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16938. /**
  16939. * Gets the current list of color gradients.
  16940. * You must use addColorGradient and removeColorGradient to udpate this list
  16941. * @returns the list of color gradients
  16942. */
  16943. getColorGradients(): Nullable<Array<ColorGradient>>;
  16944. /**
  16945. * Adds a new ramp gradient used to remap particle colors
  16946. * @param gradient defines the gradient to use (between 0 and 1)
  16947. * @param color defines the color to affect to the specified gradient
  16948. * @returns the current particle system
  16949. */
  16950. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16951. /**
  16952. * Gets the current list of ramp gradients.
  16953. * You must use addRampGradient and removeRampGradient to udpate this list
  16954. * @returns the list of ramp gradients
  16955. */
  16956. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16957. /** Gets or sets a boolean indicating that ramp gradients must be used
  16958. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16959. */
  16960. useRampGradients: boolean;
  16961. /**
  16962. * Adds a new color remap gradient
  16963. * @param gradient defines the gradient to use (between 0 and 1)
  16964. * @param min defines the color remap minimal range
  16965. * @param max defines the color remap maximal range
  16966. * @returns the current particle system
  16967. */
  16968. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16969. /**
  16970. * Gets the current list of color remap gradients.
  16971. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16972. * @returns the list of color remap gradients
  16973. */
  16974. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16975. /**
  16976. * Adds a new alpha remap gradient
  16977. * @param gradient defines the gradient to use (between 0 and 1)
  16978. * @param min defines the alpha remap minimal range
  16979. * @param max defines the alpha remap maximal range
  16980. * @returns the current particle system
  16981. */
  16982. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16983. /**
  16984. * Gets the current list of alpha remap gradients.
  16985. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16986. * @returns the list of alpha remap gradients
  16987. */
  16988. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16989. /**
  16990. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16991. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16992. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16993. * @returns the emitter
  16994. */
  16995. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16996. /**
  16997. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16998. * @param radius The radius of the hemisphere to emit from
  16999. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17000. * @returns the emitter
  17001. */
  17002. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17003. /**
  17004. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17005. * @param radius The radius of the sphere to emit from
  17006. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17007. * @returns the emitter
  17008. */
  17009. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17010. /**
  17011. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17012. * @param radius The radius of the sphere to emit from
  17013. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17014. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17015. * @returns the emitter
  17016. */
  17017. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17018. /**
  17019. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17020. * @param radius The radius of the emission cylinder
  17021. * @param height The height of the emission cylinder
  17022. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17023. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17024. * @returns the emitter
  17025. */
  17026. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17027. /**
  17028. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17029. * @param radius The radius of the cylinder to emit from
  17030. * @param height The height of the emission cylinder
  17031. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17032. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17033. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17034. * @returns the emitter
  17035. */
  17036. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17037. /**
  17038. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17039. * @param radius The radius of the cone to emit from
  17040. * @param angle The base angle of the cone
  17041. * @returns the emitter
  17042. */
  17043. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17044. /**
  17045. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17046. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17047. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17048. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17049. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17050. * @returns the emitter
  17051. */
  17052. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17053. /**
  17054. * Get hosting scene
  17055. * @returns the scene
  17056. */
  17057. getScene(): Nullable<Scene>;
  17058. }
  17059. }
  17060. declare module BABYLON {
  17061. /**
  17062. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17063. */
  17064. export class ColorSplitterBlock extends NodeMaterialBlock {
  17065. /**
  17066. * Create a new ColorSplitterBlock
  17067. * @param name defines the block name
  17068. */
  17069. constructor(name: string);
  17070. /**
  17071. * Gets the current class name
  17072. * @returns the class name
  17073. */
  17074. getClassName(): string;
  17075. /**
  17076. * Gets the rgba component (input)
  17077. */
  17078. get rgba(): NodeMaterialConnectionPoint;
  17079. /**
  17080. * Gets the rgb component (input)
  17081. */
  17082. get rgbIn(): NodeMaterialConnectionPoint;
  17083. /**
  17084. * Gets the rgb component (output)
  17085. */
  17086. get rgbOut(): NodeMaterialConnectionPoint;
  17087. /**
  17088. * Gets the r component (output)
  17089. */
  17090. get r(): NodeMaterialConnectionPoint;
  17091. /**
  17092. * Gets the g component (output)
  17093. */
  17094. get g(): NodeMaterialConnectionPoint;
  17095. /**
  17096. * Gets the b component (output)
  17097. */
  17098. get b(): NodeMaterialConnectionPoint;
  17099. /**
  17100. * Gets the a component (output)
  17101. */
  17102. get a(): NodeMaterialConnectionPoint;
  17103. protected _inputRename(name: string): string;
  17104. protected _outputRename(name: string): string;
  17105. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17106. }
  17107. }
  17108. declare module BABYLON {
  17109. /**
  17110. * Operations supported by the Trigonometry block
  17111. */
  17112. export enum TrigonometryBlockOperations {
  17113. /** Cos */
  17114. Cos = 0,
  17115. /** Sin */
  17116. Sin = 1,
  17117. /** Abs */
  17118. Abs = 2,
  17119. /** Exp */
  17120. Exp = 3,
  17121. /** Exp2 */
  17122. Exp2 = 4,
  17123. /** Round */
  17124. Round = 5,
  17125. /** Floor */
  17126. Floor = 6,
  17127. /** Ceiling */
  17128. Ceiling = 7,
  17129. /** Square root */
  17130. Sqrt = 8,
  17131. /** Log */
  17132. Log = 9,
  17133. /** Tangent */
  17134. Tan = 10,
  17135. /** Arc tangent */
  17136. ArcTan = 11,
  17137. /** Arc cosinus */
  17138. ArcCos = 12,
  17139. /** Arc sinus */
  17140. ArcSin = 13,
  17141. /** Fraction */
  17142. Fract = 14,
  17143. /** Sign */
  17144. Sign = 15,
  17145. /** To radians (from degrees) */
  17146. Radians = 16,
  17147. /** To degrees (from radians) */
  17148. Degrees = 17
  17149. }
  17150. /**
  17151. * Block used to apply trigonometry operation to floats
  17152. */
  17153. export class TrigonometryBlock extends NodeMaterialBlock {
  17154. /**
  17155. * Gets or sets the operation applied by the block
  17156. */
  17157. operation: TrigonometryBlockOperations;
  17158. /**
  17159. * Creates a new TrigonometryBlock
  17160. * @param name defines the block name
  17161. */
  17162. constructor(name: string);
  17163. /**
  17164. * Gets the current class name
  17165. * @returns the class name
  17166. */
  17167. getClassName(): string;
  17168. /**
  17169. * Gets the input component
  17170. */
  17171. get input(): NodeMaterialConnectionPoint;
  17172. /**
  17173. * Gets the output component
  17174. */
  17175. get output(): NodeMaterialConnectionPoint;
  17176. protected _buildBlock(state: NodeMaterialBuildState): this;
  17177. serialize(): any;
  17178. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17179. protected _dumpPropertiesCode(): string;
  17180. }
  17181. }
  17182. declare module BABYLON {
  17183. /**
  17184. * Interface used to configure the node material editor
  17185. */
  17186. export interface INodeMaterialEditorOptions {
  17187. /** Define the URl to load node editor script */
  17188. editorURL?: string;
  17189. }
  17190. /** @hidden */
  17191. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17192. NORMAL: boolean;
  17193. TANGENT: boolean;
  17194. UV1: boolean;
  17195. /** BONES */
  17196. NUM_BONE_INFLUENCERS: number;
  17197. BonesPerMesh: number;
  17198. BONETEXTURE: boolean;
  17199. /** MORPH TARGETS */
  17200. MORPHTARGETS: boolean;
  17201. MORPHTARGETS_NORMAL: boolean;
  17202. MORPHTARGETS_TANGENT: boolean;
  17203. MORPHTARGETS_UV: boolean;
  17204. NUM_MORPH_INFLUENCERS: number;
  17205. /** IMAGE PROCESSING */
  17206. IMAGEPROCESSING: boolean;
  17207. VIGNETTE: boolean;
  17208. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17209. VIGNETTEBLENDMODEOPAQUE: boolean;
  17210. TONEMAPPING: boolean;
  17211. TONEMAPPING_ACES: boolean;
  17212. CONTRAST: boolean;
  17213. EXPOSURE: boolean;
  17214. COLORCURVES: boolean;
  17215. COLORGRADING: boolean;
  17216. COLORGRADING3D: boolean;
  17217. SAMPLER3DGREENDEPTH: boolean;
  17218. SAMPLER3DBGRMAP: boolean;
  17219. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17220. /** MISC. */
  17221. BUMPDIRECTUV: number;
  17222. constructor();
  17223. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17224. }
  17225. /**
  17226. * Class used to configure NodeMaterial
  17227. */
  17228. export interface INodeMaterialOptions {
  17229. /**
  17230. * Defines if blocks should emit comments
  17231. */
  17232. emitComments: boolean;
  17233. }
  17234. /**
  17235. * Class used to create a node based material built by assembling shader blocks
  17236. */
  17237. export class NodeMaterial extends PushMaterial {
  17238. private static _BuildIdGenerator;
  17239. private _options;
  17240. private _vertexCompilationState;
  17241. private _fragmentCompilationState;
  17242. private _sharedData;
  17243. private _buildId;
  17244. private _buildWasSuccessful;
  17245. private _cachedWorldViewMatrix;
  17246. private _cachedWorldViewProjectionMatrix;
  17247. private _optimizers;
  17248. private _animationFrame;
  17249. /** Define the Url to load node editor script */
  17250. static EditorURL: string;
  17251. /** Define the Url to load snippets */
  17252. static SnippetUrl: string;
  17253. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17254. static IgnoreTexturesAtLoadTime: boolean;
  17255. private BJSNODEMATERIALEDITOR;
  17256. /** Get the inspector from bundle or global */
  17257. private _getGlobalNodeMaterialEditor;
  17258. /**
  17259. * Snippet ID if the material was created from the snippet server
  17260. */
  17261. snippetId: string;
  17262. /**
  17263. * Gets or sets data used by visual editor
  17264. * @see https://nme.babylonjs.com
  17265. */
  17266. editorData: any;
  17267. /**
  17268. * 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)
  17269. */
  17270. ignoreAlpha: boolean;
  17271. /**
  17272. * Defines the maximum number of lights that can be used in the material
  17273. */
  17274. maxSimultaneousLights: number;
  17275. /**
  17276. * Observable raised when the material is built
  17277. */
  17278. onBuildObservable: Observable<NodeMaterial>;
  17279. /**
  17280. * Gets or sets the root nodes of the material vertex shader
  17281. */
  17282. _vertexOutputNodes: NodeMaterialBlock[];
  17283. /**
  17284. * Gets or sets the root nodes of the material fragment (pixel) shader
  17285. */
  17286. _fragmentOutputNodes: NodeMaterialBlock[];
  17287. /** Gets or sets options to control the node material overall behavior */
  17288. get options(): INodeMaterialOptions;
  17289. set options(options: INodeMaterialOptions);
  17290. /**
  17291. * Default configuration related to image processing available in the standard Material.
  17292. */
  17293. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17294. /**
  17295. * Gets the image processing configuration used either in this material.
  17296. */
  17297. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17298. /**
  17299. * Sets the Default image processing configuration used either in the this material.
  17300. *
  17301. * If sets to null, the scene one is in use.
  17302. */
  17303. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17304. /**
  17305. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17306. */
  17307. attachedBlocks: NodeMaterialBlock[];
  17308. /**
  17309. * Specifies the mode of the node material
  17310. * @hidden
  17311. */
  17312. _mode: NodeMaterialModes;
  17313. /**
  17314. * Gets the mode property
  17315. */
  17316. get mode(): NodeMaterialModes;
  17317. /**
  17318. * A free comment about the material
  17319. */
  17320. comment: string;
  17321. /**
  17322. * Create a new node based material
  17323. * @param name defines the material name
  17324. * @param scene defines the hosting scene
  17325. * @param options defines creation option
  17326. */
  17327. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17328. /**
  17329. * Gets the current class name of the material e.g. "NodeMaterial"
  17330. * @returns the class name
  17331. */
  17332. getClassName(): string;
  17333. /**
  17334. * Keep track of the image processing observer to allow dispose and replace.
  17335. */
  17336. private _imageProcessingObserver;
  17337. /**
  17338. * Attaches a new image processing configuration to the Standard Material.
  17339. * @param configuration
  17340. */
  17341. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17342. /**
  17343. * Get a block by its name
  17344. * @param name defines the name of the block to retrieve
  17345. * @returns the required block or null if not found
  17346. */
  17347. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17348. /**
  17349. * Get a block by its name
  17350. * @param predicate defines the predicate used to find the good candidate
  17351. * @returns the required block or null if not found
  17352. */
  17353. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17354. /**
  17355. * Get an input block by its name
  17356. * @param predicate defines the predicate used to find the good candidate
  17357. * @returns the required input block or null if not found
  17358. */
  17359. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17360. /**
  17361. * Gets the list of input blocks attached to this material
  17362. * @returns an array of InputBlocks
  17363. */
  17364. getInputBlocks(): InputBlock[];
  17365. /**
  17366. * Adds a new optimizer to the list of optimizers
  17367. * @param optimizer defines the optimizers to add
  17368. * @returns the current material
  17369. */
  17370. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17371. /**
  17372. * Remove an optimizer from the list of optimizers
  17373. * @param optimizer defines the optimizers to remove
  17374. * @returns the current material
  17375. */
  17376. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17377. /**
  17378. * Add a new block to the list of output nodes
  17379. * @param node defines the node to add
  17380. * @returns the current material
  17381. */
  17382. addOutputNode(node: NodeMaterialBlock): this;
  17383. /**
  17384. * Remove a block from the list of root nodes
  17385. * @param node defines the node to remove
  17386. * @returns the current material
  17387. */
  17388. removeOutputNode(node: NodeMaterialBlock): this;
  17389. private _addVertexOutputNode;
  17390. private _removeVertexOutputNode;
  17391. private _addFragmentOutputNode;
  17392. private _removeFragmentOutputNode;
  17393. /**
  17394. * Specifies if the material will require alpha blending
  17395. * @returns a boolean specifying if alpha blending is needed
  17396. */
  17397. needAlphaBlending(): boolean;
  17398. /**
  17399. * Specifies if this material should be rendered in alpha test mode
  17400. * @returns a boolean specifying if an alpha test is needed.
  17401. */
  17402. needAlphaTesting(): boolean;
  17403. private _initializeBlock;
  17404. private _resetDualBlocks;
  17405. /**
  17406. * Remove a block from the current node material
  17407. * @param block defines the block to remove
  17408. */
  17409. removeBlock(block: NodeMaterialBlock): void;
  17410. /**
  17411. * Build the material and generates the inner effect
  17412. * @param verbose defines if the build should log activity
  17413. */
  17414. build(verbose?: boolean): void;
  17415. /**
  17416. * Runs an otpimization phase to try to improve the shader code
  17417. */
  17418. optimize(): void;
  17419. private _prepareDefinesForAttributes;
  17420. /**
  17421. * Create a post process from the material
  17422. * @param camera The camera to apply the render pass to.
  17423. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17424. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17425. * @param engine The engine which the post process will be applied. (default: current engine)
  17426. * @param reusable If the post process can be reused on the same frame. (default: false)
  17427. * @param textureType Type of textures used when performing the post process. (default: 0)
  17428. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  17429. * @returns the post process created
  17430. */
  17431. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  17432. /**
  17433. * Create the post process effect from the material
  17434. * @param postProcess The post process to create the effect for
  17435. */
  17436. createEffectForPostProcess(postProcess: PostProcess): void;
  17437. private _createEffectForPostProcess;
  17438. /**
  17439. * Create a new procedural texture based on this node material
  17440. * @param size defines the size of the texture
  17441. * @param scene defines the hosting scene
  17442. * @returns the new procedural texture attached to this node material
  17443. */
  17444. createProceduralTexture(size: number | {
  17445. width: number;
  17446. height: number;
  17447. layers?: number;
  17448. }, scene: Scene): Nullable<ProceduralTexture>;
  17449. private _createEffectForParticles;
  17450. private _checkInternals;
  17451. /**
  17452. * Create the effect to be used as the custom effect for a particle system
  17453. * @param particleSystem Particle system to create the effect for
  17454. * @param onCompiled defines a function to call when the effect creation is successful
  17455. * @param onError defines a function to call when the effect creation has failed
  17456. */
  17457. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  17458. private _processDefines;
  17459. /**
  17460. * Get if the submesh is ready to be used and all its information available.
  17461. * Child classes can use it to update shaders
  17462. * @param mesh defines the mesh to check
  17463. * @param subMesh defines which submesh to check
  17464. * @param useInstances specifies that instances should be used
  17465. * @returns a boolean indicating that the submesh is ready or not
  17466. */
  17467. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17468. /**
  17469. * Get a string representing the shaders built by the current node graph
  17470. */
  17471. get compiledShaders(): string;
  17472. /**
  17473. * Binds the world matrix to the material
  17474. * @param world defines the world transformation matrix
  17475. */
  17476. bindOnlyWorldMatrix(world: Matrix): void;
  17477. /**
  17478. * Binds the submesh to this material by preparing the effect and shader to draw
  17479. * @param world defines the world transformation matrix
  17480. * @param mesh defines the mesh containing the submesh
  17481. * @param subMesh defines the submesh to bind the material to
  17482. */
  17483. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17484. /**
  17485. * Gets the active textures from the material
  17486. * @returns an array of textures
  17487. */
  17488. getActiveTextures(): BaseTexture[];
  17489. /**
  17490. * Gets the list of texture blocks
  17491. * @returns an array of texture blocks
  17492. */
  17493. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  17494. /**
  17495. * Specifies if the material uses a texture
  17496. * @param texture defines the texture to check against the material
  17497. * @returns a boolean specifying if the material uses the texture
  17498. */
  17499. hasTexture(texture: BaseTexture): boolean;
  17500. /**
  17501. * Disposes the material
  17502. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17503. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17504. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17505. */
  17506. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17507. /** Creates the node editor window. */
  17508. private _createNodeEditor;
  17509. /**
  17510. * Launch the node material editor
  17511. * @param config Define the configuration of the editor
  17512. * @return a promise fulfilled when the node editor is visible
  17513. */
  17514. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  17515. /**
  17516. * Clear the current material
  17517. */
  17518. clear(): void;
  17519. /**
  17520. * Clear the current material and set it to a default state
  17521. */
  17522. setToDefault(): void;
  17523. /**
  17524. * Clear the current material and set it to a default state for post process
  17525. */
  17526. setToDefaultPostProcess(): void;
  17527. /**
  17528. * Clear the current material and set it to a default state for procedural texture
  17529. */
  17530. setToDefaultProceduralTexture(): void;
  17531. /**
  17532. * Clear the current material and set it to a default state for particle
  17533. */
  17534. setToDefaultParticle(): void;
  17535. /**
  17536. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  17537. * @param url defines the url to load from
  17538. * @returns a promise that will fullfil when the material is fully loaded
  17539. */
  17540. loadAsync(url: string): Promise<void>;
  17541. private _gatherBlocks;
  17542. /**
  17543. * Generate a string containing the code declaration required to create an equivalent of this material
  17544. * @returns a string
  17545. */
  17546. generateCode(): string;
  17547. /**
  17548. * Serializes this material in a JSON representation
  17549. * @returns the serialized material object
  17550. */
  17551. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  17552. private _restoreConnections;
  17553. /**
  17554. * Clear the current graph and load a new one from a serialization object
  17555. * @param source defines the JSON representation of the material
  17556. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17557. * @param merge defines whether or not the source must be merged or replace the current content
  17558. */
  17559. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  17560. /**
  17561. * Makes a duplicate of the current material.
  17562. * @param name - name to use for the new material.
  17563. */
  17564. clone(name: string): NodeMaterial;
  17565. /**
  17566. * Creates a node material from parsed material data
  17567. * @param source defines the JSON representation of the material
  17568. * @param scene defines the hosting scene
  17569. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17570. * @returns a new node material
  17571. */
  17572. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  17573. /**
  17574. * Creates a node material from a snippet saved in a remote file
  17575. * @param name defines the name of the material to create
  17576. * @param url defines the url to load from
  17577. * @param scene defines the hosting scene
  17578. * @returns a promise that will resolve to the new node material
  17579. */
  17580. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  17581. /**
  17582. * Creates a node material from a snippet saved by the node material editor
  17583. * @param snippetId defines the snippet to load
  17584. * @param scene defines the hosting scene
  17585. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17586. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  17587. * @returns a promise that will resolve to the new node material
  17588. */
  17589. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  17590. /**
  17591. * Creates a new node material set to default basic configuration
  17592. * @param name defines the name of the material
  17593. * @param scene defines the hosting scene
  17594. * @returns a new NodeMaterial
  17595. */
  17596. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  17597. }
  17598. }
  17599. declare module BABYLON {
  17600. interface ThinEngine {
  17601. /**
  17602. * Unbind a list of render target textures from the webGL context
  17603. * This is used only when drawBuffer extension or webGL2 are active
  17604. * @param textures defines the render target textures to unbind
  17605. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  17606. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  17607. */
  17608. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  17609. /**
  17610. * Create a multi render target texture
  17611. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  17612. * @param size defines the size of the texture
  17613. * @param options defines the creation options
  17614. * @returns the cube texture as an InternalTexture
  17615. */
  17616. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  17617. /**
  17618. * Update the sample count for a given multiple render target texture
  17619. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  17620. * @param textures defines the textures to update
  17621. * @param samples defines the sample count to set
  17622. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  17623. */
  17624. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  17625. /**
  17626. * Select a subsets of attachments to draw to.
  17627. * @param attachments gl attachments
  17628. */
  17629. bindAttachments(attachments: number[]): void;
  17630. /**
  17631. * Creates a layout object to draw/clear on specific textures in a MRT
  17632. * @param textureStatus textureStatus[i] indicates if the i-th is active
  17633. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  17634. */
  17635. buildTextureLayout(textureStatus: boolean[]): number[];
  17636. /**
  17637. * Restores the webgl state to only draw on the main color attachment
  17638. */
  17639. restoreSingleAttachment(): void;
  17640. }
  17641. }
  17642. declare module BABYLON {
  17643. /**
  17644. * Creation options of the multi render target texture.
  17645. */
  17646. export interface IMultiRenderTargetOptions {
  17647. /**
  17648. * Define if the texture needs to create mip maps after render.
  17649. */
  17650. generateMipMaps?: boolean;
  17651. /**
  17652. * Define the types of all the draw buffers we want to create
  17653. */
  17654. types?: number[];
  17655. /**
  17656. * Define the sampling modes of all the draw buffers we want to create
  17657. */
  17658. samplingModes?: number[];
  17659. /**
  17660. * Define if a depth buffer is required
  17661. */
  17662. generateDepthBuffer?: boolean;
  17663. /**
  17664. * Define if a stencil buffer is required
  17665. */
  17666. generateStencilBuffer?: boolean;
  17667. /**
  17668. * Define if a depth texture is required instead of a depth buffer
  17669. */
  17670. generateDepthTexture?: boolean;
  17671. /**
  17672. * Define the number of desired draw buffers
  17673. */
  17674. textureCount?: number;
  17675. /**
  17676. * Define if aspect ratio should be adapted to the texture or stay the scene one
  17677. */
  17678. doNotChangeAspectRatio?: boolean;
  17679. /**
  17680. * Define the default type of the buffers we are creating
  17681. */
  17682. defaultType?: number;
  17683. }
  17684. /**
  17685. * A multi render target, like a render target provides the ability to render to a texture.
  17686. * Unlike the render target, it can render to several draw buffers in one draw.
  17687. * This is specially interesting in deferred rendering or for any effects requiring more than
  17688. * just one color from a single pass.
  17689. */
  17690. export class MultiRenderTarget extends RenderTargetTexture {
  17691. private _internalTextures;
  17692. private _textures;
  17693. private _multiRenderTargetOptions;
  17694. private _count;
  17695. /**
  17696. * Get if draw buffers are currently supported by the used hardware and browser.
  17697. */
  17698. get isSupported(): boolean;
  17699. /**
  17700. * Get the list of textures generated by the multi render target.
  17701. */
  17702. get textures(): Texture[];
  17703. /**
  17704. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  17705. */
  17706. get count(): number;
  17707. /**
  17708. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  17709. */
  17710. get depthTexture(): Texture;
  17711. /**
  17712. * Set the wrapping mode on U of all the textures we are rendering to.
  17713. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  17714. */
  17715. set wrapU(wrap: number);
  17716. /**
  17717. * Set the wrapping mode on V of all the textures we are rendering to.
  17718. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  17719. */
  17720. set wrapV(wrap: number);
  17721. /**
  17722. * Instantiate a new multi render target texture.
  17723. * A multi render target, like a render target provides the ability to render to a texture.
  17724. * Unlike the render target, it can render to several draw buffers in one draw.
  17725. * This is specially interesting in deferred rendering or for any effects requiring more than
  17726. * just one color from a single pass.
  17727. * @param name Define the name of the texture
  17728. * @param size Define the size of the buffers to render to
  17729. * @param count Define the number of target we are rendering into
  17730. * @param scene Define the scene the texture belongs to
  17731. * @param options Define the options used to create the multi render target
  17732. */
  17733. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  17734. private _initTypes;
  17735. /** @hidden */
  17736. _rebuild(forceFullRebuild?: boolean): void;
  17737. private _createInternalTextures;
  17738. private _createTextures;
  17739. /**
  17740. * Replaces a texture within the MRT.
  17741. * @param texture The new texture to insert in the MRT
  17742. * @param index The index of the texture to replace
  17743. */
  17744. replaceTexture(texture: Texture, index: number): void;
  17745. /**
  17746. * Define the number of samples used if MSAA is enabled.
  17747. */
  17748. get samples(): number;
  17749. set samples(value: number);
  17750. /**
  17751. * Resize all the textures in the multi render target.
  17752. * Be careful as it will recreate all the data in the new texture.
  17753. * @param size Define the new size
  17754. */
  17755. resize(size: any): void;
  17756. /**
  17757. * Changes the number of render targets in this MRT
  17758. * Be careful as it will recreate all the data in the new texture.
  17759. * @param count new texture count
  17760. * @param options Specifies texture types and sampling modes for new textures
  17761. */
  17762. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  17763. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17764. /**
  17765. * Dispose the render targets and their associated resources
  17766. */
  17767. dispose(): void;
  17768. /**
  17769. * Release all the underlying texture used as draw buffers.
  17770. */
  17771. releaseInternalTextures(): void;
  17772. }
  17773. }
  17774. declare module BABYLON {
  17775. /** @hidden */
  17776. export var imageProcessingPixelShader: {
  17777. name: string;
  17778. shader: string;
  17779. };
  17780. }
  17781. declare module BABYLON {
  17782. /**
  17783. * ImageProcessingPostProcess
  17784. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  17785. */
  17786. export class ImageProcessingPostProcess extends PostProcess {
  17787. /**
  17788. * Default configuration related to image processing available in the PBR Material.
  17789. */
  17790. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17791. /**
  17792. * Gets the image processing configuration used either in this material.
  17793. */
  17794. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17795. /**
  17796. * Sets the Default image processing configuration used either in the this material.
  17797. *
  17798. * If sets to null, the scene one is in use.
  17799. */
  17800. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17801. /**
  17802. * Keep track of the image processing observer to allow dispose and replace.
  17803. */
  17804. private _imageProcessingObserver;
  17805. /**
  17806. * Attaches a new image processing configuration to the PBR Material.
  17807. * @param configuration
  17808. */
  17809. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  17810. /**
  17811. * If the post process is supported.
  17812. */
  17813. get isSupported(): boolean;
  17814. /**
  17815. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17816. */
  17817. get colorCurves(): Nullable<ColorCurves>;
  17818. /**
  17819. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17820. */
  17821. set colorCurves(value: Nullable<ColorCurves>);
  17822. /**
  17823. * Gets wether the color curves effect is enabled.
  17824. */
  17825. get colorCurvesEnabled(): boolean;
  17826. /**
  17827. * Sets wether the color curves effect is enabled.
  17828. */
  17829. set colorCurvesEnabled(value: boolean);
  17830. /**
  17831. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17832. */
  17833. get colorGradingTexture(): Nullable<BaseTexture>;
  17834. /**
  17835. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17836. */
  17837. set colorGradingTexture(value: Nullable<BaseTexture>);
  17838. /**
  17839. * Gets wether the color grading effect is enabled.
  17840. */
  17841. get colorGradingEnabled(): boolean;
  17842. /**
  17843. * Gets wether the color grading effect is enabled.
  17844. */
  17845. set colorGradingEnabled(value: boolean);
  17846. /**
  17847. * Gets exposure used in the effect.
  17848. */
  17849. get exposure(): number;
  17850. /**
  17851. * Sets exposure used in the effect.
  17852. */
  17853. set exposure(value: number);
  17854. /**
  17855. * Gets wether tonemapping is enabled or not.
  17856. */
  17857. get toneMappingEnabled(): boolean;
  17858. /**
  17859. * Sets wether tonemapping is enabled or not
  17860. */
  17861. set toneMappingEnabled(value: boolean);
  17862. /**
  17863. * Gets the type of tone mapping effect.
  17864. */
  17865. get toneMappingType(): number;
  17866. /**
  17867. * Sets the type of tone mapping effect.
  17868. */
  17869. set toneMappingType(value: number);
  17870. /**
  17871. * Gets contrast used in the effect.
  17872. */
  17873. get contrast(): number;
  17874. /**
  17875. * Sets contrast used in the effect.
  17876. */
  17877. set contrast(value: number);
  17878. /**
  17879. * Gets Vignette stretch size.
  17880. */
  17881. get vignetteStretch(): number;
  17882. /**
  17883. * Sets Vignette stretch size.
  17884. */
  17885. set vignetteStretch(value: number);
  17886. /**
  17887. * Gets Vignette centre X Offset.
  17888. */
  17889. get vignetteCentreX(): number;
  17890. /**
  17891. * Sets Vignette centre X Offset.
  17892. */
  17893. set vignetteCentreX(value: number);
  17894. /**
  17895. * Gets Vignette centre Y Offset.
  17896. */
  17897. get vignetteCentreY(): number;
  17898. /**
  17899. * Sets Vignette centre Y Offset.
  17900. */
  17901. set vignetteCentreY(value: number);
  17902. /**
  17903. * Gets Vignette weight or intensity of the vignette effect.
  17904. */
  17905. get vignetteWeight(): number;
  17906. /**
  17907. * Sets Vignette weight or intensity of the vignette effect.
  17908. */
  17909. set vignetteWeight(value: number);
  17910. /**
  17911. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17912. * if vignetteEnabled is set to true.
  17913. */
  17914. get vignetteColor(): Color4;
  17915. /**
  17916. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17917. * if vignetteEnabled is set to true.
  17918. */
  17919. set vignetteColor(value: Color4);
  17920. /**
  17921. * Gets Camera field of view used by the Vignette effect.
  17922. */
  17923. get vignetteCameraFov(): number;
  17924. /**
  17925. * Sets Camera field of view used by the Vignette effect.
  17926. */
  17927. set vignetteCameraFov(value: number);
  17928. /**
  17929. * Gets the vignette blend mode allowing different kind of effect.
  17930. */
  17931. get vignetteBlendMode(): number;
  17932. /**
  17933. * Sets the vignette blend mode allowing different kind of effect.
  17934. */
  17935. set vignetteBlendMode(value: number);
  17936. /**
  17937. * Gets wether the vignette effect is enabled.
  17938. */
  17939. get vignetteEnabled(): boolean;
  17940. /**
  17941. * Sets wether the vignette effect is enabled.
  17942. */
  17943. set vignetteEnabled(value: boolean);
  17944. private _fromLinearSpace;
  17945. /**
  17946. * Gets wether the input of the processing is in Gamma or Linear Space.
  17947. */
  17948. get fromLinearSpace(): boolean;
  17949. /**
  17950. * Sets wether the input of the processing is in Gamma or Linear Space.
  17951. */
  17952. set fromLinearSpace(value: boolean);
  17953. /**
  17954. * Defines cache preventing GC.
  17955. */
  17956. private _defines;
  17957. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  17958. /**
  17959. * "ImageProcessingPostProcess"
  17960. * @returns "ImageProcessingPostProcess"
  17961. */
  17962. getClassName(): string;
  17963. /**
  17964. * @hidden
  17965. */
  17966. _updateParameters(): void;
  17967. dispose(camera?: Camera): void;
  17968. }
  17969. }
  17970. declare module BABYLON {
  17971. /**
  17972. * Interface for defining prepass effects in the prepass post-process pipeline
  17973. */
  17974. export interface PrePassEffectConfiguration {
  17975. /**
  17976. * Name of the effect
  17977. */
  17978. name: string;
  17979. /**
  17980. * Post process to attach for this effect
  17981. */
  17982. postProcess?: PostProcess;
  17983. /**
  17984. * Textures required in the MRT
  17985. */
  17986. texturesRequired: number[];
  17987. /**
  17988. * Is the effect enabled
  17989. */
  17990. enabled: boolean;
  17991. /**
  17992. * Disposes the effect configuration
  17993. */
  17994. dispose?: () => void;
  17995. /**
  17996. * Creates the associated post process
  17997. */
  17998. createPostProcess?: () => PostProcess;
  17999. }
  18000. }
  18001. declare module BABYLON {
  18002. /**
  18003. * Options to be used when creating a FresnelParameters.
  18004. */
  18005. export type IFresnelParametersCreationOptions = {
  18006. /**
  18007. * Define the color used on edges (grazing angle)
  18008. */
  18009. leftColor?: Color3;
  18010. /**
  18011. * Define the color used on center
  18012. */
  18013. rightColor?: Color3;
  18014. /**
  18015. * Define bias applied to computed fresnel term
  18016. */
  18017. bias?: number;
  18018. /**
  18019. * Defined the power exponent applied to fresnel term
  18020. */
  18021. power?: number;
  18022. /**
  18023. * Define if the fresnel effect is enable or not.
  18024. */
  18025. isEnabled?: boolean;
  18026. };
  18027. /**
  18028. * Serialized format for FresnelParameters.
  18029. */
  18030. export type IFresnelParametersSerialized = {
  18031. /**
  18032. * Define the color used on edges (grazing angle) [as an array]
  18033. */
  18034. leftColor: number[];
  18035. /**
  18036. * Define the color used on center [as an array]
  18037. */
  18038. rightColor: number[];
  18039. /**
  18040. * Define bias applied to computed fresnel term
  18041. */
  18042. bias: number;
  18043. /**
  18044. * Defined the power exponent applied to fresnel term
  18045. */
  18046. power?: number;
  18047. /**
  18048. * Define if the fresnel effect is enable or not.
  18049. */
  18050. isEnabled: boolean;
  18051. };
  18052. /**
  18053. * This represents all the required information to add a fresnel effect on a material:
  18054. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18055. */
  18056. export class FresnelParameters {
  18057. private _isEnabled;
  18058. /**
  18059. * Define if the fresnel effect is enable or not.
  18060. */
  18061. get isEnabled(): boolean;
  18062. set isEnabled(value: boolean);
  18063. /**
  18064. * Define the color used on edges (grazing angle)
  18065. */
  18066. leftColor: Color3;
  18067. /**
  18068. * Define the color used on center
  18069. */
  18070. rightColor: Color3;
  18071. /**
  18072. * Define bias applied to computed fresnel term
  18073. */
  18074. bias: number;
  18075. /**
  18076. * Defined the power exponent applied to fresnel term
  18077. */
  18078. power: number;
  18079. /**
  18080. * Creates a new FresnelParameters object.
  18081. *
  18082. * @param options provide your own settings to optionally to override defaults
  18083. */
  18084. constructor(options?: IFresnelParametersCreationOptions);
  18085. /**
  18086. * Clones the current fresnel and its valuues
  18087. * @returns a clone fresnel configuration
  18088. */
  18089. clone(): FresnelParameters;
  18090. /**
  18091. * Determines equality between FresnelParameters objects
  18092. * @param otherFresnelParameters defines the second operand
  18093. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18094. */
  18095. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18096. /**
  18097. * Serializes the current fresnel parameters to a JSON representation.
  18098. * @return the JSON serialization
  18099. */
  18100. serialize(): IFresnelParametersSerialized;
  18101. /**
  18102. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18103. * @param parsedFresnelParameters Define the JSON representation
  18104. * @returns the parsed parameters
  18105. */
  18106. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18107. }
  18108. }
  18109. declare module BABYLON {
  18110. /**
  18111. * This groups all the flags used to control the materials channel.
  18112. */
  18113. export class MaterialFlags {
  18114. private static _DiffuseTextureEnabled;
  18115. /**
  18116. * Are diffuse textures enabled in the application.
  18117. */
  18118. static get DiffuseTextureEnabled(): boolean;
  18119. static set DiffuseTextureEnabled(value: boolean);
  18120. private static _DetailTextureEnabled;
  18121. /**
  18122. * Are detail textures enabled in the application.
  18123. */
  18124. static get DetailTextureEnabled(): boolean;
  18125. static set DetailTextureEnabled(value: boolean);
  18126. private static _AmbientTextureEnabled;
  18127. /**
  18128. * Are ambient textures enabled in the application.
  18129. */
  18130. static get AmbientTextureEnabled(): boolean;
  18131. static set AmbientTextureEnabled(value: boolean);
  18132. private static _OpacityTextureEnabled;
  18133. /**
  18134. * Are opacity textures enabled in the application.
  18135. */
  18136. static get OpacityTextureEnabled(): boolean;
  18137. static set OpacityTextureEnabled(value: boolean);
  18138. private static _ReflectionTextureEnabled;
  18139. /**
  18140. * Are reflection textures enabled in the application.
  18141. */
  18142. static get ReflectionTextureEnabled(): boolean;
  18143. static set ReflectionTextureEnabled(value: boolean);
  18144. private static _EmissiveTextureEnabled;
  18145. /**
  18146. * Are emissive textures enabled in the application.
  18147. */
  18148. static get EmissiveTextureEnabled(): boolean;
  18149. static set EmissiveTextureEnabled(value: boolean);
  18150. private static _SpecularTextureEnabled;
  18151. /**
  18152. * Are specular textures enabled in the application.
  18153. */
  18154. static get SpecularTextureEnabled(): boolean;
  18155. static set SpecularTextureEnabled(value: boolean);
  18156. private static _BumpTextureEnabled;
  18157. /**
  18158. * Are bump textures enabled in the application.
  18159. */
  18160. static get BumpTextureEnabled(): boolean;
  18161. static set BumpTextureEnabled(value: boolean);
  18162. private static _LightmapTextureEnabled;
  18163. /**
  18164. * Are lightmap textures enabled in the application.
  18165. */
  18166. static get LightmapTextureEnabled(): boolean;
  18167. static set LightmapTextureEnabled(value: boolean);
  18168. private static _RefractionTextureEnabled;
  18169. /**
  18170. * Are refraction textures enabled in the application.
  18171. */
  18172. static get RefractionTextureEnabled(): boolean;
  18173. static set RefractionTextureEnabled(value: boolean);
  18174. private static _ColorGradingTextureEnabled;
  18175. /**
  18176. * Are color grading textures enabled in the application.
  18177. */
  18178. static get ColorGradingTextureEnabled(): boolean;
  18179. static set ColorGradingTextureEnabled(value: boolean);
  18180. private static _FresnelEnabled;
  18181. /**
  18182. * Are fresnels enabled in the application.
  18183. */
  18184. static get FresnelEnabled(): boolean;
  18185. static set FresnelEnabled(value: boolean);
  18186. private static _ClearCoatTextureEnabled;
  18187. /**
  18188. * Are clear coat textures enabled in the application.
  18189. */
  18190. static get ClearCoatTextureEnabled(): boolean;
  18191. static set ClearCoatTextureEnabled(value: boolean);
  18192. private static _ClearCoatBumpTextureEnabled;
  18193. /**
  18194. * Are clear coat bump textures enabled in the application.
  18195. */
  18196. static get ClearCoatBumpTextureEnabled(): boolean;
  18197. static set ClearCoatBumpTextureEnabled(value: boolean);
  18198. private static _ClearCoatTintTextureEnabled;
  18199. /**
  18200. * Are clear coat tint textures enabled in the application.
  18201. */
  18202. static get ClearCoatTintTextureEnabled(): boolean;
  18203. static set ClearCoatTintTextureEnabled(value: boolean);
  18204. private static _SheenTextureEnabled;
  18205. /**
  18206. * Are sheen textures enabled in the application.
  18207. */
  18208. static get SheenTextureEnabled(): boolean;
  18209. static set SheenTextureEnabled(value: boolean);
  18210. private static _AnisotropicTextureEnabled;
  18211. /**
  18212. * Are anisotropic textures enabled in the application.
  18213. */
  18214. static get AnisotropicTextureEnabled(): boolean;
  18215. static set AnisotropicTextureEnabled(value: boolean);
  18216. private static _ThicknessTextureEnabled;
  18217. /**
  18218. * Are thickness textures enabled in the application.
  18219. */
  18220. static get ThicknessTextureEnabled(): boolean;
  18221. static set ThicknessTextureEnabled(value: boolean);
  18222. }
  18223. }
  18224. declare module BABYLON {
  18225. /** @hidden */
  18226. export var defaultFragmentDeclaration: {
  18227. name: string;
  18228. shader: string;
  18229. };
  18230. }
  18231. declare module BABYLON {
  18232. /** @hidden */
  18233. export var defaultUboDeclaration: {
  18234. name: string;
  18235. shader: string;
  18236. };
  18237. }
  18238. declare module BABYLON {
  18239. /** @hidden */
  18240. export var prePassDeclaration: {
  18241. name: string;
  18242. shader: string;
  18243. };
  18244. }
  18245. declare module BABYLON {
  18246. /** @hidden */
  18247. export var lightFragmentDeclaration: {
  18248. name: string;
  18249. shader: string;
  18250. };
  18251. }
  18252. declare module BABYLON {
  18253. /** @hidden */
  18254. export var lightUboDeclaration: {
  18255. name: string;
  18256. shader: string;
  18257. };
  18258. }
  18259. declare module BABYLON {
  18260. /** @hidden */
  18261. export var lightsFragmentFunctions: {
  18262. name: string;
  18263. shader: string;
  18264. };
  18265. }
  18266. declare module BABYLON {
  18267. /** @hidden */
  18268. export var shadowsFragmentFunctions: {
  18269. name: string;
  18270. shader: string;
  18271. };
  18272. }
  18273. declare module BABYLON {
  18274. /** @hidden */
  18275. export var fresnelFunction: {
  18276. name: string;
  18277. shader: string;
  18278. };
  18279. }
  18280. declare module BABYLON {
  18281. /** @hidden */
  18282. export var bumpFragmentMainFunctions: {
  18283. name: string;
  18284. shader: string;
  18285. };
  18286. }
  18287. declare module BABYLON {
  18288. /** @hidden */
  18289. export var bumpFragmentFunctions: {
  18290. name: string;
  18291. shader: string;
  18292. };
  18293. }
  18294. declare module BABYLON {
  18295. /** @hidden */
  18296. export var logDepthDeclaration: {
  18297. name: string;
  18298. shader: string;
  18299. };
  18300. }
  18301. declare module BABYLON {
  18302. /** @hidden */
  18303. export var fogFragmentDeclaration: {
  18304. name: string;
  18305. shader: string;
  18306. };
  18307. }
  18308. declare module BABYLON {
  18309. /** @hidden */
  18310. export var bumpFragment: {
  18311. name: string;
  18312. shader: string;
  18313. };
  18314. }
  18315. declare module BABYLON {
  18316. /** @hidden */
  18317. export var depthPrePass: {
  18318. name: string;
  18319. shader: string;
  18320. };
  18321. }
  18322. declare module BABYLON {
  18323. /** @hidden */
  18324. export var lightFragment: {
  18325. name: string;
  18326. shader: string;
  18327. };
  18328. }
  18329. declare module BABYLON {
  18330. /** @hidden */
  18331. export var logDepthFragment: {
  18332. name: string;
  18333. shader: string;
  18334. };
  18335. }
  18336. declare module BABYLON {
  18337. /** @hidden */
  18338. export var fogFragment: {
  18339. name: string;
  18340. shader: string;
  18341. };
  18342. }
  18343. declare module BABYLON {
  18344. /** @hidden */
  18345. export var defaultPixelShader: {
  18346. name: string;
  18347. shader: string;
  18348. };
  18349. }
  18350. declare module BABYLON {
  18351. /** @hidden */
  18352. export var defaultVertexDeclaration: {
  18353. name: string;
  18354. shader: string;
  18355. };
  18356. }
  18357. declare module BABYLON {
  18358. /** @hidden */
  18359. export var bonesDeclaration: {
  18360. name: string;
  18361. shader: string;
  18362. };
  18363. }
  18364. declare module BABYLON {
  18365. /** @hidden */
  18366. export var instancesDeclaration: {
  18367. name: string;
  18368. shader: string;
  18369. };
  18370. }
  18371. declare module BABYLON {
  18372. /** @hidden */
  18373. export var prePassVertexDeclaration: {
  18374. name: string;
  18375. shader: string;
  18376. };
  18377. }
  18378. declare module BABYLON {
  18379. /** @hidden */
  18380. export var bumpVertexDeclaration: {
  18381. name: string;
  18382. shader: string;
  18383. };
  18384. }
  18385. declare module BABYLON {
  18386. /** @hidden */
  18387. export var fogVertexDeclaration: {
  18388. name: string;
  18389. shader: string;
  18390. };
  18391. }
  18392. declare module BABYLON {
  18393. /** @hidden */
  18394. export var morphTargetsVertexGlobalDeclaration: {
  18395. name: string;
  18396. shader: string;
  18397. };
  18398. }
  18399. declare module BABYLON {
  18400. /** @hidden */
  18401. export var morphTargetsVertexDeclaration: {
  18402. name: string;
  18403. shader: string;
  18404. };
  18405. }
  18406. declare module BABYLON {
  18407. /** @hidden */
  18408. export var morphTargetsVertex: {
  18409. name: string;
  18410. shader: string;
  18411. };
  18412. }
  18413. declare module BABYLON {
  18414. /** @hidden */
  18415. export var instancesVertex: {
  18416. name: string;
  18417. shader: string;
  18418. };
  18419. }
  18420. declare module BABYLON {
  18421. /** @hidden */
  18422. export var bonesVertex: {
  18423. name: string;
  18424. shader: string;
  18425. };
  18426. }
  18427. declare module BABYLON {
  18428. /** @hidden */
  18429. export var prePassVertex: {
  18430. name: string;
  18431. shader: string;
  18432. };
  18433. }
  18434. declare module BABYLON {
  18435. /** @hidden */
  18436. export var bumpVertex: {
  18437. name: string;
  18438. shader: string;
  18439. };
  18440. }
  18441. declare module BABYLON {
  18442. /** @hidden */
  18443. export var fogVertex: {
  18444. name: string;
  18445. shader: string;
  18446. };
  18447. }
  18448. declare module BABYLON {
  18449. /** @hidden */
  18450. export var shadowsVertex: {
  18451. name: string;
  18452. shader: string;
  18453. };
  18454. }
  18455. declare module BABYLON {
  18456. /** @hidden */
  18457. export var pointCloudVertex: {
  18458. name: string;
  18459. shader: string;
  18460. };
  18461. }
  18462. declare module BABYLON {
  18463. /** @hidden */
  18464. export var logDepthVertex: {
  18465. name: string;
  18466. shader: string;
  18467. };
  18468. }
  18469. declare module BABYLON {
  18470. /** @hidden */
  18471. export var defaultVertexShader: {
  18472. name: string;
  18473. shader: string;
  18474. };
  18475. }
  18476. declare module BABYLON {
  18477. /**
  18478. * @hidden
  18479. */
  18480. export interface IMaterialDetailMapDefines {
  18481. DETAIL: boolean;
  18482. DETAILDIRECTUV: number;
  18483. DETAIL_NORMALBLENDMETHOD: number;
  18484. /** @hidden */
  18485. _areTexturesDirty: boolean;
  18486. }
  18487. /**
  18488. * Define the code related to the detail map parameters of a material
  18489. *
  18490. * Inspired from:
  18491. * 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
  18492. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  18493. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  18494. */
  18495. export class DetailMapConfiguration {
  18496. private _texture;
  18497. /**
  18498. * The detail texture of the material.
  18499. */
  18500. texture: Nullable<BaseTexture>;
  18501. /**
  18502. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  18503. * Bigger values mean stronger blending
  18504. */
  18505. diffuseBlendLevel: number;
  18506. /**
  18507. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  18508. * Bigger values mean stronger blending. Only used with PBR materials
  18509. */
  18510. roughnessBlendLevel: number;
  18511. /**
  18512. * Defines how strong the bump effect from the detail map is
  18513. * Bigger values mean stronger effect
  18514. */
  18515. bumpLevel: number;
  18516. private _normalBlendMethod;
  18517. /**
  18518. * The method used to blend the bump and detail normals together
  18519. */
  18520. normalBlendMethod: number;
  18521. private _isEnabled;
  18522. /**
  18523. * Enable or disable the detail map on this material
  18524. */
  18525. isEnabled: boolean;
  18526. /** @hidden */
  18527. private _internalMarkAllSubMeshesAsTexturesDirty;
  18528. /** @hidden */
  18529. _markAllSubMeshesAsTexturesDirty(): void;
  18530. /**
  18531. * Instantiate a new detail map
  18532. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  18533. */
  18534. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  18535. /**
  18536. * Gets whether the submesh is ready to be used or not.
  18537. * @param defines the list of "defines" to update.
  18538. * @param scene defines the scene the material belongs to.
  18539. * @returns - boolean indicating that the submesh is ready or not.
  18540. */
  18541. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  18542. /**
  18543. * Update the defines for detail map usage
  18544. * @param defines the list of "defines" to update.
  18545. * @param scene defines the scene the material belongs to.
  18546. */
  18547. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  18548. /**
  18549. * Binds the material data.
  18550. * @param uniformBuffer defines the Uniform buffer to fill in.
  18551. * @param scene defines the scene the material belongs to.
  18552. * @param isFrozen defines whether the material is frozen or not.
  18553. */
  18554. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  18555. /**
  18556. * Checks to see if a texture is used in the material.
  18557. * @param texture - Base texture to use.
  18558. * @returns - Boolean specifying if a texture is used in the material.
  18559. */
  18560. hasTexture(texture: BaseTexture): boolean;
  18561. /**
  18562. * Returns an array of the actively used textures.
  18563. * @param activeTextures Array of BaseTextures
  18564. */
  18565. getActiveTextures(activeTextures: BaseTexture[]): void;
  18566. /**
  18567. * Returns the animatable textures.
  18568. * @param animatables Array of animatable textures.
  18569. */
  18570. getAnimatables(animatables: IAnimatable[]): void;
  18571. /**
  18572. * Disposes the resources of the material.
  18573. * @param forceDisposeTextures - Forces the disposal of all textures.
  18574. */
  18575. dispose(forceDisposeTextures?: boolean): void;
  18576. /**
  18577. * Get the current class name useful for serialization or dynamic coding.
  18578. * @returns "DetailMap"
  18579. */
  18580. getClassName(): string;
  18581. /**
  18582. * Add the required uniforms to the current list.
  18583. * @param uniforms defines the current uniform list.
  18584. */
  18585. static AddUniforms(uniforms: string[]): void;
  18586. /**
  18587. * Add the required samplers to the current list.
  18588. * @param samplers defines the current sampler list.
  18589. */
  18590. static AddSamplers(samplers: string[]): void;
  18591. /**
  18592. * Add the required uniforms to the current buffer.
  18593. * @param uniformBuffer defines the current uniform buffer.
  18594. */
  18595. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  18596. /**
  18597. * Makes a duplicate of the current instance into another one.
  18598. * @param detailMap define the instance where to copy the info
  18599. */
  18600. copyTo(detailMap: DetailMapConfiguration): void;
  18601. /**
  18602. * Serializes this detail map instance
  18603. * @returns - An object with the serialized instance.
  18604. */
  18605. serialize(): any;
  18606. /**
  18607. * Parses a detail map setting from a serialized object.
  18608. * @param source - Serialized object.
  18609. * @param scene Defines the scene we are parsing for
  18610. * @param rootUrl Defines the rootUrl to load from
  18611. */
  18612. parse(source: any, scene: Scene, rootUrl: string): void;
  18613. }
  18614. }
  18615. declare module BABYLON {
  18616. /** @hidden */
  18617. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  18618. MAINUV1: boolean;
  18619. MAINUV2: boolean;
  18620. DIFFUSE: boolean;
  18621. DIFFUSEDIRECTUV: number;
  18622. DETAIL: boolean;
  18623. DETAILDIRECTUV: number;
  18624. DETAIL_NORMALBLENDMETHOD: number;
  18625. AMBIENT: boolean;
  18626. AMBIENTDIRECTUV: number;
  18627. OPACITY: boolean;
  18628. OPACITYDIRECTUV: number;
  18629. OPACITYRGB: boolean;
  18630. REFLECTION: boolean;
  18631. EMISSIVE: boolean;
  18632. EMISSIVEDIRECTUV: number;
  18633. SPECULAR: boolean;
  18634. SPECULARDIRECTUV: number;
  18635. BUMP: boolean;
  18636. BUMPDIRECTUV: number;
  18637. PARALLAX: boolean;
  18638. PARALLAXOCCLUSION: boolean;
  18639. SPECULAROVERALPHA: boolean;
  18640. CLIPPLANE: boolean;
  18641. CLIPPLANE2: boolean;
  18642. CLIPPLANE3: boolean;
  18643. CLIPPLANE4: boolean;
  18644. CLIPPLANE5: boolean;
  18645. CLIPPLANE6: boolean;
  18646. ALPHATEST: boolean;
  18647. DEPTHPREPASS: boolean;
  18648. ALPHAFROMDIFFUSE: boolean;
  18649. POINTSIZE: boolean;
  18650. FOG: boolean;
  18651. SPECULARTERM: boolean;
  18652. DIFFUSEFRESNEL: boolean;
  18653. OPACITYFRESNEL: boolean;
  18654. REFLECTIONFRESNEL: boolean;
  18655. REFRACTIONFRESNEL: boolean;
  18656. EMISSIVEFRESNEL: boolean;
  18657. FRESNEL: boolean;
  18658. NORMAL: boolean;
  18659. UV1: boolean;
  18660. UV2: boolean;
  18661. VERTEXCOLOR: boolean;
  18662. VERTEXALPHA: boolean;
  18663. NUM_BONE_INFLUENCERS: number;
  18664. BonesPerMesh: number;
  18665. BONETEXTURE: boolean;
  18666. BONES_VELOCITY_ENABLED: boolean;
  18667. INSTANCES: boolean;
  18668. THIN_INSTANCES: boolean;
  18669. GLOSSINESS: boolean;
  18670. ROUGHNESS: boolean;
  18671. EMISSIVEASILLUMINATION: boolean;
  18672. LINKEMISSIVEWITHDIFFUSE: boolean;
  18673. REFLECTIONFRESNELFROMSPECULAR: boolean;
  18674. LIGHTMAP: boolean;
  18675. LIGHTMAPDIRECTUV: number;
  18676. OBJECTSPACE_NORMALMAP: boolean;
  18677. USELIGHTMAPASSHADOWMAP: boolean;
  18678. REFLECTIONMAP_3D: boolean;
  18679. REFLECTIONMAP_SPHERICAL: boolean;
  18680. REFLECTIONMAP_PLANAR: boolean;
  18681. REFLECTIONMAP_CUBIC: boolean;
  18682. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  18683. REFLECTIONMAP_PROJECTION: boolean;
  18684. REFLECTIONMAP_SKYBOX: boolean;
  18685. REFLECTIONMAP_EXPLICIT: boolean;
  18686. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  18687. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  18688. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  18689. INVERTCUBICMAP: boolean;
  18690. LOGARITHMICDEPTH: boolean;
  18691. REFRACTION: boolean;
  18692. REFRACTIONMAP_3D: boolean;
  18693. REFLECTIONOVERALPHA: boolean;
  18694. TWOSIDEDLIGHTING: boolean;
  18695. SHADOWFLOAT: boolean;
  18696. MORPHTARGETS: boolean;
  18697. MORPHTARGETS_NORMAL: boolean;
  18698. MORPHTARGETS_TANGENT: boolean;
  18699. MORPHTARGETS_UV: boolean;
  18700. NUM_MORPH_INFLUENCERS: number;
  18701. NONUNIFORMSCALING: boolean;
  18702. PREMULTIPLYALPHA: boolean;
  18703. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  18704. ALPHABLEND: boolean;
  18705. PREPASS: boolean;
  18706. PREPASS_IRRADIANCE: boolean;
  18707. PREPASS_IRRADIANCE_INDEX: number;
  18708. PREPASS_ALBEDO: boolean;
  18709. PREPASS_ALBEDO_INDEX: number;
  18710. PREPASS_DEPTHNORMAL: boolean;
  18711. PREPASS_DEPTHNORMAL_INDEX: number;
  18712. PREPASS_POSITION: boolean;
  18713. PREPASS_POSITION_INDEX: number;
  18714. PREPASS_VELOCITY: boolean;
  18715. PREPASS_VELOCITY_INDEX: number;
  18716. PREPASS_REFLECTIVITY: boolean;
  18717. PREPASS_REFLECTIVITY_INDEX: number;
  18718. SCENE_MRT_COUNT: number;
  18719. RGBDLIGHTMAP: boolean;
  18720. RGBDREFLECTION: boolean;
  18721. RGBDREFRACTION: boolean;
  18722. IMAGEPROCESSING: boolean;
  18723. VIGNETTE: boolean;
  18724. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18725. VIGNETTEBLENDMODEOPAQUE: boolean;
  18726. TONEMAPPING: boolean;
  18727. TONEMAPPING_ACES: boolean;
  18728. CONTRAST: boolean;
  18729. COLORCURVES: boolean;
  18730. COLORGRADING: boolean;
  18731. COLORGRADING3D: boolean;
  18732. SAMPLER3DGREENDEPTH: boolean;
  18733. SAMPLER3DBGRMAP: boolean;
  18734. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18735. MULTIVIEW: boolean;
  18736. /**
  18737. * If the reflection texture on this material is in linear color space
  18738. * @hidden
  18739. */
  18740. IS_REFLECTION_LINEAR: boolean;
  18741. /**
  18742. * If the refraction texture on this material is in linear color space
  18743. * @hidden
  18744. */
  18745. IS_REFRACTION_LINEAR: boolean;
  18746. EXPOSURE: boolean;
  18747. constructor();
  18748. setReflectionMode(modeToEnable: string): void;
  18749. }
  18750. /**
  18751. * This is the default material used in Babylon. It is the best trade off between quality
  18752. * and performances.
  18753. * @see https://doc.babylonjs.com/babylon101/materials
  18754. */
  18755. export class StandardMaterial extends PushMaterial {
  18756. private _diffuseTexture;
  18757. /**
  18758. * The basic texture of the material as viewed under a light.
  18759. */
  18760. diffuseTexture: Nullable<BaseTexture>;
  18761. private _ambientTexture;
  18762. /**
  18763. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  18764. */
  18765. ambientTexture: Nullable<BaseTexture>;
  18766. private _opacityTexture;
  18767. /**
  18768. * Define the transparency of the material from a texture.
  18769. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  18770. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  18771. */
  18772. opacityTexture: Nullable<BaseTexture>;
  18773. private _reflectionTexture;
  18774. /**
  18775. * Define the texture used to display the reflection.
  18776. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18777. */
  18778. reflectionTexture: Nullable<BaseTexture>;
  18779. private _emissiveTexture;
  18780. /**
  18781. * Define texture of the material as if self lit.
  18782. * This will be mixed in the final result even in the absence of light.
  18783. */
  18784. emissiveTexture: Nullable<BaseTexture>;
  18785. private _specularTexture;
  18786. /**
  18787. * Define how the color and intensity of the highlight given by the light in the material.
  18788. */
  18789. specularTexture: Nullable<BaseTexture>;
  18790. private _bumpTexture;
  18791. /**
  18792. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  18793. * 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.
  18794. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  18795. */
  18796. bumpTexture: Nullable<BaseTexture>;
  18797. private _lightmapTexture;
  18798. /**
  18799. * Complex lighting can be computationally expensive to compute at runtime.
  18800. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  18801. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  18802. */
  18803. lightmapTexture: Nullable<BaseTexture>;
  18804. private _refractionTexture;
  18805. /**
  18806. * Define the texture used to display the refraction.
  18807. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18808. */
  18809. refractionTexture: Nullable<BaseTexture>;
  18810. /**
  18811. * The color of the material lit by the environmental background lighting.
  18812. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  18813. */
  18814. ambientColor: Color3;
  18815. /**
  18816. * The basic color of the material as viewed under a light.
  18817. */
  18818. diffuseColor: Color3;
  18819. /**
  18820. * Define how the color and intensity of the highlight given by the light in the material.
  18821. */
  18822. specularColor: Color3;
  18823. /**
  18824. * Define the color of the material as if self lit.
  18825. * This will be mixed in the final result even in the absence of light.
  18826. */
  18827. emissiveColor: Color3;
  18828. /**
  18829. * Defines how sharp are the highlights in the material.
  18830. * The bigger the value the sharper giving a more glossy feeling to the result.
  18831. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  18832. */
  18833. specularPower: number;
  18834. private _useAlphaFromDiffuseTexture;
  18835. /**
  18836. * Does the transparency come from the diffuse texture alpha channel.
  18837. */
  18838. useAlphaFromDiffuseTexture: boolean;
  18839. private _useEmissiveAsIllumination;
  18840. /**
  18841. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  18842. */
  18843. useEmissiveAsIllumination: boolean;
  18844. private _linkEmissiveWithDiffuse;
  18845. /**
  18846. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  18847. * the emissive level when the final color is close to one.
  18848. */
  18849. linkEmissiveWithDiffuse: boolean;
  18850. private _useSpecularOverAlpha;
  18851. /**
  18852. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  18853. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  18854. */
  18855. useSpecularOverAlpha: boolean;
  18856. private _useReflectionOverAlpha;
  18857. /**
  18858. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  18859. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  18860. */
  18861. useReflectionOverAlpha: boolean;
  18862. private _disableLighting;
  18863. /**
  18864. * Does lights from the scene impacts this material.
  18865. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  18866. */
  18867. disableLighting: boolean;
  18868. private _useObjectSpaceNormalMap;
  18869. /**
  18870. * Allows using an object space normal map (instead of tangent space).
  18871. */
  18872. useObjectSpaceNormalMap: boolean;
  18873. private _useParallax;
  18874. /**
  18875. * Is parallax enabled or not.
  18876. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  18877. */
  18878. useParallax: boolean;
  18879. private _useParallaxOcclusion;
  18880. /**
  18881. * Is parallax occlusion enabled or not.
  18882. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  18883. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  18884. */
  18885. useParallaxOcclusion: boolean;
  18886. /**
  18887. * 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.
  18888. */
  18889. parallaxScaleBias: number;
  18890. private _roughness;
  18891. /**
  18892. * Helps to define how blurry the reflections should appears in the material.
  18893. */
  18894. roughness: number;
  18895. /**
  18896. * In case of refraction, define the value of the index of refraction.
  18897. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18898. */
  18899. indexOfRefraction: number;
  18900. /**
  18901. * Invert the refraction texture alongside the y axis.
  18902. * It can be useful with procedural textures or probe for instance.
  18903. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18904. */
  18905. invertRefractionY: boolean;
  18906. /**
  18907. * Defines the alpha limits in alpha test mode.
  18908. */
  18909. alphaCutOff: number;
  18910. private _useLightmapAsShadowmap;
  18911. /**
  18912. * In case of light mapping, define whether the map contains light or shadow informations.
  18913. */
  18914. useLightmapAsShadowmap: boolean;
  18915. private _diffuseFresnelParameters;
  18916. /**
  18917. * Define the diffuse fresnel parameters of the material.
  18918. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18919. */
  18920. diffuseFresnelParameters: FresnelParameters;
  18921. private _opacityFresnelParameters;
  18922. /**
  18923. * Define the opacity fresnel parameters of the material.
  18924. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18925. */
  18926. opacityFresnelParameters: FresnelParameters;
  18927. private _reflectionFresnelParameters;
  18928. /**
  18929. * Define the reflection fresnel parameters of the material.
  18930. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18931. */
  18932. reflectionFresnelParameters: FresnelParameters;
  18933. private _refractionFresnelParameters;
  18934. /**
  18935. * Define the refraction fresnel parameters of the material.
  18936. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18937. */
  18938. refractionFresnelParameters: FresnelParameters;
  18939. private _emissiveFresnelParameters;
  18940. /**
  18941. * Define the emissive fresnel parameters of the material.
  18942. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18943. */
  18944. emissiveFresnelParameters: FresnelParameters;
  18945. private _useReflectionFresnelFromSpecular;
  18946. /**
  18947. * If true automatically deducts the fresnels values from the material specularity.
  18948. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18949. */
  18950. useReflectionFresnelFromSpecular: boolean;
  18951. private _useGlossinessFromSpecularMapAlpha;
  18952. /**
  18953. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  18954. */
  18955. useGlossinessFromSpecularMapAlpha: boolean;
  18956. private _maxSimultaneousLights;
  18957. /**
  18958. * Defines the maximum number of lights that can be used in the material
  18959. */
  18960. maxSimultaneousLights: number;
  18961. private _invertNormalMapX;
  18962. /**
  18963. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  18964. */
  18965. invertNormalMapX: boolean;
  18966. private _invertNormalMapY;
  18967. /**
  18968. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  18969. */
  18970. invertNormalMapY: boolean;
  18971. private _twoSidedLighting;
  18972. /**
  18973. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  18974. */
  18975. twoSidedLighting: boolean;
  18976. /**
  18977. * Default configuration related to image processing available in the standard Material.
  18978. */
  18979. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18980. /**
  18981. * Gets the image processing configuration used either in this material.
  18982. */
  18983. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18984. /**
  18985. * Sets the Default image processing configuration used either in the this material.
  18986. *
  18987. * If sets to null, the scene one is in use.
  18988. */
  18989. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18990. /**
  18991. * Keep track of the image processing observer to allow dispose and replace.
  18992. */
  18993. private _imageProcessingObserver;
  18994. /**
  18995. * Attaches a new image processing configuration to the Standard Material.
  18996. * @param configuration
  18997. */
  18998. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  18999. /**
  19000. * Defines additionnal PrePass parameters for the material.
  19001. */
  19002. readonly prePassConfiguration: PrePassConfiguration;
  19003. /**
  19004. * Gets wether the color curves effect is enabled.
  19005. */
  19006. get cameraColorCurvesEnabled(): boolean;
  19007. /**
  19008. * Sets wether the color curves effect is enabled.
  19009. */
  19010. set cameraColorCurvesEnabled(value: boolean);
  19011. /**
  19012. * Gets wether the color grading effect is enabled.
  19013. */
  19014. get cameraColorGradingEnabled(): boolean;
  19015. /**
  19016. * Gets wether the color grading effect is enabled.
  19017. */
  19018. set cameraColorGradingEnabled(value: boolean);
  19019. /**
  19020. * Gets wether tonemapping is enabled or not.
  19021. */
  19022. get cameraToneMappingEnabled(): boolean;
  19023. /**
  19024. * Sets wether tonemapping is enabled or not
  19025. */
  19026. set cameraToneMappingEnabled(value: boolean);
  19027. /**
  19028. * The camera exposure used on this material.
  19029. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19030. * This corresponds to a photographic exposure.
  19031. */
  19032. get cameraExposure(): number;
  19033. /**
  19034. * The camera exposure used on this material.
  19035. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19036. * This corresponds to a photographic exposure.
  19037. */
  19038. set cameraExposure(value: number);
  19039. /**
  19040. * Gets The camera contrast used on this material.
  19041. */
  19042. get cameraContrast(): number;
  19043. /**
  19044. * Sets The camera contrast used on this material.
  19045. */
  19046. set cameraContrast(value: number);
  19047. /**
  19048. * Gets the Color Grading 2D Lookup Texture.
  19049. */
  19050. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19051. /**
  19052. * Sets the Color Grading 2D Lookup Texture.
  19053. */
  19054. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19055. /**
  19056. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19057. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19058. * 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;
  19059. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19060. */
  19061. get cameraColorCurves(): Nullable<ColorCurves>;
  19062. /**
  19063. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19064. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19065. * 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;
  19066. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19067. */
  19068. set cameraColorCurves(value: Nullable<ColorCurves>);
  19069. /**
  19070. * Can this material render to several textures at once
  19071. */
  19072. get canRenderToMRT(): boolean;
  19073. /**
  19074. * Defines the detail map parameters for the material.
  19075. */
  19076. readonly detailMap: DetailMapConfiguration;
  19077. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19078. protected _worldViewProjectionMatrix: Matrix;
  19079. protected _globalAmbientColor: Color3;
  19080. protected _useLogarithmicDepth: boolean;
  19081. protected _rebuildInParallel: boolean;
  19082. /**
  19083. * Instantiates a new standard material.
  19084. * This is the default material used in Babylon. It is the best trade off between quality
  19085. * and performances.
  19086. * @see https://doc.babylonjs.com/babylon101/materials
  19087. * @param name Define the name of the material in the scene
  19088. * @param scene Define the scene the material belong to
  19089. */
  19090. constructor(name: string, scene: Scene);
  19091. /**
  19092. * Gets a boolean indicating that current material needs to register RTT
  19093. */
  19094. get hasRenderTargetTextures(): boolean;
  19095. /**
  19096. * Gets the current class name of the material e.g. "StandardMaterial"
  19097. * Mainly use in serialization.
  19098. * @returns the class name
  19099. */
  19100. getClassName(): string;
  19101. /**
  19102. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19103. * You can try switching to logarithmic depth.
  19104. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19105. */
  19106. get useLogarithmicDepth(): boolean;
  19107. set useLogarithmicDepth(value: boolean);
  19108. /**
  19109. * Specifies if the material will require alpha blending
  19110. * @returns a boolean specifying if alpha blending is needed
  19111. */
  19112. needAlphaBlending(): boolean;
  19113. /**
  19114. * Specifies if this material should be rendered in alpha test mode
  19115. * @returns a boolean specifying if an alpha test is needed.
  19116. */
  19117. needAlphaTesting(): boolean;
  19118. /**
  19119. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19120. */
  19121. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19122. /**
  19123. * Specifies whether or not there is a usable alpha channel for transparency.
  19124. */
  19125. protected _hasAlphaChannel(): boolean;
  19126. /**
  19127. * Get the texture used for alpha test purpose.
  19128. * @returns the diffuse texture in case of the standard material.
  19129. */
  19130. getAlphaTestTexture(): Nullable<BaseTexture>;
  19131. /**
  19132. * Get if the submesh is ready to be used and all its information available.
  19133. * Child classes can use it to update shaders
  19134. * @param mesh defines the mesh to check
  19135. * @param subMesh defines which submesh to check
  19136. * @param useInstances specifies that instances should be used
  19137. * @returns a boolean indicating that the submesh is ready or not
  19138. */
  19139. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19140. /**
  19141. * Builds the material UBO layouts.
  19142. * Used internally during the effect preparation.
  19143. */
  19144. buildUniformLayout(): void;
  19145. /**
  19146. * Unbinds the material from the mesh
  19147. */
  19148. unbind(): void;
  19149. /**
  19150. * Binds the submesh to this material by preparing the effect and shader to draw
  19151. * @param world defines the world transformation matrix
  19152. * @param mesh defines the mesh containing the submesh
  19153. * @param subMesh defines the submesh to bind the material to
  19154. */
  19155. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19156. /**
  19157. * Get the list of animatables in the material.
  19158. * @returns the list of animatables object used in the material
  19159. */
  19160. getAnimatables(): IAnimatable[];
  19161. /**
  19162. * Gets the active textures from the material
  19163. * @returns an array of textures
  19164. */
  19165. getActiveTextures(): BaseTexture[];
  19166. /**
  19167. * Specifies if the material uses a texture
  19168. * @param texture defines the texture to check against the material
  19169. * @returns a boolean specifying if the material uses the texture
  19170. */
  19171. hasTexture(texture: BaseTexture): boolean;
  19172. /**
  19173. * Disposes the material
  19174. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19175. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19176. */
  19177. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19178. /**
  19179. * Makes a duplicate of the material, and gives it a new name
  19180. * @param name defines the new name for the duplicated material
  19181. * @returns the cloned material
  19182. */
  19183. clone(name: string): StandardMaterial;
  19184. /**
  19185. * Serializes this material in a JSON representation
  19186. * @returns the serialized material object
  19187. */
  19188. serialize(): any;
  19189. /**
  19190. * Creates a standard material from parsed material data
  19191. * @param source defines the JSON representation of the material
  19192. * @param scene defines the hosting scene
  19193. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19194. * @returns a new standard material
  19195. */
  19196. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19197. /**
  19198. * Are diffuse textures enabled in the application.
  19199. */
  19200. static get DiffuseTextureEnabled(): boolean;
  19201. static set DiffuseTextureEnabled(value: boolean);
  19202. /**
  19203. * Are detail textures enabled in the application.
  19204. */
  19205. static get DetailTextureEnabled(): boolean;
  19206. static set DetailTextureEnabled(value: boolean);
  19207. /**
  19208. * Are ambient textures enabled in the application.
  19209. */
  19210. static get AmbientTextureEnabled(): boolean;
  19211. static set AmbientTextureEnabled(value: boolean);
  19212. /**
  19213. * Are opacity textures enabled in the application.
  19214. */
  19215. static get OpacityTextureEnabled(): boolean;
  19216. static set OpacityTextureEnabled(value: boolean);
  19217. /**
  19218. * Are reflection textures enabled in the application.
  19219. */
  19220. static get ReflectionTextureEnabled(): boolean;
  19221. static set ReflectionTextureEnabled(value: boolean);
  19222. /**
  19223. * Are emissive textures enabled in the application.
  19224. */
  19225. static get EmissiveTextureEnabled(): boolean;
  19226. static set EmissiveTextureEnabled(value: boolean);
  19227. /**
  19228. * Are specular textures enabled in the application.
  19229. */
  19230. static get SpecularTextureEnabled(): boolean;
  19231. static set SpecularTextureEnabled(value: boolean);
  19232. /**
  19233. * Are bump textures enabled in the application.
  19234. */
  19235. static get BumpTextureEnabled(): boolean;
  19236. static set BumpTextureEnabled(value: boolean);
  19237. /**
  19238. * Are lightmap textures enabled in the application.
  19239. */
  19240. static get LightmapTextureEnabled(): boolean;
  19241. static set LightmapTextureEnabled(value: boolean);
  19242. /**
  19243. * Are refraction textures enabled in the application.
  19244. */
  19245. static get RefractionTextureEnabled(): boolean;
  19246. static set RefractionTextureEnabled(value: boolean);
  19247. /**
  19248. * Are color grading textures enabled in the application.
  19249. */
  19250. static get ColorGradingTextureEnabled(): boolean;
  19251. static set ColorGradingTextureEnabled(value: boolean);
  19252. /**
  19253. * Are fresnels enabled in the application.
  19254. */
  19255. static get FresnelEnabled(): boolean;
  19256. static set FresnelEnabled(value: boolean);
  19257. }
  19258. }
  19259. declare module BABYLON {
  19260. /** @hidden */
  19261. export var rgbdDecodePixelShader: {
  19262. name: string;
  19263. shader: string;
  19264. };
  19265. }
  19266. declare module BABYLON {
  19267. /**
  19268. * Class used to host RGBD texture specific utilities
  19269. */
  19270. export class RGBDTextureTools {
  19271. /**
  19272. * Expand the RGBD Texture from RGBD to Half Float if possible.
  19273. * @param texture the texture to expand.
  19274. */
  19275. static ExpandRGBDTexture(texture: Texture): void;
  19276. }
  19277. }
  19278. declare module BABYLON {
  19279. /**
  19280. * Class used to host texture specific utilities
  19281. */
  19282. export class BRDFTextureTools {
  19283. /**
  19284. * Prevents texture cache collision
  19285. */
  19286. private static _instanceNumber;
  19287. /**
  19288. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  19289. * @param scene defines the hosting scene
  19290. * @returns the environment BRDF texture
  19291. */
  19292. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  19293. private static _environmentBRDFBase64Texture;
  19294. }
  19295. }
  19296. declare module BABYLON {
  19297. /**
  19298. * @hidden
  19299. */
  19300. export interface IMaterialClearCoatDefines {
  19301. CLEARCOAT: boolean;
  19302. CLEARCOAT_DEFAULTIOR: boolean;
  19303. CLEARCOAT_TEXTURE: boolean;
  19304. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  19305. CLEARCOAT_TEXTUREDIRECTUV: number;
  19306. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  19307. CLEARCOAT_BUMP: boolean;
  19308. CLEARCOAT_BUMPDIRECTUV: number;
  19309. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19310. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19311. CLEARCOAT_REMAP_F0: boolean;
  19312. CLEARCOAT_TINT: boolean;
  19313. CLEARCOAT_TINT_TEXTURE: boolean;
  19314. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  19315. /** @hidden */
  19316. _areTexturesDirty: boolean;
  19317. }
  19318. /**
  19319. * Define the code related to the clear coat parameters of the pbr material.
  19320. */
  19321. export class PBRClearCoatConfiguration {
  19322. /**
  19323. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19324. * The default fits with a polyurethane material.
  19325. * @hidden
  19326. */
  19327. static readonly _DefaultIndexOfRefraction: number;
  19328. private _isEnabled;
  19329. /**
  19330. * Defines if the clear coat is enabled in the material.
  19331. */
  19332. isEnabled: boolean;
  19333. /**
  19334. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  19335. */
  19336. intensity: number;
  19337. /**
  19338. * Defines the clear coat layer roughness.
  19339. */
  19340. roughness: number;
  19341. private _indexOfRefraction;
  19342. /**
  19343. * Defines the index of refraction of the clear coat.
  19344. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19345. * The default fits with a polyurethane material.
  19346. * Changing the default value is more performance intensive.
  19347. */
  19348. indexOfRefraction: number;
  19349. private _texture;
  19350. /**
  19351. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  19352. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  19353. * if textureRoughness is not empty, else no texture roughness is used
  19354. */
  19355. texture: Nullable<BaseTexture>;
  19356. private _useRoughnessFromMainTexture;
  19357. /**
  19358. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  19359. * If false, the green channel from textureRoughness is used for roughness
  19360. */
  19361. useRoughnessFromMainTexture: boolean;
  19362. private _textureRoughness;
  19363. /**
  19364. * Stores the clear coat roughness in a texture (green channel)
  19365. * Not used if useRoughnessFromMainTexture is true
  19366. */
  19367. textureRoughness: Nullable<BaseTexture>;
  19368. private _remapF0OnInterfaceChange;
  19369. /**
  19370. * Defines if the F0 value should be remapped to account for the interface change in the material.
  19371. */
  19372. remapF0OnInterfaceChange: boolean;
  19373. private _bumpTexture;
  19374. /**
  19375. * Define the clear coat specific bump texture.
  19376. */
  19377. bumpTexture: Nullable<BaseTexture>;
  19378. private _isTintEnabled;
  19379. /**
  19380. * Defines if the clear coat tint is enabled in the material.
  19381. */
  19382. isTintEnabled: boolean;
  19383. /**
  19384. * Defines the clear coat tint of the material.
  19385. * This is only use if tint is enabled
  19386. */
  19387. tintColor: Color3;
  19388. /**
  19389. * Defines the distance at which the tint color should be found in the
  19390. * clear coat media.
  19391. * This is only use if tint is enabled
  19392. */
  19393. tintColorAtDistance: number;
  19394. /**
  19395. * Defines the clear coat layer thickness.
  19396. * This is only use if tint is enabled
  19397. */
  19398. tintThickness: number;
  19399. private _tintTexture;
  19400. /**
  19401. * Stores the clear tint values in a texture.
  19402. * rgb is tint
  19403. * a is a thickness factor
  19404. */
  19405. tintTexture: Nullable<BaseTexture>;
  19406. /** @hidden */
  19407. private _internalMarkAllSubMeshesAsTexturesDirty;
  19408. /** @hidden */
  19409. _markAllSubMeshesAsTexturesDirty(): void;
  19410. /**
  19411. * Instantiate a new istance of clear coat configuration.
  19412. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19413. */
  19414. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19415. /**
  19416. * Gets wehter the submesh is ready to be used or not.
  19417. * @param defines the list of "defines" to update.
  19418. * @param scene defines the scene the material belongs to.
  19419. * @param engine defines the engine the material belongs to.
  19420. * @param disableBumpMap defines wether the material disables bump or not.
  19421. * @returns - boolean indicating that the submesh is ready or not.
  19422. */
  19423. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  19424. /**
  19425. * Checks to see if a texture is used in the material.
  19426. * @param defines the list of "defines" to update.
  19427. * @param scene defines the scene to the material belongs to.
  19428. */
  19429. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  19430. /**
  19431. * Binds the material data.
  19432. * @param uniformBuffer defines the Uniform buffer to fill in.
  19433. * @param scene defines the scene the material belongs to.
  19434. * @param engine defines the engine the material belongs to.
  19435. * @param disableBumpMap defines wether the material disables bump or not.
  19436. * @param isFrozen defines wether the material is frozen or not.
  19437. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  19438. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  19439. * @param subMesh the submesh to bind data for
  19440. */
  19441. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  19442. /**
  19443. * Checks to see if a texture is used in the material.
  19444. * @param texture - Base texture to use.
  19445. * @returns - Boolean specifying if a texture is used in the material.
  19446. */
  19447. hasTexture(texture: BaseTexture): boolean;
  19448. /**
  19449. * Returns an array of the actively used textures.
  19450. * @param activeTextures Array of BaseTextures
  19451. */
  19452. getActiveTextures(activeTextures: BaseTexture[]): void;
  19453. /**
  19454. * Returns the animatable textures.
  19455. * @param animatables Array of animatable textures.
  19456. */
  19457. getAnimatables(animatables: IAnimatable[]): void;
  19458. /**
  19459. * Disposes the resources of the material.
  19460. * @param forceDisposeTextures - Forces the disposal of all textures.
  19461. */
  19462. dispose(forceDisposeTextures?: boolean): void;
  19463. /**
  19464. * Get the current class name of the texture useful for serialization or dynamic coding.
  19465. * @returns "PBRClearCoatConfiguration"
  19466. */
  19467. getClassName(): string;
  19468. /**
  19469. * Add fallbacks to the effect fallbacks list.
  19470. * @param defines defines the Base texture to use.
  19471. * @param fallbacks defines the current fallback list.
  19472. * @param currentRank defines the current fallback rank.
  19473. * @returns the new fallback rank.
  19474. */
  19475. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19476. /**
  19477. * Add the required uniforms to the current list.
  19478. * @param uniforms defines the current uniform list.
  19479. */
  19480. static AddUniforms(uniforms: string[]): void;
  19481. /**
  19482. * Add the required samplers to the current list.
  19483. * @param samplers defines the current sampler list.
  19484. */
  19485. static AddSamplers(samplers: string[]): void;
  19486. /**
  19487. * Add the required uniforms to the current buffer.
  19488. * @param uniformBuffer defines the current uniform buffer.
  19489. */
  19490. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19491. /**
  19492. * Makes a duplicate of the current configuration into another one.
  19493. * @param clearCoatConfiguration define the config where to copy the info
  19494. */
  19495. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  19496. /**
  19497. * Serializes this clear coat configuration.
  19498. * @returns - An object with the serialized config.
  19499. */
  19500. serialize(): any;
  19501. /**
  19502. * Parses a anisotropy Configuration from a serialized object.
  19503. * @param source - Serialized object.
  19504. * @param scene Defines the scene we are parsing for
  19505. * @param rootUrl Defines the rootUrl to load from
  19506. */
  19507. parse(source: any, scene: Scene, rootUrl: string): void;
  19508. }
  19509. }
  19510. declare module BABYLON {
  19511. /**
  19512. * @hidden
  19513. */
  19514. export interface IMaterialAnisotropicDefines {
  19515. ANISOTROPIC: boolean;
  19516. ANISOTROPIC_TEXTURE: boolean;
  19517. ANISOTROPIC_TEXTUREDIRECTUV: number;
  19518. MAINUV1: boolean;
  19519. _areTexturesDirty: boolean;
  19520. _needUVs: boolean;
  19521. }
  19522. /**
  19523. * Define the code related to the anisotropic parameters of the pbr material.
  19524. */
  19525. export class PBRAnisotropicConfiguration {
  19526. private _isEnabled;
  19527. /**
  19528. * Defines if the anisotropy is enabled in the material.
  19529. */
  19530. isEnabled: boolean;
  19531. /**
  19532. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  19533. */
  19534. intensity: number;
  19535. /**
  19536. * Defines if the effect is along the tangents, bitangents or in between.
  19537. * By default, the effect is "strectching" the highlights along the tangents.
  19538. */
  19539. direction: Vector2;
  19540. private _texture;
  19541. /**
  19542. * Stores the anisotropy values in a texture.
  19543. * rg is direction (like normal from -1 to 1)
  19544. * b is a intensity
  19545. */
  19546. texture: Nullable<BaseTexture>;
  19547. /** @hidden */
  19548. private _internalMarkAllSubMeshesAsTexturesDirty;
  19549. /** @hidden */
  19550. _markAllSubMeshesAsTexturesDirty(): void;
  19551. /**
  19552. * Instantiate a new istance of anisotropy configuration.
  19553. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19554. */
  19555. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19556. /**
  19557. * Specifies that the submesh is ready to be used.
  19558. * @param defines the list of "defines" to update.
  19559. * @param scene defines the scene the material belongs to.
  19560. * @returns - boolean indicating that the submesh is ready or not.
  19561. */
  19562. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  19563. /**
  19564. * Checks to see if a texture is used in the material.
  19565. * @param defines the list of "defines" to update.
  19566. * @param mesh the mesh we are preparing the defines for.
  19567. * @param scene defines the scene the material belongs to.
  19568. */
  19569. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  19570. /**
  19571. * Binds the material data.
  19572. * @param uniformBuffer defines the Uniform buffer to fill in.
  19573. * @param scene defines the scene the material belongs to.
  19574. * @param isFrozen defines wether the material is frozen or not.
  19575. */
  19576. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19577. /**
  19578. * Checks to see if a texture is used in the material.
  19579. * @param texture - Base texture to use.
  19580. * @returns - Boolean specifying if a texture is used in the material.
  19581. */
  19582. hasTexture(texture: BaseTexture): boolean;
  19583. /**
  19584. * Returns an array of the actively used textures.
  19585. * @param activeTextures Array of BaseTextures
  19586. */
  19587. getActiveTextures(activeTextures: BaseTexture[]): void;
  19588. /**
  19589. * Returns the animatable textures.
  19590. * @param animatables Array of animatable textures.
  19591. */
  19592. getAnimatables(animatables: IAnimatable[]): void;
  19593. /**
  19594. * Disposes the resources of the material.
  19595. * @param forceDisposeTextures - Forces the disposal of all textures.
  19596. */
  19597. dispose(forceDisposeTextures?: boolean): void;
  19598. /**
  19599. * Get the current class name of the texture useful for serialization or dynamic coding.
  19600. * @returns "PBRAnisotropicConfiguration"
  19601. */
  19602. getClassName(): string;
  19603. /**
  19604. * Add fallbacks to the effect fallbacks list.
  19605. * @param defines defines the Base texture to use.
  19606. * @param fallbacks defines the current fallback list.
  19607. * @param currentRank defines the current fallback rank.
  19608. * @returns the new fallback rank.
  19609. */
  19610. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19611. /**
  19612. * Add the required uniforms to the current list.
  19613. * @param uniforms defines the current uniform list.
  19614. */
  19615. static AddUniforms(uniforms: string[]): void;
  19616. /**
  19617. * Add the required uniforms to the current buffer.
  19618. * @param uniformBuffer defines the current uniform buffer.
  19619. */
  19620. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19621. /**
  19622. * Add the required samplers to the current list.
  19623. * @param samplers defines the current sampler list.
  19624. */
  19625. static AddSamplers(samplers: string[]): void;
  19626. /**
  19627. * Makes a duplicate of the current configuration into another one.
  19628. * @param anisotropicConfiguration define the config where to copy the info
  19629. */
  19630. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  19631. /**
  19632. * Serializes this anisotropy configuration.
  19633. * @returns - An object with the serialized config.
  19634. */
  19635. serialize(): any;
  19636. /**
  19637. * Parses a anisotropy Configuration from a serialized object.
  19638. * @param source - Serialized object.
  19639. * @param scene Defines the scene we are parsing for
  19640. * @param rootUrl Defines the rootUrl to load from
  19641. */
  19642. parse(source: any, scene: Scene, rootUrl: string): void;
  19643. }
  19644. }
  19645. declare module BABYLON {
  19646. /**
  19647. * @hidden
  19648. */
  19649. export interface IMaterialBRDFDefines {
  19650. BRDF_V_HEIGHT_CORRELATED: boolean;
  19651. MS_BRDF_ENERGY_CONSERVATION: boolean;
  19652. SPHERICAL_HARMONICS: boolean;
  19653. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  19654. /** @hidden */
  19655. _areMiscDirty: boolean;
  19656. }
  19657. /**
  19658. * Define the code related to the BRDF parameters of the pbr material.
  19659. */
  19660. export class PBRBRDFConfiguration {
  19661. /**
  19662. * Default value used for the energy conservation.
  19663. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  19664. */
  19665. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  19666. /**
  19667. * Default value used for the Smith Visibility Height Correlated mode.
  19668. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  19669. */
  19670. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  19671. /**
  19672. * Default value used for the IBL diffuse part.
  19673. * This can help switching back to the polynomials mode globally which is a tiny bit
  19674. * less GPU intensive at the drawback of a lower quality.
  19675. */
  19676. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  19677. /**
  19678. * Default value used for activating energy conservation for the specular workflow.
  19679. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  19680. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  19681. */
  19682. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  19683. private _useEnergyConservation;
  19684. /**
  19685. * Defines if the material uses energy conservation.
  19686. */
  19687. useEnergyConservation: boolean;
  19688. private _useSmithVisibilityHeightCorrelated;
  19689. /**
  19690. * LEGACY Mode set to false
  19691. * Defines if the material uses height smith correlated visibility term.
  19692. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  19693. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  19694. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  19695. * Not relying on height correlated will also disable energy conservation.
  19696. */
  19697. useSmithVisibilityHeightCorrelated: boolean;
  19698. private _useSphericalHarmonics;
  19699. /**
  19700. * LEGACY Mode set to false
  19701. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  19702. * diffuse part of the IBL.
  19703. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  19704. * to the ground truth.
  19705. */
  19706. useSphericalHarmonics: boolean;
  19707. private _useSpecularGlossinessInputEnergyConservation;
  19708. /**
  19709. * Defines if the material uses energy conservation, when the specular workflow is active.
  19710. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  19711. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  19712. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  19713. */
  19714. useSpecularGlossinessInputEnergyConservation: boolean;
  19715. /** @hidden */
  19716. private _internalMarkAllSubMeshesAsMiscDirty;
  19717. /** @hidden */
  19718. _markAllSubMeshesAsMiscDirty(): void;
  19719. /**
  19720. * Instantiate a new istance of clear coat configuration.
  19721. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  19722. */
  19723. constructor(markAllSubMeshesAsMiscDirty: () => void);
  19724. /**
  19725. * Checks to see if a texture is used in the material.
  19726. * @param defines the list of "defines" to update.
  19727. */
  19728. prepareDefines(defines: IMaterialBRDFDefines): void;
  19729. /**
  19730. * Get the current class name of the texture useful for serialization or dynamic coding.
  19731. * @returns "PBRClearCoatConfiguration"
  19732. */
  19733. getClassName(): string;
  19734. /**
  19735. * Makes a duplicate of the current configuration into another one.
  19736. * @param brdfConfiguration define the config where to copy the info
  19737. */
  19738. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  19739. /**
  19740. * Serializes this BRDF configuration.
  19741. * @returns - An object with the serialized config.
  19742. */
  19743. serialize(): any;
  19744. /**
  19745. * Parses a anisotropy Configuration from a serialized object.
  19746. * @param source - Serialized object.
  19747. * @param scene Defines the scene we are parsing for
  19748. * @param rootUrl Defines the rootUrl to load from
  19749. */
  19750. parse(source: any, scene: Scene, rootUrl: string): void;
  19751. }
  19752. }
  19753. declare module BABYLON {
  19754. /**
  19755. * @hidden
  19756. */
  19757. export interface IMaterialSheenDefines {
  19758. SHEEN: boolean;
  19759. SHEEN_TEXTURE: boolean;
  19760. SHEEN_TEXTURE_ROUGHNESS: boolean;
  19761. SHEEN_TEXTUREDIRECTUV: number;
  19762. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  19763. SHEEN_LINKWITHALBEDO: boolean;
  19764. SHEEN_ROUGHNESS: boolean;
  19765. SHEEN_ALBEDOSCALING: boolean;
  19766. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19767. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19768. /** @hidden */
  19769. _areTexturesDirty: boolean;
  19770. }
  19771. /**
  19772. * Define the code related to the Sheen parameters of the pbr material.
  19773. */
  19774. export class PBRSheenConfiguration {
  19775. private _isEnabled;
  19776. /**
  19777. * Defines if the material uses sheen.
  19778. */
  19779. isEnabled: boolean;
  19780. private _linkSheenWithAlbedo;
  19781. /**
  19782. * Defines if the sheen is linked to the sheen color.
  19783. */
  19784. linkSheenWithAlbedo: boolean;
  19785. /**
  19786. * Defines the sheen intensity.
  19787. */
  19788. intensity: number;
  19789. /**
  19790. * Defines the sheen color.
  19791. */
  19792. color: Color3;
  19793. private _texture;
  19794. /**
  19795. * Stores the sheen tint values in a texture.
  19796. * rgb is tint
  19797. * 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)
  19798. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  19799. */
  19800. texture: Nullable<BaseTexture>;
  19801. private _useRoughnessFromMainTexture;
  19802. /**
  19803. * Indicates that the alpha channel of the texture property will be used for roughness.
  19804. * Has no effect if the roughness (and texture!) property is not defined
  19805. */
  19806. useRoughnessFromMainTexture: boolean;
  19807. private _roughness;
  19808. /**
  19809. * Defines the sheen roughness.
  19810. * It is not taken into account if linkSheenWithAlbedo is true.
  19811. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  19812. */
  19813. roughness: Nullable<number>;
  19814. private _textureRoughness;
  19815. /**
  19816. * Stores the sheen roughness in a texture.
  19817. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  19818. */
  19819. textureRoughness: Nullable<BaseTexture>;
  19820. private _albedoScaling;
  19821. /**
  19822. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  19823. * It allows the strength of the sheen effect to not depend on the base color of the material,
  19824. * making it easier to setup and tweak the effect
  19825. */
  19826. albedoScaling: boolean;
  19827. /** @hidden */
  19828. private _internalMarkAllSubMeshesAsTexturesDirty;
  19829. /** @hidden */
  19830. _markAllSubMeshesAsTexturesDirty(): void;
  19831. /**
  19832. * Instantiate a new istance of clear coat configuration.
  19833. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19834. */
  19835. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19836. /**
  19837. * Specifies that the submesh is ready to be used.
  19838. * @param defines the list of "defines" to update.
  19839. * @param scene defines the scene the material belongs to.
  19840. * @returns - boolean indicating that the submesh is ready or not.
  19841. */
  19842. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  19843. /**
  19844. * Checks to see if a texture is used in the material.
  19845. * @param defines the list of "defines" to update.
  19846. * @param scene defines the scene the material belongs to.
  19847. */
  19848. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  19849. /**
  19850. * Binds the material data.
  19851. * @param uniformBuffer defines the Uniform buffer to fill in.
  19852. * @param scene defines the scene the material belongs to.
  19853. * @param isFrozen defines wether the material is frozen or not.
  19854. * @param subMesh the submesh to bind data for
  19855. */
  19856. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  19857. /**
  19858. * Checks to see if a texture is used in the material.
  19859. * @param texture - Base texture to use.
  19860. * @returns - Boolean specifying if a texture is used in the material.
  19861. */
  19862. hasTexture(texture: BaseTexture): boolean;
  19863. /**
  19864. * Returns an array of the actively used textures.
  19865. * @param activeTextures Array of BaseTextures
  19866. */
  19867. getActiveTextures(activeTextures: BaseTexture[]): void;
  19868. /**
  19869. * Returns the animatable textures.
  19870. * @param animatables Array of animatable textures.
  19871. */
  19872. getAnimatables(animatables: IAnimatable[]): void;
  19873. /**
  19874. * Disposes the resources of the material.
  19875. * @param forceDisposeTextures - Forces the disposal of all textures.
  19876. */
  19877. dispose(forceDisposeTextures?: boolean): void;
  19878. /**
  19879. * Get the current class name of the texture useful for serialization or dynamic coding.
  19880. * @returns "PBRSheenConfiguration"
  19881. */
  19882. getClassName(): string;
  19883. /**
  19884. * Add fallbacks to the effect fallbacks list.
  19885. * @param defines defines the Base texture to use.
  19886. * @param fallbacks defines the current fallback list.
  19887. * @param currentRank defines the current fallback rank.
  19888. * @returns the new fallback rank.
  19889. */
  19890. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19891. /**
  19892. * Add the required uniforms to the current list.
  19893. * @param uniforms defines the current uniform list.
  19894. */
  19895. static AddUniforms(uniforms: string[]): void;
  19896. /**
  19897. * Add the required uniforms to the current buffer.
  19898. * @param uniformBuffer defines the current uniform buffer.
  19899. */
  19900. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19901. /**
  19902. * Add the required samplers to the current list.
  19903. * @param samplers defines the current sampler list.
  19904. */
  19905. static AddSamplers(samplers: string[]): void;
  19906. /**
  19907. * Makes a duplicate of the current configuration into another one.
  19908. * @param sheenConfiguration define the config where to copy the info
  19909. */
  19910. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  19911. /**
  19912. * Serializes this BRDF configuration.
  19913. * @returns - An object with the serialized config.
  19914. */
  19915. serialize(): any;
  19916. /**
  19917. * Parses a anisotropy Configuration from a serialized object.
  19918. * @param source - Serialized object.
  19919. * @param scene Defines the scene we are parsing for
  19920. * @param rootUrl Defines the rootUrl to load from
  19921. */
  19922. parse(source: any, scene: Scene, rootUrl: string): void;
  19923. }
  19924. }
  19925. declare module BABYLON {
  19926. /**
  19927. * @hidden
  19928. */
  19929. export interface IMaterialSubSurfaceDefines {
  19930. SUBSURFACE: boolean;
  19931. SS_REFRACTION: boolean;
  19932. SS_TRANSLUCENCY: boolean;
  19933. SS_SCATTERING: boolean;
  19934. SS_THICKNESSANDMASK_TEXTURE: boolean;
  19935. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  19936. SS_REFRACTIONMAP_3D: boolean;
  19937. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  19938. SS_LODINREFRACTIONALPHA: boolean;
  19939. SS_GAMMAREFRACTION: boolean;
  19940. SS_RGBDREFRACTION: boolean;
  19941. SS_LINEARSPECULARREFRACTION: boolean;
  19942. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  19943. SS_ALBEDOFORREFRACTIONTINT: boolean;
  19944. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  19945. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  19946. /** @hidden */
  19947. _areTexturesDirty: boolean;
  19948. }
  19949. /**
  19950. * Define the code related to the sub surface parameters of the pbr material.
  19951. */
  19952. export class PBRSubSurfaceConfiguration {
  19953. private _isRefractionEnabled;
  19954. /**
  19955. * Defines if the refraction is enabled in the material.
  19956. */
  19957. isRefractionEnabled: boolean;
  19958. private _isTranslucencyEnabled;
  19959. /**
  19960. * Defines if the translucency is enabled in the material.
  19961. */
  19962. isTranslucencyEnabled: boolean;
  19963. private _isScatteringEnabled;
  19964. /**
  19965. * Defines if the sub surface scattering is enabled in the material.
  19966. */
  19967. isScatteringEnabled: boolean;
  19968. private _scatteringDiffusionProfileIndex;
  19969. /**
  19970. * Diffusion profile for subsurface scattering.
  19971. * Useful for better scattering in the skins or foliages.
  19972. */
  19973. get scatteringDiffusionProfile(): Nullable<Color3>;
  19974. set scatteringDiffusionProfile(c: Nullable<Color3>);
  19975. /**
  19976. * Defines the refraction intensity of the material.
  19977. * The refraction when enabled replaces the Diffuse part of the material.
  19978. * The intensity helps transitionning between diffuse and refraction.
  19979. */
  19980. refractionIntensity: number;
  19981. /**
  19982. * Defines the translucency intensity of the material.
  19983. * When translucency has been enabled, this defines how much of the "translucency"
  19984. * is addded to the diffuse part of the material.
  19985. */
  19986. translucencyIntensity: number;
  19987. /**
  19988. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  19989. */
  19990. useAlbedoToTintRefraction: boolean;
  19991. private _thicknessTexture;
  19992. /**
  19993. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  19994. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  19995. * 0 would mean minimumThickness
  19996. * 1 would mean maximumThickness
  19997. * The other channels might be use as a mask to vary the different effects intensity.
  19998. */
  19999. thicknessTexture: Nullable<BaseTexture>;
  20000. private _refractionTexture;
  20001. /**
  20002. * Defines the texture to use for refraction.
  20003. */
  20004. refractionTexture: Nullable<BaseTexture>;
  20005. private _indexOfRefraction;
  20006. /**
  20007. * Index of refraction of the material base layer.
  20008. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20009. *
  20010. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20011. *
  20012. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20013. */
  20014. indexOfRefraction: number;
  20015. private _volumeIndexOfRefraction;
  20016. /**
  20017. * Index of refraction of the material's volume.
  20018. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20019. *
  20020. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20021. * the volume will use the same IOR as the surface.
  20022. */
  20023. get volumeIndexOfRefraction(): number;
  20024. set volumeIndexOfRefraction(value: number);
  20025. private _invertRefractionY;
  20026. /**
  20027. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20028. */
  20029. invertRefractionY: boolean;
  20030. private _linkRefractionWithTransparency;
  20031. /**
  20032. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20033. * Materials half opaque for instance using refraction could benefit from this control.
  20034. */
  20035. linkRefractionWithTransparency: boolean;
  20036. /**
  20037. * Defines the minimum thickness stored in the thickness map.
  20038. * If no thickness map is defined, this value will be used to simulate thickness.
  20039. */
  20040. minimumThickness: number;
  20041. /**
  20042. * Defines the maximum thickness stored in the thickness map.
  20043. */
  20044. maximumThickness: number;
  20045. /**
  20046. * Defines the volume tint of the material.
  20047. * This is used for both translucency and scattering.
  20048. */
  20049. tintColor: Color3;
  20050. /**
  20051. * Defines the distance at which the tint color should be found in the media.
  20052. * This is used for refraction only.
  20053. */
  20054. tintColorAtDistance: number;
  20055. /**
  20056. * Defines how far each channel transmit through the media.
  20057. * It is defined as a color to simplify it selection.
  20058. */
  20059. diffusionDistance: Color3;
  20060. private _useMaskFromThicknessTexture;
  20061. /**
  20062. * Stores the intensity of the different subsurface effects in the thickness texture.
  20063. * * the green channel is the translucency intensity.
  20064. * * the blue channel is the scattering intensity.
  20065. * * the alpha channel is the refraction intensity.
  20066. */
  20067. useMaskFromThicknessTexture: boolean;
  20068. private _scene;
  20069. private _useMaskFromThicknessTextureGltf;
  20070. /**
  20071. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20072. * matches the channel-packing that is used by glTF.
  20073. * * the red channel is the transmission/translucency intensity.
  20074. * * the green channel is the thickness.
  20075. */
  20076. useMaskFromThicknessTextureGltf: boolean;
  20077. /** @hidden */
  20078. private _internalMarkAllSubMeshesAsTexturesDirty;
  20079. private _internalMarkScenePrePassDirty;
  20080. /** @hidden */
  20081. _markAllSubMeshesAsTexturesDirty(): void;
  20082. /** @hidden */
  20083. _markScenePrePassDirty(): void;
  20084. /**
  20085. * Instantiate a new istance of sub surface configuration.
  20086. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20087. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20088. * @param scene The scene
  20089. */
  20090. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20091. /**
  20092. * Gets wehter the submesh is ready to be used or not.
  20093. * @param defines the list of "defines" to update.
  20094. * @param scene defines the scene the material belongs to.
  20095. * @returns - boolean indicating that the submesh is ready or not.
  20096. */
  20097. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20098. /**
  20099. * Checks to see if a texture is used in the material.
  20100. * @param defines the list of "defines" to update.
  20101. * @param scene defines the scene to the material belongs to.
  20102. */
  20103. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20104. /**
  20105. * Binds the material data.
  20106. * @param uniformBuffer defines the Uniform buffer to fill in.
  20107. * @param scene defines the scene the material belongs to.
  20108. * @param engine defines the engine the material belongs to.
  20109. * @param isFrozen defines whether the material is frozen or not.
  20110. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20111. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20112. */
  20113. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20114. /**
  20115. * Unbinds the material from the mesh.
  20116. * @param activeEffect defines the effect that should be unbound from.
  20117. * @returns true if unbound, otherwise false
  20118. */
  20119. unbind(activeEffect: Effect): boolean;
  20120. /**
  20121. * Returns the texture used for refraction or null if none is used.
  20122. * @param scene defines the scene the material belongs to.
  20123. * @returns - Refraction texture if present. If no refraction texture and refraction
  20124. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20125. */
  20126. private _getRefractionTexture;
  20127. /**
  20128. * Returns true if alpha blending should be disabled.
  20129. */
  20130. get disableAlphaBlending(): boolean;
  20131. /**
  20132. * Fills the list of render target textures.
  20133. * @param renderTargets the list of render targets to update
  20134. */
  20135. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20136. /**
  20137. * Checks to see if a texture is used in the material.
  20138. * @param texture - Base texture to use.
  20139. * @returns - Boolean specifying if a texture is used in the material.
  20140. */
  20141. hasTexture(texture: BaseTexture): boolean;
  20142. /**
  20143. * Gets a boolean indicating that current material needs to register RTT
  20144. * @returns true if this uses a render target otherwise false.
  20145. */
  20146. hasRenderTargetTextures(): boolean;
  20147. /**
  20148. * Returns an array of the actively used textures.
  20149. * @param activeTextures Array of BaseTextures
  20150. */
  20151. getActiveTextures(activeTextures: BaseTexture[]): void;
  20152. /**
  20153. * Returns the animatable textures.
  20154. * @param animatables Array of animatable textures.
  20155. */
  20156. getAnimatables(animatables: IAnimatable[]): void;
  20157. /**
  20158. * Disposes the resources of the material.
  20159. * @param forceDisposeTextures - Forces the disposal of all textures.
  20160. */
  20161. dispose(forceDisposeTextures?: boolean): void;
  20162. /**
  20163. * Get the current class name of the texture useful for serialization or dynamic coding.
  20164. * @returns "PBRSubSurfaceConfiguration"
  20165. */
  20166. getClassName(): string;
  20167. /**
  20168. * Add fallbacks to the effect fallbacks list.
  20169. * @param defines defines the Base texture to use.
  20170. * @param fallbacks defines the current fallback list.
  20171. * @param currentRank defines the current fallback rank.
  20172. * @returns the new fallback rank.
  20173. */
  20174. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20175. /**
  20176. * Add the required uniforms to the current list.
  20177. * @param uniforms defines the current uniform list.
  20178. */
  20179. static AddUniforms(uniforms: string[]): void;
  20180. /**
  20181. * Add the required samplers to the current list.
  20182. * @param samplers defines the current sampler list.
  20183. */
  20184. static AddSamplers(samplers: string[]): void;
  20185. /**
  20186. * Add the required uniforms to the current buffer.
  20187. * @param uniformBuffer defines the current uniform buffer.
  20188. */
  20189. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20190. /**
  20191. * Makes a duplicate of the current configuration into another one.
  20192. * @param configuration define the config where to copy the info
  20193. */
  20194. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20195. /**
  20196. * Serializes this Sub Surface configuration.
  20197. * @returns - An object with the serialized config.
  20198. */
  20199. serialize(): any;
  20200. /**
  20201. * Parses a anisotropy Configuration from a serialized object.
  20202. * @param source - Serialized object.
  20203. * @param scene Defines the scene we are parsing for
  20204. * @param rootUrl Defines the rootUrl to load from
  20205. */
  20206. parse(source: any, scene: Scene, rootUrl: string): void;
  20207. }
  20208. }
  20209. declare module BABYLON {
  20210. /**
  20211. * Class representing spherical harmonics coefficients to the 3rd degree
  20212. */
  20213. export class SphericalHarmonics {
  20214. /**
  20215. * Defines whether or not the harmonics have been prescaled for rendering.
  20216. */
  20217. preScaled: boolean;
  20218. /**
  20219. * The l0,0 coefficients of the spherical harmonics
  20220. */
  20221. l00: Vector3;
  20222. /**
  20223. * The l1,-1 coefficients of the spherical harmonics
  20224. */
  20225. l1_1: Vector3;
  20226. /**
  20227. * The l1,0 coefficients of the spherical harmonics
  20228. */
  20229. l10: Vector3;
  20230. /**
  20231. * The l1,1 coefficients of the spherical harmonics
  20232. */
  20233. l11: Vector3;
  20234. /**
  20235. * The l2,-2 coefficients of the spherical harmonics
  20236. */
  20237. l2_2: Vector3;
  20238. /**
  20239. * The l2,-1 coefficients of the spherical harmonics
  20240. */
  20241. l2_1: Vector3;
  20242. /**
  20243. * The l2,0 coefficients of the spherical harmonics
  20244. */
  20245. l20: Vector3;
  20246. /**
  20247. * The l2,1 coefficients of the spherical harmonics
  20248. */
  20249. l21: Vector3;
  20250. /**
  20251. * The l2,2 coefficients of the spherical harmonics
  20252. */
  20253. l22: Vector3;
  20254. /**
  20255. * Adds a light to the spherical harmonics
  20256. * @param direction the direction of the light
  20257. * @param color the color of the light
  20258. * @param deltaSolidAngle the delta solid angle of the light
  20259. */
  20260. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20261. /**
  20262. * Scales the spherical harmonics by the given amount
  20263. * @param scale the amount to scale
  20264. */
  20265. scaleInPlace(scale: number): void;
  20266. /**
  20267. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20268. *
  20269. * ```
  20270. * E_lm = A_l * L_lm
  20271. * ```
  20272. *
  20273. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20274. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20275. * the scaling factors are given in equation 9.
  20276. */
  20277. convertIncidentRadianceToIrradiance(): void;
  20278. /**
  20279. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20280. *
  20281. * ```
  20282. * L = (1/pi) * E * rho
  20283. * ```
  20284. *
  20285. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  20286. */
  20287. convertIrradianceToLambertianRadiance(): void;
  20288. /**
  20289. * Integrates the reconstruction coefficients directly in to the SH preventing further
  20290. * required operations at run time.
  20291. *
  20292. * This is simply done by scaling back the SH with Ylm constants parameter.
  20293. * The trigonometric part being applied by the shader at run time.
  20294. */
  20295. preScaleForRendering(): void;
  20296. /**
  20297. * Constructs a spherical harmonics from an array.
  20298. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  20299. * @returns the spherical harmonics
  20300. */
  20301. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  20302. /**
  20303. * Gets the spherical harmonics from polynomial
  20304. * @param polynomial the spherical polynomial
  20305. * @returns the spherical harmonics
  20306. */
  20307. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  20308. }
  20309. /**
  20310. * Class representing spherical polynomial coefficients to the 3rd degree
  20311. */
  20312. export class SphericalPolynomial {
  20313. private _harmonics;
  20314. /**
  20315. * The spherical harmonics used to create the polynomials.
  20316. */
  20317. get preScaledHarmonics(): SphericalHarmonics;
  20318. /**
  20319. * The x coefficients of the spherical polynomial
  20320. */
  20321. x: Vector3;
  20322. /**
  20323. * The y coefficients of the spherical polynomial
  20324. */
  20325. y: Vector3;
  20326. /**
  20327. * The z coefficients of the spherical polynomial
  20328. */
  20329. z: Vector3;
  20330. /**
  20331. * The xx coefficients of the spherical polynomial
  20332. */
  20333. xx: Vector3;
  20334. /**
  20335. * The yy coefficients of the spherical polynomial
  20336. */
  20337. yy: Vector3;
  20338. /**
  20339. * The zz coefficients of the spherical polynomial
  20340. */
  20341. zz: Vector3;
  20342. /**
  20343. * The xy coefficients of the spherical polynomial
  20344. */
  20345. xy: Vector3;
  20346. /**
  20347. * The yz coefficients of the spherical polynomial
  20348. */
  20349. yz: Vector3;
  20350. /**
  20351. * The zx coefficients of the spherical polynomial
  20352. */
  20353. zx: Vector3;
  20354. /**
  20355. * Adds an ambient color to the spherical polynomial
  20356. * @param color the color to add
  20357. */
  20358. addAmbient(color: Color3): void;
  20359. /**
  20360. * Scales the spherical polynomial by the given amount
  20361. * @param scale the amount to scale
  20362. */
  20363. scaleInPlace(scale: number): void;
  20364. /**
  20365. * Gets the spherical polynomial from harmonics
  20366. * @param harmonics the spherical harmonics
  20367. * @returns the spherical polynomial
  20368. */
  20369. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  20370. /**
  20371. * Constructs a spherical polynomial from an array.
  20372. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  20373. * @returns the spherical polynomial
  20374. */
  20375. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  20376. }
  20377. }
  20378. declare module BABYLON {
  20379. /**
  20380. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  20381. */
  20382. export interface CubeMapInfo {
  20383. /**
  20384. * The pixel array for the front face.
  20385. * This is stored in format, left to right, up to down format.
  20386. */
  20387. front: Nullable<ArrayBufferView>;
  20388. /**
  20389. * The pixel array for the back face.
  20390. * This is stored in format, left to right, up to down format.
  20391. */
  20392. back: Nullable<ArrayBufferView>;
  20393. /**
  20394. * The pixel array for the left face.
  20395. * This is stored in format, left to right, up to down format.
  20396. */
  20397. left: Nullable<ArrayBufferView>;
  20398. /**
  20399. * The pixel array for the right face.
  20400. * This is stored in format, left to right, up to down format.
  20401. */
  20402. right: Nullable<ArrayBufferView>;
  20403. /**
  20404. * The pixel array for the up face.
  20405. * This is stored in format, left to right, up to down format.
  20406. */
  20407. up: Nullable<ArrayBufferView>;
  20408. /**
  20409. * The pixel array for the down face.
  20410. * This is stored in format, left to right, up to down format.
  20411. */
  20412. down: Nullable<ArrayBufferView>;
  20413. /**
  20414. * The size of the cubemap stored.
  20415. *
  20416. * Each faces will be size * size pixels.
  20417. */
  20418. size: number;
  20419. /**
  20420. * The format of the texture.
  20421. *
  20422. * RGBA, RGB.
  20423. */
  20424. format: number;
  20425. /**
  20426. * The type of the texture data.
  20427. *
  20428. * UNSIGNED_INT, FLOAT.
  20429. */
  20430. type: number;
  20431. /**
  20432. * Specifies whether the texture is in gamma space.
  20433. */
  20434. gammaSpace: boolean;
  20435. }
  20436. /**
  20437. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  20438. */
  20439. export class PanoramaToCubeMapTools {
  20440. private static FACE_LEFT;
  20441. private static FACE_RIGHT;
  20442. private static FACE_FRONT;
  20443. private static FACE_BACK;
  20444. private static FACE_DOWN;
  20445. private static FACE_UP;
  20446. /**
  20447. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  20448. *
  20449. * @param float32Array The source data.
  20450. * @param inputWidth The width of the input panorama.
  20451. * @param inputHeight The height of the input panorama.
  20452. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  20453. * @return The cubemap data
  20454. */
  20455. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  20456. private static CreateCubemapTexture;
  20457. private static CalcProjectionSpherical;
  20458. }
  20459. }
  20460. declare module BABYLON {
  20461. /**
  20462. * Helper class dealing with the extraction of spherical polynomial dataArray
  20463. * from a cube map.
  20464. */
  20465. export class CubeMapToSphericalPolynomialTools {
  20466. private static FileFaces;
  20467. /**
  20468. * Converts a texture to the according Spherical Polynomial data.
  20469. * This extracts the first 3 orders only as they are the only one used in the lighting.
  20470. *
  20471. * @param texture The texture to extract the information from.
  20472. * @return The Spherical Polynomial data.
  20473. */
  20474. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  20475. /**
  20476. * Converts a cubemap to the according Spherical Polynomial data.
  20477. * This extracts the first 3 orders only as they are the only one used in the lighting.
  20478. *
  20479. * @param cubeInfo The Cube map to extract the information from.
  20480. * @return The Spherical Polynomial data.
  20481. */
  20482. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  20483. }
  20484. }
  20485. declare module BABYLON {
  20486. interface BaseTexture {
  20487. /**
  20488. * Get the polynomial representation of the texture data.
  20489. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  20490. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  20491. */
  20492. sphericalPolynomial: Nullable<SphericalPolynomial>;
  20493. }
  20494. }
  20495. declare module BABYLON {
  20496. /** @hidden */
  20497. export var pbrFragmentDeclaration: {
  20498. name: string;
  20499. shader: string;
  20500. };
  20501. }
  20502. declare module BABYLON {
  20503. /** @hidden */
  20504. export var pbrUboDeclaration: {
  20505. name: string;
  20506. shader: string;
  20507. };
  20508. }
  20509. declare module BABYLON {
  20510. /** @hidden */
  20511. export var pbrFragmentExtraDeclaration: {
  20512. name: string;
  20513. shader: string;
  20514. };
  20515. }
  20516. declare module BABYLON {
  20517. /** @hidden */
  20518. export var pbrFragmentSamplersDeclaration: {
  20519. name: string;
  20520. shader: string;
  20521. };
  20522. }
  20523. declare module BABYLON {
  20524. /** @hidden */
  20525. export var subSurfaceScatteringFunctions: {
  20526. name: string;
  20527. shader: string;
  20528. };
  20529. }
  20530. declare module BABYLON {
  20531. /** @hidden */
  20532. export var importanceSampling: {
  20533. name: string;
  20534. shader: string;
  20535. };
  20536. }
  20537. declare module BABYLON {
  20538. /** @hidden */
  20539. export var pbrHelperFunctions: {
  20540. name: string;
  20541. shader: string;
  20542. };
  20543. }
  20544. declare module BABYLON {
  20545. /** @hidden */
  20546. export var harmonicsFunctions: {
  20547. name: string;
  20548. shader: string;
  20549. };
  20550. }
  20551. declare module BABYLON {
  20552. /** @hidden */
  20553. export var pbrDirectLightingSetupFunctions: {
  20554. name: string;
  20555. shader: string;
  20556. };
  20557. }
  20558. declare module BABYLON {
  20559. /** @hidden */
  20560. export var pbrDirectLightingFalloffFunctions: {
  20561. name: string;
  20562. shader: string;
  20563. };
  20564. }
  20565. declare module BABYLON {
  20566. /** @hidden */
  20567. export var pbrBRDFFunctions: {
  20568. name: string;
  20569. shader: string;
  20570. };
  20571. }
  20572. declare module BABYLON {
  20573. /** @hidden */
  20574. export var hdrFilteringFunctions: {
  20575. name: string;
  20576. shader: string;
  20577. };
  20578. }
  20579. declare module BABYLON {
  20580. /** @hidden */
  20581. export var pbrDirectLightingFunctions: {
  20582. name: string;
  20583. shader: string;
  20584. };
  20585. }
  20586. declare module BABYLON {
  20587. /** @hidden */
  20588. export var pbrIBLFunctions: {
  20589. name: string;
  20590. shader: string;
  20591. };
  20592. }
  20593. declare module BABYLON {
  20594. /** @hidden */
  20595. export var pbrBlockAlbedoOpacity: {
  20596. name: string;
  20597. shader: string;
  20598. };
  20599. }
  20600. declare module BABYLON {
  20601. /** @hidden */
  20602. export var pbrBlockReflectivity: {
  20603. name: string;
  20604. shader: string;
  20605. };
  20606. }
  20607. declare module BABYLON {
  20608. /** @hidden */
  20609. export var pbrBlockAmbientOcclusion: {
  20610. name: string;
  20611. shader: string;
  20612. };
  20613. }
  20614. declare module BABYLON {
  20615. /** @hidden */
  20616. export var pbrBlockAlphaFresnel: {
  20617. name: string;
  20618. shader: string;
  20619. };
  20620. }
  20621. declare module BABYLON {
  20622. /** @hidden */
  20623. export var pbrBlockAnisotropic: {
  20624. name: string;
  20625. shader: string;
  20626. };
  20627. }
  20628. declare module BABYLON {
  20629. /** @hidden */
  20630. export var pbrBlockReflection: {
  20631. name: string;
  20632. shader: string;
  20633. };
  20634. }
  20635. declare module BABYLON {
  20636. /** @hidden */
  20637. export var pbrBlockSheen: {
  20638. name: string;
  20639. shader: string;
  20640. };
  20641. }
  20642. declare module BABYLON {
  20643. /** @hidden */
  20644. export var pbrBlockClearcoat: {
  20645. name: string;
  20646. shader: string;
  20647. };
  20648. }
  20649. declare module BABYLON {
  20650. /** @hidden */
  20651. export var pbrBlockSubSurface: {
  20652. name: string;
  20653. shader: string;
  20654. };
  20655. }
  20656. declare module BABYLON {
  20657. /** @hidden */
  20658. export var pbrBlockNormalGeometric: {
  20659. name: string;
  20660. shader: string;
  20661. };
  20662. }
  20663. declare module BABYLON {
  20664. /** @hidden */
  20665. export var pbrBlockNormalFinal: {
  20666. name: string;
  20667. shader: string;
  20668. };
  20669. }
  20670. declare module BABYLON {
  20671. /** @hidden */
  20672. export var pbrBlockLightmapInit: {
  20673. name: string;
  20674. shader: string;
  20675. };
  20676. }
  20677. declare module BABYLON {
  20678. /** @hidden */
  20679. export var pbrBlockGeometryInfo: {
  20680. name: string;
  20681. shader: string;
  20682. };
  20683. }
  20684. declare module BABYLON {
  20685. /** @hidden */
  20686. export var pbrBlockReflectance0: {
  20687. name: string;
  20688. shader: string;
  20689. };
  20690. }
  20691. declare module BABYLON {
  20692. /** @hidden */
  20693. export var pbrBlockReflectance: {
  20694. name: string;
  20695. shader: string;
  20696. };
  20697. }
  20698. declare module BABYLON {
  20699. /** @hidden */
  20700. export var pbrBlockDirectLighting: {
  20701. name: string;
  20702. shader: string;
  20703. };
  20704. }
  20705. declare module BABYLON {
  20706. /** @hidden */
  20707. export var pbrBlockFinalLitComponents: {
  20708. name: string;
  20709. shader: string;
  20710. };
  20711. }
  20712. declare module BABYLON {
  20713. /** @hidden */
  20714. export var pbrBlockFinalUnlitComponents: {
  20715. name: string;
  20716. shader: string;
  20717. };
  20718. }
  20719. declare module BABYLON {
  20720. /** @hidden */
  20721. export var pbrBlockFinalColorComposition: {
  20722. name: string;
  20723. shader: string;
  20724. };
  20725. }
  20726. declare module BABYLON {
  20727. /** @hidden */
  20728. export var pbrBlockImageProcessing: {
  20729. name: string;
  20730. shader: string;
  20731. };
  20732. }
  20733. declare module BABYLON {
  20734. /** @hidden */
  20735. export var pbrDebug: {
  20736. name: string;
  20737. shader: string;
  20738. };
  20739. }
  20740. declare module BABYLON {
  20741. /** @hidden */
  20742. export var pbrPixelShader: {
  20743. name: string;
  20744. shader: string;
  20745. };
  20746. }
  20747. declare module BABYLON {
  20748. /** @hidden */
  20749. export var pbrVertexDeclaration: {
  20750. name: string;
  20751. shader: string;
  20752. };
  20753. }
  20754. declare module BABYLON {
  20755. /** @hidden */
  20756. export var pbrVertexShader: {
  20757. name: string;
  20758. shader: string;
  20759. };
  20760. }
  20761. declare module BABYLON {
  20762. /**
  20763. * Manages the defines for the PBR Material.
  20764. * @hidden
  20765. */
  20766. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  20767. PBR: boolean;
  20768. NUM_SAMPLES: string;
  20769. REALTIME_FILTERING: boolean;
  20770. MAINUV1: boolean;
  20771. MAINUV2: boolean;
  20772. UV1: boolean;
  20773. UV2: boolean;
  20774. ALBEDO: boolean;
  20775. GAMMAALBEDO: boolean;
  20776. ALBEDODIRECTUV: number;
  20777. VERTEXCOLOR: boolean;
  20778. DETAIL: boolean;
  20779. DETAILDIRECTUV: number;
  20780. DETAIL_NORMALBLENDMETHOD: number;
  20781. AMBIENT: boolean;
  20782. AMBIENTDIRECTUV: number;
  20783. AMBIENTINGRAYSCALE: boolean;
  20784. OPACITY: boolean;
  20785. VERTEXALPHA: boolean;
  20786. OPACITYDIRECTUV: number;
  20787. OPACITYRGB: boolean;
  20788. ALPHATEST: boolean;
  20789. DEPTHPREPASS: boolean;
  20790. ALPHABLEND: boolean;
  20791. ALPHAFROMALBEDO: boolean;
  20792. ALPHATESTVALUE: string;
  20793. SPECULAROVERALPHA: boolean;
  20794. RADIANCEOVERALPHA: boolean;
  20795. ALPHAFRESNEL: boolean;
  20796. LINEARALPHAFRESNEL: boolean;
  20797. PREMULTIPLYALPHA: boolean;
  20798. EMISSIVE: boolean;
  20799. EMISSIVEDIRECTUV: number;
  20800. REFLECTIVITY: boolean;
  20801. REFLECTIVITYDIRECTUV: number;
  20802. SPECULARTERM: boolean;
  20803. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  20804. MICROSURFACEAUTOMATIC: boolean;
  20805. LODBASEDMICROSFURACE: boolean;
  20806. MICROSURFACEMAP: boolean;
  20807. MICROSURFACEMAPDIRECTUV: number;
  20808. METALLICWORKFLOW: boolean;
  20809. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  20810. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  20811. METALLNESSSTOREINMETALMAPBLUE: boolean;
  20812. AOSTOREINMETALMAPRED: boolean;
  20813. METALLIC_REFLECTANCE: boolean;
  20814. METALLIC_REFLECTANCEDIRECTUV: number;
  20815. ENVIRONMENTBRDF: boolean;
  20816. ENVIRONMENTBRDF_RGBD: boolean;
  20817. NORMAL: boolean;
  20818. TANGENT: boolean;
  20819. BUMP: boolean;
  20820. BUMPDIRECTUV: number;
  20821. OBJECTSPACE_NORMALMAP: boolean;
  20822. PARALLAX: boolean;
  20823. PARALLAXOCCLUSION: boolean;
  20824. NORMALXYSCALE: boolean;
  20825. LIGHTMAP: boolean;
  20826. LIGHTMAPDIRECTUV: number;
  20827. USELIGHTMAPASSHADOWMAP: boolean;
  20828. GAMMALIGHTMAP: boolean;
  20829. RGBDLIGHTMAP: boolean;
  20830. REFLECTION: boolean;
  20831. REFLECTIONMAP_3D: boolean;
  20832. REFLECTIONMAP_SPHERICAL: boolean;
  20833. REFLECTIONMAP_PLANAR: boolean;
  20834. REFLECTIONMAP_CUBIC: boolean;
  20835. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  20836. REFLECTIONMAP_PROJECTION: boolean;
  20837. REFLECTIONMAP_SKYBOX: boolean;
  20838. REFLECTIONMAP_EXPLICIT: boolean;
  20839. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  20840. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  20841. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  20842. INVERTCUBICMAP: boolean;
  20843. USESPHERICALFROMREFLECTIONMAP: boolean;
  20844. USEIRRADIANCEMAP: boolean;
  20845. SPHERICAL_HARMONICS: boolean;
  20846. USESPHERICALINVERTEX: boolean;
  20847. REFLECTIONMAP_OPPOSITEZ: boolean;
  20848. LODINREFLECTIONALPHA: boolean;
  20849. GAMMAREFLECTION: boolean;
  20850. RGBDREFLECTION: boolean;
  20851. LINEARSPECULARREFLECTION: boolean;
  20852. RADIANCEOCCLUSION: boolean;
  20853. HORIZONOCCLUSION: boolean;
  20854. INSTANCES: boolean;
  20855. THIN_INSTANCES: boolean;
  20856. PREPASS: boolean;
  20857. PREPASS_IRRADIANCE: boolean;
  20858. PREPASS_IRRADIANCE_INDEX: number;
  20859. PREPASS_ALBEDO: boolean;
  20860. PREPASS_ALBEDO_INDEX: number;
  20861. PREPASS_DEPTHNORMAL: boolean;
  20862. PREPASS_DEPTHNORMAL_INDEX: number;
  20863. PREPASS_POSITION: boolean;
  20864. PREPASS_POSITION_INDEX: number;
  20865. PREPASS_VELOCITY: boolean;
  20866. PREPASS_VELOCITY_INDEX: number;
  20867. PREPASS_REFLECTIVITY: boolean;
  20868. PREPASS_REFLECTIVITY_INDEX: number;
  20869. SCENE_MRT_COUNT: number;
  20870. NUM_BONE_INFLUENCERS: number;
  20871. BonesPerMesh: number;
  20872. BONETEXTURE: boolean;
  20873. BONES_VELOCITY_ENABLED: boolean;
  20874. NONUNIFORMSCALING: boolean;
  20875. MORPHTARGETS: boolean;
  20876. MORPHTARGETS_NORMAL: boolean;
  20877. MORPHTARGETS_TANGENT: boolean;
  20878. MORPHTARGETS_UV: boolean;
  20879. NUM_MORPH_INFLUENCERS: number;
  20880. IMAGEPROCESSING: boolean;
  20881. VIGNETTE: boolean;
  20882. VIGNETTEBLENDMODEMULTIPLY: boolean;
  20883. VIGNETTEBLENDMODEOPAQUE: boolean;
  20884. TONEMAPPING: boolean;
  20885. TONEMAPPING_ACES: boolean;
  20886. CONTRAST: boolean;
  20887. COLORCURVES: boolean;
  20888. COLORGRADING: boolean;
  20889. COLORGRADING3D: boolean;
  20890. SAMPLER3DGREENDEPTH: boolean;
  20891. SAMPLER3DBGRMAP: boolean;
  20892. IMAGEPROCESSINGPOSTPROCESS: boolean;
  20893. EXPOSURE: boolean;
  20894. MULTIVIEW: boolean;
  20895. USEPHYSICALLIGHTFALLOFF: boolean;
  20896. USEGLTFLIGHTFALLOFF: boolean;
  20897. TWOSIDEDLIGHTING: boolean;
  20898. SHADOWFLOAT: boolean;
  20899. CLIPPLANE: boolean;
  20900. CLIPPLANE2: boolean;
  20901. CLIPPLANE3: boolean;
  20902. CLIPPLANE4: boolean;
  20903. CLIPPLANE5: boolean;
  20904. CLIPPLANE6: boolean;
  20905. POINTSIZE: boolean;
  20906. FOG: boolean;
  20907. LOGARITHMICDEPTH: boolean;
  20908. FORCENORMALFORWARD: boolean;
  20909. SPECULARAA: boolean;
  20910. CLEARCOAT: boolean;
  20911. CLEARCOAT_DEFAULTIOR: boolean;
  20912. CLEARCOAT_TEXTURE: boolean;
  20913. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20914. CLEARCOAT_TEXTUREDIRECTUV: number;
  20915. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20916. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20917. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20918. CLEARCOAT_BUMP: boolean;
  20919. CLEARCOAT_BUMPDIRECTUV: number;
  20920. CLEARCOAT_REMAP_F0: boolean;
  20921. CLEARCOAT_TINT: boolean;
  20922. CLEARCOAT_TINT_TEXTURE: boolean;
  20923. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20924. ANISOTROPIC: boolean;
  20925. ANISOTROPIC_TEXTURE: boolean;
  20926. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20927. BRDF_V_HEIGHT_CORRELATED: boolean;
  20928. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20929. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20930. SHEEN: boolean;
  20931. SHEEN_TEXTURE: boolean;
  20932. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20933. SHEEN_TEXTUREDIRECTUV: number;
  20934. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20935. SHEEN_LINKWITHALBEDO: boolean;
  20936. SHEEN_ROUGHNESS: boolean;
  20937. SHEEN_ALBEDOSCALING: boolean;
  20938. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20939. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20940. SUBSURFACE: boolean;
  20941. SS_REFRACTION: boolean;
  20942. SS_TRANSLUCENCY: boolean;
  20943. SS_SCATTERING: boolean;
  20944. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20945. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20946. SS_REFRACTIONMAP_3D: boolean;
  20947. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20948. SS_LODINREFRACTIONALPHA: boolean;
  20949. SS_GAMMAREFRACTION: boolean;
  20950. SS_RGBDREFRACTION: boolean;
  20951. SS_LINEARSPECULARREFRACTION: boolean;
  20952. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20953. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20954. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20955. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20956. UNLIT: boolean;
  20957. DEBUGMODE: number;
  20958. /**
  20959. * Initializes the PBR Material defines.
  20960. */
  20961. constructor();
  20962. /**
  20963. * Resets the PBR Material defines.
  20964. */
  20965. reset(): void;
  20966. }
  20967. /**
  20968. * The Physically based material base class of BJS.
  20969. *
  20970. * This offers the main features of a standard PBR material.
  20971. * For more information, please refer to the documentation :
  20972. * https://doc.babylonjs.com/how_to/physically_based_rendering
  20973. */
  20974. export abstract class PBRBaseMaterial extends PushMaterial {
  20975. /**
  20976. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  20977. */
  20978. static readonly PBRMATERIAL_OPAQUE: number;
  20979. /**
  20980. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  20981. */
  20982. static readonly PBRMATERIAL_ALPHATEST: number;
  20983. /**
  20984. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20985. */
  20986. static readonly PBRMATERIAL_ALPHABLEND: number;
  20987. /**
  20988. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20989. * They are also discarded below the alpha cutoff threshold to improve performances.
  20990. */
  20991. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  20992. /**
  20993. * Defines the default value of how much AO map is occluding the analytical lights
  20994. * (point spot...).
  20995. */
  20996. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  20997. /**
  20998. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  20999. */
  21000. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21001. /**
  21002. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21003. * to enhance interoperability with other engines.
  21004. */
  21005. static readonly LIGHTFALLOFF_GLTF: number;
  21006. /**
  21007. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21008. * to enhance interoperability with other materials.
  21009. */
  21010. static readonly LIGHTFALLOFF_STANDARD: number;
  21011. /**
  21012. * Intensity of the direct lights e.g. the four lights available in your scene.
  21013. * This impacts both the direct diffuse and specular highlights.
  21014. */
  21015. protected _directIntensity: number;
  21016. /**
  21017. * Intensity of the emissive part of the material.
  21018. * This helps controlling the emissive effect without modifying the emissive color.
  21019. */
  21020. protected _emissiveIntensity: number;
  21021. /**
  21022. * Intensity of the environment e.g. how much the environment will light the object
  21023. * either through harmonics for rough material or through the refelction for shiny ones.
  21024. */
  21025. protected _environmentIntensity: number;
  21026. /**
  21027. * This is a special control allowing the reduction of the specular highlights coming from the
  21028. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21029. */
  21030. protected _specularIntensity: number;
  21031. /**
  21032. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21033. */
  21034. private _lightingInfos;
  21035. /**
  21036. * Debug Control allowing disabling the bump map on this material.
  21037. */
  21038. protected _disableBumpMap: boolean;
  21039. /**
  21040. * AKA Diffuse Texture in standard nomenclature.
  21041. */
  21042. protected _albedoTexture: Nullable<BaseTexture>;
  21043. /**
  21044. * AKA Occlusion Texture in other nomenclature.
  21045. */
  21046. protected _ambientTexture: Nullable<BaseTexture>;
  21047. /**
  21048. * AKA Occlusion Texture Intensity in other nomenclature.
  21049. */
  21050. protected _ambientTextureStrength: number;
  21051. /**
  21052. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21053. * 1 means it completely occludes it
  21054. * 0 mean it has no impact
  21055. */
  21056. protected _ambientTextureImpactOnAnalyticalLights: number;
  21057. /**
  21058. * Stores the alpha values in a texture.
  21059. */
  21060. protected _opacityTexture: Nullable<BaseTexture>;
  21061. /**
  21062. * Stores the reflection values in a texture.
  21063. */
  21064. protected _reflectionTexture: Nullable<BaseTexture>;
  21065. /**
  21066. * Stores the emissive values in a texture.
  21067. */
  21068. protected _emissiveTexture: Nullable<BaseTexture>;
  21069. /**
  21070. * AKA Specular texture in other nomenclature.
  21071. */
  21072. protected _reflectivityTexture: Nullable<BaseTexture>;
  21073. /**
  21074. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21075. */
  21076. protected _metallicTexture: Nullable<BaseTexture>;
  21077. /**
  21078. * Specifies the metallic scalar of the metallic/roughness workflow.
  21079. * Can also be used to scale the metalness values of the metallic texture.
  21080. */
  21081. protected _metallic: Nullable<number>;
  21082. /**
  21083. * Specifies the roughness scalar of the metallic/roughness workflow.
  21084. * Can also be used to scale the roughness values of the metallic texture.
  21085. */
  21086. protected _roughness: Nullable<number>;
  21087. /**
  21088. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21089. * By default the indexOfrefraction is used to compute F0;
  21090. *
  21091. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21092. *
  21093. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21094. * F90 = metallicReflectanceColor;
  21095. */
  21096. protected _metallicF0Factor: number;
  21097. /**
  21098. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21099. * By default the F90 is always 1;
  21100. *
  21101. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21102. *
  21103. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21104. * F90 = metallicReflectanceColor;
  21105. */
  21106. protected _metallicReflectanceColor: Color3;
  21107. /**
  21108. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21109. * This is multiply against the scalar values defined in the material.
  21110. */
  21111. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21112. /**
  21113. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21114. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21115. */
  21116. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21117. /**
  21118. * Stores surface normal data used to displace a mesh in a texture.
  21119. */
  21120. protected _bumpTexture: Nullable<BaseTexture>;
  21121. /**
  21122. * Stores the pre-calculated light information of a mesh in a texture.
  21123. */
  21124. protected _lightmapTexture: Nullable<BaseTexture>;
  21125. /**
  21126. * The color of a material in ambient lighting.
  21127. */
  21128. protected _ambientColor: Color3;
  21129. /**
  21130. * AKA Diffuse Color in other nomenclature.
  21131. */
  21132. protected _albedoColor: Color3;
  21133. /**
  21134. * AKA Specular Color in other nomenclature.
  21135. */
  21136. protected _reflectivityColor: Color3;
  21137. /**
  21138. * The color applied when light is reflected from a material.
  21139. */
  21140. protected _reflectionColor: Color3;
  21141. /**
  21142. * The color applied when light is emitted from a material.
  21143. */
  21144. protected _emissiveColor: Color3;
  21145. /**
  21146. * AKA Glossiness in other nomenclature.
  21147. */
  21148. protected _microSurface: number;
  21149. /**
  21150. * Specifies that the material will use the light map as a show map.
  21151. */
  21152. protected _useLightmapAsShadowmap: boolean;
  21153. /**
  21154. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21155. * makes the reflect vector face the model (under horizon).
  21156. */
  21157. protected _useHorizonOcclusion: boolean;
  21158. /**
  21159. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21160. * too much the area relying on ambient texture to define their ambient occlusion.
  21161. */
  21162. protected _useRadianceOcclusion: boolean;
  21163. /**
  21164. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21165. */
  21166. protected _useAlphaFromAlbedoTexture: boolean;
  21167. /**
  21168. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21169. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21170. */
  21171. protected _useSpecularOverAlpha: boolean;
  21172. /**
  21173. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21174. */
  21175. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21176. /**
  21177. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21178. */
  21179. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21180. /**
  21181. * Specifies if the metallic texture contains the roughness information in its green channel.
  21182. */
  21183. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21184. /**
  21185. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21186. */
  21187. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21188. /**
  21189. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21190. */
  21191. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21192. /**
  21193. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21194. */
  21195. protected _useAmbientInGrayScale: boolean;
  21196. /**
  21197. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21198. * The material will try to infer what glossiness each pixel should be.
  21199. */
  21200. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21201. /**
  21202. * Defines the falloff type used in this material.
  21203. * It by default is Physical.
  21204. */
  21205. protected _lightFalloff: number;
  21206. /**
  21207. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21208. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21209. */
  21210. protected _useRadianceOverAlpha: boolean;
  21211. /**
  21212. * Allows using an object space normal map (instead of tangent space).
  21213. */
  21214. protected _useObjectSpaceNormalMap: boolean;
  21215. /**
  21216. * Allows using the bump map in parallax mode.
  21217. */
  21218. protected _useParallax: boolean;
  21219. /**
  21220. * Allows using the bump map in parallax occlusion mode.
  21221. */
  21222. protected _useParallaxOcclusion: boolean;
  21223. /**
  21224. * Controls the scale bias of the parallax mode.
  21225. */
  21226. protected _parallaxScaleBias: number;
  21227. /**
  21228. * If sets to true, disables all the lights affecting the material.
  21229. */
  21230. protected _disableLighting: boolean;
  21231. /**
  21232. * Number of Simultaneous lights allowed on the material.
  21233. */
  21234. protected _maxSimultaneousLights: number;
  21235. /**
  21236. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  21237. */
  21238. protected _invertNormalMapX: boolean;
  21239. /**
  21240. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  21241. */
  21242. protected _invertNormalMapY: boolean;
  21243. /**
  21244. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21245. */
  21246. protected _twoSidedLighting: boolean;
  21247. /**
  21248. * Defines the alpha limits in alpha test mode.
  21249. */
  21250. protected _alphaCutOff: number;
  21251. /**
  21252. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21253. */
  21254. protected _forceAlphaTest: boolean;
  21255. /**
  21256. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21257. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21258. */
  21259. protected _useAlphaFresnel: boolean;
  21260. /**
  21261. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21262. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21263. */
  21264. protected _useLinearAlphaFresnel: boolean;
  21265. /**
  21266. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  21267. * from cos thetav and roughness:
  21268. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  21269. */
  21270. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  21271. /**
  21272. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21273. */
  21274. protected _forceIrradianceInFragment: boolean;
  21275. private _realTimeFiltering;
  21276. /**
  21277. * Enables realtime filtering on the texture.
  21278. */
  21279. get realTimeFiltering(): boolean;
  21280. set realTimeFiltering(b: boolean);
  21281. private _realTimeFilteringQuality;
  21282. /**
  21283. * Quality switch for realtime filtering
  21284. */
  21285. get realTimeFilteringQuality(): number;
  21286. set realTimeFilteringQuality(n: number);
  21287. /**
  21288. * Can this material render to several textures at once
  21289. */
  21290. get canRenderToMRT(): boolean;
  21291. /**
  21292. * Force normal to face away from face.
  21293. */
  21294. protected _forceNormalForward: boolean;
  21295. /**
  21296. * Enables specular anti aliasing in the PBR shader.
  21297. * It will both interacts on the Geometry for analytical and IBL lighting.
  21298. * It also prefilter the roughness map based on the bump values.
  21299. */
  21300. protected _enableSpecularAntiAliasing: boolean;
  21301. /**
  21302. * Default configuration related to image processing available in the PBR Material.
  21303. */
  21304. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  21305. /**
  21306. * Keep track of the image processing observer to allow dispose and replace.
  21307. */
  21308. private _imageProcessingObserver;
  21309. /**
  21310. * Attaches a new image processing configuration to the PBR Material.
  21311. * @param configuration
  21312. */
  21313. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  21314. /**
  21315. * Stores the available render targets.
  21316. */
  21317. private _renderTargets;
  21318. /**
  21319. * Sets the global ambient color for the material used in lighting calculations.
  21320. */
  21321. private _globalAmbientColor;
  21322. /**
  21323. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  21324. */
  21325. private _useLogarithmicDepth;
  21326. /**
  21327. * If set to true, no lighting calculations will be applied.
  21328. */
  21329. private _unlit;
  21330. private _debugMode;
  21331. /**
  21332. * @hidden
  21333. * This is reserved for the inspector.
  21334. * Defines the material debug mode.
  21335. * It helps seeing only some components of the material while troubleshooting.
  21336. */
  21337. debugMode: number;
  21338. /**
  21339. * @hidden
  21340. * This is reserved for the inspector.
  21341. * Specify from where on screen the debug mode should start.
  21342. * The value goes from -1 (full screen) to 1 (not visible)
  21343. * It helps with side by side comparison against the final render
  21344. * This defaults to -1
  21345. */
  21346. private debugLimit;
  21347. /**
  21348. * @hidden
  21349. * This is reserved for the inspector.
  21350. * As the default viewing range might not be enough (if the ambient is really small for instance)
  21351. * You can use the factor to better multiply the final value.
  21352. */
  21353. private debugFactor;
  21354. /**
  21355. * Defines the clear coat layer parameters for the material.
  21356. */
  21357. readonly clearCoat: PBRClearCoatConfiguration;
  21358. /**
  21359. * Defines the anisotropic parameters for the material.
  21360. */
  21361. readonly anisotropy: PBRAnisotropicConfiguration;
  21362. /**
  21363. * Defines the BRDF parameters for the material.
  21364. */
  21365. readonly brdf: PBRBRDFConfiguration;
  21366. /**
  21367. * Defines the Sheen parameters for the material.
  21368. */
  21369. readonly sheen: PBRSheenConfiguration;
  21370. /**
  21371. * Defines the SubSurface parameters for the material.
  21372. */
  21373. readonly subSurface: PBRSubSurfaceConfiguration;
  21374. /**
  21375. * Defines additionnal PrePass parameters for the material.
  21376. */
  21377. readonly prePassConfiguration: PrePassConfiguration;
  21378. /**
  21379. * Defines the detail map parameters for the material.
  21380. */
  21381. readonly detailMap: DetailMapConfiguration;
  21382. protected _rebuildInParallel: boolean;
  21383. /**
  21384. * Instantiates a new PBRMaterial instance.
  21385. *
  21386. * @param name The material name
  21387. * @param scene The scene the material will be use in.
  21388. */
  21389. constructor(name: string, scene: Scene);
  21390. /**
  21391. * Gets a boolean indicating that current material needs to register RTT
  21392. */
  21393. get hasRenderTargetTextures(): boolean;
  21394. /**
  21395. * Gets the name of the material class.
  21396. */
  21397. getClassName(): string;
  21398. /**
  21399. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  21400. */
  21401. get useLogarithmicDepth(): boolean;
  21402. /**
  21403. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  21404. */
  21405. set useLogarithmicDepth(value: boolean);
  21406. /**
  21407. * Returns true if alpha blending should be disabled.
  21408. */
  21409. protected get _disableAlphaBlending(): boolean;
  21410. /**
  21411. * Specifies whether or not this material should be rendered in alpha blend mode.
  21412. */
  21413. needAlphaBlending(): boolean;
  21414. /**
  21415. * Specifies whether or not this material should be rendered in alpha test mode.
  21416. */
  21417. needAlphaTesting(): boolean;
  21418. /**
  21419. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  21420. */
  21421. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  21422. /**
  21423. * Specifies whether or not there is a usable alpha channel for transparency.
  21424. */
  21425. protected _hasAlphaChannel(): boolean;
  21426. /**
  21427. * Gets the texture used for the alpha test.
  21428. */
  21429. getAlphaTestTexture(): Nullable<BaseTexture>;
  21430. /**
  21431. * Specifies that the submesh is ready to be used.
  21432. * @param mesh - BJS mesh.
  21433. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  21434. * @param useInstances - Specifies that instances should be used.
  21435. * @returns - boolean indicating that the submesh is ready or not.
  21436. */
  21437. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  21438. /**
  21439. * Specifies if the material uses metallic roughness workflow.
  21440. * @returns boolean specifiying if the material uses metallic roughness workflow.
  21441. */
  21442. isMetallicWorkflow(): boolean;
  21443. private _prepareEffect;
  21444. private _prepareDefines;
  21445. /**
  21446. * Force shader compilation
  21447. */
  21448. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  21449. /**
  21450. * Initializes the uniform buffer layout for the shader.
  21451. */
  21452. buildUniformLayout(): void;
  21453. /**
  21454. * Unbinds the material from the mesh
  21455. */
  21456. unbind(): void;
  21457. /**
  21458. * Binds the submesh data.
  21459. * @param world - The world matrix.
  21460. * @param mesh - The BJS mesh.
  21461. * @param subMesh - A submesh of the BJS mesh.
  21462. */
  21463. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21464. /**
  21465. * Returns the animatable textures.
  21466. * @returns - Array of animatable textures.
  21467. */
  21468. getAnimatables(): IAnimatable[];
  21469. /**
  21470. * Returns the texture used for reflections.
  21471. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  21472. */
  21473. private _getReflectionTexture;
  21474. /**
  21475. * Returns an array of the actively used textures.
  21476. * @returns - Array of BaseTextures
  21477. */
  21478. getActiveTextures(): BaseTexture[];
  21479. /**
  21480. * Checks to see if a texture is used in the material.
  21481. * @param texture - Base texture to use.
  21482. * @returns - Boolean specifying if a texture is used in the material.
  21483. */
  21484. hasTexture(texture: BaseTexture): boolean;
  21485. /**
  21486. * Sets the required values to the prepass renderer.
  21487. * @param prePassRenderer defines the prepass renderer to setup
  21488. */
  21489. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  21490. /**
  21491. * Disposes the resources of the material.
  21492. * @param forceDisposeEffect - Forces the disposal of effects.
  21493. * @param forceDisposeTextures - Forces the disposal of all textures.
  21494. */
  21495. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  21496. }
  21497. }
  21498. declare module BABYLON {
  21499. /**
  21500. * The Physically based material of BJS.
  21501. *
  21502. * This offers the main features of a standard PBR material.
  21503. * For more information, please refer to the documentation :
  21504. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21505. */
  21506. export class PBRMaterial extends PBRBaseMaterial {
  21507. /**
  21508. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21509. */
  21510. static readonly PBRMATERIAL_OPAQUE: number;
  21511. /**
  21512. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21513. */
  21514. static readonly PBRMATERIAL_ALPHATEST: number;
  21515. /**
  21516. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21517. */
  21518. static readonly PBRMATERIAL_ALPHABLEND: number;
  21519. /**
  21520. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21521. * They are also discarded below the alpha cutoff threshold to improve performances.
  21522. */
  21523. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21524. /**
  21525. * Defines the default value of how much AO map is occluding the analytical lights
  21526. * (point spot...).
  21527. */
  21528. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21529. /**
  21530. * Intensity of the direct lights e.g. the four lights available in your scene.
  21531. * This impacts both the direct diffuse and specular highlights.
  21532. */
  21533. directIntensity: number;
  21534. /**
  21535. * Intensity of the emissive part of the material.
  21536. * This helps controlling the emissive effect without modifying the emissive color.
  21537. */
  21538. emissiveIntensity: number;
  21539. /**
  21540. * Intensity of the environment e.g. how much the environment will light the object
  21541. * either through harmonics for rough material or through the refelction for shiny ones.
  21542. */
  21543. environmentIntensity: number;
  21544. /**
  21545. * This is a special control allowing the reduction of the specular highlights coming from the
  21546. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21547. */
  21548. specularIntensity: number;
  21549. /**
  21550. * Debug Control allowing disabling the bump map on this material.
  21551. */
  21552. disableBumpMap: boolean;
  21553. /**
  21554. * AKA Diffuse Texture in standard nomenclature.
  21555. */
  21556. albedoTexture: BaseTexture;
  21557. /**
  21558. * AKA Occlusion Texture in other nomenclature.
  21559. */
  21560. ambientTexture: BaseTexture;
  21561. /**
  21562. * AKA Occlusion Texture Intensity in other nomenclature.
  21563. */
  21564. ambientTextureStrength: number;
  21565. /**
  21566. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21567. * 1 means it completely occludes it
  21568. * 0 mean it has no impact
  21569. */
  21570. ambientTextureImpactOnAnalyticalLights: number;
  21571. /**
  21572. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  21573. */
  21574. opacityTexture: BaseTexture;
  21575. /**
  21576. * Stores the reflection values in a texture.
  21577. */
  21578. reflectionTexture: Nullable<BaseTexture>;
  21579. /**
  21580. * Stores the emissive values in a texture.
  21581. */
  21582. emissiveTexture: BaseTexture;
  21583. /**
  21584. * AKA Specular texture in other nomenclature.
  21585. */
  21586. reflectivityTexture: BaseTexture;
  21587. /**
  21588. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21589. */
  21590. metallicTexture: BaseTexture;
  21591. /**
  21592. * Specifies the metallic scalar of the metallic/roughness workflow.
  21593. * Can also be used to scale the metalness values of the metallic texture.
  21594. */
  21595. metallic: Nullable<number>;
  21596. /**
  21597. * Specifies the roughness scalar of the metallic/roughness workflow.
  21598. * Can also be used to scale the roughness values of the metallic texture.
  21599. */
  21600. roughness: Nullable<number>;
  21601. /**
  21602. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21603. * By default the indexOfrefraction is used to compute F0;
  21604. *
  21605. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21606. *
  21607. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21608. * F90 = metallicReflectanceColor;
  21609. */
  21610. metallicF0Factor: number;
  21611. /**
  21612. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21613. * By default the F90 is always 1;
  21614. *
  21615. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21616. *
  21617. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21618. * F90 = metallicReflectanceColor;
  21619. */
  21620. metallicReflectanceColor: Color3;
  21621. /**
  21622. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21623. * This is multiply against the scalar values defined in the material.
  21624. */
  21625. metallicReflectanceTexture: Nullable<BaseTexture>;
  21626. /**
  21627. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21628. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21629. */
  21630. microSurfaceTexture: BaseTexture;
  21631. /**
  21632. * Stores surface normal data used to displace a mesh in a texture.
  21633. */
  21634. bumpTexture: BaseTexture;
  21635. /**
  21636. * Stores the pre-calculated light information of a mesh in a texture.
  21637. */
  21638. lightmapTexture: BaseTexture;
  21639. /**
  21640. * Stores the refracted light information in a texture.
  21641. */
  21642. get refractionTexture(): Nullable<BaseTexture>;
  21643. set refractionTexture(value: Nullable<BaseTexture>);
  21644. /**
  21645. * The color of a material in ambient lighting.
  21646. */
  21647. ambientColor: Color3;
  21648. /**
  21649. * AKA Diffuse Color in other nomenclature.
  21650. */
  21651. albedoColor: Color3;
  21652. /**
  21653. * AKA Specular Color in other nomenclature.
  21654. */
  21655. reflectivityColor: Color3;
  21656. /**
  21657. * The color reflected from the material.
  21658. */
  21659. reflectionColor: Color3;
  21660. /**
  21661. * The color emitted from the material.
  21662. */
  21663. emissiveColor: Color3;
  21664. /**
  21665. * AKA Glossiness in other nomenclature.
  21666. */
  21667. microSurface: number;
  21668. /**
  21669. * Index of refraction of the material base layer.
  21670. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21671. *
  21672. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  21673. *
  21674. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  21675. */
  21676. get indexOfRefraction(): number;
  21677. set indexOfRefraction(value: number);
  21678. /**
  21679. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21680. */
  21681. get invertRefractionY(): boolean;
  21682. set invertRefractionY(value: boolean);
  21683. /**
  21684. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21685. * Materials half opaque for instance using refraction could benefit from this control.
  21686. */
  21687. get linkRefractionWithTransparency(): boolean;
  21688. set linkRefractionWithTransparency(value: boolean);
  21689. /**
  21690. * If true, the light map contains occlusion information instead of lighting info.
  21691. */
  21692. useLightmapAsShadowmap: boolean;
  21693. /**
  21694. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21695. */
  21696. useAlphaFromAlbedoTexture: boolean;
  21697. /**
  21698. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21699. */
  21700. forceAlphaTest: boolean;
  21701. /**
  21702. * Defines the alpha limits in alpha test mode.
  21703. */
  21704. alphaCutOff: number;
  21705. /**
  21706. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  21707. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21708. */
  21709. useSpecularOverAlpha: boolean;
  21710. /**
  21711. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21712. */
  21713. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21714. /**
  21715. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21716. */
  21717. useRoughnessFromMetallicTextureAlpha: boolean;
  21718. /**
  21719. * Specifies if the metallic texture contains the roughness information in its green channel.
  21720. */
  21721. useRoughnessFromMetallicTextureGreen: boolean;
  21722. /**
  21723. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21724. */
  21725. useMetallnessFromMetallicTextureBlue: boolean;
  21726. /**
  21727. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21728. */
  21729. useAmbientOcclusionFromMetallicTextureRed: boolean;
  21730. /**
  21731. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21732. */
  21733. useAmbientInGrayScale: boolean;
  21734. /**
  21735. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21736. * The material will try to infer what glossiness each pixel should be.
  21737. */
  21738. useAutoMicroSurfaceFromReflectivityMap: boolean;
  21739. /**
  21740. * BJS is using an harcoded light falloff based on a manually sets up range.
  21741. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  21742. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  21743. */
  21744. get usePhysicalLightFalloff(): boolean;
  21745. /**
  21746. * BJS is using an harcoded light falloff based on a manually sets up range.
  21747. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  21748. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  21749. */
  21750. set usePhysicalLightFalloff(value: boolean);
  21751. /**
  21752. * In order to support the falloff compatibility with gltf, a special mode has been added
  21753. * to reproduce the gltf light falloff.
  21754. */
  21755. get useGLTFLightFalloff(): boolean;
  21756. /**
  21757. * In order to support the falloff compatibility with gltf, a special mode has been added
  21758. * to reproduce the gltf light falloff.
  21759. */
  21760. set useGLTFLightFalloff(value: boolean);
  21761. /**
  21762. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21763. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21764. */
  21765. useRadianceOverAlpha: boolean;
  21766. /**
  21767. * Allows using an object space normal map (instead of tangent space).
  21768. */
  21769. useObjectSpaceNormalMap: boolean;
  21770. /**
  21771. * Allows using the bump map in parallax mode.
  21772. */
  21773. useParallax: boolean;
  21774. /**
  21775. * Allows using the bump map in parallax occlusion mode.
  21776. */
  21777. useParallaxOcclusion: boolean;
  21778. /**
  21779. * Controls the scale bias of the parallax mode.
  21780. */
  21781. parallaxScaleBias: number;
  21782. /**
  21783. * If sets to true, disables all the lights affecting the material.
  21784. */
  21785. disableLighting: boolean;
  21786. /**
  21787. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21788. */
  21789. forceIrradianceInFragment: boolean;
  21790. /**
  21791. * Number of Simultaneous lights allowed on the material.
  21792. */
  21793. maxSimultaneousLights: number;
  21794. /**
  21795. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  21796. */
  21797. invertNormalMapX: boolean;
  21798. /**
  21799. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  21800. */
  21801. invertNormalMapY: boolean;
  21802. /**
  21803. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21804. */
  21805. twoSidedLighting: boolean;
  21806. /**
  21807. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21808. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21809. */
  21810. useAlphaFresnel: boolean;
  21811. /**
  21812. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21813. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21814. */
  21815. useLinearAlphaFresnel: boolean;
  21816. /**
  21817. * Let user defines the brdf lookup texture used for IBL.
  21818. * A default 8bit version is embedded but you could point at :
  21819. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  21820. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  21821. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  21822. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  21823. */
  21824. environmentBRDFTexture: Nullable<BaseTexture>;
  21825. /**
  21826. * Force normal to face away from face.
  21827. */
  21828. forceNormalForward: boolean;
  21829. /**
  21830. * Enables specular anti aliasing in the PBR shader.
  21831. * It will both interacts on the Geometry for analytical and IBL lighting.
  21832. * It also prefilter the roughness map based on the bump values.
  21833. */
  21834. enableSpecularAntiAliasing: boolean;
  21835. /**
  21836. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21837. * makes the reflect vector face the model (under horizon).
  21838. */
  21839. useHorizonOcclusion: boolean;
  21840. /**
  21841. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21842. * too much the area relying on ambient texture to define their ambient occlusion.
  21843. */
  21844. useRadianceOcclusion: boolean;
  21845. /**
  21846. * If set to true, no lighting calculations will be applied.
  21847. */
  21848. unlit: boolean;
  21849. /**
  21850. * Gets the image processing configuration used either in this material.
  21851. */
  21852. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  21853. /**
  21854. * Sets the Default image processing configuration used either in the this material.
  21855. *
  21856. * If sets to null, the scene one is in use.
  21857. */
  21858. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  21859. /**
  21860. * Gets wether the color curves effect is enabled.
  21861. */
  21862. get cameraColorCurvesEnabled(): boolean;
  21863. /**
  21864. * Sets wether the color curves effect is enabled.
  21865. */
  21866. set cameraColorCurvesEnabled(value: boolean);
  21867. /**
  21868. * Gets wether the color grading effect is enabled.
  21869. */
  21870. get cameraColorGradingEnabled(): boolean;
  21871. /**
  21872. * Gets wether the color grading effect is enabled.
  21873. */
  21874. set cameraColorGradingEnabled(value: boolean);
  21875. /**
  21876. * Gets wether tonemapping is enabled or not.
  21877. */
  21878. get cameraToneMappingEnabled(): boolean;
  21879. /**
  21880. * Sets wether tonemapping is enabled or not
  21881. */
  21882. set cameraToneMappingEnabled(value: boolean);
  21883. /**
  21884. * The camera exposure used on this material.
  21885. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21886. * This corresponds to a photographic exposure.
  21887. */
  21888. get cameraExposure(): number;
  21889. /**
  21890. * The camera exposure used on this material.
  21891. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21892. * This corresponds to a photographic exposure.
  21893. */
  21894. set cameraExposure(value: number);
  21895. /**
  21896. * Gets The camera contrast used on this material.
  21897. */
  21898. get cameraContrast(): number;
  21899. /**
  21900. * Sets The camera contrast used on this material.
  21901. */
  21902. set cameraContrast(value: number);
  21903. /**
  21904. * Gets the Color Grading 2D Lookup Texture.
  21905. */
  21906. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  21907. /**
  21908. * Sets the Color Grading 2D Lookup Texture.
  21909. */
  21910. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  21911. /**
  21912. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21913. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21914. * 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;
  21915. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21916. */
  21917. get cameraColorCurves(): Nullable<ColorCurves>;
  21918. /**
  21919. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21920. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21921. * 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;
  21922. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21923. */
  21924. set cameraColorCurves(value: Nullable<ColorCurves>);
  21925. /**
  21926. * Instantiates a new PBRMaterial instance.
  21927. *
  21928. * @param name The material name
  21929. * @param scene The scene the material will be use in.
  21930. */
  21931. constructor(name: string, scene: Scene);
  21932. /**
  21933. * Returns the name of this material class.
  21934. */
  21935. getClassName(): string;
  21936. /**
  21937. * Makes a duplicate of the current material.
  21938. * @param name - name to use for the new material.
  21939. */
  21940. clone(name: string): PBRMaterial;
  21941. /**
  21942. * Serializes this PBR Material.
  21943. * @returns - An object with the serialized material.
  21944. */
  21945. serialize(): any;
  21946. /**
  21947. * Parses a PBR Material from a serialized object.
  21948. * @param source - Serialized object.
  21949. * @param scene - BJS scene instance.
  21950. * @param rootUrl - url for the scene object
  21951. * @returns - PBRMaterial
  21952. */
  21953. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  21954. }
  21955. }
  21956. declare module BABYLON {
  21957. /** @hidden */
  21958. export var mrtFragmentDeclaration: {
  21959. name: string;
  21960. shader: string;
  21961. };
  21962. }
  21963. declare module BABYLON {
  21964. /** @hidden */
  21965. export var geometryPixelShader: {
  21966. name: string;
  21967. shader: string;
  21968. };
  21969. }
  21970. declare module BABYLON {
  21971. /** @hidden */
  21972. export var geometryVertexShader: {
  21973. name: string;
  21974. shader: string;
  21975. };
  21976. }
  21977. declare module BABYLON {
  21978. /** @hidden */
  21979. interface ISavedTransformationMatrix {
  21980. world: Matrix;
  21981. viewProjection: Matrix;
  21982. }
  21983. /**
  21984. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  21985. */
  21986. export class GeometryBufferRenderer {
  21987. /**
  21988. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  21989. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  21990. */
  21991. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  21992. /**
  21993. * Constant used to retrieve the position texture index in the G-Buffer textures array
  21994. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  21995. */
  21996. static readonly POSITION_TEXTURE_TYPE: number;
  21997. /**
  21998. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  21999. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22000. */
  22001. static readonly VELOCITY_TEXTURE_TYPE: number;
  22002. /**
  22003. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22004. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22005. */
  22006. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22007. /**
  22008. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22009. * in order to compute objects velocities when enableVelocity is set to "true"
  22010. * @hidden
  22011. */
  22012. _previousTransformationMatrices: {
  22013. [index: number]: ISavedTransformationMatrix;
  22014. };
  22015. /**
  22016. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22017. * in order to compute objects velocities when enableVelocity is set to "true"
  22018. * @hidden
  22019. */
  22020. _previousBonesTransformationMatrices: {
  22021. [index: number]: Float32Array;
  22022. };
  22023. /**
  22024. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22025. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22026. */
  22027. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22028. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22029. renderTransparentMeshes: boolean;
  22030. private _scene;
  22031. private _resizeObserver;
  22032. private _multiRenderTarget;
  22033. private _ratio;
  22034. private _enablePosition;
  22035. private _enableVelocity;
  22036. private _enableReflectivity;
  22037. private _positionIndex;
  22038. private _velocityIndex;
  22039. private _reflectivityIndex;
  22040. private _depthNormalIndex;
  22041. private _linkedWithPrePass;
  22042. private _prePassRenderer;
  22043. private _attachments;
  22044. protected _effect: Effect;
  22045. protected _cachedDefines: string;
  22046. /**
  22047. * @hidden
  22048. * Sets up internal structures to share outputs with PrePassRenderer
  22049. * This method should only be called by the PrePassRenderer itself
  22050. */
  22051. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22052. /**
  22053. * @hidden
  22054. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22055. * This method should only be called by the PrePassRenderer itself
  22056. */
  22057. _unlinkPrePassRenderer(): void;
  22058. /**
  22059. * @hidden
  22060. * Resets the geometry buffer layout
  22061. */
  22062. _resetLayout(): void;
  22063. /**
  22064. * @hidden
  22065. * Replaces a texture in the geometry buffer renderer
  22066. * Useful when linking textures of the prepass renderer
  22067. */
  22068. _forceTextureType(geometryBufferType: number, index: number): void;
  22069. /**
  22070. * @hidden
  22071. * Sets texture attachments
  22072. * Useful when linking textures of the prepass renderer
  22073. */
  22074. _setAttachments(attachments: number[]): void;
  22075. /**
  22076. * @hidden
  22077. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22078. * Useful when linking textures of the prepass renderer
  22079. */
  22080. _linkInternalTexture(internalTexture: InternalTexture): void;
  22081. /**
  22082. * Gets the render list (meshes to be rendered) used in the G buffer.
  22083. */
  22084. get renderList(): Nullable<AbstractMesh[]>;
  22085. /**
  22086. * Set the render list (meshes to be rendered) used in the G buffer.
  22087. */
  22088. set renderList(meshes: Nullable<AbstractMesh[]>);
  22089. /**
  22090. * Gets wether or not G buffer are supported by the running hardware.
  22091. * This requires draw buffer supports
  22092. */
  22093. get isSupported(): boolean;
  22094. /**
  22095. * Returns the index of the given texture type in the G-Buffer textures array
  22096. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22097. * @returns the index of the given texture type in the G-Buffer textures array
  22098. */
  22099. getTextureIndex(textureType: number): number;
  22100. /**
  22101. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22102. */
  22103. get enablePosition(): boolean;
  22104. /**
  22105. * Sets whether or not objects positions are enabled for the G buffer.
  22106. */
  22107. set enablePosition(enable: boolean);
  22108. /**
  22109. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22110. */
  22111. get enableVelocity(): boolean;
  22112. /**
  22113. * Sets wether or not objects velocities are enabled for the G buffer.
  22114. */
  22115. set enableVelocity(enable: boolean);
  22116. /**
  22117. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22118. */
  22119. get enableReflectivity(): boolean;
  22120. /**
  22121. * Sets wether or not objects roughness are enabled for the G buffer.
  22122. */
  22123. set enableReflectivity(enable: boolean);
  22124. /**
  22125. * Gets the scene associated with the buffer.
  22126. */
  22127. get scene(): Scene;
  22128. /**
  22129. * Gets the ratio used by the buffer during its creation.
  22130. * How big is the buffer related to the main canvas.
  22131. */
  22132. get ratio(): number;
  22133. /** @hidden */
  22134. static _SceneComponentInitialization: (scene: Scene) => void;
  22135. /**
  22136. * Creates a new G Buffer for the scene
  22137. * @param scene The scene the buffer belongs to
  22138. * @param ratio How big is the buffer related to the main canvas.
  22139. */
  22140. constructor(scene: Scene, ratio?: number);
  22141. /**
  22142. * Checks wether everything is ready to render a submesh to the G buffer.
  22143. * @param subMesh the submesh to check readiness for
  22144. * @param useInstances is the mesh drawn using instance or not
  22145. * @returns true if ready otherwise false
  22146. */
  22147. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22148. /**
  22149. * Gets the current underlying G Buffer.
  22150. * @returns the buffer
  22151. */
  22152. getGBuffer(): MultiRenderTarget;
  22153. /**
  22154. * Gets the number of samples used to render the buffer (anti aliasing).
  22155. */
  22156. get samples(): number;
  22157. /**
  22158. * Sets the number of samples used to render the buffer (anti aliasing).
  22159. */
  22160. set samples(value: number);
  22161. /**
  22162. * Disposes the renderer and frees up associated resources.
  22163. */
  22164. dispose(): void;
  22165. private _assignRenderTargetIndices;
  22166. protected _createRenderTargets(): void;
  22167. private _copyBonesTransformationMatrices;
  22168. }
  22169. }
  22170. declare module BABYLON {
  22171. /**
  22172. * Renders a pre pass of the scene
  22173. * This means every mesh in the scene will be rendered to a render target texture
  22174. * And then this texture will be composited to the rendering canvas with post processes
  22175. * It is necessary for effects like subsurface scattering or deferred shading
  22176. */
  22177. export class PrePassRenderer {
  22178. /** @hidden */
  22179. static _SceneComponentInitialization: (scene: Scene) => void;
  22180. private _textureFormats;
  22181. /**
  22182. * To save performance, we can excluded skinned meshes from the prepass
  22183. */
  22184. excludedSkinnedMesh: AbstractMesh[];
  22185. /**
  22186. * Force material to be excluded from the prepass
  22187. * Can be useful when `useGeometryBufferFallback` is set to `true`
  22188. * and you don't want a material to show in the effect.
  22189. */
  22190. excludedMaterials: Material[];
  22191. private _textureIndices;
  22192. private _scene;
  22193. private _engine;
  22194. private _isDirty;
  22195. /**
  22196. * Number of textures in the multi render target texture where the scene is directly rendered
  22197. */
  22198. mrtCount: number;
  22199. /**
  22200. * The render target where the scene is directly rendered
  22201. */
  22202. prePassRT: MultiRenderTarget;
  22203. private _multiRenderAttachments;
  22204. private _defaultAttachments;
  22205. private _clearAttachments;
  22206. private _postProcesses;
  22207. private readonly _clearColor;
  22208. /**
  22209. * Image processing post process for composition
  22210. */
  22211. imageProcessingPostProcess: ImageProcessingPostProcess;
  22212. /**
  22213. * Configuration for prepass effects
  22214. */
  22215. private _effectConfigurations;
  22216. private _mrtFormats;
  22217. private _mrtLayout;
  22218. private _enabled;
  22219. /**
  22220. * Indicates if the prepass is enabled
  22221. */
  22222. get enabled(): boolean;
  22223. /**
  22224. * How many samples are used for MSAA of the scene render target
  22225. */
  22226. get samples(): number;
  22227. set samples(n: number);
  22228. private _geometryBuffer;
  22229. private _useGeometryBufferFallback;
  22230. /**
  22231. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  22232. */
  22233. get useGeometryBufferFallback(): boolean;
  22234. set useGeometryBufferFallback(value: boolean);
  22235. /**
  22236. * Instanciates a prepass renderer
  22237. * @param scene The scene
  22238. */
  22239. constructor(scene: Scene);
  22240. private _initializeAttachments;
  22241. private _createCompositionEffect;
  22242. /**
  22243. * Indicates if rendering a prepass is supported
  22244. */
  22245. get isSupported(): boolean;
  22246. /**
  22247. * Sets the proper output textures to draw in the engine.
  22248. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  22249. * @param subMesh Submesh on which the effect is applied
  22250. */
  22251. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  22252. /**
  22253. * @hidden
  22254. */
  22255. _beforeCameraDraw(): void;
  22256. /**
  22257. * @hidden
  22258. */
  22259. _afterCameraDraw(): void;
  22260. private _checkRTSize;
  22261. private _bindFrameBuffer;
  22262. /**
  22263. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  22264. */
  22265. clear(): void;
  22266. private _setState;
  22267. private _updateGeometryBufferLayout;
  22268. /**
  22269. * Adds an effect configuration to the prepass.
  22270. * If an effect has already been added, it won't add it twice and will return the configuration
  22271. * already present.
  22272. * @param cfg the effect configuration
  22273. * @return the effect configuration now used by the prepass
  22274. */
  22275. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  22276. /**
  22277. * Returns the index of a texture in the multi render target texture array.
  22278. * @param type Texture type
  22279. * @return The index
  22280. */
  22281. getIndex(type: number): number;
  22282. private _enable;
  22283. private _disable;
  22284. private _resetLayout;
  22285. private _resetPostProcessChain;
  22286. private _bindPostProcessChain;
  22287. /**
  22288. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  22289. */
  22290. markAsDirty(): void;
  22291. /**
  22292. * Enables a texture on the MultiRenderTarget for prepass
  22293. */
  22294. private _enableTextures;
  22295. private _update;
  22296. private _markAllMaterialsAsPrePassDirty;
  22297. /**
  22298. * Disposes the prepass renderer.
  22299. */
  22300. dispose(): void;
  22301. }
  22302. }
  22303. declare module BABYLON {
  22304. /**
  22305. * Size options for a post process
  22306. */
  22307. export type PostProcessOptions = {
  22308. width: number;
  22309. height: number;
  22310. };
  22311. /**
  22312. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22313. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22314. */
  22315. export class PostProcess {
  22316. /**
  22317. * Gets or sets the unique id of the post process
  22318. */
  22319. uniqueId: number;
  22320. /** Name of the PostProcess. */
  22321. name: string;
  22322. /**
  22323. * Width of the texture to apply the post process on
  22324. */
  22325. width: number;
  22326. /**
  22327. * Height of the texture to apply the post process on
  22328. */
  22329. height: number;
  22330. /**
  22331. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22332. */
  22333. nodeMaterialSource: Nullable<NodeMaterial>;
  22334. /**
  22335. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22336. * @hidden
  22337. */
  22338. _outputTexture: Nullable<InternalTexture>;
  22339. /**
  22340. * Sampling mode used by the shader
  22341. * See https://doc.babylonjs.com/classes/3.1/texture
  22342. */
  22343. renderTargetSamplingMode: number;
  22344. /**
  22345. * Clear color to use when screen clearing
  22346. */
  22347. clearColor: Color4;
  22348. /**
  22349. * If the buffer needs to be cleared before applying the post process. (default: true)
  22350. * Should be set to false if shader will overwrite all previous pixels.
  22351. */
  22352. autoClear: boolean;
  22353. /**
  22354. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22355. */
  22356. alphaMode: number;
  22357. /**
  22358. * Sets the setAlphaBlendConstants of the babylon engine
  22359. */
  22360. alphaConstants: Color4;
  22361. /**
  22362. * Animations to be used for the post processing
  22363. */
  22364. animations: Animation[];
  22365. /**
  22366. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22367. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22368. */
  22369. enablePixelPerfectMode: boolean;
  22370. /**
  22371. * Force the postprocess to be applied without taking in account viewport
  22372. */
  22373. forceFullscreenViewport: boolean;
  22374. /**
  22375. * List of inspectable custom properties (used by the Inspector)
  22376. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22377. */
  22378. inspectableCustomProperties: IInspectable[];
  22379. /**
  22380. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22381. *
  22382. * | Value | Type | Description |
  22383. * | ----- | ----------------------------------- | ----------- |
  22384. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22385. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22386. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22387. *
  22388. */
  22389. scaleMode: number;
  22390. /**
  22391. * Force textures to be a power of two (default: false)
  22392. */
  22393. alwaysForcePOT: boolean;
  22394. private _samples;
  22395. /**
  22396. * Number of sample textures (default: 1)
  22397. */
  22398. get samples(): number;
  22399. set samples(n: number);
  22400. /**
  22401. * Modify the scale of the post process to be the same as the viewport (default: false)
  22402. */
  22403. adaptScaleToCurrentViewport: boolean;
  22404. private _camera;
  22405. protected _scene: Scene;
  22406. private _engine;
  22407. private _options;
  22408. private _reusable;
  22409. private _textureType;
  22410. private _textureFormat;
  22411. /**
  22412. * Smart array of input and output textures for the post process.
  22413. * @hidden
  22414. */
  22415. _textures: SmartArray<InternalTexture>;
  22416. /**
  22417. * The index in _textures that corresponds to the output texture.
  22418. * @hidden
  22419. */
  22420. _currentRenderTextureInd: number;
  22421. private _effect;
  22422. private _samplers;
  22423. private _fragmentUrl;
  22424. private _vertexUrl;
  22425. private _parameters;
  22426. private _scaleRatio;
  22427. protected _indexParameters: any;
  22428. private _shareOutputWithPostProcess;
  22429. private _texelSize;
  22430. private _forcedOutputTexture;
  22431. /**
  22432. * Prepass configuration in case this post process needs a texture from prepass
  22433. * @hidden
  22434. */
  22435. _prePassEffectConfiguration: PrePassEffectConfiguration;
  22436. /**
  22437. * Returns the fragment url or shader name used in the post process.
  22438. * @returns the fragment url or name in the shader store.
  22439. */
  22440. getEffectName(): string;
  22441. /**
  22442. * An event triggered when the postprocess is activated.
  22443. */
  22444. onActivateObservable: Observable<Camera>;
  22445. private _onActivateObserver;
  22446. /**
  22447. * A function that is added to the onActivateObservable
  22448. */
  22449. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22450. /**
  22451. * An event triggered when the postprocess changes its size.
  22452. */
  22453. onSizeChangedObservable: Observable<PostProcess>;
  22454. private _onSizeChangedObserver;
  22455. /**
  22456. * A function that is added to the onSizeChangedObservable
  22457. */
  22458. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22459. /**
  22460. * An event triggered when the postprocess applies its effect.
  22461. */
  22462. onApplyObservable: Observable<Effect>;
  22463. private _onApplyObserver;
  22464. /**
  22465. * A function that is added to the onApplyObservable
  22466. */
  22467. set onApply(callback: (effect: Effect) => void);
  22468. /**
  22469. * An event triggered before rendering the postprocess
  22470. */
  22471. onBeforeRenderObservable: Observable<Effect>;
  22472. private _onBeforeRenderObserver;
  22473. /**
  22474. * A function that is added to the onBeforeRenderObservable
  22475. */
  22476. set onBeforeRender(callback: (effect: Effect) => void);
  22477. /**
  22478. * An event triggered after rendering the postprocess
  22479. */
  22480. onAfterRenderObservable: Observable<Effect>;
  22481. private _onAfterRenderObserver;
  22482. /**
  22483. * A function that is added to the onAfterRenderObservable
  22484. */
  22485. set onAfterRender(callback: (efect: Effect) => void);
  22486. /**
  22487. * 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
  22488. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22489. */
  22490. get inputTexture(): InternalTexture;
  22491. set inputTexture(value: InternalTexture);
  22492. /**
  22493. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22494. * the only way to unset it is to use this function to restore its internal state
  22495. */
  22496. restoreDefaultInputTexture(): void;
  22497. /**
  22498. * Gets the camera which post process is applied to.
  22499. * @returns The camera the post process is applied to.
  22500. */
  22501. getCamera(): Camera;
  22502. /**
  22503. * Gets the texel size of the postprocess.
  22504. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22505. */
  22506. get texelSize(): Vector2;
  22507. /**
  22508. * Creates a new instance PostProcess
  22509. * @param name The name of the PostProcess.
  22510. * @param fragmentUrl The url of the fragment shader to be used.
  22511. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22512. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22513. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22514. * @param camera The camera to apply the render pass to.
  22515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22516. * @param engine The engine which the post process will be applied. (default: current engine)
  22517. * @param reusable If the post process can be reused on the same frame. (default: false)
  22518. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22519. * @param textureType Type of textures used when performing the post process. (default: 0)
  22520. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22521. * @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
  22522. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  22523. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22524. */
  22525. 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);
  22526. /**
  22527. * Gets a string identifying the name of the class
  22528. * @returns "PostProcess" string
  22529. */
  22530. getClassName(): string;
  22531. /**
  22532. * Gets the engine which this post process belongs to.
  22533. * @returns The engine the post process was enabled with.
  22534. */
  22535. getEngine(): Engine;
  22536. /**
  22537. * The effect that is created when initializing the post process.
  22538. * @returns The created effect corresponding the the postprocess.
  22539. */
  22540. getEffect(): Effect;
  22541. /**
  22542. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22543. * @param postProcess The post process to share the output with.
  22544. * @returns This post process.
  22545. */
  22546. shareOutputWith(postProcess: PostProcess): PostProcess;
  22547. /**
  22548. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22549. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22550. */
  22551. useOwnOutput(): void;
  22552. /**
  22553. * Updates the effect with the current post process compile time values and recompiles the shader.
  22554. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22555. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22556. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22557. * @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
  22558. * @param onCompiled Called when the shader has been compiled.
  22559. * @param onError Called if there is an error when compiling a shader.
  22560. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22561. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22562. */
  22563. 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;
  22564. /**
  22565. * The post process is reusable if it can be used multiple times within one frame.
  22566. * @returns If the post process is reusable
  22567. */
  22568. isReusable(): boolean;
  22569. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22570. markTextureDirty(): void;
  22571. /**
  22572. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22573. * 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.
  22574. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22575. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22576. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22577. * @returns The target texture that was bound to be written to.
  22578. */
  22579. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22580. /**
  22581. * If the post process is supported.
  22582. */
  22583. get isSupported(): boolean;
  22584. /**
  22585. * The aspect ratio of the output texture.
  22586. */
  22587. get aspectRatio(): number;
  22588. /**
  22589. * Get a value indicating if the post-process is ready to be used
  22590. * @returns true if the post-process is ready (shader is compiled)
  22591. */
  22592. isReady(): boolean;
  22593. /**
  22594. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22595. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22596. */
  22597. apply(): Nullable<Effect>;
  22598. private _disposeTextures;
  22599. /**
  22600. * Sets the required values to the prepass renderer.
  22601. * @param prePassRenderer defines the prepass renderer to setup.
  22602. * @returns true if the pre pass is needed.
  22603. */
  22604. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22605. /**
  22606. * Disposes the post process.
  22607. * @param camera The camera to dispose the post process on.
  22608. */
  22609. dispose(camera?: Camera): void;
  22610. /**
  22611. * Serializes the particle system to a JSON object
  22612. * @returns the JSON object
  22613. */
  22614. serialize(): any;
  22615. /**
  22616. * Creates a material from parsed material data
  22617. * @param parsedPostProcess defines parsed post process data
  22618. * @param scene defines the hosting scene
  22619. * @param rootUrl defines the root URL to use to load textures
  22620. * @returns a new post process
  22621. */
  22622. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  22623. }
  22624. }
  22625. declare module BABYLON {
  22626. /** @hidden */
  22627. export var kernelBlurVaryingDeclaration: {
  22628. name: string;
  22629. shader: string;
  22630. };
  22631. }
  22632. declare module BABYLON {
  22633. /** @hidden */
  22634. export var packingFunctions: {
  22635. name: string;
  22636. shader: string;
  22637. };
  22638. }
  22639. declare module BABYLON {
  22640. /** @hidden */
  22641. export var kernelBlurFragment: {
  22642. name: string;
  22643. shader: string;
  22644. };
  22645. }
  22646. declare module BABYLON {
  22647. /** @hidden */
  22648. export var kernelBlurFragment2: {
  22649. name: string;
  22650. shader: string;
  22651. };
  22652. }
  22653. declare module BABYLON {
  22654. /** @hidden */
  22655. export var kernelBlurPixelShader: {
  22656. name: string;
  22657. shader: string;
  22658. };
  22659. }
  22660. declare module BABYLON {
  22661. /** @hidden */
  22662. export var kernelBlurVertex: {
  22663. name: string;
  22664. shader: string;
  22665. };
  22666. }
  22667. declare module BABYLON {
  22668. /** @hidden */
  22669. export var kernelBlurVertexShader: {
  22670. name: string;
  22671. shader: string;
  22672. };
  22673. }
  22674. declare module BABYLON {
  22675. /**
  22676. * The Blur Post Process which blurs an image based on a kernel and direction.
  22677. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22678. */
  22679. export class BlurPostProcess extends PostProcess {
  22680. private blockCompilation;
  22681. protected _kernel: number;
  22682. protected _idealKernel: number;
  22683. protected _packedFloat: boolean;
  22684. private _staticDefines;
  22685. /** The direction in which to blur the image. */
  22686. direction: Vector2;
  22687. /**
  22688. * Sets the length in pixels of the blur sample region
  22689. */
  22690. set kernel(v: number);
  22691. /**
  22692. * Gets the length in pixels of the blur sample region
  22693. */
  22694. get kernel(): number;
  22695. /**
  22696. * Sets wether or not the blur needs to unpack/repack floats
  22697. */
  22698. set packedFloat(v: boolean);
  22699. /**
  22700. * Gets wether or not the blur is unpacking/repacking floats
  22701. */
  22702. get packedFloat(): boolean;
  22703. /**
  22704. * Gets a string identifying the name of the class
  22705. * @returns "BlurPostProcess" string
  22706. */
  22707. getClassName(): string;
  22708. /**
  22709. * Creates a new instance BlurPostProcess
  22710. * @param name The name of the effect.
  22711. * @param direction The direction in which to blur the image.
  22712. * @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.
  22713. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22714. * @param camera The camera to apply the render pass to.
  22715. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22716. * @param engine The engine which the post process will be applied. (default: current engine)
  22717. * @param reusable If the post process can be reused on the same frame. (default: false)
  22718. * @param textureType Type of textures used when performing the post process. (default: 0)
  22719. * @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)
  22720. */
  22721. 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);
  22722. /**
  22723. * Updates the effect with the current post process compile time values and recompiles the shader.
  22724. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22725. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22726. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22727. * @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
  22728. * @param onCompiled Called when the shader has been compiled.
  22729. * @param onError Called if there is an error when compiling a shader.
  22730. */
  22731. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22732. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22733. /**
  22734. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22735. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22736. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22737. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22738. * The gaps between physical kernels are compensated for in the weighting of the samples
  22739. * @param idealKernel Ideal blur kernel.
  22740. * @return Nearest best kernel.
  22741. */
  22742. protected _nearestBestKernel(idealKernel: number): number;
  22743. /**
  22744. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22745. * @param x The point on the Gaussian distribution to sample.
  22746. * @return the value of the Gaussian function at x.
  22747. */
  22748. protected _gaussianWeight(x: number): number;
  22749. /**
  22750. * Generates a string that can be used as a floating point number in GLSL.
  22751. * @param x Value to print.
  22752. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22753. * @return GLSL float string.
  22754. */
  22755. protected _glslFloat(x: number, decimalFigures?: number): string;
  22756. /** @hidden */
  22757. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  22758. }
  22759. }
  22760. declare module BABYLON {
  22761. /**
  22762. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22763. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22764. * You can then easily use it as a reflectionTexture on a flat surface.
  22765. * In case the surface is not a plane, please consider relying on reflection probes.
  22766. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22767. */
  22768. export class MirrorTexture extends RenderTargetTexture {
  22769. private scene;
  22770. /**
  22771. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22772. * 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.
  22773. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22774. */
  22775. mirrorPlane: Plane;
  22776. /**
  22777. * Define the blur ratio used to blur the reflection if needed.
  22778. */
  22779. set blurRatio(value: number);
  22780. get blurRatio(): number;
  22781. /**
  22782. * Define the adaptive blur kernel used to blur the reflection if needed.
  22783. * This will autocompute the closest best match for the `blurKernel`
  22784. */
  22785. set adaptiveBlurKernel(value: number);
  22786. /**
  22787. * Define the blur kernel used to blur the reflection if needed.
  22788. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22789. */
  22790. set blurKernel(value: number);
  22791. /**
  22792. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22793. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22794. */
  22795. set blurKernelX(value: number);
  22796. get blurKernelX(): number;
  22797. /**
  22798. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22799. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22800. */
  22801. set blurKernelY(value: number);
  22802. get blurKernelY(): number;
  22803. private _autoComputeBlurKernel;
  22804. protected _onRatioRescale(): void;
  22805. private _updateGammaSpace;
  22806. private _imageProcessingConfigChangeObserver;
  22807. private _transformMatrix;
  22808. private _mirrorMatrix;
  22809. private _savedViewMatrix;
  22810. private _blurX;
  22811. private _blurY;
  22812. private _adaptiveBlurKernel;
  22813. private _blurKernelX;
  22814. private _blurKernelY;
  22815. private _blurRatio;
  22816. /**
  22817. * Instantiates a Mirror Texture.
  22818. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22819. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22820. * You can then easily use it as a reflectionTexture on a flat surface.
  22821. * In case the surface is not a plane, please consider relying on reflection probes.
  22822. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22823. * @param name
  22824. * @param size
  22825. * @param scene
  22826. * @param generateMipMaps
  22827. * @param type
  22828. * @param samplingMode
  22829. * @param generateDepthBuffer
  22830. */
  22831. constructor(name: string, size: number | {
  22832. width: number;
  22833. height: number;
  22834. } | {
  22835. ratio: number;
  22836. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22837. private _preparePostProcesses;
  22838. /**
  22839. * Clone the mirror texture.
  22840. * @returns the cloned texture
  22841. */
  22842. clone(): MirrorTexture;
  22843. /**
  22844. * Serialize the texture to a JSON representation you could use in Parse later on
  22845. * @returns the serialized JSON representation
  22846. */
  22847. serialize(): any;
  22848. /**
  22849. * Dispose the texture and release its associated resources.
  22850. */
  22851. dispose(): void;
  22852. }
  22853. }
  22854. declare module BABYLON {
  22855. /**
  22856. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22857. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22858. */
  22859. export class Texture extends BaseTexture {
  22860. /**
  22861. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22862. */
  22863. static SerializeBuffers: boolean;
  22864. /**
  22865. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  22866. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  22867. */
  22868. static ForceSerializeBuffers: boolean;
  22869. /** @hidden */
  22870. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22871. /** @hidden */
  22872. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22873. /** @hidden */
  22874. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22875. /** nearest is mag = nearest and min = nearest and mip = linear */
  22876. static readonly NEAREST_SAMPLINGMODE: number;
  22877. /** nearest is mag = nearest and min = nearest and mip = linear */
  22878. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22879. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22880. static readonly BILINEAR_SAMPLINGMODE: number;
  22881. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22882. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22883. /** Trilinear is mag = linear and min = linear and mip = linear */
  22884. static readonly TRILINEAR_SAMPLINGMODE: number;
  22885. /** Trilinear is mag = linear and min = linear and mip = linear */
  22886. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22887. /** mag = nearest and min = nearest and mip = nearest */
  22888. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22889. /** mag = nearest and min = linear and mip = nearest */
  22890. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22891. /** mag = nearest and min = linear and mip = linear */
  22892. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22893. /** mag = nearest and min = linear and mip = none */
  22894. static readonly NEAREST_LINEAR: number;
  22895. /** mag = nearest and min = nearest and mip = none */
  22896. static readonly NEAREST_NEAREST: number;
  22897. /** mag = linear and min = nearest and mip = nearest */
  22898. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22899. /** mag = linear and min = nearest and mip = linear */
  22900. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22901. /** mag = linear and min = linear and mip = none */
  22902. static readonly LINEAR_LINEAR: number;
  22903. /** mag = linear and min = nearest and mip = none */
  22904. static readonly LINEAR_NEAREST: number;
  22905. /** Explicit coordinates mode */
  22906. static readonly EXPLICIT_MODE: number;
  22907. /** Spherical coordinates mode */
  22908. static readonly SPHERICAL_MODE: number;
  22909. /** Planar coordinates mode */
  22910. static readonly PLANAR_MODE: number;
  22911. /** Cubic coordinates mode */
  22912. static readonly CUBIC_MODE: number;
  22913. /** Projection coordinates mode */
  22914. static readonly PROJECTION_MODE: number;
  22915. /** Inverse Cubic coordinates mode */
  22916. static readonly SKYBOX_MODE: number;
  22917. /** Inverse Cubic coordinates mode */
  22918. static readonly INVCUBIC_MODE: number;
  22919. /** Equirectangular coordinates mode */
  22920. static readonly EQUIRECTANGULAR_MODE: number;
  22921. /** Equirectangular Fixed coordinates mode */
  22922. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22923. /** Equirectangular Fixed Mirrored coordinates mode */
  22924. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22925. /** Texture is not repeating outside of 0..1 UVs */
  22926. static readonly CLAMP_ADDRESSMODE: number;
  22927. /** Texture is repeating outside of 0..1 UVs */
  22928. static readonly WRAP_ADDRESSMODE: number;
  22929. /** Texture is repeating and mirrored */
  22930. static readonly MIRROR_ADDRESSMODE: number;
  22931. /**
  22932. * 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
  22933. */
  22934. static UseSerializedUrlIfAny: boolean;
  22935. /**
  22936. * Define the url of the texture.
  22937. */
  22938. url: Nullable<string>;
  22939. /**
  22940. * Define an offset on the texture to offset the u coordinates of the UVs
  22941. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22942. */
  22943. uOffset: number;
  22944. /**
  22945. * Define an offset on the texture to offset the v coordinates of the UVs
  22946. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22947. */
  22948. vOffset: number;
  22949. /**
  22950. * Define an offset on the texture to scale the u coordinates of the UVs
  22951. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22952. */
  22953. uScale: number;
  22954. /**
  22955. * Define an offset on the texture to scale the v coordinates of the UVs
  22956. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22957. */
  22958. vScale: number;
  22959. /**
  22960. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22961. * @see https://doc.babylonjs.com/how_to/more_materials
  22962. */
  22963. uAng: number;
  22964. /**
  22965. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22966. * @see https://doc.babylonjs.com/how_to/more_materials
  22967. */
  22968. vAng: number;
  22969. /**
  22970. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22971. * @see https://doc.babylonjs.com/how_to/more_materials
  22972. */
  22973. wAng: number;
  22974. /**
  22975. * Defines the center of rotation (U)
  22976. */
  22977. uRotationCenter: number;
  22978. /**
  22979. * Defines the center of rotation (V)
  22980. */
  22981. vRotationCenter: number;
  22982. /**
  22983. * Defines the center of rotation (W)
  22984. */
  22985. wRotationCenter: number;
  22986. /**
  22987. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  22988. */
  22989. homogeneousRotationInUVTransform: boolean;
  22990. /**
  22991. * Are mip maps generated for this texture or not.
  22992. */
  22993. get noMipmap(): boolean;
  22994. /**
  22995. * List of inspectable custom properties (used by the Inspector)
  22996. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22997. */
  22998. inspectableCustomProperties: Nullable<IInspectable[]>;
  22999. private _noMipmap;
  23000. /** @hidden */
  23001. _invertY: boolean;
  23002. private _rowGenerationMatrix;
  23003. private _cachedTextureMatrix;
  23004. private _projectionModeMatrix;
  23005. private _t0;
  23006. private _t1;
  23007. private _t2;
  23008. private _cachedUOffset;
  23009. private _cachedVOffset;
  23010. private _cachedUScale;
  23011. private _cachedVScale;
  23012. private _cachedUAng;
  23013. private _cachedVAng;
  23014. private _cachedWAng;
  23015. private _cachedProjectionMatrixId;
  23016. private _cachedURotationCenter;
  23017. private _cachedVRotationCenter;
  23018. private _cachedWRotationCenter;
  23019. private _cachedHomogeneousRotationInUVTransform;
  23020. private _cachedCoordinatesMode;
  23021. /** @hidden */
  23022. protected _initialSamplingMode: number;
  23023. /** @hidden */
  23024. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23025. private _deleteBuffer;
  23026. protected _format: Nullable<number>;
  23027. private _delayedOnLoad;
  23028. private _delayedOnError;
  23029. private _mimeType?;
  23030. private _loaderOptions?;
  23031. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23032. get mimeType(): string | undefined;
  23033. /**
  23034. * Observable triggered once the texture has been loaded.
  23035. */
  23036. onLoadObservable: Observable<Texture>;
  23037. protected _isBlocking: boolean;
  23038. /**
  23039. * Is the texture preventing material to render while loading.
  23040. * If false, a default texture will be used instead of the loading one during the preparation step.
  23041. */
  23042. set isBlocking(value: boolean);
  23043. get isBlocking(): boolean;
  23044. /**
  23045. * Get the current sampling mode associated with the texture.
  23046. */
  23047. get samplingMode(): number;
  23048. /**
  23049. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23050. */
  23051. get invertY(): boolean;
  23052. /**
  23053. * Instantiates a new texture.
  23054. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23055. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23056. * @param url defines the url of the picture to load as a texture
  23057. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23058. * @param noMipmap defines if the texture will require mip maps or not
  23059. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23060. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23061. * @param onLoad defines a callback triggered when the texture has been loaded
  23062. * @param onError defines a callback triggered when an error occurred during the loading session
  23063. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23064. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23065. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23066. * @param mimeType defines an optional mime type information
  23067. * @param loaderOptions options to be passed to the loader
  23068. */
  23069. 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);
  23070. /**
  23071. * Update the url (and optional buffer) of this texture if url was null during construction.
  23072. * @param url the url of the texture
  23073. * @param buffer the buffer of the texture (defaults to null)
  23074. * @param onLoad callback called when the texture is loaded (defaults to null)
  23075. */
  23076. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23077. /**
  23078. * Finish the loading sequence of a texture flagged as delayed load.
  23079. * @hidden
  23080. */
  23081. delayLoad(): void;
  23082. private _prepareRowForTextureGeneration;
  23083. /**
  23084. * Checks if the texture has the same transform matrix than another texture
  23085. * @param texture texture to check against
  23086. * @returns true if the transforms are the same, else false
  23087. */
  23088. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23089. /**
  23090. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23091. * @returns the transform matrix of the texture.
  23092. */
  23093. getTextureMatrix(uBase?: number): Matrix;
  23094. /**
  23095. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23096. * @returns The reflection texture transform
  23097. */
  23098. getReflectionTextureMatrix(): Matrix;
  23099. /**
  23100. * Clones the texture.
  23101. * @returns the cloned texture
  23102. */
  23103. clone(): Texture;
  23104. /**
  23105. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23106. * @returns The JSON representation of the texture
  23107. */
  23108. serialize(): any;
  23109. /**
  23110. * Get the current class name of the texture useful for serialization or dynamic coding.
  23111. * @returns "Texture"
  23112. */
  23113. getClassName(): string;
  23114. /**
  23115. * Dispose the texture and release its associated resources.
  23116. */
  23117. dispose(): void;
  23118. /**
  23119. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23120. * @param parsedTexture Define the JSON representation of the texture
  23121. * @param scene Define the scene the parsed texture should be instantiated in
  23122. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23123. * @returns The parsed texture if successful
  23124. */
  23125. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23126. /**
  23127. * Creates a texture from its base 64 representation.
  23128. * @param data Define the base64 payload without the data: prefix
  23129. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23130. * @param scene Define the scene the texture should belong to
  23131. * @param noMipmap Forces the texture to not create mip map information if true
  23132. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23133. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23134. * @param onLoad define a callback triggered when the texture has been loaded
  23135. * @param onError define a callback triggered when an error occurred during the loading session
  23136. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23137. * @returns the created texture
  23138. */
  23139. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23140. /**
  23141. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23142. * @param data Define the base64 payload without the data: prefix
  23143. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23144. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23145. * @param scene Define the scene the texture should belong to
  23146. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23147. * @param noMipmap Forces the texture to not create mip map information if true
  23148. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23149. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23150. * @param onLoad define a callback triggered when the texture has been loaded
  23151. * @param onError define a callback triggered when an error occurred during the loading session
  23152. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23153. * @returns the created texture
  23154. */
  23155. 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;
  23156. }
  23157. }
  23158. declare module BABYLON {
  23159. /**
  23160. * ThinSprite Class used to represent a thin sprite
  23161. * This is the base class for sprites but can also directly be used with ThinEngine
  23162. * @see https://doc.babylonjs.com/babylon101/sprites
  23163. */
  23164. export class ThinSprite {
  23165. /** Gets or sets the cell index in the sprite sheet */
  23166. cellIndex: number;
  23167. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  23168. cellRef: string;
  23169. /** Gets or sets the current world position */
  23170. position: IVector3Like;
  23171. /** Gets or sets the main color */
  23172. color: IColor4Like;
  23173. /** Gets or sets the width */
  23174. width: number;
  23175. /** Gets or sets the height */
  23176. height: number;
  23177. /** Gets or sets rotation angle */
  23178. angle: number;
  23179. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  23180. invertU: boolean;
  23181. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  23182. invertV: boolean;
  23183. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  23184. isVisible: boolean;
  23185. /**
  23186. * Returns a boolean indicating if the animation is started
  23187. */
  23188. get animationStarted(): boolean;
  23189. /** Gets the initial key for the animation (setting it will restart the animation) */
  23190. get fromIndex(): number;
  23191. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23192. get toIndex(): number;
  23193. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23194. get loopAnimation(): boolean;
  23195. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23196. get delay(): number;
  23197. /** @hidden */
  23198. _xOffset: number;
  23199. /** @hidden */
  23200. _yOffset: number;
  23201. /** @hidden */
  23202. _xSize: number;
  23203. /** @hidden */
  23204. _ySize: number;
  23205. private _animationStarted;
  23206. protected _loopAnimation: boolean;
  23207. protected _fromIndex: number;
  23208. protected _toIndex: number;
  23209. protected _delay: number;
  23210. private _direction;
  23211. private _time;
  23212. private _onBaseAnimationEnd;
  23213. /**
  23214. * Creates a new Thin Sprite
  23215. */
  23216. constructor();
  23217. /**
  23218. * Starts an animation
  23219. * @param from defines the initial key
  23220. * @param to defines the end key
  23221. * @param loop defines if the animation must loop
  23222. * @param delay defines the start delay (in ms)
  23223. * @param onAnimationEnd defines a callback for when the animation ends
  23224. */
  23225. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  23226. /** Stops current animation (if any) */
  23227. stopAnimation(): void;
  23228. /** @hidden */
  23229. _animate(deltaTime: number): void;
  23230. }
  23231. }
  23232. declare module BABYLON {
  23233. /** @hidden */
  23234. export var imageProcessingCompatibility: {
  23235. name: string;
  23236. shader: string;
  23237. };
  23238. }
  23239. declare module BABYLON {
  23240. /** @hidden */
  23241. export var spritesPixelShader: {
  23242. name: string;
  23243. shader: string;
  23244. };
  23245. }
  23246. declare module BABYLON {
  23247. /** @hidden */
  23248. export var spritesVertexShader: {
  23249. name: string;
  23250. shader: string;
  23251. };
  23252. }
  23253. declare module BABYLON {
  23254. /**
  23255. * Class used to render sprites.
  23256. *
  23257. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  23258. */
  23259. export class SpriteRenderer {
  23260. /**
  23261. * Defines the texture of the spritesheet
  23262. */
  23263. texture: Nullable<ThinTexture>;
  23264. /**
  23265. * Defines the default width of a cell in the spritesheet
  23266. */
  23267. cellWidth: number;
  23268. /**
  23269. * Defines the default height of a cell in the spritesheet
  23270. */
  23271. cellHeight: number;
  23272. /**
  23273. * Blend mode use to render the particle, it can be any of
  23274. * the static Constants.ALPHA_x properties provided in this class.
  23275. * Default value is Constants.ALPHA_COMBINE
  23276. */
  23277. blendMode: number;
  23278. /**
  23279. * Gets or sets a boolean indicating if alpha mode is automatically
  23280. * reset.
  23281. */
  23282. autoResetAlpha: boolean;
  23283. /**
  23284. * Disables writing to the depth buffer when rendering the sprites.
  23285. * It can be handy to disable depth writing when using textures without alpha channel
  23286. * and setting some specific blend modes.
  23287. */
  23288. disableDepthWrite: boolean;
  23289. /**
  23290. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  23291. */
  23292. fogEnabled: boolean;
  23293. /**
  23294. * Gets the capacity of the manager
  23295. */
  23296. get capacity(): number;
  23297. private readonly _engine;
  23298. private readonly _useVAO;
  23299. private readonly _useInstancing;
  23300. private readonly _scene;
  23301. private readonly _capacity;
  23302. private readonly _epsilon;
  23303. private _vertexBufferSize;
  23304. private _vertexData;
  23305. private _buffer;
  23306. private _vertexBuffers;
  23307. private _spriteBuffer;
  23308. private _indexBuffer;
  23309. private _effectBase;
  23310. private _effectFog;
  23311. private _vertexArrayObject;
  23312. /**
  23313. * Creates a new sprite Renderer
  23314. * @param engine defines the engine the renderer works with
  23315. * @param capacity defines the maximum allowed number of sprites
  23316. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  23317. * @param scene defines the hosting scene
  23318. */
  23319. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  23320. /**
  23321. * Render all child sprites
  23322. * @param sprites defines the list of sprites to render
  23323. * @param deltaTime defines the time since last frame
  23324. * @param viewMatrix defines the viewMatrix to use to render the sprites
  23325. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  23326. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  23327. */
  23328. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  23329. private _appendSpriteVertex;
  23330. /**
  23331. * Release associated resources
  23332. */
  23333. dispose(): void;
  23334. }
  23335. }
  23336. declare module BABYLON {
  23337. /**
  23338. * Defines the minimum interface to fullfil in order to be a sprite manager.
  23339. */
  23340. export interface ISpriteManager extends IDisposable {
  23341. /**
  23342. * Gets manager's name
  23343. */
  23344. name: string;
  23345. /**
  23346. * Restricts the camera to viewing objects with the same layerMask.
  23347. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  23348. */
  23349. layerMask: number;
  23350. /**
  23351. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23352. */
  23353. isPickable: boolean;
  23354. /**
  23355. * Gets the hosting scene
  23356. */
  23357. scene: Scene;
  23358. /**
  23359. * Specifies the rendering group id for this mesh (0 by default)
  23360. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23361. */
  23362. renderingGroupId: number;
  23363. /**
  23364. * Defines the list of sprites managed by the manager.
  23365. */
  23366. sprites: Array<Sprite>;
  23367. /**
  23368. * Gets or sets the spritesheet texture
  23369. */
  23370. texture: Texture;
  23371. /** Defines the default width of a cell in the spritesheet */
  23372. cellWidth: number;
  23373. /** Defines the default height of a cell in the spritesheet */
  23374. cellHeight: number;
  23375. /**
  23376. * Tests the intersection of a sprite with a specific ray.
  23377. * @param ray The ray we are sending to test the collision
  23378. * @param camera The camera space we are sending rays in
  23379. * @param predicate A predicate allowing excluding sprites from the list of object to test
  23380. * @param fastCheck defines if the first intersection will be used (and not the closest)
  23381. * @returns picking info or null.
  23382. */
  23383. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23384. /**
  23385. * Intersects the sprites with a ray
  23386. * @param ray defines the ray to intersect with
  23387. * @param camera defines the current active camera
  23388. * @param predicate defines a predicate used to select candidate sprites
  23389. * @returns null if no hit or a PickingInfo array
  23390. */
  23391. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  23392. /**
  23393. * Renders the list of sprites on screen.
  23394. */
  23395. render(): void;
  23396. }
  23397. /**
  23398. * Class used to manage multiple sprites on the same spritesheet
  23399. * @see https://doc.babylonjs.com/babylon101/sprites
  23400. */
  23401. export class SpriteManager implements ISpriteManager {
  23402. /** defines the manager's name */
  23403. name: string;
  23404. /** Define the Url to load snippets */
  23405. static SnippetUrl: string;
  23406. /** Snippet ID if the manager was created from the snippet server */
  23407. snippetId: string;
  23408. /** Gets the list of sprites */
  23409. sprites: Sprite[];
  23410. /** Gets or sets the rendering group id (0 by default) */
  23411. renderingGroupId: number;
  23412. /** Gets or sets camera layer mask */
  23413. layerMask: number;
  23414. /** Gets or sets a boolean indicating if the sprites are pickable */
  23415. isPickable: boolean;
  23416. /**
  23417. * An event triggered when the manager is disposed.
  23418. */
  23419. onDisposeObservable: Observable<SpriteManager>;
  23420. /**
  23421. * Callback called when the manager is disposed
  23422. */
  23423. set onDispose(callback: () => void);
  23424. /**
  23425. * Gets or sets the unique id of the sprite
  23426. */
  23427. uniqueId: number;
  23428. /**
  23429. * Gets the array of sprites
  23430. */
  23431. get children(): Sprite[];
  23432. /**
  23433. * Gets the hosting scene
  23434. */
  23435. get scene(): Scene;
  23436. /**
  23437. * Gets the capacity of the manager
  23438. */
  23439. get capacity(): number;
  23440. /**
  23441. * Gets or sets the spritesheet texture
  23442. */
  23443. get texture(): Texture;
  23444. set texture(value: Texture);
  23445. /** Defines the default width of a cell in the spritesheet */
  23446. get cellWidth(): number;
  23447. set cellWidth(value: number);
  23448. /** Defines the default height of a cell in the spritesheet */
  23449. get cellHeight(): number;
  23450. set cellHeight(value: number);
  23451. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  23452. get fogEnabled(): boolean;
  23453. set fogEnabled(value: boolean);
  23454. /**
  23455. * Blend mode use to render the particle, it can be any of
  23456. * the static Constants.ALPHA_x properties provided in this class.
  23457. * Default value is Constants.ALPHA_COMBINE
  23458. */
  23459. get blendMode(): number;
  23460. set blendMode(blendMode: number);
  23461. /** Disables writing to the depth buffer when rendering the sprites.
  23462. * It can be handy to disable depth writing when using textures without alpha channel
  23463. * and setting some specific blend modes.
  23464. */
  23465. disableDepthWrite: boolean;
  23466. private _spriteRenderer;
  23467. /** Associative array from JSON sprite data file */
  23468. private _cellData;
  23469. /** Array of sprite names from JSON sprite data file */
  23470. private _spriteMap;
  23471. /** True when packed cell data from JSON file is ready*/
  23472. private _packedAndReady;
  23473. private _textureContent;
  23474. private _onDisposeObserver;
  23475. private _fromPacked;
  23476. private _scene;
  23477. /**
  23478. * Creates a new sprite manager
  23479. * @param name defines the manager's name
  23480. * @param imgUrl defines the sprite sheet url
  23481. * @param capacity defines the maximum allowed number of sprites
  23482. * @param cellSize defines the size of a sprite cell
  23483. * @param scene defines the hosting scene
  23484. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  23485. * @param samplingMode defines the smapling mode to use with spritesheet
  23486. * @param fromPacked set to false; do not alter
  23487. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  23488. */
  23489. constructor(
  23490. /** defines the manager's name */
  23491. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  23492. /**
  23493. * Returns the string "SpriteManager"
  23494. * @returns "SpriteManager"
  23495. */
  23496. getClassName(): string;
  23497. private _makePacked;
  23498. private _checkTextureAlpha;
  23499. /**
  23500. * Intersects the sprites with a ray
  23501. * @param ray defines the ray to intersect with
  23502. * @param camera defines the current active camera
  23503. * @param predicate defines a predicate used to select candidate sprites
  23504. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  23505. * @returns null if no hit or a PickingInfo
  23506. */
  23507. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23508. /**
  23509. * Intersects the sprites with a ray
  23510. * @param ray defines the ray to intersect with
  23511. * @param camera defines the current active camera
  23512. * @param predicate defines a predicate used to select candidate sprites
  23513. * @returns null if no hit or a PickingInfo array
  23514. */
  23515. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  23516. /**
  23517. * Render all child sprites
  23518. */
  23519. render(): void;
  23520. private _customUpdate;
  23521. /**
  23522. * Release associated resources
  23523. */
  23524. dispose(): void;
  23525. /**
  23526. * Serializes the sprite manager to a JSON object
  23527. * @param serializeTexture defines if the texture must be serialized as well
  23528. * @returns the JSON object
  23529. */
  23530. serialize(serializeTexture?: boolean): any;
  23531. /**
  23532. * Parses a JSON object to create a new sprite manager.
  23533. * @param parsedManager The JSON object to parse
  23534. * @param scene The scene to create the sprite managerin
  23535. * @param rootUrl The root url to use to load external dependencies like texture
  23536. * @returns the new sprite manager
  23537. */
  23538. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  23539. /**
  23540. * Creates a sprite manager from a snippet saved in a remote file
  23541. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  23542. * @param url defines the url to load from
  23543. * @param scene defines the hosting scene
  23544. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23545. * @returns a promise that will resolve to the new sprite manager
  23546. */
  23547. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  23548. /**
  23549. * Creates a sprite manager from a snippet saved by the sprite editor
  23550. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  23551. * @param scene defines the hosting scene
  23552. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23553. * @returns a promise that will resolve to the new sprite manager
  23554. */
  23555. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  23556. }
  23557. }
  23558. declare module BABYLON {
  23559. /**
  23560. * Class used to represent a sprite
  23561. * @see https://doc.babylonjs.com/babylon101/sprites
  23562. */
  23563. export class Sprite extends ThinSprite implements IAnimatable {
  23564. /** defines the name */
  23565. name: string;
  23566. /** Gets or sets the current world position */
  23567. position: Vector3;
  23568. /** Gets or sets the main color */
  23569. color: Color4;
  23570. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  23571. disposeWhenFinishedAnimating: boolean;
  23572. /** Gets the list of attached animations */
  23573. animations: Nullable<Array<Animation>>;
  23574. /** Gets or sets a boolean indicating if the sprite can be picked */
  23575. isPickable: boolean;
  23576. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  23577. useAlphaForPicking: boolean;
  23578. /**
  23579. * Gets or sets the associated action manager
  23580. */
  23581. actionManager: Nullable<ActionManager>;
  23582. /**
  23583. * An event triggered when the control has been disposed
  23584. */
  23585. onDisposeObservable: Observable<Sprite>;
  23586. private _manager;
  23587. private _onAnimationEnd;
  23588. /**
  23589. * Gets or sets the sprite size
  23590. */
  23591. get size(): number;
  23592. set size(value: number);
  23593. /**
  23594. * Gets or sets the unique id of the sprite
  23595. */
  23596. uniqueId: number;
  23597. /**
  23598. * Gets the manager of this sprite
  23599. */
  23600. get manager(): ISpriteManager;
  23601. /**
  23602. * Creates a new Sprite
  23603. * @param name defines the name
  23604. * @param manager defines the manager
  23605. */
  23606. constructor(
  23607. /** defines the name */
  23608. name: string, manager: ISpriteManager);
  23609. /**
  23610. * Returns the string "Sprite"
  23611. * @returns "Sprite"
  23612. */
  23613. getClassName(): string;
  23614. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  23615. get fromIndex(): number;
  23616. set fromIndex(value: number);
  23617. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23618. get toIndex(): number;
  23619. set toIndex(value: number);
  23620. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23621. get loopAnimation(): boolean;
  23622. set loopAnimation(value: boolean);
  23623. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23624. get delay(): number;
  23625. set delay(value: number);
  23626. /**
  23627. * Starts an animation
  23628. * @param from defines the initial key
  23629. * @param to defines the end key
  23630. * @param loop defines if the animation must loop
  23631. * @param delay defines the start delay (in ms)
  23632. * @param onAnimationEnd defines a callback to call when animation ends
  23633. */
  23634. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  23635. private _endAnimation;
  23636. /** Release associated resources */
  23637. dispose(): void;
  23638. /**
  23639. * Serializes the sprite to a JSON object
  23640. * @returns the JSON object
  23641. */
  23642. serialize(): any;
  23643. /**
  23644. * Parses a JSON object to create a new sprite
  23645. * @param parsedSprite The JSON object to parse
  23646. * @param manager defines the hosting manager
  23647. * @returns the new sprite
  23648. */
  23649. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  23650. }
  23651. }
  23652. declare module BABYLON {
  23653. /**
  23654. * Information about the result of picking within a scene
  23655. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  23656. */
  23657. export class PickingInfo {
  23658. /** @hidden */
  23659. _pickingUnavailable: boolean;
  23660. /**
  23661. * If the pick collided with an object
  23662. */
  23663. hit: boolean;
  23664. /**
  23665. * Distance away where the pick collided
  23666. */
  23667. distance: number;
  23668. /**
  23669. * The location of pick collision
  23670. */
  23671. pickedPoint: Nullable<Vector3>;
  23672. /**
  23673. * The mesh corresponding the the pick collision
  23674. */
  23675. pickedMesh: Nullable<AbstractMesh>;
  23676. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  23677. bu: number;
  23678. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  23679. bv: number;
  23680. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23681. faceId: number;
  23682. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23683. subMeshFaceId: number;
  23684. /** Id of the the submesh that was picked */
  23685. subMeshId: number;
  23686. /** If a sprite was picked, this will be the sprite the pick collided with */
  23687. pickedSprite: Nullable<Sprite>;
  23688. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  23689. thinInstanceIndex: number;
  23690. /**
  23691. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  23692. */
  23693. originMesh: Nullable<AbstractMesh>;
  23694. /**
  23695. * The ray that was used to perform the picking.
  23696. */
  23697. ray: Nullable<Ray>;
  23698. /**
  23699. * Gets the normal correspodning to the face the pick collided with
  23700. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  23701. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  23702. * @returns The normal correspodning to the face the pick collided with
  23703. */
  23704. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  23705. /**
  23706. * Gets the texture coordinates of where the pick occured
  23707. * @returns the vector containing the coordnates of the texture
  23708. */
  23709. getTextureCoordinates(): Nullable<Vector2>;
  23710. }
  23711. }
  23712. declare module BABYLON {
  23713. /**
  23714. * Gather the list of pointer event types as constants.
  23715. */
  23716. export class PointerEventTypes {
  23717. /**
  23718. * 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.
  23719. */
  23720. static readonly POINTERDOWN: number;
  23721. /**
  23722. * The pointerup event is fired when a pointer is no longer active.
  23723. */
  23724. static readonly POINTERUP: number;
  23725. /**
  23726. * The pointermove event is fired when a pointer changes coordinates.
  23727. */
  23728. static readonly POINTERMOVE: number;
  23729. /**
  23730. * The pointerwheel event is fired when a mouse wheel has been rotated.
  23731. */
  23732. static readonly POINTERWHEEL: number;
  23733. /**
  23734. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  23735. */
  23736. static readonly POINTERPICK: number;
  23737. /**
  23738. * The pointertap event is fired when a the object has been touched and released without drag.
  23739. */
  23740. static readonly POINTERTAP: number;
  23741. /**
  23742. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  23743. */
  23744. static readonly POINTERDOUBLETAP: number;
  23745. }
  23746. /**
  23747. * Base class of pointer info types.
  23748. */
  23749. export class PointerInfoBase {
  23750. /**
  23751. * Defines the type of event (PointerEventTypes)
  23752. */
  23753. type: number;
  23754. /**
  23755. * Defines the related dom event
  23756. */
  23757. event: PointerEvent | MouseWheelEvent;
  23758. /**
  23759. * Instantiates the base class of pointers info.
  23760. * @param type Defines the type of event (PointerEventTypes)
  23761. * @param event Defines the related dom event
  23762. */
  23763. constructor(
  23764. /**
  23765. * Defines the type of event (PointerEventTypes)
  23766. */
  23767. type: number,
  23768. /**
  23769. * Defines the related dom event
  23770. */
  23771. event: PointerEvent | MouseWheelEvent);
  23772. }
  23773. /**
  23774. * This class is used to store pointer related info for the onPrePointerObservable event.
  23775. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  23776. */
  23777. export class PointerInfoPre extends PointerInfoBase {
  23778. /**
  23779. * Ray from a pointer if availible (eg. 6dof controller)
  23780. */
  23781. ray: Nullable<Ray>;
  23782. /**
  23783. * Defines the local position of the pointer on the canvas.
  23784. */
  23785. localPosition: Vector2;
  23786. /**
  23787. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  23788. */
  23789. skipOnPointerObservable: boolean;
  23790. /**
  23791. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  23792. * @param type Defines the type of event (PointerEventTypes)
  23793. * @param event Defines the related dom event
  23794. * @param localX Defines the local x coordinates of the pointer when the event occured
  23795. * @param localY Defines the local y coordinates of the pointer when the event occured
  23796. */
  23797. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  23798. }
  23799. /**
  23800. * This type contains all the data related to a pointer event in Babylon.js.
  23801. * 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.
  23802. */
  23803. export class PointerInfo extends PointerInfoBase {
  23804. /**
  23805. * Defines the picking info associated to the info (if any)\
  23806. */
  23807. pickInfo: Nullable<PickingInfo>;
  23808. /**
  23809. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  23810. * @param type Defines the type of event (PointerEventTypes)
  23811. * @param event Defines the related dom event
  23812. * @param pickInfo Defines the picking info associated to the info (if any)\
  23813. */
  23814. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  23815. /**
  23816. * Defines the picking info associated to the info (if any)\
  23817. */
  23818. pickInfo: Nullable<PickingInfo>);
  23819. }
  23820. /**
  23821. * Data relating to a touch event on the screen.
  23822. */
  23823. export interface PointerTouch {
  23824. /**
  23825. * X coordinate of touch.
  23826. */
  23827. x: number;
  23828. /**
  23829. * Y coordinate of touch.
  23830. */
  23831. y: number;
  23832. /**
  23833. * Id of touch. Unique for each finger.
  23834. */
  23835. pointerId: number;
  23836. /**
  23837. * Event type passed from DOM.
  23838. */
  23839. type: any;
  23840. }
  23841. }
  23842. declare module BABYLON {
  23843. /**
  23844. * Manage the mouse inputs to control the movement of a free camera.
  23845. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23846. */
  23847. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  23848. /**
  23849. * Define if touch is enabled in the mouse input
  23850. */
  23851. touchEnabled: boolean;
  23852. /**
  23853. * Defines the camera the input is attached to.
  23854. */
  23855. camera: FreeCamera;
  23856. /**
  23857. * Defines the buttons associated with the input to handle camera move.
  23858. */
  23859. buttons: number[];
  23860. /**
  23861. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  23862. */
  23863. angularSensibility: number;
  23864. private _pointerInput;
  23865. private _onMouseMove;
  23866. private _observer;
  23867. private previousPosition;
  23868. /**
  23869. * Observable for when a pointer move event occurs containing the move offset
  23870. */
  23871. onPointerMovedObservable: Observable<{
  23872. offsetX: number;
  23873. offsetY: number;
  23874. }>;
  23875. /**
  23876. * @hidden
  23877. * If the camera should be rotated automatically based on pointer movement
  23878. */
  23879. _allowCameraRotation: boolean;
  23880. /**
  23881. * Manage the mouse inputs to control the movement of a free camera.
  23882. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23883. * @param touchEnabled Defines if touch is enabled or not
  23884. */
  23885. constructor(
  23886. /**
  23887. * Define if touch is enabled in the mouse input
  23888. */
  23889. touchEnabled?: boolean);
  23890. /**
  23891. * Attach the input controls to a specific dom element to get the input from.
  23892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  23893. */
  23894. attachControl(noPreventDefault?: boolean): void;
  23895. /**
  23896. * Called on JS contextmenu event.
  23897. * Override this method to provide functionality.
  23898. */
  23899. protected onContextMenu(evt: PointerEvent): void;
  23900. /**
  23901. * Detach the current controls from the specified dom element.
  23902. */
  23903. detachControl(): void;
  23904. /**
  23905. * Gets the class name of the current intput.
  23906. * @returns the class name
  23907. */
  23908. getClassName(): string;
  23909. /**
  23910. * Get the friendly name associated with the input class.
  23911. * @returns the input friendly name
  23912. */
  23913. getSimpleName(): string;
  23914. }
  23915. }
  23916. declare module BABYLON {
  23917. /**
  23918. * Base class for mouse wheel input..
  23919. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  23920. * for example usage.
  23921. */
  23922. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  23923. /**
  23924. * Defines the camera the input is attached to.
  23925. */
  23926. abstract camera: Camera;
  23927. /**
  23928. * How fast is the camera moves in relation to X axis mouseWheel events.
  23929. * Use negative value to reverse direction.
  23930. */
  23931. wheelPrecisionX: number;
  23932. /**
  23933. * How fast is the camera moves in relation to Y axis mouseWheel events.
  23934. * Use negative value to reverse direction.
  23935. */
  23936. wheelPrecisionY: number;
  23937. /**
  23938. * How fast is the camera moves in relation to Z axis mouseWheel events.
  23939. * Use negative value to reverse direction.
  23940. */
  23941. wheelPrecisionZ: number;
  23942. /**
  23943. * Observable for when a mouse wheel move event occurs.
  23944. */
  23945. onChangedObservable: Observable<{
  23946. wheelDeltaX: number;
  23947. wheelDeltaY: number;
  23948. wheelDeltaZ: number;
  23949. }>;
  23950. private _wheel;
  23951. private _observer;
  23952. /**
  23953. * Attach the input controls to a specific dom element to get the input from.
  23954. * @param noPreventDefault Defines whether event caught by the controls
  23955. * should call preventdefault().
  23956. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  23957. */
  23958. attachControl(noPreventDefault?: boolean): void;
  23959. /**
  23960. * Detach the current controls from the specified dom element.
  23961. */
  23962. detachControl(): void;
  23963. /**
  23964. * Called for each rendered frame.
  23965. */
  23966. checkInputs(): void;
  23967. /**
  23968. * Gets the class name of the current intput.
  23969. * @returns the class name
  23970. */
  23971. getClassName(): string;
  23972. /**
  23973. * Get the friendly name associated with the input class.
  23974. * @returns the input friendly name
  23975. */
  23976. getSimpleName(): string;
  23977. /**
  23978. * Incremental value of multiple mouse wheel movements of the X axis.
  23979. * Should be zero-ed when read.
  23980. */
  23981. protected _wheelDeltaX: number;
  23982. /**
  23983. * Incremental value of multiple mouse wheel movements of the Y axis.
  23984. * Should be zero-ed when read.
  23985. */
  23986. protected _wheelDeltaY: number;
  23987. /**
  23988. * Incremental value of multiple mouse wheel movements of the Z axis.
  23989. * Should be zero-ed when read.
  23990. */
  23991. protected _wheelDeltaZ: number;
  23992. /**
  23993. * Firefox uses a different scheme to report scroll distances to other
  23994. * browsers. Rather than use complicated methods to calculate the exact
  23995. * multiple we need to apply, let's just cheat and use a constant.
  23996. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  23997. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  23998. */
  23999. private readonly _ffMultiplier;
  24000. /**
  24001. * Different event attributes for wheel data fall into a few set ranges.
  24002. * Some relevant but dated date here:
  24003. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24004. */
  24005. private readonly _normalize;
  24006. }
  24007. }
  24008. declare module BABYLON {
  24009. /**
  24010. * Manage the mouse wheel inputs to control a free camera.
  24011. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24012. */
  24013. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24014. /**
  24015. * Defines the camera the input is attached to.
  24016. */
  24017. camera: FreeCamera;
  24018. /**
  24019. * Gets the class name of the current input.
  24020. * @returns the class name
  24021. */
  24022. getClassName(): string;
  24023. /**
  24024. * Set which movement axis (relative to camera's orientation) the mouse
  24025. * wheel's X axis controls.
  24026. * @param axis The axis to be moved. Set null to clear.
  24027. */
  24028. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24029. /**
  24030. * Get the configured movement axis (relative to camera's orientation) the
  24031. * mouse wheel's X axis controls.
  24032. * @returns The configured axis or null if none.
  24033. */
  24034. get wheelXMoveRelative(): Nullable<Coordinate>;
  24035. /**
  24036. * Set which movement axis (relative to camera's orientation) the mouse
  24037. * wheel's Y axis controls.
  24038. * @param axis The axis to be moved. Set null to clear.
  24039. */
  24040. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24041. /**
  24042. * Get the configured movement axis (relative to camera's orientation) the
  24043. * mouse wheel's Y axis controls.
  24044. * @returns The configured axis or null if none.
  24045. */
  24046. get wheelYMoveRelative(): Nullable<Coordinate>;
  24047. /**
  24048. * Set which movement axis (relative to camera's orientation) the mouse
  24049. * wheel's Z axis controls.
  24050. * @param axis The axis to be moved. Set null to clear.
  24051. */
  24052. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24053. /**
  24054. * Get the configured movement axis (relative to camera's orientation) the
  24055. * mouse wheel's Z axis controls.
  24056. * @returns The configured axis or null if none.
  24057. */
  24058. get wheelZMoveRelative(): Nullable<Coordinate>;
  24059. /**
  24060. * Set which rotation axis (relative to camera's orientation) the mouse
  24061. * wheel's X axis controls.
  24062. * @param axis The axis to be moved. Set null to clear.
  24063. */
  24064. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24065. /**
  24066. * Get the configured rotation axis (relative to camera's orientation) the
  24067. * mouse wheel's X axis controls.
  24068. * @returns The configured axis or null if none.
  24069. */
  24070. get wheelXRotateRelative(): Nullable<Coordinate>;
  24071. /**
  24072. * Set which rotation axis (relative to camera's orientation) the mouse
  24073. * wheel's Y axis controls.
  24074. * @param axis The axis to be moved. Set null to clear.
  24075. */
  24076. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  24077. /**
  24078. * Get the configured rotation axis (relative to camera's orientation) the
  24079. * mouse wheel's Y axis controls.
  24080. * @returns The configured axis or null if none.
  24081. */
  24082. get wheelYRotateRelative(): Nullable<Coordinate>;
  24083. /**
  24084. * Set which rotation axis (relative to camera's orientation) the mouse
  24085. * wheel's Z axis controls.
  24086. * @param axis The axis to be moved. Set null to clear.
  24087. */
  24088. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  24089. /**
  24090. * Get the configured rotation axis (relative to camera's orientation) the
  24091. * mouse wheel's Z axis controls.
  24092. * @returns The configured axis or null if none.
  24093. */
  24094. get wheelZRotateRelative(): Nullable<Coordinate>;
  24095. /**
  24096. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  24097. * controls.
  24098. * @param axis The axis to be moved. Set null to clear.
  24099. */
  24100. set wheelXMoveScene(axis: Nullable<Coordinate>);
  24101. /**
  24102. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24103. * X axis controls.
  24104. * @returns The configured axis or null if none.
  24105. */
  24106. get wheelXMoveScene(): Nullable<Coordinate>;
  24107. /**
  24108. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  24109. * controls.
  24110. * @param axis The axis to be moved. Set null to clear.
  24111. */
  24112. set wheelYMoveScene(axis: Nullable<Coordinate>);
  24113. /**
  24114. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24115. * Y axis controls.
  24116. * @returns The configured axis or null if none.
  24117. */
  24118. get wheelYMoveScene(): Nullable<Coordinate>;
  24119. /**
  24120. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  24121. * controls.
  24122. * @param axis The axis to be moved. Set null to clear.
  24123. */
  24124. set wheelZMoveScene(axis: Nullable<Coordinate>);
  24125. /**
  24126. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24127. * Z axis controls.
  24128. * @returns The configured axis or null if none.
  24129. */
  24130. get wheelZMoveScene(): Nullable<Coordinate>;
  24131. /**
  24132. * Called for each rendered frame.
  24133. */
  24134. checkInputs(): void;
  24135. private _moveRelative;
  24136. private _rotateRelative;
  24137. private _moveScene;
  24138. /**
  24139. * These are set to the desired default behaviour.
  24140. */
  24141. private _wheelXAction;
  24142. private _wheelXActionCoordinate;
  24143. private _wheelYAction;
  24144. private _wheelYActionCoordinate;
  24145. private _wheelZAction;
  24146. private _wheelZActionCoordinate;
  24147. /**
  24148. * Update the camera according to any configured properties for the 3
  24149. * mouse-wheel axis.
  24150. */
  24151. private _updateCamera;
  24152. }
  24153. }
  24154. declare module BABYLON {
  24155. /**
  24156. * Manage the touch inputs to control the movement of a free camera.
  24157. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24158. */
  24159. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24160. /**
  24161. * Define if mouse events can be treated as touch events
  24162. */
  24163. allowMouse: boolean;
  24164. /**
  24165. * Defines the camera the input is attached to.
  24166. */
  24167. camera: FreeCamera;
  24168. /**
  24169. * Defines the touch sensibility for rotation.
  24170. * The higher the faster.
  24171. */
  24172. touchAngularSensibility: number;
  24173. /**
  24174. * Defines the touch sensibility for move.
  24175. * The higher the faster.
  24176. */
  24177. touchMoveSensibility: number;
  24178. private _offsetX;
  24179. private _offsetY;
  24180. private _pointerPressed;
  24181. private _pointerInput?;
  24182. private _observer;
  24183. private _onLostFocus;
  24184. /**
  24185. * Manage the touch inputs to control the movement of a free camera.
  24186. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24187. * @param allowMouse Defines if mouse events can be treated as touch events
  24188. */
  24189. constructor(
  24190. /**
  24191. * Define if mouse events can be treated as touch events
  24192. */
  24193. allowMouse?: boolean);
  24194. /**
  24195. * Attach the input controls to a specific dom element to get the input from.
  24196. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24197. */
  24198. attachControl(noPreventDefault?: boolean): void;
  24199. /**
  24200. * Detach the current controls from the specified dom element.
  24201. */
  24202. detachControl(): void;
  24203. /**
  24204. * Update the current camera state depending on the inputs that have been used this frame.
  24205. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  24206. */
  24207. checkInputs(): void;
  24208. /**
  24209. * Gets the class name of the current intput.
  24210. * @returns the class name
  24211. */
  24212. getClassName(): string;
  24213. /**
  24214. * Get the friendly name associated with the input class.
  24215. * @returns the input friendly name
  24216. */
  24217. getSimpleName(): string;
  24218. }
  24219. }
  24220. declare module BABYLON {
  24221. /**
  24222. * Default Inputs manager for the FreeCamera.
  24223. * It groups all the default supported inputs for ease of use.
  24224. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24225. */
  24226. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  24227. /**
  24228. * @hidden
  24229. */
  24230. _mouseInput: Nullable<FreeCameraMouseInput>;
  24231. /**
  24232. * @hidden
  24233. */
  24234. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  24235. /**
  24236. * Instantiates a new FreeCameraInputsManager.
  24237. * @param camera Defines the camera the inputs belong to
  24238. */
  24239. constructor(camera: FreeCamera);
  24240. /**
  24241. * Add keyboard input support to the input manager.
  24242. * @returns the current input manager
  24243. */
  24244. addKeyboard(): FreeCameraInputsManager;
  24245. /**
  24246. * Add mouse input support to the input manager.
  24247. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  24248. * @returns the current input manager
  24249. */
  24250. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  24251. /**
  24252. * Removes the mouse input support from the manager
  24253. * @returns the current input manager
  24254. */
  24255. removeMouse(): FreeCameraInputsManager;
  24256. /**
  24257. * Add mouse wheel input support to the input manager.
  24258. * @returns the current input manager
  24259. */
  24260. addMouseWheel(): FreeCameraInputsManager;
  24261. /**
  24262. * Removes the mouse wheel input support from the manager
  24263. * @returns the current input manager
  24264. */
  24265. removeMouseWheel(): FreeCameraInputsManager;
  24266. /**
  24267. * Add touch input support to the input manager.
  24268. * @returns the current input manager
  24269. */
  24270. addTouch(): FreeCameraInputsManager;
  24271. /**
  24272. * Remove all attached input methods from a camera
  24273. */
  24274. clear(): void;
  24275. }
  24276. }
  24277. declare module BABYLON {
  24278. /**
  24279. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24280. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  24281. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  24282. */
  24283. export class FreeCamera extends TargetCamera {
  24284. /**
  24285. * Define the collision ellipsoid of the camera.
  24286. * This is helpful to simulate a camera body like the player body around the camera
  24287. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  24288. */
  24289. ellipsoid: Vector3;
  24290. /**
  24291. * Define an offset for the position of the ellipsoid around the camera.
  24292. * This can be helpful to determine the center of the body near the gravity center of the body
  24293. * instead of its head.
  24294. */
  24295. ellipsoidOffset: Vector3;
  24296. /**
  24297. * Enable or disable collisions of the camera with the rest of the scene objects.
  24298. */
  24299. checkCollisions: boolean;
  24300. /**
  24301. * Enable or disable gravity on the camera.
  24302. */
  24303. applyGravity: boolean;
  24304. /**
  24305. * Define the input manager associated to the camera.
  24306. */
  24307. inputs: FreeCameraInputsManager;
  24308. /**
  24309. * Gets the input sensibility for a mouse input. (default is 2000.0)
  24310. * Higher values reduce sensitivity.
  24311. */
  24312. get angularSensibility(): number;
  24313. /**
  24314. * Sets the input sensibility for a mouse input. (default is 2000.0)
  24315. * Higher values reduce sensitivity.
  24316. */
  24317. set angularSensibility(value: number);
  24318. /**
  24319. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  24320. */
  24321. get keysUp(): number[];
  24322. set keysUp(value: number[]);
  24323. /**
  24324. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  24325. */
  24326. get keysUpward(): number[];
  24327. set keysUpward(value: number[]);
  24328. /**
  24329. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  24330. */
  24331. get keysDown(): number[];
  24332. set keysDown(value: number[]);
  24333. /**
  24334. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  24335. */
  24336. get keysDownward(): number[];
  24337. set keysDownward(value: number[]);
  24338. /**
  24339. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  24340. */
  24341. get keysLeft(): number[];
  24342. set keysLeft(value: number[]);
  24343. /**
  24344. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  24345. */
  24346. get keysRight(): number[];
  24347. set keysRight(value: number[]);
  24348. /**
  24349. * Event raised when the camera collide with a mesh in the scene.
  24350. */
  24351. onCollide: (collidedMesh: AbstractMesh) => void;
  24352. private _collider;
  24353. private _needMoveForGravity;
  24354. private _oldPosition;
  24355. private _diffPosition;
  24356. private _newPosition;
  24357. /** @hidden */
  24358. _localDirection: Vector3;
  24359. /** @hidden */
  24360. _transformedDirection: Vector3;
  24361. /**
  24362. * Instantiates a Free Camera.
  24363. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24364. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  24365. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  24366. * @param name Define the name of the camera in the scene
  24367. * @param position Define the start position of the camera in the scene
  24368. * @param scene Define the scene the camera belongs to
  24369. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  24370. */
  24371. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24372. /**
  24373. * Attach the input controls to a specific dom element to get the input from.
  24374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24375. */
  24376. attachControl(noPreventDefault?: boolean): void;
  24377. /**
  24378. * Attach the input controls to a specific dom element to get the input from.
  24379. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  24380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24381. * BACK COMPAT SIGNATURE ONLY.
  24382. */
  24383. attachControl(ignored: any, noPreventDefault?: boolean): void;
  24384. /**
  24385. * Detach the current controls from the specified dom element.
  24386. */
  24387. detachControl(): void;
  24388. /**
  24389. * Detach the current controls from the specified dom element.
  24390. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  24391. */
  24392. detachControl(ignored: any): void;
  24393. private _collisionMask;
  24394. /**
  24395. * Define a collision mask to limit the list of object the camera can collide with
  24396. */
  24397. get collisionMask(): number;
  24398. set collisionMask(mask: number);
  24399. /** @hidden */
  24400. _collideWithWorld(displacement: Vector3): void;
  24401. private _onCollisionPositionChange;
  24402. /** @hidden */
  24403. _checkInputs(): void;
  24404. /** @hidden */
  24405. _decideIfNeedsToMove(): boolean;
  24406. /** @hidden */
  24407. _updatePosition(): void;
  24408. /**
  24409. * Destroy the camera and release the current resources hold by it.
  24410. */
  24411. dispose(): void;
  24412. /**
  24413. * Gets the current object class name.
  24414. * @return the class name
  24415. */
  24416. getClassName(): string;
  24417. }
  24418. }
  24419. declare module BABYLON {
  24420. /**
  24421. * Represents a gamepad control stick position
  24422. */
  24423. export class StickValues {
  24424. /**
  24425. * The x component of the control stick
  24426. */
  24427. x: number;
  24428. /**
  24429. * The y component of the control stick
  24430. */
  24431. y: number;
  24432. /**
  24433. * Initializes the gamepad x and y control stick values
  24434. * @param x The x component of the gamepad control stick value
  24435. * @param y The y component of the gamepad control stick value
  24436. */
  24437. constructor(
  24438. /**
  24439. * The x component of the control stick
  24440. */
  24441. x: number,
  24442. /**
  24443. * The y component of the control stick
  24444. */
  24445. y: number);
  24446. }
  24447. /**
  24448. * An interface which manages callbacks for gamepad button changes
  24449. */
  24450. export interface GamepadButtonChanges {
  24451. /**
  24452. * Called when a gamepad has been changed
  24453. */
  24454. changed: boolean;
  24455. /**
  24456. * Called when a gamepad press event has been triggered
  24457. */
  24458. pressChanged: boolean;
  24459. /**
  24460. * Called when a touch event has been triggered
  24461. */
  24462. touchChanged: boolean;
  24463. /**
  24464. * Called when a value has changed
  24465. */
  24466. valueChanged: boolean;
  24467. }
  24468. /**
  24469. * Represents a gamepad
  24470. */
  24471. export class Gamepad {
  24472. /**
  24473. * The id of the gamepad
  24474. */
  24475. id: string;
  24476. /**
  24477. * The index of the gamepad
  24478. */
  24479. index: number;
  24480. /**
  24481. * The browser gamepad
  24482. */
  24483. browserGamepad: any;
  24484. /**
  24485. * Specifies what type of gamepad this represents
  24486. */
  24487. type: number;
  24488. private _leftStick;
  24489. private _rightStick;
  24490. /** @hidden */
  24491. _isConnected: boolean;
  24492. private _leftStickAxisX;
  24493. private _leftStickAxisY;
  24494. private _rightStickAxisX;
  24495. private _rightStickAxisY;
  24496. /**
  24497. * Triggered when the left control stick has been changed
  24498. */
  24499. private _onleftstickchanged;
  24500. /**
  24501. * Triggered when the right control stick has been changed
  24502. */
  24503. private _onrightstickchanged;
  24504. /**
  24505. * Represents a gamepad controller
  24506. */
  24507. static GAMEPAD: number;
  24508. /**
  24509. * Represents a generic controller
  24510. */
  24511. static GENERIC: number;
  24512. /**
  24513. * Represents an XBox controller
  24514. */
  24515. static XBOX: number;
  24516. /**
  24517. * Represents a pose-enabled controller
  24518. */
  24519. static POSE_ENABLED: number;
  24520. /**
  24521. * Represents an Dual Shock controller
  24522. */
  24523. static DUALSHOCK: number;
  24524. /**
  24525. * Specifies whether the left control stick should be Y-inverted
  24526. */
  24527. protected _invertLeftStickY: boolean;
  24528. /**
  24529. * Specifies if the gamepad has been connected
  24530. */
  24531. get isConnected(): boolean;
  24532. /**
  24533. * Initializes the gamepad
  24534. * @param id The id of the gamepad
  24535. * @param index The index of the gamepad
  24536. * @param browserGamepad The browser gamepad
  24537. * @param leftStickX The x component of the left joystick
  24538. * @param leftStickY The y component of the left joystick
  24539. * @param rightStickX The x component of the right joystick
  24540. * @param rightStickY The y component of the right joystick
  24541. */
  24542. constructor(
  24543. /**
  24544. * The id of the gamepad
  24545. */
  24546. id: string,
  24547. /**
  24548. * The index of the gamepad
  24549. */
  24550. index: number,
  24551. /**
  24552. * The browser gamepad
  24553. */
  24554. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  24555. /**
  24556. * Callback triggered when the left joystick has changed
  24557. * @param callback
  24558. */
  24559. onleftstickchanged(callback: (values: StickValues) => void): void;
  24560. /**
  24561. * Callback triggered when the right joystick has changed
  24562. * @param callback
  24563. */
  24564. onrightstickchanged(callback: (values: StickValues) => void): void;
  24565. /**
  24566. * Gets the left joystick
  24567. */
  24568. get leftStick(): StickValues;
  24569. /**
  24570. * Sets the left joystick values
  24571. */
  24572. set leftStick(newValues: StickValues);
  24573. /**
  24574. * Gets the right joystick
  24575. */
  24576. get rightStick(): StickValues;
  24577. /**
  24578. * Sets the right joystick value
  24579. */
  24580. set rightStick(newValues: StickValues);
  24581. /**
  24582. * Updates the gamepad joystick positions
  24583. */
  24584. update(): void;
  24585. /**
  24586. * Disposes the gamepad
  24587. */
  24588. dispose(): void;
  24589. }
  24590. /**
  24591. * Represents a generic gamepad
  24592. */
  24593. export class GenericPad extends Gamepad {
  24594. private _buttons;
  24595. private _onbuttondown;
  24596. private _onbuttonup;
  24597. /**
  24598. * Observable triggered when a button has been pressed
  24599. */
  24600. onButtonDownObservable: Observable<number>;
  24601. /**
  24602. * Observable triggered when a button has been released
  24603. */
  24604. onButtonUpObservable: Observable<number>;
  24605. /**
  24606. * Callback triggered when a button has been pressed
  24607. * @param callback Called when a button has been pressed
  24608. */
  24609. onbuttondown(callback: (buttonPressed: number) => void): void;
  24610. /**
  24611. * Callback triggered when a button has been released
  24612. * @param callback Called when a button has been released
  24613. */
  24614. onbuttonup(callback: (buttonReleased: number) => void): void;
  24615. /**
  24616. * Initializes the generic gamepad
  24617. * @param id The id of the generic gamepad
  24618. * @param index The index of the generic gamepad
  24619. * @param browserGamepad The browser gamepad
  24620. */
  24621. constructor(id: string, index: number, browserGamepad: any);
  24622. private _setButtonValue;
  24623. /**
  24624. * Updates the generic gamepad
  24625. */
  24626. update(): void;
  24627. /**
  24628. * Disposes the generic gamepad
  24629. */
  24630. dispose(): void;
  24631. }
  24632. }
  24633. declare module BABYLON {
  24634. /**
  24635. * Defines a runtime animation
  24636. */
  24637. export class RuntimeAnimation {
  24638. private _events;
  24639. /**
  24640. * The current frame of the runtime animation
  24641. */
  24642. private _currentFrame;
  24643. /**
  24644. * The animation used by the runtime animation
  24645. */
  24646. private _animation;
  24647. /**
  24648. * The target of the runtime animation
  24649. */
  24650. private _target;
  24651. /**
  24652. * The initiating animatable
  24653. */
  24654. private _host;
  24655. /**
  24656. * The original value of the runtime animation
  24657. */
  24658. private _originalValue;
  24659. /**
  24660. * The original blend value of the runtime animation
  24661. */
  24662. private _originalBlendValue;
  24663. /**
  24664. * The offsets cache of the runtime animation
  24665. */
  24666. private _offsetsCache;
  24667. /**
  24668. * The high limits cache of the runtime animation
  24669. */
  24670. private _highLimitsCache;
  24671. /**
  24672. * Specifies if the runtime animation has been stopped
  24673. */
  24674. private _stopped;
  24675. /**
  24676. * The blending factor of the runtime animation
  24677. */
  24678. private _blendingFactor;
  24679. /**
  24680. * The BabylonJS scene
  24681. */
  24682. private _scene;
  24683. /**
  24684. * The current value of the runtime animation
  24685. */
  24686. private _currentValue;
  24687. /** @hidden */
  24688. _animationState: _IAnimationState;
  24689. /**
  24690. * The active target of the runtime animation
  24691. */
  24692. private _activeTargets;
  24693. private _currentActiveTarget;
  24694. private _directTarget;
  24695. /**
  24696. * The target path of the runtime animation
  24697. */
  24698. private _targetPath;
  24699. /**
  24700. * The weight of the runtime animation
  24701. */
  24702. private _weight;
  24703. /**
  24704. * The ratio offset of the runtime animation
  24705. */
  24706. private _ratioOffset;
  24707. /**
  24708. * The previous delay of the runtime animation
  24709. */
  24710. private _previousDelay;
  24711. /**
  24712. * The previous ratio of the runtime animation
  24713. */
  24714. private _previousRatio;
  24715. private _enableBlending;
  24716. private _keys;
  24717. private _minFrame;
  24718. private _maxFrame;
  24719. private _minValue;
  24720. private _maxValue;
  24721. private _targetIsArray;
  24722. /**
  24723. * Gets the current frame of the runtime animation
  24724. */
  24725. get currentFrame(): number;
  24726. /**
  24727. * Gets the weight of the runtime animation
  24728. */
  24729. get weight(): number;
  24730. /**
  24731. * Gets the current value of the runtime animation
  24732. */
  24733. get currentValue(): any;
  24734. /**
  24735. * Gets the target path of the runtime animation
  24736. */
  24737. get targetPath(): string;
  24738. /**
  24739. * Gets the actual target of the runtime animation
  24740. */
  24741. get target(): any;
  24742. /**
  24743. * Gets the additive state of the runtime animation
  24744. */
  24745. get isAdditive(): boolean;
  24746. /** @hidden */
  24747. _onLoop: () => void;
  24748. /**
  24749. * Create a new RuntimeAnimation object
  24750. * @param target defines the target of the animation
  24751. * @param animation defines the source animation object
  24752. * @param scene defines the hosting scene
  24753. * @param host defines the initiating Animatable
  24754. */
  24755. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  24756. private _preparePath;
  24757. /**
  24758. * Gets the animation from the runtime animation
  24759. */
  24760. get animation(): Animation;
  24761. /**
  24762. * Resets the runtime animation to the beginning
  24763. * @param restoreOriginal defines whether to restore the target property to the original value
  24764. */
  24765. reset(restoreOriginal?: boolean): void;
  24766. /**
  24767. * Specifies if the runtime animation is stopped
  24768. * @returns Boolean specifying if the runtime animation is stopped
  24769. */
  24770. isStopped(): boolean;
  24771. /**
  24772. * Disposes of the runtime animation
  24773. */
  24774. dispose(): void;
  24775. /**
  24776. * Apply the interpolated value to the target
  24777. * @param currentValue defines the value computed by the animation
  24778. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  24779. */
  24780. setValue(currentValue: any, weight: number): void;
  24781. private _getOriginalValues;
  24782. private _setValue;
  24783. /**
  24784. * Gets the loop pmode of the runtime animation
  24785. * @returns Loop Mode
  24786. */
  24787. private _getCorrectLoopMode;
  24788. /**
  24789. * Move the current animation to a given frame
  24790. * @param frame defines the frame to move to
  24791. */
  24792. goToFrame(frame: number): void;
  24793. /**
  24794. * @hidden Internal use only
  24795. */
  24796. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  24797. /**
  24798. * Execute the current animation
  24799. * @param delay defines the delay to add to the current frame
  24800. * @param from defines the lower bound of the animation range
  24801. * @param to defines the upper bound of the animation range
  24802. * @param loop defines if the current animation must loop
  24803. * @param speedRatio defines the current speed ratio
  24804. * @param weight defines the weight of the animation (default is -1 so no weight)
  24805. * @param onLoop optional callback called when animation loops
  24806. * @returns a boolean indicating if the animation is running
  24807. */
  24808. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  24809. }
  24810. }
  24811. declare module BABYLON {
  24812. /**
  24813. * Class used to store an actual running animation
  24814. */
  24815. export class Animatable {
  24816. /** defines the target object */
  24817. target: any;
  24818. /** defines the starting frame number (default is 0) */
  24819. fromFrame: number;
  24820. /** defines the ending frame number (default is 100) */
  24821. toFrame: number;
  24822. /** defines if the animation must loop (default is false) */
  24823. loopAnimation: boolean;
  24824. /** defines a callback to call when animation ends if it is not looping */
  24825. onAnimationEnd?: (() => void) | null | undefined;
  24826. /** defines a callback to call when animation loops */
  24827. onAnimationLoop?: (() => void) | null | undefined;
  24828. /** defines whether the animation should be evaluated additively */
  24829. isAdditive: boolean;
  24830. private _localDelayOffset;
  24831. private _pausedDelay;
  24832. private _runtimeAnimations;
  24833. private _paused;
  24834. private _scene;
  24835. private _speedRatio;
  24836. private _weight;
  24837. private _syncRoot;
  24838. /**
  24839. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  24840. * This will only apply for non looping animation (default is true)
  24841. */
  24842. disposeOnEnd: boolean;
  24843. /**
  24844. * Gets a boolean indicating if the animation has started
  24845. */
  24846. animationStarted: boolean;
  24847. /**
  24848. * Observer raised when the animation ends
  24849. */
  24850. onAnimationEndObservable: Observable<Animatable>;
  24851. /**
  24852. * Observer raised when the animation loops
  24853. */
  24854. onAnimationLoopObservable: Observable<Animatable>;
  24855. /**
  24856. * Gets the root Animatable used to synchronize and normalize animations
  24857. */
  24858. get syncRoot(): Nullable<Animatable>;
  24859. /**
  24860. * Gets the current frame of the first RuntimeAnimation
  24861. * Used to synchronize Animatables
  24862. */
  24863. get masterFrame(): number;
  24864. /**
  24865. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  24866. */
  24867. get weight(): number;
  24868. set weight(value: number);
  24869. /**
  24870. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  24871. */
  24872. get speedRatio(): number;
  24873. set speedRatio(value: number);
  24874. /**
  24875. * Creates a new Animatable
  24876. * @param scene defines the hosting scene
  24877. * @param target defines the target object
  24878. * @param fromFrame defines the starting frame number (default is 0)
  24879. * @param toFrame defines the ending frame number (default is 100)
  24880. * @param loopAnimation defines if the animation must loop (default is false)
  24881. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  24882. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  24883. * @param animations defines a group of animation to add to the new Animatable
  24884. * @param onAnimationLoop defines a callback to call when animation loops
  24885. * @param isAdditive defines whether the animation should be evaluated additively
  24886. */
  24887. constructor(scene: Scene,
  24888. /** defines the target object */
  24889. target: any,
  24890. /** defines the starting frame number (default is 0) */
  24891. fromFrame?: number,
  24892. /** defines the ending frame number (default is 100) */
  24893. toFrame?: number,
  24894. /** defines if the animation must loop (default is false) */
  24895. loopAnimation?: boolean, speedRatio?: number,
  24896. /** defines a callback to call when animation ends if it is not looping */
  24897. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  24898. /** defines a callback to call when animation loops */
  24899. onAnimationLoop?: (() => void) | null | undefined,
  24900. /** defines whether the animation should be evaluated additively */
  24901. isAdditive?: boolean);
  24902. /**
  24903. * Synchronize and normalize current Animatable with a source Animatable
  24904. * This is useful when using animation weights and when animations are not of the same length
  24905. * @param root defines the root Animatable to synchronize with
  24906. * @returns the current Animatable
  24907. */
  24908. syncWith(root: Animatable): Animatable;
  24909. /**
  24910. * Gets the list of runtime animations
  24911. * @returns an array of RuntimeAnimation
  24912. */
  24913. getAnimations(): RuntimeAnimation[];
  24914. /**
  24915. * Adds more animations to the current animatable
  24916. * @param target defines the target of the animations
  24917. * @param animations defines the new animations to add
  24918. */
  24919. appendAnimations(target: any, animations: Animation[]): void;
  24920. /**
  24921. * Gets the source animation for a specific property
  24922. * @param property defines the propertyu to look for
  24923. * @returns null or the source animation for the given property
  24924. */
  24925. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  24926. /**
  24927. * Gets the runtime animation for a specific property
  24928. * @param property defines the propertyu to look for
  24929. * @returns null or the runtime animation for the given property
  24930. */
  24931. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  24932. /**
  24933. * Resets the animatable to its original state
  24934. */
  24935. reset(): void;
  24936. /**
  24937. * Allows the animatable to blend with current running animations
  24938. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24939. * @param blendingSpeed defines the blending speed to use
  24940. */
  24941. enableBlending(blendingSpeed: number): void;
  24942. /**
  24943. * Disable animation blending
  24944. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24945. */
  24946. disableBlending(): void;
  24947. /**
  24948. * Jump directly to a given frame
  24949. * @param frame defines the frame to jump to
  24950. */
  24951. goToFrame(frame: number): void;
  24952. /**
  24953. * Pause the animation
  24954. */
  24955. pause(): void;
  24956. /**
  24957. * Restart the animation
  24958. */
  24959. restart(): void;
  24960. private _raiseOnAnimationEnd;
  24961. /**
  24962. * Stop and delete the current animation
  24963. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  24964. * @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)
  24965. */
  24966. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  24967. /**
  24968. * Wait asynchronously for the animation to end
  24969. * @returns a promise which will be fullfilled when the animation ends
  24970. */
  24971. waitAsync(): Promise<Animatable>;
  24972. /** @hidden */
  24973. _animate(delay: number): boolean;
  24974. }
  24975. interface Scene {
  24976. /** @hidden */
  24977. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  24978. /** @hidden */
  24979. _processLateAnimationBindingsForMatrices(holder: {
  24980. totalWeight: number;
  24981. totalAdditiveWeight: number;
  24982. animations: RuntimeAnimation[];
  24983. additiveAnimations: RuntimeAnimation[];
  24984. originalValue: Matrix;
  24985. }): any;
  24986. /** @hidden */
  24987. _processLateAnimationBindingsForQuaternions(holder: {
  24988. totalWeight: number;
  24989. totalAdditiveWeight: number;
  24990. animations: RuntimeAnimation[];
  24991. additiveAnimations: RuntimeAnimation[];
  24992. originalValue: Quaternion;
  24993. }, refQuaternion: Quaternion): Quaternion;
  24994. /** @hidden */
  24995. _processLateAnimationBindings(): void;
  24996. /**
  24997. * Will start the animation sequence of a given target
  24998. * @param target defines the target
  24999. * @param from defines from which frame should animation start
  25000. * @param to defines until which frame should animation run.
  25001. * @param weight defines the weight to apply to the animation (1.0 by default)
  25002. * @param loop defines if the animation loops
  25003. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25004. * @param onAnimationEnd defines the function to be executed when the animation ends
  25005. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25006. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25007. * @param onAnimationLoop defines the callback to call when an animation loops
  25008. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25009. * @returns the animatable object created for this animation
  25010. */
  25011. 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;
  25012. /**
  25013. * Will start the animation sequence of a given target
  25014. * @param target defines the target
  25015. * @param from defines from which frame should animation start
  25016. * @param to defines until which frame should animation run.
  25017. * @param loop defines if the animation loops
  25018. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25019. * @param onAnimationEnd defines the function to be executed when the animation ends
  25020. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25021. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25022. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25023. * @param onAnimationLoop defines the callback to call when an animation loops
  25024. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25025. * @returns the animatable object created for this animation
  25026. */
  25027. 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;
  25028. /**
  25029. * Will start the animation sequence of a given target and its hierarchy
  25030. * @param target defines the target
  25031. * @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.
  25032. * @param from defines from which frame should animation start
  25033. * @param to defines until which frame should animation run.
  25034. * @param loop defines if the animation loops
  25035. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25036. * @param onAnimationEnd defines the function to be executed when the animation ends
  25037. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25038. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25039. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25040. * @param onAnimationLoop defines the callback to call when an animation loops
  25041. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25042. * @returns the list of created animatables
  25043. */
  25044. 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[];
  25045. /**
  25046. * Begin a new animation on a given node
  25047. * @param target defines the target where the animation will take place
  25048. * @param animations defines the list of animations to start
  25049. * @param from defines the initial value
  25050. * @param to defines the final value
  25051. * @param loop defines if you want animation to loop (off by default)
  25052. * @param speedRatio defines the speed ratio to apply to all animations
  25053. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25054. * @param onAnimationLoop defines the callback to call when an animation loops
  25055. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25056. * @returns the list of created animatables
  25057. */
  25058. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25059. /**
  25060. * Begin a new animation on a given node and its hierarchy
  25061. * @param target defines the root node where the animation will take place
  25062. * @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.
  25063. * @param animations defines the list of animations to start
  25064. * @param from defines the initial value
  25065. * @param to defines the final value
  25066. * @param loop defines if you want animation to loop (off by default)
  25067. * @param speedRatio defines the speed ratio to apply to all animations
  25068. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25069. * @param onAnimationLoop defines the callback to call when an animation loops
  25070. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25071. * @returns the list of animatables created for all nodes
  25072. */
  25073. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25074. /**
  25075. * Gets the animatable associated with a specific target
  25076. * @param target defines the target of the animatable
  25077. * @returns the required animatable if found
  25078. */
  25079. getAnimatableByTarget(target: any): Nullable<Animatable>;
  25080. /**
  25081. * Gets all animatables associated with a given target
  25082. * @param target defines the target to look animatables for
  25083. * @returns an array of Animatables
  25084. */
  25085. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  25086. /**
  25087. * Stops and removes all animations that have been applied to the scene
  25088. */
  25089. stopAllAnimations(): void;
  25090. /**
  25091. * Gets the current delta time used by animation engine
  25092. */
  25093. deltaTime: number;
  25094. }
  25095. interface Bone {
  25096. /**
  25097. * Copy an animation range from another bone
  25098. * @param source defines the source bone
  25099. * @param rangeName defines the range name to copy
  25100. * @param frameOffset defines the frame offset
  25101. * @param rescaleAsRequired defines if rescaling must be applied if required
  25102. * @param skelDimensionsRatio defines the scaling ratio
  25103. * @returns true if operation was successful
  25104. */
  25105. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  25106. }
  25107. }
  25108. declare module BABYLON {
  25109. /**
  25110. * Class used to override all child animations of a given target
  25111. */
  25112. export class AnimationPropertiesOverride {
  25113. /**
  25114. * Gets or sets a value indicating if animation blending must be used
  25115. */
  25116. enableBlending: boolean;
  25117. /**
  25118. * Gets or sets the blending speed to use when enableBlending is true
  25119. */
  25120. blendingSpeed: number;
  25121. /**
  25122. * Gets or sets the default loop mode to use
  25123. */
  25124. loopMode: number;
  25125. }
  25126. }
  25127. declare module BABYLON {
  25128. /**
  25129. * Class used to handle skinning animations
  25130. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25131. */
  25132. export class Skeleton implements IAnimatable {
  25133. /** defines the skeleton name */
  25134. name: string;
  25135. /** defines the skeleton Id */
  25136. id: string;
  25137. /**
  25138. * Defines the list of child bones
  25139. */
  25140. bones: Bone[];
  25141. /**
  25142. * Defines an estimate of the dimension of the skeleton at rest
  25143. */
  25144. dimensionsAtRest: Vector3;
  25145. /**
  25146. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25147. */
  25148. needInitialSkinMatrix: boolean;
  25149. /**
  25150. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25151. */
  25152. overrideMesh: Nullable<AbstractMesh>;
  25153. /**
  25154. * Gets the list of animations attached to this skeleton
  25155. */
  25156. animations: Array<Animation>;
  25157. private _scene;
  25158. private _isDirty;
  25159. private _transformMatrices;
  25160. private _transformMatrixTexture;
  25161. private _meshesWithPoseMatrix;
  25162. private _animatables;
  25163. private _identity;
  25164. private _synchronizedWithMesh;
  25165. private _ranges;
  25166. private _lastAbsoluteTransformsUpdateId;
  25167. private _canUseTextureForBones;
  25168. private _uniqueId;
  25169. /** @hidden */
  25170. _numBonesWithLinkedTransformNode: number;
  25171. /** @hidden */
  25172. _hasWaitingData: Nullable<boolean>;
  25173. /** @hidden */
  25174. _waitingOverrideMeshId: Nullable<string>;
  25175. /**
  25176. * Specifies if the skeleton should be serialized
  25177. */
  25178. doNotSerialize: boolean;
  25179. private _useTextureToStoreBoneMatrices;
  25180. /**
  25181. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  25182. * Please note that this option is not available if the hardware does not support it
  25183. */
  25184. get useTextureToStoreBoneMatrices(): boolean;
  25185. set useTextureToStoreBoneMatrices(value: boolean);
  25186. private _animationPropertiesOverride;
  25187. /**
  25188. * Gets or sets the animation properties override
  25189. */
  25190. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25191. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25192. /**
  25193. * List of inspectable custom properties (used by the Inspector)
  25194. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25195. */
  25196. inspectableCustomProperties: IInspectable[];
  25197. /**
  25198. * An observable triggered before computing the skeleton's matrices
  25199. */
  25200. onBeforeComputeObservable: Observable<Skeleton>;
  25201. /**
  25202. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  25203. */
  25204. get isUsingTextureForMatrices(): boolean;
  25205. /**
  25206. * Gets the unique ID of this skeleton
  25207. */
  25208. get uniqueId(): number;
  25209. /**
  25210. * Creates a new skeleton
  25211. * @param name defines the skeleton name
  25212. * @param id defines the skeleton Id
  25213. * @param scene defines the hosting scene
  25214. */
  25215. constructor(
  25216. /** defines the skeleton name */
  25217. name: string,
  25218. /** defines the skeleton Id */
  25219. id: string, scene: Scene);
  25220. /**
  25221. * Gets the current object class name.
  25222. * @return the class name
  25223. */
  25224. getClassName(): string;
  25225. /**
  25226. * Returns an array containing the root bones
  25227. * @returns an array containing the root bones
  25228. */
  25229. getChildren(): Array<Bone>;
  25230. /**
  25231. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  25232. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25233. * @returns a Float32Array containing matrices data
  25234. */
  25235. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  25236. /**
  25237. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  25238. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25239. * @returns a raw texture containing the data
  25240. */
  25241. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  25242. /**
  25243. * Gets the current hosting scene
  25244. * @returns a scene object
  25245. */
  25246. getScene(): Scene;
  25247. /**
  25248. * Gets a string representing the current skeleton data
  25249. * @param fullDetails defines a boolean indicating if we want a verbose version
  25250. * @returns a string representing the current skeleton data
  25251. */
  25252. toString(fullDetails?: boolean): string;
  25253. /**
  25254. * Get bone's index searching by name
  25255. * @param name defines bone's name to search for
  25256. * @return the indice of the bone. Returns -1 if not found
  25257. */
  25258. getBoneIndexByName(name: string): number;
  25259. /**
  25260. * Creater a new animation range
  25261. * @param name defines the name of the range
  25262. * @param from defines the start key
  25263. * @param to defines the end key
  25264. */
  25265. createAnimationRange(name: string, from: number, to: number): void;
  25266. /**
  25267. * Delete a specific animation range
  25268. * @param name defines the name of the range
  25269. * @param deleteFrames defines if frames must be removed as well
  25270. */
  25271. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25272. /**
  25273. * Gets a specific animation range
  25274. * @param name defines the name of the range to look for
  25275. * @returns the requested animation range or null if not found
  25276. */
  25277. getAnimationRange(name: string): Nullable<AnimationRange>;
  25278. /**
  25279. * Gets the list of all animation ranges defined on this skeleton
  25280. * @returns an array
  25281. */
  25282. getAnimationRanges(): Nullable<AnimationRange>[];
  25283. /**
  25284. * Copy animation range from a source skeleton.
  25285. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  25286. * @param source defines the source skeleton
  25287. * @param name defines the name of the range to copy
  25288. * @param rescaleAsRequired defines if rescaling must be applied if required
  25289. * @returns true if operation was successful
  25290. */
  25291. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  25292. /**
  25293. * Forces the skeleton to go to rest pose
  25294. */
  25295. returnToRest(): void;
  25296. private _getHighestAnimationFrame;
  25297. /**
  25298. * Begin a specific animation range
  25299. * @param name defines the name of the range to start
  25300. * @param loop defines if looping must be turned on (false by default)
  25301. * @param speedRatio defines the speed ratio to apply (1 by default)
  25302. * @param onAnimationEnd defines a callback which will be called when animation will end
  25303. * @returns a new animatable
  25304. */
  25305. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25306. /**
  25307. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  25308. * @param skeleton defines the Skeleton containing the animation range to convert
  25309. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  25310. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  25311. * @returns the original skeleton
  25312. */
  25313. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  25314. /** @hidden */
  25315. _markAsDirty(): void;
  25316. /** @hidden */
  25317. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25318. /** @hidden */
  25319. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25320. private _computeTransformMatrices;
  25321. /**
  25322. * Build all resources required to render a skeleton
  25323. */
  25324. prepare(): void;
  25325. /**
  25326. * Gets the list of animatables currently running for this skeleton
  25327. * @returns an array of animatables
  25328. */
  25329. getAnimatables(): IAnimatable[];
  25330. /**
  25331. * Clone the current skeleton
  25332. * @param name defines the name of the new skeleton
  25333. * @param id defines the id of the new skeleton
  25334. * @returns the new skeleton
  25335. */
  25336. clone(name: string, id?: string): Skeleton;
  25337. /**
  25338. * Enable animation blending for this skeleton
  25339. * @param blendingSpeed defines the blending speed to apply
  25340. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25341. */
  25342. enableBlending(blendingSpeed?: number): void;
  25343. /**
  25344. * Releases all resources associated with the current skeleton
  25345. */
  25346. dispose(): void;
  25347. /**
  25348. * Serialize the skeleton in a JSON object
  25349. * @returns a JSON object
  25350. */
  25351. serialize(): any;
  25352. /**
  25353. * Creates a new skeleton from serialized data
  25354. * @param parsedSkeleton defines the serialized data
  25355. * @param scene defines the hosting scene
  25356. * @returns a new skeleton
  25357. */
  25358. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  25359. /**
  25360. * Compute all node absolute transforms
  25361. * @param forceUpdate defines if computation must be done even if cache is up to date
  25362. */
  25363. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  25364. /**
  25365. * Gets the root pose matrix
  25366. * @returns a matrix
  25367. */
  25368. getPoseMatrix(): Nullable<Matrix>;
  25369. /**
  25370. * Sorts bones per internal index
  25371. */
  25372. sortBones(): void;
  25373. private _sortBones;
  25374. /**
  25375. * Set the current local matrix as the restPose for all bones in the skeleton.
  25376. */
  25377. setCurrentPoseAsRest(): void;
  25378. }
  25379. }
  25380. declare module BABYLON {
  25381. /**
  25382. * Class used to store bone information
  25383. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25384. */
  25385. export class Bone extends Node {
  25386. /**
  25387. * defines the bone name
  25388. */
  25389. name: string;
  25390. private static _tmpVecs;
  25391. private static _tmpQuat;
  25392. private static _tmpMats;
  25393. /**
  25394. * Gets the list of child bones
  25395. */
  25396. children: Bone[];
  25397. /** Gets the animations associated with this bone */
  25398. animations: Animation[];
  25399. /**
  25400. * Gets or sets bone length
  25401. */
  25402. length: number;
  25403. /**
  25404. * @hidden Internal only
  25405. * Set this value to map this bone to a different index in the transform matrices
  25406. * Set this value to -1 to exclude the bone from the transform matrices
  25407. */
  25408. _index: Nullable<number>;
  25409. private _skeleton;
  25410. private _localMatrix;
  25411. private _restPose;
  25412. private _bindPose;
  25413. private _baseMatrix;
  25414. private _absoluteTransform;
  25415. private _invertedAbsoluteTransform;
  25416. private _parent;
  25417. private _scalingDeterminant;
  25418. private _worldTransform;
  25419. private _localScaling;
  25420. private _localRotation;
  25421. private _localPosition;
  25422. private _needToDecompose;
  25423. private _needToCompose;
  25424. /** @hidden */
  25425. _linkedTransformNode: Nullable<TransformNode>;
  25426. /** @hidden */
  25427. _waitingTransformNodeId: Nullable<string>;
  25428. /** @hidden */
  25429. get _matrix(): Matrix;
  25430. /** @hidden */
  25431. set _matrix(value: Matrix);
  25432. /**
  25433. * Create a new bone
  25434. * @param name defines the bone name
  25435. * @param skeleton defines the parent skeleton
  25436. * @param parentBone defines the parent (can be null if the bone is the root)
  25437. * @param localMatrix defines the local matrix
  25438. * @param restPose defines the rest pose matrix
  25439. * @param baseMatrix defines the base matrix
  25440. * @param index defines index of the bone in the hiearchy
  25441. */
  25442. constructor(
  25443. /**
  25444. * defines the bone name
  25445. */
  25446. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  25447. /**
  25448. * Gets the current object class name.
  25449. * @return the class name
  25450. */
  25451. getClassName(): string;
  25452. /**
  25453. * Gets the parent skeleton
  25454. * @returns a skeleton
  25455. */
  25456. getSkeleton(): Skeleton;
  25457. /**
  25458. * Gets parent bone
  25459. * @returns a bone or null if the bone is the root of the bone hierarchy
  25460. */
  25461. getParent(): Nullable<Bone>;
  25462. /**
  25463. * Returns an array containing the root bones
  25464. * @returns an array containing the root bones
  25465. */
  25466. getChildren(): Array<Bone>;
  25467. /**
  25468. * Gets the node index in matrix array generated for rendering
  25469. * @returns the node index
  25470. */
  25471. getIndex(): number;
  25472. /**
  25473. * Sets the parent bone
  25474. * @param parent defines the parent (can be null if the bone is the root)
  25475. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25476. */
  25477. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  25478. /**
  25479. * Gets the local matrix
  25480. * @returns a matrix
  25481. */
  25482. getLocalMatrix(): Matrix;
  25483. /**
  25484. * Gets the base matrix (initial matrix which remains unchanged)
  25485. * @returns a matrix
  25486. */
  25487. getBaseMatrix(): Matrix;
  25488. /**
  25489. * Gets the rest pose matrix
  25490. * @returns a matrix
  25491. */
  25492. getRestPose(): Matrix;
  25493. /**
  25494. * Sets the rest pose matrix
  25495. * @param matrix the local-space rest pose to set for this bone
  25496. */
  25497. setRestPose(matrix: Matrix): void;
  25498. /**
  25499. * Gets the bind pose matrix
  25500. * @returns the bind pose matrix
  25501. */
  25502. getBindPose(): Matrix;
  25503. /**
  25504. * Sets the bind pose matrix
  25505. * @param matrix the local-space bind pose to set for this bone
  25506. */
  25507. setBindPose(matrix: Matrix): void;
  25508. /**
  25509. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  25510. */
  25511. getWorldMatrix(): Matrix;
  25512. /**
  25513. * Sets the local matrix to rest pose matrix
  25514. */
  25515. returnToRest(): void;
  25516. /**
  25517. * Gets the inverse of the absolute transform matrix.
  25518. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  25519. * @returns a matrix
  25520. */
  25521. getInvertedAbsoluteTransform(): Matrix;
  25522. /**
  25523. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  25524. * @returns a matrix
  25525. */
  25526. getAbsoluteTransform(): Matrix;
  25527. /**
  25528. * Links with the given transform node.
  25529. * The local matrix of this bone is copied from the transform node every frame.
  25530. * @param transformNode defines the transform node to link to
  25531. */
  25532. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  25533. /**
  25534. * Gets the node used to drive the bone's transformation
  25535. * @returns a transform node or null
  25536. */
  25537. getTransformNode(): Nullable<TransformNode>;
  25538. /** Gets or sets current position (in local space) */
  25539. get position(): Vector3;
  25540. set position(newPosition: Vector3);
  25541. /** Gets or sets current rotation (in local space) */
  25542. get rotation(): Vector3;
  25543. set rotation(newRotation: Vector3);
  25544. /** Gets or sets current rotation quaternion (in local space) */
  25545. get rotationQuaternion(): Quaternion;
  25546. set rotationQuaternion(newRotation: Quaternion);
  25547. /** Gets or sets current scaling (in local space) */
  25548. get scaling(): Vector3;
  25549. set scaling(newScaling: Vector3);
  25550. /**
  25551. * Gets the animation properties override
  25552. */
  25553. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25554. private _decompose;
  25555. private _compose;
  25556. /**
  25557. * Update the base and local matrices
  25558. * @param matrix defines the new base or local matrix
  25559. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25560. * @param updateLocalMatrix defines if the local matrix should be updated
  25561. */
  25562. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  25563. /** @hidden */
  25564. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  25565. /**
  25566. * Flag the bone as dirty (Forcing it to update everything)
  25567. */
  25568. markAsDirty(): void;
  25569. /** @hidden */
  25570. _markAsDirtyAndCompose(): void;
  25571. private _markAsDirtyAndDecompose;
  25572. /**
  25573. * Translate the bone in local or world space
  25574. * @param vec The amount to translate the bone
  25575. * @param space The space that the translation is in
  25576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25577. */
  25578. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25579. /**
  25580. * Set the postion of the bone in local or world space
  25581. * @param position The position to set the bone
  25582. * @param space The space that the position is in
  25583. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25584. */
  25585. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25586. /**
  25587. * Set the absolute position of the bone (world space)
  25588. * @param position The position to set the bone
  25589. * @param mesh The mesh that this bone is attached to
  25590. */
  25591. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  25592. /**
  25593. * Scale the bone on the x, y and z axes (in local space)
  25594. * @param x The amount to scale the bone on the x axis
  25595. * @param y The amount to scale the bone on the y axis
  25596. * @param z The amount to scale the bone on the z axis
  25597. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  25598. */
  25599. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  25600. /**
  25601. * Set the bone scaling in local space
  25602. * @param scale defines the scaling vector
  25603. */
  25604. setScale(scale: Vector3): void;
  25605. /**
  25606. * Gets the current scaling in local space
  25607. * @returns the current scaling vector
  25608. */
  25609. getScale(): Vector3;
  25610. /**
  25611. * Gets the current scaling in local space and stores it in a target vector
  25612. * @param result defines the target vector
  25613. */
  25614. getScaleToRef(result: Vector3): void;
  25615. /**
  25616. * Set the yaw, pitch, and roll of the bone in local or world space
  25617. * @param yaw The rotation of the bone on the y axis
  25618. * @param pitch The rotation of the bone on the x axis
  25619. * @param roll The rotation of the bone on the z axis
  25620. * @param space The space that the axes of rotation are in
  25621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25622. */
  25623. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  25624. /**
  25625. * Add a rotation to the bone on an axis in local or world space
  25626. * @param axis The axis to rotate the bone on
  25627. * @param amount The amount to rotate the bone
  25628. * @param space The space that the axis is in
  25629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25630. */
  25631. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  25632. /**
  25633. * Set the rotation of the bone to a particular axis angle in local or world space
  25634. * @param axis The axis to rotate the bone on
  25635. * @param angle The angle that the bone should be rotated to
  25636. * @param space The space that the axis is in
  25637. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25638. */
  25639. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  25640. /**
  25641. * Set the euler rotation of the bone in local or world space
  25642. * @param rotation The euler rotation that the bone should be set to
  25643. * @param space The space that the rotation is in
  25644. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25645. */
  25646. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25647. /**
  25648. * Set the quaternion rotation of the bone in local or world space
  25649. * @param quat The quaternion rotation that the bone should be set to
  25650. * @param space The space that the rotation is in
  25651. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25652. */
  25653. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  25654. /**
  25655. * Set the rotation matrix of the bone in local or world space
  25656. * @param rotMat The rotation matrix that the bone should be set to
  25657. * @param space The space that the rotation is in
  25658. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25659. */
  25660. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  25661. private _rotateWithMatrix;
  25662. private _getNegativeRotationToRef;
  25663. /**
  25664. * Get the position of the bone in local or world space
  25665. * @param space The space that the returned position is in
  25666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25667. * @returns The position of the bone
  25668. */
  25669. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25670. /**
  25671. * Copy the position of the bone to a vector3 in local or world space
  25672. * @param space The space that the returned position is in
  25673. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25674. * @param result The vector3 to copy the position to
  25675. */
  25676. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  25677. /**
  25678. * Get the absolute position of the bone (world space)
  25679. * @param mesh The mesh that this bone is attached to
  25680. * @returns The absolute position of the bone
  25681. */
  25682. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  25683. /**
  25684. * Copy the absolute position of the bone (world space) to the result param
  25685. * @param mesh The mesh that this bone is attached to
  25686. * @param result The vector3 to copy the absolute position to
  25687. */
  25688. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  25689. /**
  25690. * Compute the absolute transforms of this bone and its children
  25691. */
  25692. computeAbsoluteTransforms(): void;
  25693. /**
  25694. * Get the world direction from an axis that is in the local space of the bone
  25695. * @param localAxis The local direction that is used to compute the world direction
  25696. * @param mesh The mesh that this bone is attached to
  25697. * @returns The world direction
  25698. */
  25699. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25700. /**
  25701. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  25702. * @param localAxis The local direction that is used to compute the world direction
  25703. * @param mesh The mesh that this bone is attached to
  25704. * @param result The vector3 that the world direction will be copied to
  25705. */
  25706. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25707. /**
  25708. * Get the euler rotation of the bone in local or world space
  25709. * @param space The space that the rotation should be in
  25710. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25711. * @returns The euler rotation
  25712. */
  25713. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25714. /**
  25715. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  25716. * @param space The space that the rotation should be in
  25717. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25718. * @param result The vector3 that the rotation should be copied to
  25719. */
  25720. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25721. /**
  25722. * Get the quaternion rotation of the bone in either local or world space
  25723. * @param space The space that the rotation should be in
  25724. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25725. * @returns The quaternion rotation
  25726. */
  25727. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  25728. /**
  25729. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  25730. * @param space The space that the rotation should be in
  25731. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25732. * @param result The quaternion that the rotation should be copied to
  25733. */
  25734. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  25735. /**
  25736. * Get the rotation matrix of the bone in local or world space
  25737. * @param space The space that the rotation should be in
  25738. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25739. * @returns The rotation matrix
  25740. */
  25741. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  25742. /**
  25743. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  25744. * @param space The space that the rotation should be in
  25745. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25746. * @param result The quaternion that the rotation should be copied to
  25747. */
  25748. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  25749. /**
  25750. * Get the world position of a point that is in the local space of the bone
  25751. * @param position The local position
  25752. * @param mesh The mesh that this bone is attached to
  25753. * @returns The world position
  25754. */
  25755. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25756. /**
  25757. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  25758. * @param position The local position
  25759. * @param mesh The mesh that this bone is attached to
  25760. * @param result The vector3 that the world position should be copied to
  25761. */
  25762. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25763. /**
  25764. * Get the local position of a point that is in world space
  25765. * @param position The world position
  25766. * @param mesh The mesh that this bone is attached to
  25767. * @returns The local position
  25768. */
  25769. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25770. /**
  25771. * Get the local position of a point that is in world space and copy it to the result param
  25772. * @param position The world position
  25773. * @param mesh The mesh that this bone is attached to
  25774. * @param result The vector3 that the local position should be copied to
  25775. */
  25776. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25777. /**
  25778. * Set the current local matrix as the restPose for this bone.
  25779. */
  25780. setCurrentPoseAsRest(): void;
  25781. }
  25782. }
  25783. declare module BABYLON {
  25784. /**
  25785. * 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.
  25786. * @see https://doc.babylonjs.com/how_to/transformnode
  25787. */
  25788. export class TransformNode extends Node {
  25789. /**
  25790. * Object will not rotate to face the camera
  25791. */
  25792. static BILLBOARDMODE_NONE: number;
  25793. /**
  25794. * Object will rotate to face the camera but only on the x axis
  25795. */
  25796. static BILLBOARDMODE_X: number;
  25797. /**
  25798. * Object will rotate to face the camera but only on the y axis
  25799. */
  25800. static BILLBOARDMODE_Y: number;
  25801. /**
  25802. * Object will rotate to face the camera but only on the z axis
  25803. */
  25804. static BILLBOARDMODE_Z: number;
  25805. /**
  25806. * Object will rotate to face the camera
  25807. */
  25808. static BILLBOARDMODE_ALL: number;
  25809. /**
  25810. * Object will rotate to face the camera's position instead of orientation
  25811. */
  25812. static BILLBOARDMODE_USE_POSITION: number;
  25813. private static _TmpRotation;
  25814. private static _TmpScaling;
  25815. private static _TmpTranslation;
  25816. private _forward;
  25817. private _forwardInverted;
  25818. private _up;
  25819. private _right;
  25820. private _rightInverted;
  25821. private _position;
  25822. private _rotation;
  25823. private _rotationQuaternion;
  25824. protected _scaling: Vector3;
  25825. protected _isDirty: boolean;
  25826. private _transformToBoneReferal;
  25827. private _isAbsoluteSynced;
  25828. private _billboardMode;
  25829. /**
  25830. * Gets or sets the billboard mode. Default is 0.
  25831. *
  25832. * | Value | Type | Description |
  25833. * | --- | --- | --- |
  25834. * | 0 | BILLBOARDMODE_NONE | |
  25835. * | 1 | BILLBOARDMODE_X | |
  25836. * | 2 | BILLBOARDMODE_Y | |
  25837. * | 4 | BILLBOARDMODE_Z | |
  25838. * | 7 | BILLBOARDMODE_ALL | |
  25839. *
  25840. */
  25841. get billboardMode(): number;
  25842. set billboardMode(value: number);
  25843. private _preserveParentRotationForBillboard;
  25844. /**
  25845. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  25846. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  25847. */
  25848. get preserveParentRotationForBillboard(): boolean;
  25849. set preserveParentRotationForBillboard(value: boolean);
  25850. /**
  25851. * 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
  25852. */
  25853. scalingDeterminant: number;
  25854. private _infiniteDistance;
  25855. /**
  25856. * Gets or sets the distance of the object to max, often used by skybox
  25857. */
  25858. get infiniteDistance(): boolean;
  25859. set infiniteDistance(value: boolean);
  25860. /**
  25861. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  25862. * By default the system will update normals to compensate
  25863. */
  25864. ignoreNonUniformScaling: boolean;
  25865. /**
  25866. * 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
  25867. */
  25868. reIntegrateRotationIntoRotationQuaternion: boolean;
  25869. /** @hidden */
  25870. _poseMatrix: Nullable<Matrix>;
  25871. /** @hidden */
  25872. _localMatrix: Matrix;
  25873. private _usePivotMatrix;
  25874. private _absolutePosition;
  25875. private _absoluteScaling;
  25876. private _absoluteRotationQuaternion;
  25877. private _pivotMatrix;
  25878. private _pivotMatrixInverse;
  25879. /** @hidden */
  25880. _postMultiplyPivotMatrix: boolean;
  25881. protected _isWorldMatrixFrozen: boolean;
  25882. /** @hidden */
  25883. _indexInSceneTransformNodesArray: number;
  25884. /**
  25885. * An event triggered after the world matrix is updated
  25886. */
  25887. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  25888. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  25889. /**
  25890. * Gets a string identifying the name of the class
  25891. * @returns "TransformNode" string
  25892. */
  25893. getClassName(): string;
  25894. /**
  25895. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  25896. */
  25897. get position(): Vector3;
  25898. set position(newPosition: Vector3);
  25899. /**
  25900. * 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)).
  25901. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  25902. */
  25903. get rotation(): Vector3;
  25904. set rotation(newRotation: Vector3);
  25905. /**
  25906. * 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)).
  25907. */
  25908. get scaling(): Vector3;
  25909. set scaling(newScaling: Vector3);
  25910. /**
  25911. * 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).
  25912. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  25913. */
  25914. get rotationQuaternion(): Nullable<Quaternion>;
  25915. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  25916. /**
  25917. * The forward direction of that transform in world space.
  25918. */
  25919. get forward(): Vector3;
  25920. /**
  25921. * The up direction of that transform in world space.
  25922. */
  25923. get up(): Vector3;
  25924. /**
  25925. * The right direction of that transform in world space.
  25926. */
  25927. get right(): Vector3;
  25928. /**
  25929. * Copies the parameter passed Matrix into the mesh Pose matrix.
  25930. * @param matrix the matrix to copy the pose from
  25931. * @returns this TransformNode.
  25932. */
  25933. updatePoseMatrix(matrix: Matrix): TransformNode;
  25934. /**
  25935. * Returns the mesh Pose matrix.
  25936. * @returns the pose matrix
  25937. */
  25938. getPoseMatrix(): Matrix;
  25939. /** @hidden */
  25940. _isSynchronized(): boolean;
  25941. /** @hidden */
  25942. _initCache(): void;
  25943. /**
  25944. * Flag the transform node as dirty (Forcing it to update everything)
  25945. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  25946. * @returns this transform node
  25947. */
  25948. markAsDirty(property: string): TransformNode;
  25949. /**
  25950. * Returns the current mesh absolute position.
  25951. * Returns a Vector3.
  25952. */
  25953. get absolutePosition(): Vector3;
  25954. /**
  25955. * Returns the current mesh absolute scaling.
  25956. * Returns a Vector3.
  25957. */
  25958. get absoluteScaling(): Vector3;
  25959. /**
  25960. * Returns the current mesh absolute rotation.
  25961. * Returns a Quaternion.
  25962. */
  25963. get absoluteRotationQuaternion(): Quaternion;
  25964. /**
  25965. * Sets a new matrix to apply before all other transformation
  25966. * @param matrix defines the transform matrix
  25967. * @returns the current TransformNode
  25968. */
  25969. setPreTransformMatrix(matrix: Matrix): TransformNode;
  25970. /**
  25971. * Sets a new pivot matrix to the current node
  25972. * @param matrix defines the new pivot matrix to use
  25973. * @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
  25974. * @returns the current TransformNode
  25975. */
  25976. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  25977. /**
  25978. * Returns the mesh pivot matrix.
  25979. * Default : Identity.
  25980. * @returns the matrix
  25981. */
  25982. getPivotMatrix(): Matrix;
  25983. /**
  25984. * Instantiate (when possible) or clone that node with its hierarchy
  25985. * @param newParent defines the new parent to use for the instance (or clone)
  25986. * @param options defines options to configure how copy is done
  25987. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  25988. * @returns an instance (or a clone) of the current node with its hiearchy
  25989. */
  25990. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25991. doNotInstantiate: boolean;
  25992. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25993. /**
  25994. * Prevents the World matrix to be computed any longer
  25995. * @param newWorldMatrix defines an optional matrix to use as world matrix
  25996. * @returns the TransformNode.
  25997. */
  25998. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  25999. /**
  26000. * Allows back the World matrix computation.
  26001. * @returns the TransformNode.
  26002. */
  26003. unfreezeWorldMatrix(): this;
  26004. /**
  26005. * True if the World matrix has been frozen.
  26006. */
  26007. get isWorldMatrixFrozen(): boolean;
  26008. /**
  26009. * Retuns the mesh absolute position in the World.
  26010. * @returns a Vector3.
  26011. */
  26012. getAbsolutePosition(): Vector3;
  26013. /**
  26014. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26015. * @param absolutePosition the absolute position to set
  26016. * @returns the TransformNode.
  26017. */
  26018. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26019. /**
  26020. * Sets the mesh position in its local space.
  26021. * @param vector3 the position to set in localspace
  26022. * @returns the TransformNode.
  26023. */
  26024. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26025. /**
  26026. * Returns the mesh position in the local space from the current World matrix values.
  26027. * @returns a new Vector3.
  26028. */
  26029. getPositionExpressedInLocalSpace(): Vector3;
  26030. /**
  26031. * Translates the mesh along the passed Vector3 in its local space.
  26032. * @param vector3 the distance to translate in localspace
  26033. * @returns the TransformNode.
  26034. */
  26035. locallyTranslate(vector3: Vector3): TransformNode;
  26036. private static _lookAtVectorCache;
  26037. /**
  26038. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26039. * @param targetPoint the position (must be in same space as current mesh) to look at
  26040. * @param yawCor optional yaw (y-axis) correction in radians
  26041. * @param pitchCor optional pitch (x-axis) correction in radians
  26042. * @param rollCor optional roll (z-axis) correction in radians
  26043. * @param space the choosen space of the target
  26044. * @returns the TransformNode.
  26045. */
  26046. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26047. /**
  26048. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26049. * This Vector3 is expressed in the World space.
  26050. * @param localAxis axis to rotate
  26051. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26052. */
  26053. getDirection(localAxis: Vector3): Vector3;
  26054. /**
  26055. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26056. * localAxis is expressed in the mesh local space.
  26057. * result is computed in the Wordl space from the mesh World matrix.
  26058. * @param localAxis axis to rotate
  26059. * @param result the resulting transformnode
  26060. * @returns this TransformNode.
  26061. */
  26062. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26063. /**
  26064. * Sets this transform node rotation to the given local axis.
  26065. * @param localAxis the axis in local space
  26066. * @param yawCor optional yaw (y-axis) correction in radians
  26067. * @param pitchCor optional pitch (x-axis) correction in radians
  26068. * @param rollCor optional roll (z-axis) correction in radians
  26069. * @returns this TransformNode
  26070. */
  26071. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  26072. /**
  26073. * Sets a new pivot point to the current node
  26074. * @param point defines the new pivot point to use
  26075. * @param space defines if the point is in world or local space (local by default)
  26076. * @returns the current TransformNode
  26077. */
  26078. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26079. /**
  26080. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26081. * @returns the pivot point
  26082. */
  26083. getPivotPoint(): Vector3;
  26084. /**
  26085. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26086. * @param result the vector3 to store the result
  26087. * @returns this TransformNode.
  26088. */
  26089. getPivotPointToRef(result: Vector3): TransformNode;
  26090. /**
  26091. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26092. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  26093. */
  26094. getAbsolutePivotPoint(): Vector3;
  26095. /**
  26096. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26097. * @param result vector3 to store the result
  26098. * @returns this TransformNode.
  26099. */
  26100. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26101. /**
  26102. * Defines the passed node as the parent of the current node.
  26103. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26104. * @see https://doc.babylonjs.com/how_to/parenting
  26105. * @param node the node ot set as the parent
  26106. * @returns this TransformNode.
  26107. */
  26108. setParent(node: Nullable<Node>): TransformNode;
  26109. private _nonUniformScaling;
  26110. /**
  26111. * True if the scaling property of this object is non uniform eg. (1,2,1)
  26112. */
  26113. get nonUniformScaling(): boolean;
  26114. /** @hidden */
  26115. _updateNonUniformScalingState(value: boolean): boolean;
  26116. /**
  26117. * Attach the current TransformNode to another TransformNode associated with a bone
  26118. * @param bone Bone affecting the TransformNode
  26119. * @param affectedTransformNode TransformNode associated with the bone
  26120. * @returns this object
  26121. */
  26122. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26123. /**
  26124. * Detach the transform node if its associated with a bone
  26125. * @returns this object
  26126. */
  26127. detachFromBone(): TransformNode;
  26128. private static _rotationAxisCache;
  26129. /**
  26130. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26131. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26132. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26133. * The passed axis is also normalized.
  26134. * @param axis the axis to rotate around
  26135. * @param amount the amount to rotate in radians
  26136. * @param space Space to rotate in (Default: local)
  26137. * @returns the TransformNode.
  26138. */
  26139. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26140. /**
  26141. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26142. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26143. * The passed axis is also normalized. .
  26144. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26145. * @param point the point to rotate around
  26146. * @param axis the axis to rotate around
  26147. * @param amount the amount to rotate in radians
  26148. * @returns the TransformNode
  26149. */
  26150. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26151. /**
  26152. * Translates the mesh along the axis vector for the passed distance in the given space.
  26153. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26154. * @param axis the axis to translate in
  26155. * @param distance the distance to translate
  26156. * @param space Space to rotate in (Default: local)
  26157. * @returns the TransformNode.
  26158. */
  26159. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26160. /**
  26161. * Adds a rotation step to the mesh current rotation.
  26162. * x, y, z are Euler angles expressed in radians.
  26163. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26164. * This means this rotation is made in the mesh local space only.
  26165. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26166. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26167. * ```javascript
  26168. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26169. * ```
  26170. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26171. * 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.
  26172. * @param x Rotation to add
  26173. * @param y Rotation to add
  26174. * @param z Rotation to add
  26175. * @returns the TransformNode.
  26176. */
  26177. addRotation(x: number, y: number, z: number): TransformNode;
  26178. /**
  26179. * @hidden
  26180. */
  26181. protected _getEffectiveParent(): Nullable<Node>;
  26182. /**
  26183. * Computes the world matrix of the node
  26184. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26185. * @returns the world matrix
  26186. */
  26187. computeWorldMatrix(force?: boolean): Matrix;
  26188. /**
  26189. * Resets this nodeTransform's local matrix to Matrix.Identity().
  26190. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  26191. */
  26192. resetLocalMatrix(independentOfChildren?: boolean): void;
  26193. protected _afterComputeWorldMatrix(): void;
  26194. /**
  26195. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26196. * @param func callback function to add
  26197. *
  26198. * @returns the TransformNode.
  26199. */
  26200. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26201. /**
  26202. * Removes a registered callback function.
  26203. * @param func callback function to remove
  26204. * @returns the TransformNode.
  26205. */
  26206. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26207. /**
  26208. * Gets the position of the current mesh in camera space
  26209. * @param camera defines the camera to use
  26210. * @returns a position
  26211. */
  26212. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  26213. /**
  26214. * Returns the distance from the mesh to the active camera
  26215. * @param camera defines the camera to use
  26216. * @returns the distance
  26217. */
  26218. getDistanceToCamera(camera?: Nullable<Camera>): number;
  26219. /**
  26220. * Clone the current transform node
  26221. * @param name Name of the new clone
  26222. * @param newParent New parent for the clone
  26223. * @param doNotCloneChildren Do not clone children hierarchy
  26224. * @returns the new transform node
  26225. */
  26226. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  26227. /**
  26228. * Serializes the objects information.
  26229. * @param currentSerializationObject defines the object to serialize in
  26230. * @returns the serialized object
  26231. */
  26232. serialize(currentSerializationObject?: any): any;
  26233. /**
  26234. * Returns a new TransformNode object parsed from the source provided.
  26235. * @param parsedTransformNode is the source.
  26236. * @param scene the scne the object belongs to
  26237. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  26238. * @returns a new TransformNode object parsed from the source provided.
  26239. */
  26240. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  26241. /**
  26242. * Get all child-transformNodes of this node
  26243. * @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
  26244. * @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
  26245. * @returns an array of TransformNode
  26246. */
  26247. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  26248. /**
  26249. * Releases resources associated with this transform node.
  26250. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26251. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26252. */
  26253. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26254. /**
  26255. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26256. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26257. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26258. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26259. * @returns the current mesh
  26260. */
  26261. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  26262. private _syncAbsoluteScalingAndRotation;
  26263. }
  26264. }
  26265. declare module BABYLON {
  26266. /**
  26267. * Defines the types of pose enabled controllers that are supported
  26268. */
  26269. export enum PoseEnabledControllerType {
  26270. /**
  26271. * HTC Vive
  26272. */
  26273. VIVE = 0,
  26274. /**
  26275. * Oculus Rift
  26276. */
  26277. OCULUS = 1,
  26278. /**
  26279. * Windows mixed reality
  26280. */
  26281. WINDOWS = 2,
  26282. /**
  26283. * Samsung gear VR
  26284. */
  26285. GEAR_VR = 3,
  26286. /**
  26287. * Google Daydream
  26288. */
  26289. DAYDREAM = 4,
  26290. /**
  26291. * Generic
  26292. */
  26293. GENERIC = 5
  26294. }
  26295. /**
  26296. * Defines the MutableGamepadButton interface for the state of a gamepad button
  26297. */
  26298. export interface MutableGamepadButton {
  26299. /**
  26300. * Value of the button/trigger
  26301. */
  26302. value: number;
  26303. /**
  26304. * If the button/trigger is currently touched
  26305. */
  26306. touched: boolean;
  26307. /**
  26308. * If the button/trigger is currently pressed
  26309. */
  26310. pressed: boolean;
  26311. }
  26312. /**
  26313. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  26314. * @hidden
  26315. */
  26316. export interface ExtendedGamepadButton extends GamepadButton {
  26317. /**
  26318. * If the button/trigger is currently pressed
  26319. */
  26320. readonly pressed: boolean;
  26321. /**
  26322. * If the button/trigger is currently touched
  26323. */
  26324. readonly touched: boolean;
  26325. /**
  26326. * Value of the button/trigger
  26327. */
  26328. readonly value: number;
  26329. }
  26330. /** @hidden */
  26331. export interface _GamePadFactory {
  26332. /**
  26333. * Returns whether or not the current gamepad can be created for this type of controller.
  26334. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26335. * @returns true if it can be created, otherwise false
  26336. */
  26337. canCreate(gamepadInfo: any): boolean;
  26338. /**
  26339. * Creates a new instance of the Gamepad.
  26340. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26341. * @returns the new gamepad instance
  26342. */
  26343. create(gamepadInfo: any): Gamepad;
  26344. }
  26345. /**
  26346. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26347. */
  26348. export class PoseEnabledControllerHelper {
  26349. /** @hidden */
  26350. static _ControllerFactories: _GamePadFactory[];
  26351. /** @hidden */
  26352. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  26353. /**
  26354. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26355. * @param vrGamepad the gamepad to initialized
  26356. * @returns a vr controller of the type the gamepad identified as
  26357. */
  26358. static InitiateController(vrGamepad: any): Gamepad;
  26359. }
  26360. /**
  26361. * Defines the PoseEnabledController object that contains state of a vr capable controller
  26362. */
  26363. export class PoseEnabledController extends Gamepad implements PoseControlled {
  26364. /**
  26365. * If the controller is used in a webXR session
  26366. */
  26367. isXR: boolean;
  26368. private _deviceRoomPosition;
  26369. private _deviceRoomRotationQuaternion;
  26370. /**
  26371. * The device position in babylon space
  26372. */
  26373. devicePosition: Vector3;
  26374. /**
  26375. * The device rotation in babylon space
  26376. */
  26377. deviceRotationQuaternion: Quaternion;
  26378. /**
  26379. * The scale factor of the device in babylon space
  26380. */
  26381. deviceScaleFactor: number;
  26382. /**
  26383. * (Likely devicePosition should be used instead) The device position in its room space
  26384. */
  26385. position: Vector3;
  26386. /**
  26387. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  26388. */
  26389. rotationQuaternion: Quaternion;
  26390. /**
  26391. * The type of controller (Eg. Windows mixed reality)
  26392. */
  26393. controllerType: PoseEnabledControllerType;
  26394. protected _calculatedPosition: Vector3;
  26395. private _calculatedRotation;
  26396. /**
  26397. * The raw pose from the device
  26398. */
  26399. rawPose: DevicePose;
  26400. private _trackPosition;
  26401. private _maxRotationDistFromHeadset;
  26402. private _draggedRoomRotation;
  26403. /**
  26404. * @hidden
  26405. */
  26406. _disableTrackPosition(fixedPosition: Vector3): void;
  26407. /**
  26408. * Internal, the mesh attached to the controller
  26409. * @hidden
  26410. */
  26411. _mesh: Nullable<AbstractMesh>;
  26412. private _poseControlledCamera;
  26413. private _leftHandSystemQuaternion;
  26414. /**
  26415. * Internal, matrix used to convert room space to babylon space
  26416. * @hidden
  26417. */
  26418. _deviceToWorld: Matrix;
  26419. /**
  26420. * Node to be used when casting a ray from the controller
  26421. * @hidden
  26422. */
  26423. _pointingPoseNode: Nullable<TransformNode>;
  26424. /**
  26425. * Name of the child mesh that can be used to cast a ray from the controller
  26426. */
  26427. static readonly POINTING_POSE: string;
  26428. /**
  26429. * Creates a new PoseEnabledController from a gamepad
  26430. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  26431. */
  26432. constructor(browserGamepad: any);
  26433. private _workingMatrix;
  26434. /**
  26435. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  26436. */
  26437. update(): void;
  26438. /**
  26439. * Updates only the pose device and mesh without doing any button event checking
  26440. */
  26441. protected _updatePoseAndMesh(): void;
  26442. /**
  26443. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  26444. * @param poseData raw pose fromthe device
  26445. */
  26446. updateFromDevice(poseData: DevicePose): void;
  26447. /**
  26448. * @hidden
  26449. */
  26450. _meshAttachedObservable: Observable<AbstractMesh>;
  26451. /**
  26452. * Attaches a mesh to the controller
  26453. * @param mesh the mesh to be attached
  26454. */
  26455. attachToMesh(mesh: AbstractMesh): void;
  26456. /**
  26457. * Attaches the controllers mesh to a camera
  26458. * @param camera the camera the mesh should be attached to
  26459. */
  26460. attachToPoseControlledCamera(camera: TargetCamera): void;
  26461. /**
  26462. * Disposes of the controller
  26463. */
  26464. dispose(): void;
  26465. /**
  26466. * The mesh that is attached to the controller
  26467. */
  26468. get mesh(): Nullable<AbstractMesh>;
  26469. /**
  26470. * Gets the ray of the controller in the direction the controller is pointing
  26471. * @param length the length the resulting ray should be
  26472. * @returns a ray in the direction the controller is pointing
  26473. */
  26474. getForwardRay(length?: number): Ray;
  26475. }
  26476. }
  26477. declare module BABYLON {
  26478. /**
  26479. * Defines the WebVRController object that represents controllers tracked in 3D space
  26480. */
  26481. export abstract class WebVRController extends PoseEnabledController {
  26482. /**
  26483. * Internal, the default controller model for the controller
  26484. */
  26485. protected _defaultModel: Nullable<AbstractMesh>;
  26486. /**
  26487. * Fired when the trigger state has changed
  26488. */
  26489. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  26490. /**
  26491. * Fired when the main button state has changed
  26492. */
  26493. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26494. /**
  26495. * Fired when the secondary button state has changed
  26496. */
  26497. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26498. /**
  26499. * Fired when the pad state has changed
  26500. */
  26501. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  26502. /**
  26503. * Fired when controllers stick values have changed
  26504. */
  26505. onPadValuesChangedObservable: Observable<StickValues>;
  26506. /**
  26507. * Array of button availible on the controller
  26508. */
  26509. protected _buttons: Array<MutableGamepadButton>;
  26510. private _onButtonStateChange;
  26511. /**
  26512. * Fired when a controller button's state has changed
  26513. * @param callback the callback containing the button that was modified
  26514. */
  26515. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  26516. /**
  26517. * X and Y axis corresponding to the controllers joystick
  26518. */
  26519. pad: StickValues;
  26520. /**
  26521. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  26522. */
  26523. hand: string;
  26524. /**
  26525. * The default controller model for the controller
  26526. */
  26527. get defaultModel(): Nullable<AbstractMesh>;
  26528. /**
  26529. * Creates a new WebVRController from a gamepad
  26530. * @param vrGamepad the gamepad that the WebVRController should be created from
  26531. */
  26532. constructor(vrGamepad: any);
  26533. /**
  26534. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  26535. */
  26536. update(): void;
  26537. /**
  26538. * Function to be called when a button is modified
  26539. */
  26540. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  26541. /**
  26542. * Loads a mesh and attaches it to the controller
  26543. * @param scene the scene the mesh should be added to
  26544. * @param meshLoaded callback for when the mesh has been loaded
  26545. */
  26546. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  26547. private _setButtonValue;
  26548. private _changes;
  26549. private _checkChanges;
  26550. /**
  26551. * Disposes of th webVRCOntroller
  26552. */
  26553. dispose(): void;
  26554. }
  26555. }
  26556. declare module BABYLON {
  26557. /**
  26558. * The HemisphericLight simulates the ambient environment light,
  26559. * so the passed direction is the light reflection direction, not the incoming direction.
  26560. */
  26561. export class HemisphericLight extends Light {
  26562. /**
  26563. * The groundColor is the light in the opposite direction to the one specified during creation.
  26564. * 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.
  26565. */
  26566. groundColor: Color3;
  26567. /**
  26568. * The light reflection direction, not the incoming direction.
  26569. */
  26570. direction: Vector3;
  26571. /**
  26572. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  26573. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  26574. * The HemisphericLight can't cast shadows.
  26575. * Documentation : https://doc.babylonjs.com/babylon101/lights
  26576. * @param name The friendly name of the light
  26577. * @param direction The direction of the light reflection
  26578. * @param scene The scene the light belongs to
  26579. */
  26580. constructor(name: string, direction: Vector3, scene: Scene);
  26581. protected _buildUniformLayout(): void;
  26582. /**
  26583. * Returns the string "HemisphericLight".
  26584. * @return The class name
  26585. */
  26586. getClassName(): string;
  26587. /**
  26588. * Sets the HemisphericLight direction towards the passed target (Vector3).
  26589. * Returns the updated direction.
  26590. * @param target The target the direction should point to
  26591. * @return The computed direction
  26592. */
  26593. setDirectionToTarget(target: Vector3): Vector3;
  26594. /**
  26595. * Returns the shadow generator associated to the light.
  26596. * @returns Always null for hemispheric lights because it does not support shadows.
  26597. */
  26598. getShadowGenerator(): Nullable<IShadowGenerator>;
  26599. /**
  26600. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  26601. * @param effect The effect to update
  26602. * @param lightIndex The index of the light in the effect to update
  26603. * @returns The hemispheric light
  26604. */
  26605. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  26606. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  26607. /**
  26608. * Computes the world matrix of the node
  26609. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26610. * @param useWasUpdatedFlag defines a reserved property
  26611. * @returns the world matrix
  26612. */
  26613. computeWorldMatrix(): Matrix;
  26614. /**
  26615. * Returns the integer 3.
  26616. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  26617. */
  26618. getTypeID(): number;
  26619. /**
  26620. * Prepares the list of defines specific to the light type.
  26621. * @param defines the list of defines
  26622. * @param lightIndex defines the index of the light for the effect
  26623. */
  26624. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  26625. }
  26626. }
  26627. declare module BABYLON {
  26628. /** @hidden */
  26629. export var vrMultiviewToSingleviewPixelShader: {
  26630. name: string;
  26631. shader: string;
  26632. };
  26633. }
  26634. declare module BABYLON {
  26635. /**
  26636. * Renders to multiple views with a single draw call
  26637. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  26638. */
  26639. export class MultiviewRenderTarget extends RenderTargetTexture {
  26640. /**
  26641. * Creates a multiview render target
  26642. * @param scene scene used with the render target
  26643. * @param size the size of the render target (used for each view)
  26644. */
  26645. constructor(scene: Scene, size?: number | {
  26646. width: number;
  26647. height: number;
  26648. } | {
  26649. ratio: number;
  26650. });
  26651. /**
  26652. * @hidden
  26653. * @param faceIndex the face index, if its a cube texture
  26654. */
  26655. _bindFrameBuffer(faceIndex?: number): void;
  26656. /**
  26657. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  26658. * @returns the view count
  26659. */
  26660. getViewCount(): number;
  26661. }
  26662. }
  26663. declare module BABYLON {
  26664. interface Engine {
  26665. /**
  26666. * Creates a new multiview render target
  26667. * @param width defines the width of the texture
  26668. * @param height defines the height of the texture
  26669. * @returns the created multiview texture
  26670. */
  26671. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  26672. /**
  26673. * Binds a multiview framebuffer to be drawn to
  26674. * @param multiviewTexture texture to bind
  26675. */
  26676. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  26677. }
  26678. interface Camera {
  26679. /**
  26680. * @hidden
  26681. * 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)
  26682. */
  26683. _useMultiviewToSingleView: boolean;
  26684. /**
  26685. * @hidden
  26686. * 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)
  26687. */
  26688. _multiviewTexture: Nullable<RenderTargetTexture>;
  26689. /**
  26690. * @hidden
  26691. * ensures the multiview texture of the camera exists and has the specified width/height
  26692. * @param width height to set on the multiview texture
  26693. * @param height width to set on the multiview texture
  26694. */
  26695. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  26696. }
  26697. interface Scene {
  26698. /** @hidden */
  26699. _transformMatrixR: Matrix;
  26700. /** @hidden */
  26701. _multiviewSceneUbo: Nullable<UniformBuffer>;
  26702. /** @hidden */
  26703. _createMultiviewUbo(): void;
  26704. /** @hidden */
  26705. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  26706. /** @hidden */
  26707. _renderMultiviewToSingleView(camera: Camera): void;
  26708. }
  26709. }
  26710. declare module BABYLON {
  26711. /**
  26712. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  26713. * This will not be used for webXR as it supports displaying texture arrays directly
  26714. */
  26715. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  26716. /**
  26717. * Gets a string identifying the name of the class
  26718. * @returns "VRMultiviewToSingleviewPostProcess" string
  26719. */
  26720. getClassName(): string;
  26721. /**
  26722. * Initializes a VRMultiviewToSingleview
  26723. * @param name name of the post process
  26724. * @param camera camera to be applied to
  26725. * @param scaleFactor scaling factor to the size of the output texture
  26726. */
  26727. constructor(name: string, camera: Camera, scaleFactor: number);
  26728. }
  26729. }
  26730. declare module BABYLON {
  26731. /**
  26732. * Interface used to define additional presentation attributes
  26733. */
  26734. export interface IVRPresentationAttributes {
  26735. /**
  26736. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  26737. */
  26738. highRefreshRate: boolean;
  26739. /**
  26740. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  26741. */
  26742. foveationLevel: number;
  26743. }
  26744. interface Engine {
  26745. /** @hidden */
  26746. _vrDisplay: any;
  26747. /** @hidden */
  26748. _vrSupported: boolean;
  26749. /** @hidden */
  26750. _oldSize: Size;
  26751. /** @hidden */
  26752. _oldHardwareScaleFactor: number;
  26753. /** @hidden */
  26754. _vrExclusivePointerMode: boolean;
  26755. /** @hidden */
  26756. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  26757. /** @hidden */
  26758. _onVRDisplayPointerRestricted: () => void;
  26759. /** @hidden */
  26760. _onVRDisplayPointerUnrestricted: () => void;
  26761. /** @hidden */
  26762. _onVrDisplayConnect: Nullable<(display: any) => void>;
  26763. /** @hidden */
  26764. _onVrDisplayDisconnect: Nullable<() => void>;
  26765. /** @hidden */
  26766. _onVrDisplayPresentChange: Nullable<() => void>;
  26767. /**
  26768. * Observable signaled when VR display mode changes
  26769. */
  26770. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26771. /**
  26772. * Observable signaled when VR request present is complete
  26773. */
  26774. onVRRequestPresentComplete: Observable<boolean>;
  26775. /**
  26776. * Observable signaled when VR request present starts
  26777. */
  26778. onVRRequestPresentStart: Observable<Engine>;
  26779. /**
  26780. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26781. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26782. */
  26783. isInVRExclusivePointerMode: boolean;
  26784. /**
  26785. * Gets a boolean indicating if a webVR device was detected
  26786. * @returns true if a webVR device was detected
  26787. */
  26788. isVRDevicePresent(): boolean;
  26789. /**
  26790. * Gets the current webVR device
  26791. * @returns the current webVR device (or null)
  26792. */
  26793. getVRDevice(): any;
  26794. /**
  26795. * Initializes a webVR display and starts listening to display change events
  26796. * The onVRDisplayChangedObservable will be notified upon these changes
  26797. * @returns A promise containing a VRDisplay and if vr is supported
  26798. */
  26799. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  26800. /** @hidden */
  26801. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  26802. /**
  26803. * Gets or sets the presentation attributes used to configure VR rendering
  26804. */
  26805. vrPresentationAttributes?: IVRPresentationAttributes;
  26806. /**
  26807. * Call this function to switch to webVR mode
  26808. * Will do nothing if webVR is not supported or if there is no webVR device
  26809. * @param options the webvr options provided to the camera. mainly used for multiview
  26810. * @see https://doc.babylonjs.com/how_to/webvr_camera
  26811. */
  26812. enableVR(options: WebVROptions): void;
  26813. /** @hidden */
  26814. _onVRFullScreenTriggered(): void;
  26815. }
  26816. }
  26817. declare module BABYLON {
  26818. /**
  26819. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  26820. * IMPORTANT!! The data is right-hand data.
  26821. * @export
  26822. * @interface DevicePose
  26823. */
  26824. export interface DevicePose {
  26825. /**
  26826. * The position of the device, values in array are [x,y,z].
  26827. */
  26828. readonly position: Nullable<Float32Array>;
  26829. /**
  26830. * The linearVelocity of the device, values in array are [x,y,z].
  26831. */
  26832. readonly linearVelocity: Nullable<Float32Array>;
  26833. /**
  26834. * The linearAcceleration of the device, values in array are [x,y,z].
  26835. */
  26836. readonly linearAcceleration: Nullable<Float32Array>;
  26837. /**
  26838. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  26839. */
  26840. readonly orientation: Nullable<Float32Array>;
  26841. /**
  26842. * The angularVelocity of the device, values in array are [x,y,z].
  26843. */
  26844. readonly angularVelocity: Nullable<Float32Array>;
  26845. /**
  26846. * The angularAcceleration of the device, values in array are [x,y,z].
  26847. */
  26848. readonly angularAcceleration: Nullable<Float32Array>;
  26849. }
  26850. /**
  26851. * Interface representing a pose controlled object in Babylon.
  26852. * A pose controlled object has both regular pose values as well as pose values
  26853. * from an external device such as a VR head mounted display
  26854. */
  26855. export interface PoseControlled {
  26856. /**
  26857. * The position of the object in babylon space.
  26858. */
  26859. position: Vector3;
  26860. /**
  26861. * The rotation quaternion of the object in babylon space.
  26862. */
  26863. rotationQuaternion: Quaternion;
  26864. /**
  26865. * The position of the device in babylon space.
  26866. */
  26867. devicePosition?: Vector3;
  26868. /**
  26869. * The rotation quaternion of the device in babylon space.
  26870. */
  26871. deviceRotationQuaternion: Quaternion;
  26872. /**
  26873. * The raw pose coming from the device.
  26874. */
  26875. rawPose: Nullable<DevicePose>;
  26876. /**
  26877. * The scale of the device to be used when translating from device space to babylon space.
  26878. */
  26879. deviceScaleFactor: number;
  26880. /**
  26881. * Updates the poseControlled values based on the input device pose.
  26882. * @param poseData the pose data to update the object with
  26883. */
  26884. updateFromDevice(poseData: DevicePose): void;
  26885. }
  26886. /**
  26887. * Set of options to customize the webVRCamera
  26888. */
  26889. export interface WebVROptions {
  26890. /**
  26891. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  26892. */
  26893. trackPosition?: boolean;
  26894. /**
  26895. * Sets the scale of the vrDevice in babylon space. (default: 1)
  26896. */
  26897. positionScale?: number;
  26898. /**
  26899. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  26900. */
  26901. displayName?: string;
  26902. /**
  26903. * Should the native controller meshes be initialized. (default: true)
  26904. */
  26905. controllerMeshes?: boolean;
  26906. /**
  26907. * Creating a default HemiLight only on controllers. (default: true)
  26908. */
  26909. defaultLightingOnControllers?: boolean;
  26910. /**
  26911. * If you don't want to use the default VR button of the helper. (default: false)
  26912. */
  26913. useCustomVRButton?: boolean;
  26914. /**
  26915. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  26916. */
  26917. customVRButton?: HTMLButtonElement;
  26918. /**
  26919. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  26920. */
  26921. rayLength?: number;
  26922. /**
  26923. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  26924. */
  26925. defaultHeight?: number;
  26926. /**
  26927. * If multiview should be used if availible (default: false)
  26928. */
  26929. useMultiview?: boolean;
  26930. }
  26931. /**
  26932. * This represents a WebVR camera.
  26933. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  26934. * @example https://doc.babylonjs.com/how_to/webvr_camera
  26935. */
  26936. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  26937. private webVROptions;
  26938. /**
  26939. * @hidden
  26940. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  26941. */
  26942. _vrDevice: any;
  26943. /**
  26944. * The rawPose of the vrDevice.
  26945. */
  26946. rawPose: Nullable<DevicePose>;
  26947. private _onVREnabled;
  26948. private _specsVersion;
  26949. private _attached;
  26950. private _frameData;
  26951. protected _descendants: Array<Node>;
  26952. private _deviceRoomPosition;
  26953. /** @hidden */
  26954. _deviceRoomRotationQuaternion: Quaternion;
  26955. private _standingMatrix;
  26956. /**
  26957. * Represents device position in babylon space.
  26958. */
  26959. devicePosition: Vector3;
  26960. /**
  26961. * Represents device rotation in babylon space.
  26962. */
  26963. deviceRotationQuaternion: Quaternion;
  26964. /**
  26965. * The scale of the device to be used when translating from device space to babylon space.
  26966. */
  26967. deviceScaleFactor: number;
  26968. private _deviceToWorld;
  26969. private _worldToDevice;
  26970. /**
  26971. * References to the webVR controllers for the vrDevice.
  26972. */
  26973. controllers: Array<WebVRController>;
  26974. /**
  26975. * Emits an event when a controller is attached.
  26976. */
  26977. onControllersAttachedObservable: Observable<WebVRController[]>;
  26978. /**
  26979. * Emits an event when a controller's mesh has been loaded;
  26980. */
  26981. onControllerMeshLoadedObservable: Observable<WebVRController>;
  26982. /**
  26983. * Emits an event when the HMD's pose has been updated.
  26984. */
  26985. onPoseUpdatedFromDeviceObservable: Observable<any>;
  26986. private _poseSet;
  26987. /**
  26988. * If the rig cameras be used as parent instead of this camera.
  26989. */
  26990. rigParenting: boolean;
  26991. private _lightOnControllers;
  26992. private _defaultHeight?;
  26993. /**
  26994. * Instantiates a WebVRFreeCamera.
  26995. * @param name The name of the WebVRFreeCamera
  26996. * @param position The starting anchor position for the camera
  26997. * @param scene The scene the camera belongs to
  26998. * @param webVROptions a set of customizable options for the webVRCamera
  26999. */
  27000. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  27001. /**
  27002. * Gets the device distance from the ground in meters.
  27003. * @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.
  27004. */
  27005. deviceDistanceToRoomGround(): number;
  27006. /**
  27007. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27008. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  27009. */
  27010. useStandingMatrix(callback?: (bool: boolean) => void): void;
  27011. /**
  27012. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27013. * @returns A promise with a boolean set to if the standing matrix is supported.
  27014. */
  27015. useStandingMatrixAsync(): Promise<boolean>;
  27016. /**
  27017. * Disposes the camera
  27018. */
  27019. dispose(): void;
  27020. /**
  27021. * Gets a vrController by name.
  27022. * @param name The name of the controller to retreive
  27023. * @returns the controller matching the name specified or null if not found
  27024. */
  27025. getControllerByName(name: string): Nullable<WebVRController>;
  27026. private _leftController;
  27027. /**
  27028. * The controller corresponding to the users left hand.
  27029. */
  27030. get leftController(): Nullable<WebVRController>;
  27031. private _rightController;
  27032. /**
  27033. * The controller corresponding to the users right hand.
  27034. */
  27035. get rightController(): Nullable<WebVRController>;
  27036. /**
  27037. * Casts a ray forward from the vrCamera's gaze.
  27038. * @param length Length of the ray (default: 100)
  27039. * @returns the ray corresponding to the gaze
  27040. */
  27041. getForwardRay(length?: number): Ray;
  27042. /**
  27043. * @hidden
  27044. * Updates the camera based on device's frame data
  27045. */
  27046. _checkInputs(): void;
  27047. /**
  27048. * Updates the poseControlled values based on the input device pose.
  27049. * @param poseData Pose coming from the device
  27050. */
  27051. updateFromDevice(poseData: DevicePose): void;
  27052. private _detachIfAttached;
  27053. /**
  27054. * WebVR's attach control will start broadcasting frames to the device.
  27055. * Note that in certain browsers (chrome for example) this function must be called
  27056. * within a user-interaction callback. Example:
  27057. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27058. *
  27059. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27060. */
  27061. attachControl(noPreventDefault?: boolean): void;
  27062. /**
  27063. * Detach the current controls from the specified dom element.
  27064. */
  27065. detachControl(): void;
  27066. /**
  27067. * @returns the name of this class
  27068. */
  27069. getClassName(): string;
  27070. /**
  27071. * Calls resetPose on the vrDisplay
  27072. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27073. */
  27074. resetToCurrentRotation(): void;
  27075. /**
  27076. * @hidden
  27077. * Updates the rig cameras (left and right eye)
  27078. */
  27079. _updateRigCameras(): void;
  27080. private _workingVector;
  27081. private _oneVector;
  27082. private _workingMatrix;
  27083. private updateCacheCalled;
  27084. private _correctPositionIfNotTrackPosition;
  27085. /**
  27086. * @hidden
  27087. * Updates the cached values of the camera
  27088. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27089. */
  27090. _updateCache(ignoreParentClass?: boolean): void;
  27091. /**
  27092. * @hidden
  27093. * Get current device position in babylon world
  27094. */
  27095. _computeDevicePosition(): void;
  27096. /**
  27097. * Updates the current device position and rotation in the babylon world
  27098. */
  27099. update(): void;
  27100. /**
  27101. * @hidden
  27102. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27103. * @returns an identity matrix
  27104. */
  27105. _getViewMatrix(): Matrix;
  27106. private _tmpMatrix;
  27107. /**
  27108. * This function is called by the two RIG cameras.
  27109. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27110. * @hidden
  27111. */
  27112. _getWebVRViewMatrix(): Matrix;
  27113. /** @hidden */
  27114. _getWebVRProjectionMatrix(): Matrix;
  27115. private _onGamepadConnectedObserver;
  27116. private _onGamepadDisconnectedObserver;
  27117. private _updateCacheWhenTrackingDisabledObserver;
  27118. /**
  27119. * Initializes the controllers and their meshes
  27120. */
  27121. initControllers(): void;
  27122. }
  27123. }
  27124. declare module BABYLON {
  27125. /**
  27126. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27127. *
  27128. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27129. *
  27130. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27131. */
  27132. export class MaterialHelper {
  27133. /**
  27134. * Bind the current view position to an effect.
  27135. * @param effect The effect to be bound
  27136. * @param scene The scene the eyes position is used from
  27137. * @param variableName name of the shader variable that will hold the eye position
  27138. */
  27139. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  27140. /**
  27141. * Helps preparing the defines values about the UVs in used in the effect.
  27142. * UVs are shared as much as we can accross channels in the shaders.
  27143. * @param texture The texture we are preparing the UVs for
  27144. * @param defines The defines to update
  27145. * @param key The channel key "diffuse", "specular"... used in the shader
  27146. */
  27147. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27148. /**
  27149. * Binds a texture matrix value to its corrsponding uniform
  27150. * @param texture The texture to bind the matrix for
  27151. * @param uniformBuffer The uniform buffer receivin the data
  27152. * @param key The channel key "diffuse", "specular"... used in the shader
  27153. */
  27154. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27155. /**
  27156. * Gets the current status of the fog (should it be enabled?)
  27157. * @param mesh defines the mesh to evaluate for fog support
  27158. * @param scene defines the hosting scene
  27159. * @returns true if fog must be enabled
  27160. */
  27161. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27162. /**
  27163. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27164. * @param mesh defines the current mesh
  27165. * @param scene defines the current scene
  27166. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27167. * @param pointsCloud defines if point cloud rendering has to be turned on
  27168. * @param fogEnabled defines if fog has to be turned on
  27169. * @param alphaTest defines if alpha testing has to be turned on
  27170. * @param defines defines the current list of defines
  27171. */
  27172. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  27173. /**
  27174. * Helper used to prepare the list of defines associated with frame values for shader compilation
  27175. * @param scene defines the current scene
  27176. * @param engine defines the current engine
  27177. * @param defines specifies the list of active defines
  27178. * @param useInstances defines if instances have to be turned on
  27179. * @param useClipPlane defines if clip plane have to be turned on
  27180. * @param useInstances defines if instances have to be turned on
  27181. * @param useThinInstances defines if thin instances have to be turned on
  27182. */
  27183. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  27184. /**
  27185. * Prepares the defines for bones
  27186. * @param mesh The mesh containing the geometry data we will draw
  27187. * @param defines The defines to update
  27188. */
  27189. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  27190. /**
  27191. * Prepares the defines for morph targets
  27192. * @param mesh The mesh containing the geometry data we will draw
  27193. * @param defines The defines to update
  27194. */
  27195. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  27196. /**
  27197. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  27198. * @param mesh The mesh containing the geometry data we will draw
  27199. * @param defines The defines to update
  27200. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  27201. * @param useBones Precise whether bones should be used or not (override mesh info)
  27202. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  27203. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  27204. * @returns false if defines are considered not dirty and have not been checked
  27205. */
  27206. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  27207. /**
  27208. * Prepares the defines related to multiview
  27209. * @param scene The scene we are intending to draw
  27210. * @param defines The defines to update
  27211. */
  27212. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  27213. /**
  27214. * Prepares the defines related to the prepass
  27215. * @param scene The scene we are intending to draw
  27216. * @param defines The defines to update
  27217. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  27218. */
  27219. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  27220. /**
  27221. * Prepares the defines related to the light information passed in parameter
  27222. * @param scene The scene we are intending to draw
  27223. * @param mesh The mesh the effect is compiling for
  27224. * @param light The light the effect is compiling for
  27225. * @param lightIndex The index of the light
  27226. * @param defines The defines to update
  27227. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27228. * @param state Defines the current state regarding what is needed (normals, etc...)
  27229. */
  27230. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  27231. needNormals: boolean;
  27232. needRebuild: boolean;
  27233. shadowEnabled: boolean;
  27234. specularEnabled: boolean;
  27235. lightmapMode: boolean;
  27236. }): void;
  27237. /**
  27238. * Prepares the defines related to the light information passed in parameter
  27239. * @param scene The scene we are intending to draw
  27240. * @param mesh The mesh the effect is compiling for
  27241. * @param defines The defines to update
  27242. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27243. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  27244. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  27245. * @returns true if normals will be required for the rest of the effect
  27246. */
  27247. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  27248. /**
  27249. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  27250. * @param lightIndex defines the light index
  27251. * @param uniformsList The uniform list
  27252. * @param samplersList The sampler list
  27253. * @param projectedLightTexture defines if projected texture must be used
  27254. * @param uniformBuffersList defines an optional list of uniform buffers
  27255. */
  27256. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  27257. /**
  27258. * Prepares the uniforms and samplers list to be used in the effect
  27259. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  27260. * @param samplersList The sampler list
  27261. * @param defines The defines helping in the list generation
  27262. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  27263. */
  27264. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  27265. /**
  27266. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  27267. * @param defines The defines to update while falling back
  27268. * @param fallbacks The authorized effect fallbacks
  27269. * @param maxSimultaneousLights The maximum number of lights allowed
  27270. * @param rank the current rank of the Effect
  27271. * @returns The newly affected rank
  27272. */
  27273. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  27274. private static _TmpMorphInfluencers;
  27275. /**
  27276. * Prepares the list of attributes required for morph targets according to the effect defines.
  27277. * @param attribs The current list of supported attribs
  27278. * @param mesh The mesh to prepare the morph targets attributes for
  27279. * @param influencers The number of influencers
  27280. */
  27281. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  27282. /**
  27283. * Prepares the list of attributes required for morph targets according to the effect defines.
  27284. * @param attribs The current list of supported attribs
  27285. * @param mesh The mesh to prepare the morph targets attributes for
  27286. * @param defines The current Defines of the effect
  27287. */
  27288. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  27289. /**
  27290. * Prepares the list of attributes required for bones according to the effect defines.
  27291. * @param attribs The current list of supported attribs
  27292. * @param mesh The mesh to prepare the bones attributes for
  27293. * @param defines The current Defines of the effect
  27294. * @param fallbacks The current efffect fallback strategy
  27295. */
  27296. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  27297. /**
  27298. * Check and prepare the list of attributes required for instances according to the effect defines.
  27299. * @param attribs The current list of supported attribs
  27300. * @param defines The current MaterialDefines of the effect
  27301. */
  27302. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  27303. /**
  27304. * Add the list of attributes required for instances to the attribs array.
  27305. * @param attribs The current list of supported attribs
  27306. */
  27307. static PushAttributesForInstances(attribs: string[]): void;
  27308. /**
  27309. * Binds the light information to the effect.
  27310. * @param light The light containing the generator
  27311. * @param effect The effect we are binding the data to
  27312. * @param lightIndex The light index in the effect used to render
  27313. */
  27314. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  27315. /**
  27316. * Binds the lights information from the scene to the effect for the given mesh.
  27317. * @param light Light to bind
  27318. * @param lightIndex Light index
  27319. * @param scene The scene where the light belongs to
  27320. * @param effect The effect we are binding the data to
  27321. * @param useSpecular Defines if specular is supported
  27322. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27323. */
  27324. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  27325. /**
  27326. * Binds the lights information from the scene to the effect for the given mesh.
  27327. * @param scene The scene the lights belongs to
  27328. * @param mesh The mesh we are binding the information to render
  27329. * @param effect The effect we are binding the data to
  27330. * @param defines The generated defines for the effect
  27331. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  27332. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27333. */
  27334. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  27335. private static _tempFogColor;
  27336. /**
  27337. * Binds the fog information from the scene to the effect for the given mesh.
  27338. * @param scene The scene the lights belongs to
  27339. * @param mesh The mesh we are binding the information to render
  27340. * @param effect The effect we are binding the data to
  27341. * @param linearSpace Defines if the fog effect is applied in linear space
  27342. */
  27343. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  27344. /**
  27345. * Binds the bones information from the mesh to the effect.
  27346. * @param mesh The mesh we are binding the information to render
  27347. * @param effect The effect we are binding the data to
  27348. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  27349. */
  27350. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  27351. private static _CopyBonesTransformationMatrices;
  27352. /**
  27353. * Binds the morph targets information from the mesh to the effect.
  27354. * @param abstractMesh The mesh we are binding the information to render
  27355. * @param effect The effect we are binding the data to
  27356. */
  27357. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  27358. /**
  27359. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  27360. * @param defines The generated defines used in the effect
  27361. * @param effect The effect we are binding the data to
  27362. * @param scene The scene we are willing to render with logarithmic scale for
  27363. */
  27364. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  27365. /**
  27366. * Binds the clip plane information from the scene to the effect.
  27367. * @param scene The scene the clip plane information are extracted from
  27368. * @param effect The effect we are binding the data to
  27369. */
  27370. static BindClipPlane(effect: Effect, scene: Scene): void;
  27371. }
  27372. }
  27373. declare module BABYLON {
  27374. /** @hidden */
  27375. export var bayerDitherFunctions: {
  27376. name: string;
  27377. shader: string;
  27378. };
  27379. }
  27380. declare module BABYLON {
  27381. /** @hidden */
  27382. export var shadowMapFragmentDeclaration: {
  27383. name: string;
  27384. shader: string;
  27385. };
  27386. }
  27387. declare module BABYLON {
  27388. /** @hidden */
  27389. export var shadowMapFragment: {
  27390. name: string;
  27391. shader: string;
  27392. };
  27393. }
  27394. declare module BABYLON {
  27395. /** @hidden */
  27396. export var shadowMapPixelShader: {
  27397. name: string;
  27398. shader: string;
  27399. };
  27400. }
  27401. declare module BABYLON {
  27402. /** @hidden */
  27403. export var shadowMapVertexDeclaration: {
  27404. name: string;
  27405. shader: string;
  27406. };
  27407. }
  27408. declare module BABYLON {
  27409. /** @hidden */
  27410. export var shadowMapVertexNormalBias: {
  27411. name: string;
  27412. shader: string;
  27413. };
  27414. }
  27415. declare module BABYLON {
  27416. /** @hidden */
  27417. export var shadowMapVertexMetric: {
  27418. name: string;
  27419. shader: string;
  27420. };
  27421. }
  27422. declare module BABYLON {
  27423. /** @hidden */
  27424. export var shadowMapVertexShader: {
  27425. name: string;
  27426. shader: string;
  27427. };
  27428. }
  27429. declare module BABYLON {
  27430. /** @hidden */
  27431. export var depthBoxBlurPixelShader: {
  27432. name: string;
  27433. shader: string;
  27434. };
  27435. }
  27436. declare module BABYLON {
  27437. /** @hidden */
  27438. export var shadowMapFragmentSoftTransparentShadow: {
  27439. name: string;
  27440. shader: string;
  27441. };
  27442. }
  27443. declare module BABYLON {
  27444. /**
  27445. * Creates an instance based on a source mesh.
  27446. */
  27447. export class InstancedMesh extends AbstractMesh {
  27448. private _sourceMesh;
  27449. private _currentLOD;
  27450. /** @hidden */
  27451. _indexInSourceMeshInstanceArray: number;
  27452. constructor(name: string, source: Mesh);
  27453. /**
  27454. * Returns the string "InstancedMesh".
  27455. */
  27456. getClassName(): string;
  27457. /** Gets the list of lights affecting that mesh */
  27458. get lightSources(): Light[];
  27459. _resyncLightSources(): void;
  27460. _resyncLightSource(light: Light): void;
  27461. _removeLightSource(light: Light, dispose: boolean): void;
  27462. /**
  27463. * If the source mesh receives shadows
  27464. */
  27465. get receiveShadows(): boolean;
  27466. /**
  27467. * The material of the source mesh
  27468. */
  27469. get material(): Nullable<Material>;
  27470. /**
  27471. * Visibility of the source mesh
  27472. */
  27473. get visibility(): number;
  27474. /**
  27475. * Skeleton of the source mesh
  27476. */
  27477. get skeleton(): Nullable<Skeleton>;
  27478. /**
  27479. * Rendering ground id of the source mesh
  27480. */
  27481. get renderingGroupId(): number;
  27482. set renderingGroupId(value: number);
  27483. /**
  27484. * Returns the total number of vertices (integer).
  27485. */
  27486. getTotalVertices(): number;
  27487. /**
  27488. * Returns a positive integer : the total number of indices in this mesh geometry.
  27489. * @returns the numner of indices or zero if the mesh has no geometry.
  27490. */
  27491. getTotalIndices(): number;
  27492. /**
  27493. * The source mesh of the instance
  27494. */
  27495. get sourceMesh(): Mesh;
  27496. /**
  27497. * Creates a new InstancedMesh object from the mesh model.
  27498. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27499. * @param name defines the name of the new instance
  27500. * @returns a new InstancedMesh
  27501. */
  27502. createInstance(name: string): InstancedMesh;
  27503. /**
  27504. * Is this node ready to be used/rendered
  27505. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27506. * @return {boolean} is it ready
  27507. */
  27508. isReady(completeCheck?: boolean): boolean;
  27509. /**
  27510. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27511. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  27512. * @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.
  27513. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  27514. */
  27515. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  27516. /**
  27517. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27518. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27519. * The `data` are either a numeric array either a Float32Array.
  27520. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  27521. * 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).
  27522. * Note that a new underlying VertexBuffer object is created each call.
  27523. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27524. *
  27525. * Possible `kind` values :
  27526. * - VertexBuffer.PositionKind
  27527. * - VertexBuffer.UVKind
  27528. * - VertexBuffer.UV2Kind
  27529. * - VertexBuffer.UV3Kind
  27530. * - VertexBuffer.UV4Kind
  27531. * - VertexBuffer.UV5Kind
  27532. * - VertexBuffer.UV6Kind
  27533. * - VertexBuffer.ColorKind
  27534. * - VertexBuffer.MatricesIndicesKind
  27535. * - VertexBuffer.MatricesIndicesExtraKind
  27536. * - VertexBuffer.MatricesWeightsKind
  27537. * - VertexBuffer.MatricesWeightsExtraKind
  27538. *
  27539. * Returns the Mesh.
  27540. */
  27541. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27542. /**
  27543. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27544. * If the mesh has no geometry, it is simply returned as it is.
  27545. * The `data` are either a numeric array either a Float32Array.
  27546. * No new underlying VertexBuffer object is created.
  27547. * 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.
  27548. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  27549. *
  27550. * Possible `kind` values :
  27551. * - VertexBuffer.PositionKind
  27552. * - VertexBuffer.UVKind
  27553. * - VertexBuffer.UV2Kind
  27554. * - VertexBuffer.UV3Kind
  27555. * - VertexBuffer.UV4Kind
  27556. * - VertexBuffer.UV5Kind
  27557. * - VertexBuffer.UV6Kind
  27558. * - VertexBuffer.ColorKind
  27559. * - VertexBuffer.MatricesIndicesKind
  27560. * - VertexBuffer.MatricesIndicesExtraKind
  27561. * - VertexBuffer.MatricesWeightsKind
  27562. * - VertexBuffer.MatricesWeightsExtraKind
  27563. *
  27564. * Returns the Mesh.
  27565. */
  27566. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  27567. /**
  27568. * Sets the mesh indices.
  27569. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  27570. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27571. * This method creates a new index buffer each call.
  27572. * Returns the Mesh.
  27573. */
  27574. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  27575. /**
  27576. * Boolean : True if the mesh owns the requested kind of data.
  27577. */
  27578. isVerticesDataPresent(kind: string): boolean;
  27579. /**
  27580. * Returns an array of indices (IndicesArray).
  27581. */
  27582. getIndices(): Nullable<IndicesArray>;
  27583. get _positions(): Nullable<Vector3[]>;
  27584. /**
  27585. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27586. * This means the mesh underlying bounding box and sphere are recomputed.
  27587. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27588. * @returns the current mesh
  27589. */
  27590. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  27591. /** @hidden */
  27592. _preActivate(): InstancedMesh;
  27593. /** @hidden */
  27594. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27595. /** @hidden */
  27596. _postActivate(): void;
  27597. getWorldMatrix(): Matrix;
  27598. get isAnInstance(): boolean;
  27599. /**
  27600. * Returns the current associated LOD AbstractMesh.
  27601. */
  27602. getLOD(camera: Camera): AbstractMesh;
  27603. /** @hidden */
  27604. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27605. /** @hidden */
  27606. _syncSubMeshes(): InstancedMesh;
  27607. /** @hidden */
  27608. _generatePointsArray(): boolean;
  27609. /** @hidden */
  27610. _updateBoundingInfo(): AbstractMesh;
  27611. /**
  27612. * Creates a new InstancedMesh from the current mesh.
  27613. * - name (string) : the cloned mesh name
  27614. * - newParent (optional Node) : the optional Node to parent the clone to.
  27615. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  27616. *
  27617. * Returns the clone.
  27618. */
  27619. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  27620. /**
  27621. * Disposes the InstancedMesh.
  27622. * Returns nothing.
  27623. */
  27624. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27625. }
  27626. interface Mesh {
  27627. /**
  27628. * Register a custom buffer that will be instanced
  27629. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27630. * @param kind defines the buffer kind
  27631. * @param stride defines the stride in floats
  27632. */
  27633. registerInstancedBuffer(kind: string, stride: number): void;
  27634. /**
  27635. * true to use the edge renderer for all instances of this mesh
  27636. */
  27637. edgesShareWithInstances: boolean;
  27638. /** @hidden */
  27639. _userInstancedBuffersStorage: {
  27640. data: {
  27641. [key: string]: Float32Array;
  27642. };
  27643. sizes: {
  27644. [key: string]: number;
  27645. };
  27646. vertexBuffers: {
  27647. [key: string]: Nullable<VertexBuffer>;
  27648. };
  27649. strides: {
  27650. [key: string]: number;
  27651. };
  27652. };
  27653. }
  27654. interface AbstractMesh {
  27655. /**
  27656. * Object used to store instanced buffers defined by user
  27657. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27658. */
  27659. instancedBuffers: {
  27660. [key: string]: any;
  27661. };
  27662. }
  27663. }
  27664. declare module BABYLON {
  27665. /**
  27666. * Defines the options associated with the creation of a shader material.
  27667. */
  27668. export interface IShaderMaterialOptions {
  27669. /**
  27670. * Does the material work in alpha blend mode
  27671. */
  27672. needAlphaBlending: boolean;
  27673. /**
  27674. * Does the material work in alpha test mode
  27675. */
  27676. needAlphaTesting: boolean;
  27677. /**
  27678. * The list of attribute names used in the shader
  27679. */
  27680. attributes: string[];
  27681. /**
  27682. * The list of unifrom names used in the shader
  27683. */
  27684. uniforms: string[];
  27685. /**
  27686. * The list of UBO names used in the shader
  27687. */
  27688. uniformBuffers: string[];
  27689. /**
  27690. * The list of sampler names used in the shader
  27691. */
  27692. samplers: string[];
  27693. /**
  27694. * The list of defines used in the shader
  27695. */
  27696. defines: string[];
  27697. }
  27698. /**
  27699. * 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.
  27700. *
  27701. * This returned material effects how the mesh will look based on the code in the shaders.
  27702. *
  27703. * @see https://doc.babylonjs.com/how_to/shader_material
  27704. */
  27705. export class ShaderMaterial extends Material {
  27706. private _shaderPath;
  27707. private _options;
  27708. private _textures;
  27709. private _textureArrays;
  27710. private _floats;
  27711. private _ints;
  27712. private _floatsArrays;
  27713. private _colors3;
  27714. private _colors3Arrays;
  27715. private _colors4;
  27716. private _colors4Arrays;
  27717. private _vectors2;
  27718. private _vectors3;
  27719. private _vectors4;
  27720. private _matrices;
  27721. private _matrixArrays;
  27722. private _matrices3x3;
  27723. private _matrices2x2;
  27724. private _vectors2Arrays;
  27725. private _vectors3Arrays;
  27726. private _vectors4Arrays;
  27727. private _cachedWorldViewMatrix;
  27728. private _cachedWorldViewProjectionMatrix;
  27729. private _renderId;
  27730. private _multiview;
  27731. private _cachedDefines;
  27732. /** Define the Url to load snippets */
  27733. static SnippetUrl: string;
  27734. /** Snippet ID if the material was created from the snippet server */
  27735. snippetId: string;
  27736. /**
  27737. * Instantiate a new shader material.
  27738. * 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.
  27739. * This returned material effects how the mesh will look based on the code in the shaders.
  27740. * @see https://doc.babylonjs.com/how_to/shader_material
  27741. * @param name Define the name of the material in the scene
  27742. * @param scene Define the scene the material belongs to
  27743. * @param shaderPath Defines the route to the shader code in one of three ways:
  27744. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  27745. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  27746. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  27747. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  27748. * @param options Define the options used to create the shader
  27749. */
  27750. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  27751. /**
  27752. * Gets the shader path used to define the shader code
  27753. * It can be modified to trigger a new compilation
  27754. */
  27755. get shaderPath(): any;
  27756. /**
  27757. * Sets the shader path used to define the shader code
  27758. * It can be modified to trigger a new compilation
  27759. */
  27760. set shaderPath(shaderPath: any);
  27761. /**
  27762. * Gets the options used to compile the shader.
  27763. * They can be modified to trigger a new compilation
  27764. */
  27765. get options(): IShaderMaterialOptions;
  27766. /**
  27767. * Gets the current class name of the material e.g. "ShaderMaterial"
  27768. * Mainly use in serialization.
  27769. * @returns the class name
  27770. */
  27771. getClassName(): string;
  27772. /**
  27773. * Specifies if the material will require alpha blending
  27774. * @returns a boolean specifying if alpha blending is needed
  27775. */
  27776. needAlphaBlending(): boolean;
  27777. /**
  27778. * Specifies if this material should be rendered in alpha test mode
  27779. * @returns a boolean specifying if an alpha test is needed.
  27780. */
  27781. needAlphaTesting(): boolean;
  27782. private _checkUniform;
  27783. /**
  27784. * Set a texture in the shader.
  27785. * @param name Define the name of the uniform samplers as defined in the shader
  27786. * @param texture Define the texture to bind to this sampler
  27787. * @return the material itself allowing "fluent" like uniform updates
  27788. */
  27789. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  27790. /**
  27791. * Set a texture array in the shader.
  27792. * @param name Define the name of the uniform sampler array as defined in the shader
  27793. * @param textures Define the list of textures to bind to this sampler
  27794. * @return the material itself allowing "fluent" like uniform updates
  27795. */
  27796. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  27797. /**
  27798. * Set a float in the shader.
  27799. * @param name Define the name of the uniform as defined in the shader
  27800. * @param value Define the value to give to the uniform
  27801. * @return the material itself allowing "fluent" like uniform updates
  27802. */
  27803. setFloat(name: string, value: number): ShaderMaterial;
  27804. /**
  27805. * Set a int in the shader.
  27806. * @param name Define the name of the uniform as defined in the shader
  27807. * @param value Define the value to give to the uniform
  27808. * @return the material itself allowing "fluent" like uniform updates
  27809. */
  27810. setInt(name: string, value: number): ShaderMaterial;
  27811. /**
  27812. * Set an array of floats in the shader.
  27813. * @param name Define the name of the uniform as defined in the shader
  27814. * @param value Define the value to give to the uniform
  27815. * @return the material itself allowing "fluent" like uniform updates
  27816. */
  27817. setFloats(name: string, value: number[]): ShaderMaterial;
  27818. /**
  27819. * Set a vec3 in the shader from a Color3.
  27820. * @param name Define the name of the uniform as defined in the shader
  27821. * @param value Define the value to give to the uniform
  27822. * @return the material itself allowing "fluent" like uniform updates
  27823. */
  27824. setColor3(name: string, value: Color3): ShaderMaterial;
  27825. /**
  27826. * Set a vec3 array in the shader from a Color3 array.
  27827. * @param name Define the name of the uniform as defined in the shader
  27828. * @param value Define the value to give to the uniform
  27829. * @return the material itself allowing "fluent" like uniform updates
  27830. */
  27831. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  27832. /**
  27833. * Set a vec4 in the shader from a Color4.
  27834. * @param name Define the name of the uniform as defined in the shader
  27835. * @param value Define the value to give to the uniform
  27836. * @return the material itself allowing "fluent" like uniform updates
  27837. */
  27838. setColor4(name: string, value: Color4): ShaderMaterial;
  27839. /**
  27840. * Set a vec4 array in the shader from a Color4 array.
  27841. * @param name Define the name of the uniform as defined in the shader
  27842. * @param value Define the value to give to the uniform
  27843. * @return the material itself allowing "fluent" like uniform updates
  27844. */
  27845. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  27846. /**
  27847. * Set a vec2 in the shader from a Vector2.
  27848. * @param name Define the name of the uniform as defined in the shader
  27849. * @param value Define the value to give to the uniform
  27850. * @return the material itself allowing "fluent" like uniform updates
  27851. */
  27852. setVector2(name: string, value: Vector2): ShaderMaterial;
  27853. /**
  27854. * Set a vec3 in the shader from a Vector3.
  27855. * @param name Define the name of the uniform as defined in the shader
  27856. * @param value Define the value to give to the uniform
  27857. * @return the material itself allowing "fluent" like uniform updates
  27858. */
  27859. setVector3(name: string, value: Vector3): ShaderMaterial;
  27860. /**
  27861. * Set a vec4 in the shader from a Vector4.
  27862. * @param name Define the name of the uniform as defined in the shader
  27863. * @param value Define the value to give to the uniform
  27864. * @return the material itself allowing "fluent" like uniform updates
  27865. */
  27866. setVector4(name: string, value: Vector4): ShaderMaterial;
  27867. /**
  27868. * Set a mat4 in the shader from a Matrix.
  27869. * @param name Define the name of the uniform as defined in the shader
  27870. * @param value Define the value to give to the uniform
  27871. * @return the material itself allowing "fluent" like uniform updates
  27872. */
  27873. setMatrix(name: string, value: Matrix): ShaderMaterial;
  27874. /**
  27875. * Set a float32Array in the shader from a matrix array.
  27876. * @param name Define the name of the uniform as defined in the shader
  27877. * @param value Define the value to give to the uniform
  27878. * @return the material itself allowing "fluent" like uniform updates
  27879. */
  27880. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  27881. /**
  27882. * Set a mat3 in the shader from a Float32Array.
  27883. * @param name Define the name of the uniform as defined in the shader
  27884. * @param value Define the value to give to the uniform
  27885. * @return the material itself allowing "fluent" like uniform updates
  27886. */
  27887. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27888. /**
  27889. * Set a mat2 in the shader from a Float32Array.
  27890. * @param name Define the name of the uniform as defined in the shader
  27891. * @param value Define the value to give to the uniform
  27892. * @return the material itself allowing "fluent" like uniform updates
  27893. */
  27894. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27895. /**
  27896. * Set a vec2 array in the shader from a number array.
  27897. * @param name Define the name of the uniform as defined in the shader
  27898. * @param value Define the value to give to the uniform
  27899. * @return the material itself allowing "fluent" like uniform updates
  27900. */
  27901. setArray2(name: string, value: number[]): ShaderMaterial;
  27902. /**
  27903. * Set a vec3 array in the shader from a number array.
  27904. * @param name Define the name of the uniform as defined in the shader
  27905. * @param value Define the value to give to the uniform
  27906. * @return the material itself allowing "fluent" like uniform updates
  27907. */
  27908. setArray3(name: string, value: number[]): ShaderMaterial;
  27909. /**
  27910. * Set a vec4 array in the shader from a number array.
  27911. * @param name Define the name of the uniform as defined in the shader
  27912. * @param value Define the value to give to the uniform
  27913. * @return the material itself allowing "fluent" like uniform updates
  27914. */
  27915. setArray4(name: string, value: number[]): ShaderMaterial;
  27916. private _checkCache;
  27917. /**
  27918. * Specifies that the submesh is ready to be used
  27919. * @param mesh defines the mesh to check
  27920. * @param subMesh defines which submesh to check
  27921. * @param useInstances specifies that instances should be used
  27922. * @returns a boolean indicating that the submesh is ready or not
  27923. */
  27924. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27925. /**
  27926. * Checks if the material is ready to render the requested mesh
  27927. * @param mesh Define the mesh to render
  27928. * @param useInstances Define whether or not the material is used with instances
  27929. * @returns true if ready, otherwise false
  27930. */
  27931. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27932. /**
  27933. * Binds the world matrix to the material
  27934. * @param world defines the world transformation matrix
  27935. * @param effectOverride - If provided, use this effect instead of internal effect
  27936. */
  27937. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  27938. /**
  27939. * Binds the submesh to this material by preparing the effect and shader to draw
  27940. * @param world defines the world transformation matrix
  27941. * @param mesh defines the mesh containing the submesh
  27942. * @param subMesh defines the submesh to bind the material to
  27943. */
  27944. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27945. /**
  27946. * Binds the material to the mesh
  27947. * @param world defines the world transformation matrix
  27948. * @param mesh defines the mesh to bind the material to
  27949. * @param effectOverride - If provided, use this effect instead of internal effect
  27950. */
  27951. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  27952. protected _afterBind(mesh?: Mesh): void;
  27953. /**
  27954. * Gets the active textures from the material
  27955. * @returns an array of textures
  27956. */
  27957. getActiveTextures(): BaseTexture[];
  27958. /**
  27959. * Specifies if the material uses a texture
  27960. * @param texture defines the texture to check against the material
  27961. * @returns a boolean specifying if the material uses the texture
  27962. */
  27963. hasTexture(texture: BaseTexture): boolean;
  27964. /**
  27965. * Makes a duplicate of the material, and gives it a new name
  27966. * @param name defines the new name for the duplicated material
  27967. * @returns the cloned material
  27968. */
  27969. clone(name: string): ShaderMaterial;
  27970. /**
  27971. * Disposes the material
  27972. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27973. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27974. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  27975. */
  27976. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  27977. /**
  27978. * Serializes this material in a JSON representation
  27979. * @returns the serialized material object
  27980. */
  27981. serialize(): any;
  27982. /**
  27983. * Creates a shader material from parsed shader material data
  27984. * @param source defines the JSON represnetation of the material
  27985. * @param scene defines the hosting scene
  27986. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27987. * @returns a new material
  27988. */
  27989. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  27990. /**
  27991. * Creates a new ShaderMaterial from a snippet saved in a remote file
  27992. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  27993. * @param url defines the url to load from
  27994. * @param scene defines the hosting scene
  27995. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27996. * @returns a promise that will resolve to the new ShaderMaterial
  27997. */
  27998. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  27999. /**
  28000. * Creates a ShaderMaterial from a snippet saved by the Inspector
  28001. * @param snippetId defines the snippet to load
  28002. * @param scene defines the hosting scene
  28003. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28004. * @returns a promise that will resolve to the new ShaderMaterial
  28005. */
  28006. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28007. }
  28008. }
  28009. declare module BABYLON {
  28010. /** @hidden */
  28011. export var colorPixelShader: {
  28012. name: string;
  28013. shader: string;
  28014. };
  28015. }
  28016. declare module BABYLON {
  28017. /** @hidden */
  28018. export var colorVertexShader: {
  28019. name: string;
  28020. shader: string;
  28021. };
  28022. }
  28023. declare module BABYLON {
  28024. /**
  28025. * Line mesh
  28026. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  28027. */
  28028. export class LinesMesh extends Mesh {
  28029. /**
  28030. * If vertex color should be applied to the mesh
  28031. */
  28032. readonly useVertexColor?: boolean | undefined;
  28033. /**
  28034. * If vertex alpha should be applied to the mesh
  28035. */
  28036. readonly useVertexAlpha?: boolean | undefined;
  28037. /**
  28038. * Color of the line (Default: White)
  28039. */
  28040. color: Color3;
  28041. /**
  28042. * Alpha of the line (Default: 1)
  28043. */
  28044. alpha: number;
  28045. /**
  28046. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28047. * This margin is expressed in world space coordinates, so its value may vary.
  28048. * Default value is 0.1
  28049. */
  28050. intersectionThreshold: number;
  28051. private _colorShader;
  28052. private color4;
  28053. /**
  28054. * Creates a new LinesMesh
  28055. * @param name defines the name
  28056. * @param scene defines the hosting scene
  28057. * @param parent defines the parent mesh if any
  28058. * @param source defines the optional source LinesMesh used to clone data from
  28059. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28060. * When false, achieved by calling a clone(), also passing False.
  28061. * This will make creation of children, recursive.
  28062. * @param useVertexColor defines if this LinesMesh supports vertex color
  28063. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28064. */
  28065. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28066. /**
  28067. * If vertex color should be applied to the mesh
  28068. */
  28069. useVertexColor?: boolean | undefined,
  28070. /**
  28071. * If vertex alpha should be applied to the mesh
  28072. */
  28073. useVertexAlpha?: boolean | undefined);
  28074. private _addClipPlaneDefine;
  28075. private _removeClipPlaneDefine;
  28076. isReady(): boolean;
  28077. /**
  28078. * Returns the string "LineMesh"
  28079. */
  28080. getClassName(): string;
  28081. /**
  28082. * @hidden
  28083. */
  28084. get material(): Material;
  28085. /**
  28086. * @hidden
  28087. */
  28088. set material(value: Material);
  28089. /**
  28090. * @hidden
  28091. */
  28092. get checkCollisions(): boolean;
  28093. /** @hidden */
  28094. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28095. /** @hidden */
  28096. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28097. /**
  28098. * Disposes of the line mesh
  28099. * @param doNotRecurse If children should be disposed
  28100. */
  28101. dispose(doNotRecurse?: boolean): void;
  28102. /**
  28103. * Returns a new LineMesh object cloned from the current one.
  28104. */
  28105. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28106. /**
  28107. * Creates a new InstancedLinesMesh object from the mesh model.
  28108. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28109. * @param name defines the name of the new instance
  28110. * @returns a new InstancedLinesMesh
  28111. */
  28112. createInstance(name: string): InstancedLinesMesh;
  28113. }
  28114. /**
  28115. * Creates an instance based on a source LinesMesh
  28116. */
  28117. export class InstancedLinesMesh extends InstancedMesh {
  28118. /**
  28119. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28120. * This margin is expressed in world space coordinates, so its value may vary.
  28121. * Initilized with the intersectionThreshold value of the source LinesMesh
  28122. */
  28123. intersectionThreshold: number;
  28124. constructor(name: string, source: LinesMesh);
  28125. /**
  28126. * Returns the string "InstancedLinesMesh".
  28127. */
  28128. getClassName(): string;
  28129. }
  28130. }
  28131. declare module BABYLON {
  28132. /** @hidden */
  28133. export var linePixelShader: {
  28134. name: string;
  28135. shader: string;
  28136. };
  28137. }
  28138. declare module BABYLON {
  28139. /** @hidden */
  28140. export var lineVertexShader: {
  28141. name: string;
  28142. shader: string;
  28143. };
  28144. }
  28145. declare module BABYLON {
  28146. interface Scene {
  28147. /** @hidden */
  28148. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28149. }
  28150. interface AbstractMesh {
  28151. /**
  28152. * Gets the edgesRenderer associated with the mesh
  28153. */
  28154. edgesRenderer: Nullable<EdgesRenderer>;
  28155. }
  28156. interface LinesMesh {
  28157. /**
  28158. * Enables the edge rendering mode on the mesh.
  28159. * This mode makes the mesh edges visible
  28160. * @param epsilon defines the maximal distance between two angles to detect a face
  28161. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28162. * @returns the currentAbstractMesh
  28163. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28164. */
  28165. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28166. }
  28167. interface InstancedLinesMesh {
  28168. /**
  28169. * Enables the edge rendering mode on the mesh.
  28170. * This mode makes the mesh edges visible
  28171. * @param epsilon defines the maximal distance between two angles to detect a face
  28172. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28173. * @returns the current InstancedLinesMesh
  28174. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28175. */
  28176. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28177. }
  28178. /**
  28179. * Defines the minimum contract an Edges renderer should follow.
  28180. */
  28181. export interface IEdgesRenderer extends IDisposable {
  28182. /**
  28183. * Gets or sets a boolean indicating if the edgesRenderer is active
  28184. */
  28185. isEnabled: boolean;
  28186. /**
  28187. * Renders the edges of the attached mesh,
  28188. */
  28189. render(): void;
  28190. /**
  28191. * Checks wether or not the edges renderer is ready to render.
  28192. * @return true if ready, otherwise false.
  28193. */
  28194. isReady(): boolean;
  28195. /**
  28196. * List of instances to render in case the source mesh has instances
  28197. */
  28198. customInstances: SmartArray<Matrix>;
  28199. }
  28200. /**
  28201. * Defines the additional options of the edges renderer
  28202. */
  28203. export interface IEdgesRendererOptions {
  28204. /**
  28205. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  28206. * If not defined, the default value is true
  28207. */
  28208. useAlternateEdgeFinder?: boolean;
  28209. /**
  28210. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  28211. * If not defined, the default value is true.
  28212. * 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)
  28213. * This option is used only if useAlternateEdgeFinder = true
  28214. */
  28215. useFastVertexMerger?: boolean;
  28216. /**
  28217. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  28218. * The default value is 1e-6
  28219. * This option is used only if useAlternateEdgeFinder = true
  28220. */
  28221. epsilonVertexMerge?: number;
  28222. /**
  28223. * 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
  28224. * 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.
  28225. * This option is used only if useAlternateEdgeFinder = true
  28226. */
  28227. applyTessellation?: boolean;
  28228. /**
  28229. * 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
  28230. * The default value is 1e-6
  28231. * This option is used only if useAlternateEdgeFinder = true
  28232. */
  28233. epsilonVertexAligned?: number;
  28234. }
  28235. /**
  28236. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28237. */
  28238. export class EdgesRenderer implements IEdgesRenderer {
  28239. /**
  28240. * Define the size of the edges with an orthographic camera
  28241. */
  28242. edgesWidthScalerForOrthographic: number;
  28243. /**
  28244. * Define the size of the edges with a perspective camera
  28245. */
  28246. edgesWidthScalerForPerspective: number;
  28247. protected _source: AbstractMesh;
  28248. protected _linesPositions: number[];
  28249. protected _linesNormals: number[];
  28250. protected _linesIndices: number[];
  28251. protected _epsilon: number;
  28252. protected _indicesCount: number;
  28253. protected _lineShader: ShaderMaterial;
  28254. protected _ib: DataBuffer;
  28255. protected _buffers: {
  28256. [key: string]: Nullable<VertexBuffer>;
  28257. };
  28258. protected _buffersForInstances: {
  28259. [key: string]: Nullable<VertexBuffer>;
  28260. };
  28261. protected _checkVerticesInsteadOfIndices: boolean;
  28262. protected _options: Nullable<IEdgesRendererOptions>;
  28263. private _meshRebuildObserver;
  28264. private _meshDisposeObserver;
  28265. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  28266. isEnabled: boolean;
  28267. /** Gets the vertices generated by the edge renderer */
  28268. get linesPositions(): Immutable<Array<number>>;
  28269. /** Gets the normals generated by the edge renderer */
  28270. get linesNormals(): Immutable<Array<number>>;
  28271. /** Gets the indices generated by the edge renderer */
  28272. get linesIndices(): Immutable<Array<number>>;
  28273. /**
  28274. * List of instances to render in case the source mesh has instances
  28275. */
  28276. customInstances: SmartArray<Matrix>;
  28277. private static GetShader;
  28278. /**
  28279. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  28280. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  28281. * @param source Mesh used to create edges
  28282. * @param epsilon sum of angles in adjacency to check for edge
  28283. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  28284. * @param generateEdgesLines - should generate Lines or only prepare resources.
  28285. * @param options The options to apply when generating the edges
  28286. */
  28287. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  28288. protected _prepareRessources(): void;
  28289. /** @hidden */
  28290. _rebuild(): void;
  28291. /**
  28292. * Releases the required resources for the edges renderer
  28293. */
  28294. dispose(): void;
  28295. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  28296. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  28297. /**
  28298. * Checks if the pair of p0 and p1 is en edge
  28299. * @param faceIndex
  28300. * @param edge
  28301. * @param faceNormals
  28302. * @param p0
  28303. * @param p1
  28304. * @private
  28305. */
  28306. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28307. /**
  28308. * push line into the position, normal and index buffer
  28309. * @protected
  28310. */
  28311. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  28312. /**
  28313. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  28314. */
  28315. private _tessellateTriangle;
  28316. private _generateEdgesLinesAlternate;
  28317. /**
  28318. * Generates lines edges from adjacencjes
  28319. * @private
  28320. */
  28321. _generateEdgesLines(): void;
  28322. /**
  28323. * Checks wether or not the edges renderer is ready to render.
  28324. * @return true if ready, otherwise false.
  28325. */
  28326. isReady(): boolean;
  28327. /**
  28328. * Renders the edges of the attached mesh,
  28329. */
  28330. render(): void;
  28331. }
  28332. /**
  28333. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  28334. */
  28335. export class LineEdgesRenderer extends EdgesRenderer {
  28336. /**
  28337. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  28338. * @param source LineMesh used to generate edges
  28339. * @param epsilon not important (specified angle for edge detection)
  28340. * @param checkVerticesInsteadOfIndices not important for LineMesh
  28341. */
  28342. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  28343. /**
  28344. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  28345. */
  28346. _generateEdgesLines(): void;
  28347. }
  28348. }
  28349. declare module BABYLON {
  28350. /**
  28351. * This represents the object necessary to create a rendering group.
  28352. * This is exclusively used and created by the rendering manager.
  28353. * To modify the behavior, you use the available helpers in your scene or meshes.
  28354. * @hidden
  28355. */
  28356. export class RenderingGroup {
  28357. index: number;
  28358. private static _zeroVector;
  28359. private _scene;
  28360. private _opaqueSubMeshes;
  28361. private _transparentSubMeshes;
  28362. private _alphaTestSubMeshes;
  28363. private _depthOnlySubMeshes;
  28364. private _particleSystems;
  28365. private _spriteManagers;
  28366. private _opaqueSortCompareFn;
  28367. private _alphaTestSortCompareFn;
  28368. private _transparentSortCompareFn;
  28369. private _renderOpaque;
  28370. private _renderAlphaTest;
  28371. private _renderTransparent;
  28372. /** @hidden */
  28373. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  28374. onBeforeTransparentRendering: () => void;
  28375. /**
  28376. * Set the opaque sort comparison function.
  28377. * If null the sub meshes will be render in the order they were created
  28378. */
  28379. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28380. /**
  28381. * Set the alpha test sort comparison function.
  28382. * If null the sub meshes will be render in the order they were created
  28383. */
  28384. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28385. /**
  28386. * Set the transparent sort comparison function.
  28387. * If null the sub meshes will be render in the order they were created
  28388. */
  28389. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28390. /**
  28391. * Creates a new rendering group.
  28392. * @param index The rendering group index
  28393. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  28394. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  28395. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  28396. */
  28397. 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>);
  28398. /**
  28399. * Render all the sub meshes contained in the group.
  28400. * @param customRenderFunction Used to override the default render behaviour of the group.
  28401. * @returns true if rendered some submeshes.
  28402. */
  28403. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  28404. /**
  28405. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  28406. * @param subMeshes The submeshes to render
  28407. */
  28408. private renderOpaqueSorted;
  28409. /**
  28410. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  28411. * @param subMeshes The submeshes to render
  28412. */
  28413. private renderAlphaTestSorted;
  28414. /**
  28415. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  28416. * @param subMeshes The submeshes to render
  28417. */
  28418. private renderTransparentSorted;
  28419. /**
  28420. * Renders the submeshes in a specified order.
  28421. * @param subMeshes The submeshes to sort before render
  28422. * @param sortCompareFn The comparison function use to sort
  28423. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  28424. * @param transparent Specifies to activate blending if true
  28425. */
  28426. private static renderSorted;
  28427. /**
  28428. * Renders the submeshes in the order they were dispatched (no sort applied).
  28429. * @param subMeshes The submeshes to render
  28430. */
  28431. private static renderUnsorted;
  28432. /**
  28433. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28434. * are rendered back to front if in the same alpha index.
  28435. *
  28436. * @param a The first submesh
  28437. * @param b The second submesh
  28438. * @returns The result of the comparison
  28439. */
  28440. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  28441. /**
  28442. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28443. * are rendered back to front.
  28444. *
  28445. * @param a The first submesh
  28446. * @param b The second submesh
  28447. * @returns The result of the comparison
  28448. */
  28449. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  28450. /**
  28451. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28452. * are rendered front to back (prevent overdraw).
  28453. *
  28454. * @param a The first submesh
  28455. * @param b The second submesh
  28456. * @returns The result of the comparison
  28457. */
  28458. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  28459. /**
  28460. * Resets the different lists of submeshes to prepare a new frame.
  28461. */
  28462. prepare(): void;
  28463. dispose(): void;
  28464. /**
  28465. * Inserts the submesh in its correct queue depending on its material.
  28466. * @param subMesh The submesh to dispatch
  28467. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28468. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28469. */
  28470. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28471. dispatchSprites(spriteManager: ISpriteManager): void;
  28472. dispatchParticles(particleSystem: IParticleSystem): void;
  28473. private _renderParticles;
  28474. private _renderSprites;
  28475. }
  28476. }
  28477. declare module BABYLON {
  28478. /**
  28479. * Interface describing the different options available in the rendering manager
  28480. * regarding Auto Clear between groups.
  28481. */
  28482. export interface IRenderingManagerAutoClearSetup {
  28483. /**
  28484. * Defines whether or not autoclear is enable.
  28485. */
  28486. autoClear: boolean;
  28487. /**
  28488. * Defines whether or not to autoclear the depth buffer.
  28489. */
  28490. depth: boolean;
  28491. /**
  28492. * Defines whether or not to autoclear the stencil buffer.
  28493. */
  28494. stencil: boolean;
  28495. }
  28496. /**
  28497. * This class is used by the onRenderingGroupObservable
  28498. */
  28499. export class RenderingGroupInfo {
  28500. /**
  28501. * The Scene that being rendered
  28502. */
  28503. scene: Scene;
  28504. /**
  28505. * The camera currently used for the rendering pass
  28506. */
  28507. camera: Nullable<Camera>;
  28508. /**
  28509. * The ID of the renderingGroup being processed
  28510. */
  28511. renderingGroupId: number;
  28512. }
  28513. /**
  28514. * This is the manager responsible of all the rendering for meshes sprites and particles.
  28515. * It is enable to manage the different groups as well as the different necessary sort functions.
  28516. * This should not be used directly aside of the few static configurations
  28517. */
  28518. export class RenderingManager {
  28519. /**
  28520. * The max id used for rendering groups (not included)
  28521. */
  28522. static MAX_RENDERINGGROUPS: number;
  28523. /**
  28524. * The min id used for rendering groups (included)
  28525. */
  28526. static MIN_RENDERINGGROUPS: number;
  28527. /**
  28528. * Used to globally prevent autoclearing scenes.
  28529. */
  28530. static AUTOCLEAR: boolean;
  28531. /**
  28532. * @hidden
  28533. */
  28534. _useSceneAutoClearSetup: boolean;
  28535. private _scene;
  28536. private _renderingGroups;
  28537. private _depthStencilBufferAlreadyCleaned;
  28538. private _autoClearDepthStencil;
  28539. private _customOpaqueSortCompareFn;
  28540. private _customAlphaTestSortCompareFn;
  28541. private _customTransparentSortCompareFn;
  28542. private _renderingGroupInfo;
  28543. /**
  28544. * Instantiates a new rendering group for a particular scene
  28545. * @param scene Defines the scene the groups belongs to
  28546. */
  28547. constructor(scene: Scene);
  28548. private _clearDepthStencilBuffer;
  28549. /**
  28550. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  28551. * @hidden
  28552. */
  28553. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  28554. /**
  28555. * Resets the different information of the group to prepare a new frame
  28556. * @hidden
  28557. */
  28558. reset(): void;
  28559. /**
  28560. * Dispose and release the group and its associated resources.
  28561. * @hidden
  28562. */
  28563. dispose(): void;
  28564. /**
  28565. * Clear the info related to rendering groups preventing retention points during dispose.
  28566. */
  28567. freeRenderingGroups(): void;
  28568. private _prepareRenderingGroup;
  28569. /**
  28570. * Add a sprite manager to the rendering manager in order to render it this frame.
  28571. * @param spriteManager Define the sprite manager to render
  28572. */
  28573. dispatchSprites(spriteManager: ISpriteManager): void;
  28574. /**
  28575. * Add a particle system to the rendering manager in order to render it this frame.
  28576. * @param particleSystem Define the particle system to render
  28577. */
  28578. dispatchParticles(particleSystem: IParticleSystem): void;
  28579. /**
  28580. * Add a submesh to the manager in order to render it this frame
  28581. * @param subMesh The submesh to dispatch
  28582. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28583. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28584. */
  28585. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28586. /**
  28587. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28588. * This allowed control for front to back rendering or reversly depending of the special needs.
  28589. *
  28590. * @param renderingGroupId The rendering group id corresponding to its index
  28591. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28592. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28593. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28594. */
  28595. 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;
  28596. /**
  28597. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28598. *
  28599. * @param renderingGroupId The rendering group id corresponding to its index
  28600. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28601. * @param depth Automatically clears depth between groups if true and autoClear is true.
  28602. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  28603. */
  28604. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  28605. /**
  28606. * Gets the current auto clear configuration for one rendering group of the rendering
  28607. * manager.
  28608. * @param index the rendering group index to get the information for
  28609. * @returns The auto clear setup for the requested rendering group
  28610. */
  28611. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  28612. }
  28613. }
  28614. declare module BABYLON {
  28615. /**
  28616. * Defines the options associated with the creation of a custom shader for a shadow generator.
  28617. */
  28618. export interface ICustomShaderOptions {
  28619. /**
  28620. * Gets or sets the custom shader name to use
  28621. */
  28622. shaderName: string;
  28623. /**
  28624. * The list of attribute names used in the shader
  28625. */
  28626. attributes?: string[];
  28627. /**
  28628. * The list of unifrom names used in the shader
  28629. */
  28630. uniforms?: string[];
  28631. /**
  28632. * The list of sampler names used in the shader
  28633. */
  28634. samplers?: string[];
  28635. /**
  28636. * The list of defines used in the shader
  28637. */
  28638. defines?: string[];
  28639. }
  28640. /**
  28641. * Interface to implement to create a shadow generator compatible with BJS.
  28642. */
  28643. export interface IShadowGenerator {
  28644. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28645. id: string;
  28646. /**
  28647. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  28648. * @returns The render target texture if present otherwise, null
  28649. */
  28650. getShadowMap(): Nullable<RenderTargetTexture>;
  28651. /**
  28652. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  28653. * @param subMesh The submesh we want to render in the shadow map
  28654. * @param useInstances Defines wether will draw in the map using instances
  28655. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  28656. * @returns true if ready otherwise, false
  28657. */
  28658. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  28659. /**
  28660. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  28661. * @param defines Defines of the material we want to update
  28662. * @param lightIndex Index of the light in the enabled light list of the material
  28663. */
  28664. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  28665. /**
  28666. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  28667. * defined in the generator but impacting the effect).
  28668. * It implies the unifroms available on the materials are the standard BJS ones.
  28669. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  28670. * @param effect The effect we are binfing the information for
  28671. */
  28672. bindShadowLight(lightIndex: string, effect: Effect): void;
  28673. /**
  28674. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  28675. * (eq to shadow prjection matrix * light transform matrix)
  28676. * @returns The transform matrix used to create the shadow map
  28677. */
  28678. getTransformMatrix(): Matrix;
  28679. /**
  28680. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  28681. * Cube and 2D textures for instance.
  28682. */
  28683. recreateShadowMap(): void;
  28684. /**
  28685. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28686. * @param onCompiled Callback triggered at the and of the effects compilation
  28687. * @param options Sets of optional options forcing the compilation with different modes
  28688. */
  28689. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  28690. useInstances: boolean;
  28691. }>): void;
  28692. /**
  28693. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28694. * @param options Sets of optional options forcing the compilation with different modes
  28695. * @returns A promise that resolves when the compilation completes
  28696. */
  28697. forceCompilationAsync(options?: Partial<{
  28698. useInstances: boolean;
  28699. }>): Promise<void>;
  28700. /**
  28701. * Serializes the shadow generator setup to a json object.
  28702. * @returns The serialized JSON object
  28703. */
  28704. serialize(): any;
  28705. /**
  28706. * Disposes the Shadow map and related Textures and effects.
  28707. */
  28708. dispose(): void;
  28709. }
  28710. /**
  28711. * Default implementation IShadowGenerator.
  28712. * This is the main object responsible of generating shadows in the framework.
  28713. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  28714. */
  28715. export class ShadowGenerator implements IShadowGenerator {
  28716. /**
  28717. * Name of the shadow generator class
  28718. */
  28719. static CLASSNAME: string;
  28720. /**
  28721. * Shadow generator mode None: no filtering applied.
  28722. */
  28723. static readonly FILTER_NONE: number;
  28724. /**
  28725. * Shadow generator mode ESM: Exponential Shadow Mapping.
  28726. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28727. */
  28728. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  28729. /**
  28730. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  28731. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  28732. */
  28733. static readonly FILTER_POISSONSAMPLING: number;
  28734. /**
  28735. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  28736. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28737. */
  28738. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  28739. /**
  28740. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  28741. * edge artifacts on steep falloff.
  28742. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28743. */
  28744. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  28745. /**
  28746. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  28747. * edge artifacts on steep falloff.
  28748. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28749. */
  28750. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  28751. /**
  28752. * Shadow generator mode PCF: Percentage Closer Filtering
  28753. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28754. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  28755. */
  28756. static readonly FILTER_PCF: number;
  28757. /**
  28758. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  28759. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28760. * Contact Hardening
  28761. */
  28762. static readonly FILTER_PCSS: number;
  28763. /**
  28764. * Reserved for PCF and PCSS
  28765. * Highest Quality.
  28766. *
  28767. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  28768. *
  28769. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  28770. */
  28771. static readonly QUALITY_HIGH: number;
  28772. /**
  28773. * Reserved for PCF and PCSS
  28774. * Good tradeoff for quality/perf cross devices
  28775. *
  28776. * Execute PCF on a 3*3 kernel.
  28777. *
  28778. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  28779. */
  28780. static readonly QUALITY_MEDIUM: number;
  28781. /**
  28782. * Reserved for PCF and PCSS
  28783. * The lowest quality but the fastest.
  28784. *
  28785. * Execute PCF on a 1*1 kernel.
  28786. *
  28787. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  28788. */
  28789. static readonly QUALITY_LOW: number;
  28790. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28791. id: string;
  28792. /** Gets or sets the custom shader name to use */
  28793. customShaderOptions: ICustomShaderOptions;
  28794. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  28795. customAllowRendering: (subMesh: SubMesh) => boolean;
  28796. /**
  28797. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  28798. */
  28799. onBeforeShadowMapRenderObservable: Observable<Effect>;
  28800. /**
  28801. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  28802. */
  28803. onAfterShadowMapRenderObservable: Observable<Effect>;
  28804. /**
  28805. * Observable triggered before a mesh is rendered in the shadow map.
  28806. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  28807. */
  28808. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  28809. /**
  28810. * Observable triggered after a mesh is rendered in the shadow map.
  28811. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  28812. */
  28813. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  28814. protected _bias: number;
  28815. /**
  28816. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  28817. */
  28818. get bias(): number;
  28819. /**
  28820. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  28821. */
  28822. set bias(bias: number);
  28823. protected _normalBias: number;
  28824. /**
  28825. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28826. */
  28827. get normalBias(): number;
  28828. /**
  28829. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28830. */
  28831. set normalBias(normalBias: number);
  28832. protected _blurBoxOffset: number;
  28833. /**
  28834. * Gets the blur box offset: offset applied during the blur pass.
  28835. * Only useful if useKernelBlur = false
  28836. */
  28837. get blurBoxOffset(): number;
  28838. /**
  28839. * Sets the blur box offset: offset applied during the blur pass.
  28840. * Only useful if useKernelBlur = false
  28841. */
  28842. set blurBoxOffset(value: number);
  28843. protected _blurScale: number;
  28844. /**
  28845. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  28846. * 2 means half of the size.
  28847. */
  28848. get blurScale(): number;
  28849. /**
  28850. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  28851. * 2 means half of the size.
  28852. */
  28853. set blurScale(value: number);
  28854. protected _blurKernel: number;
  28855. /**
  28856. * Gets the blur kernel: kernel size of the blur pass.
  28857. * Only useful if useKernelBlur = true
  28858. */
  28859. get blurKernel(): number;
  28860. /**
  28861. * Sets the blur kernel: kernel size of the blur pass.
  28862. * Only useful if useKernelBlur = true
  28863. */
  28864. set blurKernel(value: number);
  28865. protected _useKernelBlur: boolean;
  28866. /**
  28867. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  28868. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28869. */
  28870. get useKernelBlur(): boolean;
  28871. /**
  28872. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  28873. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28874. */
  28875. set useKernelBlur(value: boolean);
  28876. protected _depthScale: number;
  28877. /**
  28878. * Gets the depth scale used in ESM mode.
  28879. */
  28880. get depthScale(): number;
  28881. /**
  28882. * Sets the depth scale used in ESM mode.
  28883. * This can override the scale stored on the light.
  28884. */
  28885. set depthScale(value: number);
  28886. protected _validateFilter(filter: number): number;
  28887. protected _filter: number;
  28888. /**
  28889. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  28890. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28891. */
  28892. get filter(): number;
  28893. /**
  28894. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  28895. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28896. */
  28897. set filter(value: number);
  28898. /**
  28899. * Gets if the current filter is set to Poisson Sampling.
  28900. */
  28901. get usePoissonSampling(): boolean;
  28902. /**
  28903. * Sets the current filter to Poisson Sampling.
  28904. */
  28905. set usePoissonSampling(value: boolean);
  28906. /**
  28907. * Gets if the current filter is set to ESM.
  28908. */
  28909. get useExponentialShadowMap(): boolean;
  28910. /**
  28911. * Sets the current filter is to ESM.
  28912. */
  28913. set useExponentialShadowMap(value: boolean);
  28914. /**
  28915. * Gets if the current filter is set to filtered ESM.
  28916. */
  28917. get useBlurExponentialShadowMap(): boolean;
  28918. /**
  28919. * Gets if the current filter is set to filtered ESM.
  28920. */
  28921. set useBlurExponentialShadowMap(value: boolean);
  28922. /**
  28923. * Gets if the current filter is set to "close ESM" (using the inverse of the
  28924. * exponential to prevent steep falloff artifacts).
  28925. */
  28926. get useCloseExponentialShadowMap(): boolean;
  28927. /**
  28928. * Sets the current filter to "close ESM" (using the inverse of the
  28929. * exponential to prevent steep falloff artifacts).
  28930. */
  28931. set useCloseExponentialShadowMap(value: boolean);
  28932. /**
  28933. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  28934. * exponential to prevent steep falloff artifacts).
  28935. */
  28936. get useBlurCloseExponentialShadowMap(): boolean;
  28937. /**
  28938. * Sets the current filter to filtered "close ESM" (using the inverse of the
  28939. * exponential to prevent steep falloff artifacts).
  28940. */
  28941. set useBlurCloseExponentialShadowMap(value: boolean);
  28942. /**
  28943. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  28944. */
  28945. get usePercentageCloserFiltering(): boolean;
  28946. /**
  28947. * Sets the current filter to "PCF" (percentage closer filtering).
  28948. */
  28949. set usePercentageCloserFiltering(value: boolean);
  28950. protected _filteringQuality: number;
  28951. /**
  28952. * Gets the PCF or PCSS Quality.
  28953. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28954. */
  28955. get filteringQuality(): number;
  28956. /**
  28957. * Sets the PCF or PCSS Quality.
  28958. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  28959. */
  28960. set filteringQuality(filteringQuality: number);
  28961. /**
  28962. * Gets if the current filter is set to "PCSS" (contact hardening).
  28963. */
  28964. get useContactHardeningShadow(): boolean;
  28965. /**
  28966. * Sets the current filter to "PCSS" (contact hardening).
  28967. */
  28968. set useContactHardeningShadow(value: boolean);
  28969. protected _contactHardeningLightSizeUVRatio: number;
  28970. /**
  28971. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  28972. * Using a ratio helps keeping shape stability independently of the map size.
  28973. *
  28974. * It does not account for the light projection as it was having too much
  28975. * instability during the light setup or during light position changes.
  28976. *
  28977. * Only valid if useContactHardeningShadow is true.
  28978. */
  28979. get contactHardeningLightSizeUVRatio(): number;
  28980. /**
  28981. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  28982. * Using a ratio helps keeping shape stability independently of the map size.
  28983. *
  28984. * It does not account for the light projection as it was having too much
  28985. * instability during the light setup or during light position changes.
  28986. *
  28987. * Only valid if useContactHardeningShadow is true.
  28988. */
  28989. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  28990. protected _darkness: number;
  28991. /** Gets or sets the actual darkness of a shadow */
  28992. get darkness(): number;
  28993. set darkness(value: number);
  28994. /**
  28995. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  28996. * 0 means strongest and 1 would means no shadow.
  28997. * @returns the darkness.
  28998. */
  28999. getDarkness(): number;
  29000. /**
  29001. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29002. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29003. * @returns the shadow generator allowing fluent coding.
  29004. */
  29005. setDarkness(darkness: number): ShadowGenerator;
  29006. protected _transparencyShadow: boolean;
  29007. /** Gets or sets the ability to have transparent shadow */
  29008. get transparencyShadow(): boolean;
  29009. set transparencyShadow(value: boolean);
  29010. /**
  29011. * Sets the ability to have transparent shadow (boolean).
  29012. * @param transparent True if transparent else False
  29013. * @returns the shadow generator allowing fluent coding
  29014. */
  29015. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29016. /**
  29017. * Enables or disables shadows with varying strength based on the transparency
  29018. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  29019. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  29020. * mesh.visibility * alphaTexture.a
  29021. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  29022. */
  29023. enableSoftTransparentShadow: boolean;
  29024. protected _shadowMap: Nullable<RenderTargetTexture>;
  29025. protected _shadowMap2: Nullable<RenderTargetTexture>;
  29026. /**
  29027. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29028. * @returns The render target texture if present otherwise, null
  29029. */
  29030. getShadowMap(): Nullable<RenderTargetTexture>;
  29031. /**
  29032. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29033. * @returns The render target texture if the shadow map is present otherwise, null
  29034. */
  29035. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29036. /**
  29037. * Gets the class name of that object
  29038. * @returns "ShadowGenerator"
  29039. */
  29040. getClassName(): string;
  29041. /**
  29042. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29043. * @param mesh Mesh to add
  29044. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29045. * @returns the Shadow Generator itself
  29046. */
  29047. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29048. /**
  29049. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29050. * @param mesh Mesh to remove
  29051. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29052. * @returns the Shadow Generator itself
  29053. */
  29054. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29055. /**
  29056. * Controls the extent to which the shadows fade out at the edge of the frustum
  29057. */
  29058. frustumEdgeFalloff: number;
  29059. protected _light: IShadowLight;
  29060. /**
  29061. * Returns the associated light object.
  29062. * @returns the light generating the shadow
  29063. */
  29064. getLight(): IShadowLight;
  29065. /**
  29066. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29067. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29068. * It might on the other hand introduce peter panning.
  29069. */
  29070. forceBackFacesOnly: boolean;
  29071. protected _scene: Scene;
  29072. protected _lightDirection: Vector3;
  29073. protected _effect: Effect;
  29074. protected _viewMatrix: Matrix;
  29075. protected _projectionMatrix: Matrix;
  29076. protected _transformMatrix: Matrix;
  29077. protected _cachedPosition: Vector3;
  29078. protected _cachedDirection: Vector3;
  29079. protected _cachedDefines: string;
  29080. protected _currentRenderID: number;
  29081. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29082. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29083. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29084. protected _blurPostProcesses: PostProcess[];
  29085. protected _mapSize: number;
  29086. protected _currentFaceIndex: number;
  29087. protected _currentFaceIndexCache: number;
  29088. protected _textureType: number;
  29089. protected _defaultTextureMatrix: Matrix;
  29090. protected _storedUniqueId: Nullable<number>;
  29091. /** @hidden */
  29092. static _SceneComponentInitialization: (scene: Scene) => void;
  29093. /**
  29094. * Gets or sets the size of the texture what stores the shadows
  29095. */
  29096. get mapSize(): number;
  29097. set mapSize(size: number);
  29098. /**
  29099. * Creates a ShadowGenerator object.
  29100. * A ShadowGenerator is the required tool to use the shadows.
  29101. * Each light casting shadows needs to use its own ShadowGenerator.
  29102. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29103. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29104. * @param light The light object generating the shadows.
  29105. * @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.
  29106. */
  29107. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29108. protected _initializeGenerator(): void;
  29109. protected _createTargetRenderTexture(): void;
  29110. protected _initializeShadowMap(): void;
  29111. protected _initializeBlurRTTAndPostProcesses(): void;
  29112. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29113. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29114. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29115. protected _applyFilterValues(): void;
  29116. /**
  29117. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29118. * @param onCompiled Callback triggered at the and of the effects compilation
  29119. * @param options Sets of optional options forcing the compilation with different modes
  29120. */
  29121. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29122. useInstances: boolean;
  29123. }>): void;
  29124. /**
  29125. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29126. * @param options Sets of optional options forcing the compilation with different modes
  29127. * @returns A promise that resolves when the compilation completes
  29128. */
  29129. forceCompilationAsync(options?: Partial<{
  29130. useInstances: boolean;
  29131. }>): Promise<void>;
  29132. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29133. private _prepareShadowDefines;
  29134. /**
  29135. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29136. * @param subMesh The submesh we want to render in the shadow map
  29137. * @param useInstances Defines wether will draw in the map using instances
  29138. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29139. * @returns true if ready otherwise, false
  29140. */
  29141. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29142. /**
  29143. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29144. * @param defines Defines of the material we want to update
  29145. * @param lightIndex Index of the light in the enabled light list of the material
  29146. */
  29147. prepareDefines(defines: any, lightIndex: number): void;
  29148. /**
  29149. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29150. * defined in the generator but impacting the effect).
  29151. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29152. * @param effect The effect we are binfing the information for
  29153. */
  29154. bindShadowLight(lightIndex: string, effect: Effect): void;
  29155. /**
  29156. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29157. * (eq to shadow prjection matrix * light transform matrix)
  29158. * @returns The transform matrix used to create the shadow map
  29159. */
  29160. getTransformMatrix(): Matrix;
  29161. /**
  29162. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29163. * Cube and 2D textures for instance.
  29164. */
  29165. recreateShadowMap(): void;
  29166. protected _disposeBlurPostProcesses(): void;
  29167. protected _disposeRTTandPostProcesses(): void;
  29168. /**
  29169. * Disposes the ShadowGenerator.
  29170. * Returns nothing.
  29171. */
  29172. dispose(): void;
  29173. /**
  29174. * Serializes the shadow generator setup to a json object.
  29175. * @returns The serialized JSON object
  29176. */
  29177. serialize(): any;
  29178. /**
  29179. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29180. * @param parsedShadowGenerator The JSON object to parse
  29181. * @param scene The scene to create the shadow map for
  29182. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29183. * @returns The parsed shadow generator
  29184. */
  29185. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29186. }
  29187. }
  29188. declare module BABYLON {
  29189. /**
  29190. * Options to be used when creating a shadow depth material
  29191. */
  29192. export interface IIOptionShadowDepthMaterial {
  29193. /** Variables in the vertex shader code that need to have their names remapped.
  29194. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29195. * "var_name" should be either: worldPos or vNormalW
  29196. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29197. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29198. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29199. */
  29200. remappedVariables?: string[];
  29201. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29202. standalone?: boolean;
  29203. }
  29204. /**
  29205. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29206. */
  29207. export class ShadowDepthWrapper {
  29208. private _scene;
  29209. private _options?;
  29210. private _baseMaterial;
  29211. private _onEffectCreatedObserver;
  29212. private _subMeshToEffect;
  29213. private _subMeshToDepthEffect;
  29214. private _meshes;
  29215. /** @hidden */
  29216. _matriceNames: any;
  29217. /** Gets the standalone status of the wrapper */
  29218. get standalone(): boolean;
  29219. /** Gets the base material the wrapper is built upon */
  29220. get baseMaterial(): Material;
  29221. /**
  29222. * Instantiate a new shadow depth wrapper.
  29223. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29224. * generate the shadow depth map. For more information, please refer to the documentation:
  29225. * https://doc.babylonjs.com/babylon101/shadows
  29226. * @param baseMaterial Material to wrap
  29227. * @param scene Define the scene the material belongs to
  29228. * @param options Options used to create the wrapper
  29229. */
  29230. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29231. /**
  29232. * Gets the effect to use to generate the depth map
  29233. * @param subMesh subMesh to get the effect for
  29234. * @param shadowGenerator shadow generator to get the effect for
  29235. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29236. */
  29237. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29238. /**
  29239. * Specifies that the submesh is ready to be used for depth rendering
  29240. * @param subMesh submesh to check
  29241. * @param defines the list of defines to take into account when checking the effect
  29242. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29243. * @param useInstances specifies that instances should be used
  29244. * @returns a boolean indicating that the submesh is ready or not
  29245. */
  29246. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29247. /**
  29248. * Disposes the resources
  29249. */
  29250. dispose(): void;
  29251. private _makeEffect;
  29252. }
  29253. }
  29254. declare module BABYLON {
  29255. /**
  29256. * Options for compiling materials.
  29257. */
  29258. export interface IMaterialCompilationOptions {
  29259. /**
  29260. * Defines whether clip planes are enabled.
  29261. */
  29262. clipPlane: boolean;
  29263. /**
  29264. * Defines whether instances are enabled.
  29265. */
  29266. useInstances: boolean;
  29267. }
  29268. /**
  29269. * Options passed when calling customShaderNameResolve
  29270. */
  29271. export interface ICustomShaderNameResolveOptions {
  29272. /**
  29273. * 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
  29274. */
  29275. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29276. }
  29277. /**
  29278. * Base class for the main features of a material in Babylon.js
  29279. */
  29280. export class Material implements IAnimatable {
  29281. /**
  29282. * Returns the triangle fill mode
  29283. */
  29284. static readonly TriangleFillMode: number;
  29285. /**
  29286. * Returns the wireframe mode
  29287. */
  29288. static readonly WireFrameFillMode: number;
  29289. /**
  29290. * Returns the point fill mode
  29291. */
  29292. static readonly PointFillMode: number;
  29293. /**
  29294. * Returns the point list draw mode
  29295. */
  29296. static readonly PointListDrawMode: number;
  29297. /**
  29298. * Returns the line list draw mode
  29299. */
  29300. static readonly LineListDrawMode: number;
  29301. /**
  29302. * Returns the line loop draw mode
  29303. */
  29304. static readonly LineLoopDrawMode: number;
  29305. /**
  29306. * Returns the line strip draw mode
  29307. */
  29308. static readonly LineStripDrawMode: number;
  29309. /**
  29310. * Returns the triangle strip draw mode
  29311. */
  29312. static readonly TriangleStripDrawMode: number;
  29313. /**
  29314. * Returns the triangle fan draw mode
  29315. */
  29316. static readonly TriangleFanDrawMode: number;
  29317. /**
  29318. * Stores the clock-wise side orientation
  29319. */
  29320. static readonly ClockWiseSideOrientation: number;
  29321. /**
  29322. * Stores the counter clock-wise side orientation
  29323. */
  29324. static readonly CounterClockWiseSideOrientation: number;
  29325. /**
  29326. * The dirty texture flag value
  29327. */
  29328. static readonly TextureDirtyFlag: number;
  29329. /**
  29330. * The dirty light flag value
  29331. */
  29332. static readonly LightDirtyFlag: number;
  29333. /**
  29334. * The dirty fresnel flag value
  29335. */
  29336. static readonly FresnelDirtyFlag: number;
  29337. /**
  29338. * The dirty attribute flag value
  29339. */
  29340. static readonly AttributesDirtyFlag: number;
  29341. /**
  29342. * The dirty misc flag value
  29343. */
  29344. static readonly MiscDirtyFlag: number;
  29345. /**
  29346. * The dirty prepass flag value
  29347. */
  29348. static readonly PrePassDirtyFlag: number;
  29349. /**
  29350. * The all dirty flag value
  29351. */
  29352. static readonly AllDirtyFlag: number;
  29353. /**
  29354. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  29355. */
  29356. static readonly MATERIAL_OPAQUE: number;
  29357. /**
  29358. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  29359. */
  29360. static readonly MATERIAL_ALPHATEST: number;
  29361. /**
  29362. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29363. */
  29364. static readonly MATERIAL_ALPHABLEND: number;
  29365. /**
  29366. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29367. * They are also discarded below the alpha cutoff threshold to improve performances.
  29368. */
  29369. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  29370. /**
  29371. * The Whiteout method is used to blend normals.
  29372. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29373. */
  29374. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  29375. /**
  29376. * The Reoriented Normal Mapping method is used to blend normals.
  29377. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29378. */
  29379. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  29380. /**
  29381. * Custom callback helping to override the default shader used in the material.
  29382. */
  29383. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  29384. /**
  29385. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  29386. */
  29387. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  29388. /**
  29389. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  29390. * This means that the material can keep using a previous shader while a new one is being compiled.
  29391. * This is mostly used when shader parallel compilation is supported (true by default)
  29392. */
  29393. allowShaderHotSwapping: boolean;
  29394. /**
  29395. * The ID of the material
  29396. */
  29397. id: string;
  29398. /**
  29399. * Gets or sets the unique id of the material
  29400. */
  29401. uniqueId: number;
  29402. /**
  29403. * The name of the material
  29404. */
  29405. name: string;
  29406. /**
  29407. * Gets or sets user defined metadata
  29408. */
  29409. metadata: any;
  29410. /**
  29411. * For internal use only. Please do not use.
  29412. */
  29413. reservedDataStore: any;
  29414. /**
  29415. * Specifies if the ready state should be checked on each call
  29416. */
  29417. checkReadyOnEveryCall: boolean;
  29418. /**
  29419. * Specifies if the ready state should be checked once
  29420. */
  29421. checkReadyOnlyOnce: boolean;
  29422. /**
  29423. * The state of the material
  29424. */
  29425. state: string;
  29426. /**
  29427. * If the material can be rendered to several textures with MRT extension
  29428. */
  29429. get canRenderToMRT(): boolean;
  29430. /**
  29431. * The alpha value of the material
  29432. */
  29433. protected _alpha: number;
  29434. /**
  29435. * List of inspectable custom properties (used by the Inspector)
  29436. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29437. */
  29438. inspectableCustomProperties: IInspectable[];
  29439. /**
  29440. * Sets the alpha value of the material
  29441. */
  29442. set alpha(value: number);
  29443. /**
  29444. * Gets the alpha value of the material
  29445. */
  29446. get alpha(): number;
  29447. /**
  29448. * Specifies if back face culling is enabled
  29449. */
  29450. protected _backFaceCulling: boolean;
  29451. /**
  29452. * Sets the back-face culling state
  29453. */
  29454. set backFaceCulling(value: boolean);
  29455. /**
  29456. * Gets the back-face culling state
  29457. */
  29458. get backFaceCulling(): boolean;
  29459. /**
  29460. * Stores the value for side orientation
  29461. */
  29462. sideOrientation: number;
  29463. /**
  29464. * Callback triggered when the material is compiled
  29465. */
  29466. onCompiled: Nullable<(effect: Effect) => void>;
  29467. /**
  29468. * Callback triggered when an error occurs
  29469. */
  29470. onError: Nullable<(effect: Effect, errors: string) => void>;
  29471. /**
  29472. * Callback triggered to get the render target textures
  29473. */
  29474. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29475. /**
  29476. * Gets a boolean indicating that current material needs to register RTT
  29477. */
  29478. get hasRenderTargetTextures(): boolean;
  29479. /**
  29480. * Specifies if the material should be serialized
  29481. */
  29482. doNotSerialize: boolean;
  29483. /**
  29484. * @hidden
  29485. */
  29486. _storeEffectOnSubMeshes: boolean;
  29487. /**
  29488. * Stores the animations for the material
  29489. */
  29490. animations: Nullable<Array<Animation>>;
  29491. /**
  29492. * An event triggered when the material is disposed
  29493. */
  29494. onDisposeObservable: Observable<Material>;
  29495. /**
  29496. * An observer which watches for dispose events
  29497. */
  29498. private _onDisposeObserver;
  29499. private _onUnBindObservable;
  29500. /**
  29501. * Called during a dispose event
  29502. */
  29503. set onDispose(callback: () => void);
  29504. private _onBindObservable;
  29505. /**
  29506. * An event triggered when the material is bound
  29507. */
  29508. get onBindObservable(): Observable<AbstractMesh>;
  29509. /**
  29510. * An observer which watches for bind events
  29511. */
  29512. private _onBindObserver;
  29513. /**
  29514. * Called during a bind event
  29515. */
  29516. set onBind(callback: (Mesh: AbstractMesh) => void);
  29517. /**
  29518. * An event triggered when the material is unbound
  29519. */
  29520. get onUnBindObservable(): Observable<Material>;
  29521. protected _onEffectCreatedObservable: Nullable<Observable<{
  29522. effect: Effect;
  29523. subMesh: Nullable<SubMesh>;
  29524. }>>;
  29525. /**
  29526. * An event triggered when the effect is (re)created
  29527. */
  29528. get onEffectCreatedObservable(): Observable<{
  29529. effect: Effect;
  29530. subMesh: Nullable<SubMesh>;
  29531. }>;
  29532. /**
  29533. * Stores the value of the alpha mode
  29534. */
  29535. private _alphaMode;
  29536. /**
  29537. * Sets the value of the alpha mode.
  29538. *
  29539. * | Value | Type | Description |
  29540. * | --- | --- | --- |
  29541. * | 0 | ALPHA_DISABLE | |
  29542. * | 1 | ALPHA_ADD | |
  29543. * | 2 | ALPHA_COMBINE | |
  29544. * | 3 | ALPHA_SUBTRACT | |
  29545. * | 4 | ALPHA_MULTIPLY | |
  29546. * | 5 | ALPHA_MAXIMIZED | |
  29547. * | 6 | ALPHA_ONEONE | |
  29548. * | 7 | ALPHA_PREMULTIPLIED | |
  29549. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29550. * | 9 | ALPHA_INTERPOLATE | |
  29551. * | 10 | ALPHA_SCREENMODE | |
  29552. *
  29553. */
  29554. set alphaMode(value: number);
  29555. /**
  29556. * Gets the value of the alpha mode
  29557. */
  29558. get alphaMode(): number;
  29559. /**
  29560. * Stores the state of the need depth pre-pass value
  29561. */
  29562. private _needDepthPrePass;
  29563. /**
  29564. * Sets the need depth pre-pass value
  29565. */
  29566. set needDepthPrePass(value: boolean);
  29567. /**
  29568. * Gets the depth pre-pass value
  29569. */
  29570. get needDepthPrePass(): boolean;
  29571. /**
  29572. * Specifies if depth writing should be disabled
  29573. */
  29574. disableDepthWrite: boolean;
  29575. /**
  29576. * Specifies if color writing should be disabled
  29577. */
  29578. disableColorWrite: boolean;
  29579. /**
  29580. * Specifies if depth writing should be forced
  29581. */
  29582. forceDepthWrite: boolean;
  29583. /**
  29584. * Specifies the depth function that should be used. 0 means the default engine function
  29585. */
  29586. depthFunction: number;
  29587. /**
  29588. * Specifies if there should be a separate pass for culling
  29589. */
  29590. separateCullingPass: boolean;
  29591. /**
  29592. * Stores the state specifing if fog should be enabled
  29593. */
  29594. private _fogEnabled;
  29595. /**
  29596. * Sets the state for enabling fog
  29597. */
  29598. set fogEnabled(value: boolean);
  29599. /**
  29600. * Gets the value of the fog enabled state
  29601. */
  29602. get fogEnabled(): boolean;
  29603. /**
  29604. * Stores the size of points
  29605. */
  29606. pointSize: number;
  29607. /**
  29608. * Stores the z offset value
  29609. */
  29610. zOffset: number;
  29611. get wireframe(): boolean;
  29612. /**
  29613. * Sets the state of wireframe mode
  29614. */
  29615. set wireframe(value: boolean);
  29616. /**
  29617. * Gets the value specifying if point clouds are enabled
  29618. */
  29619. get pointsCloud(): boolean;
  29620. /**
  29621. * Sets the state of point cloud mode
  29622. */
  29623. set pointsCloud(value: boolean);
  29624. /**
  29625. * Gets the material fill mode
  29626. */
  29627. get fillMode(): number;
  29628. /**
  29629. * Sets the material fill mode
  29630. */
  29631. set fillMode(value: number);
  29632. /**
  29633. * @hidden
  29634. * Stores the effects for the material
  29635. */
  29636. _effect: Nullable<Effect>;
  29637. /**
  29638. * Specifies if uniform buffers should be used
  29639. */
  29640. private _useUBO;
  29641. /**
  29642. * Stores a reference to the scene
  29643. */
  29644. private _scene;
  29645. /**
  29646. * Stores the fill mode state
  29647. */
  29648. private _fillMode;
  29649. /**
  29650. * Specifies if the depth write state should be cached
  29651. */
  29652. private _cachedDepthWriteState;
  29653. /**
  29654. * Specifies if the color write state should be cached
  29655. */
  29656. private _cachedColorWriteState;
  29657. /**
  29658. * Specifies if the depth function state should be cached
  29659. */
  29660. private _cachedDepthFunctionState;
  29661. /**
  29662. * Stores the uniform buffer
  29663. */
  29664. protected _uniformBuffer: UniformBuffer;
  29665. /** @hidden */
  29666. _indexInSceneMaterialArray: number;
  29667. /** @hidden */
  29668. meshMap: Nullable<{
  29669. [id: string]: AbstractMesh | undefined;
  29670. }>;
  29671. /**
  29672. * Creates a material instance
  29673. * @param name defines the name of the material
  29674. * @param scene defines the scene to reference
  29675. * @param doNotAdd specifies if the material should be added to the scene
  29676. */
  29677. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29678. /**
  29679. * Returns a string representation of the current material
  29680. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29681. * @returns a string with material information
  29682. */
  29683. toString(fullDetails?: boolean): string;
  29684. /**
  29685. * Gets the class name of the material
  29686. * @returns a string with the class name of the material
  29687. */
  29688. getClassName(): string;
  29689. /**
  29690. * Specifies if updates for the material been locked
  29691. */
  29692. get isFrozen(): boolean;
  29693. /**
  29694. * Locks updates for the material
  29695. */
  29696. freeze(): void;
  29697. /**
  29698. * Unlocks updates for the material
  29699. */
  29700. unfreeze(): void;
  29701. /**
  29702. * Specifies if the material is ready to be used
  29703. * @param mesh defines the mesh to check
  29704. * @param useInstances specifies if instances should be used
  29705. * @returns a boolean indicating if the material is ready to be used
  29706. */
  29707. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29708. /**
  29709. * Specifies that the submesh is ready to be used
  29710. * @param mesh defines the mesh to check
  29711. * @param subMesh defines which submesh to check
  29712. * @param useInstances specifies that instances should be used
  29713. * @returns a boolean indicating that the submesh is ready or not
  29714. */
  29715. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29716. /**
  29717. * Returns the material effect
  29718. * @returns the effect associated with the material
  29719. */
  29720. getEffect(): Nullable<Effect>;
  29721. /**
  29722. * Returns the current scene
  29723. * @returns a Scene
  29724. */
  29725. getScene(): Scene;
  29726. /**
  29727. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29728. */
  29729. protected _forceAlphaTest: boolean;
  29730. /**
  29731. * The transparency mode of the material.
  29732. */
  29733. protected _transparencyMode: Nullable<number>;
  29734. /**
  29735. * Gets the current transparency mode.
  29736. */
  29737. get transparencyMode(): Nullable<number>;
  29738. /**
  29739. * Sets the transparency mode of the material.
  29740. *
  29741. * | Value | Type | Description |
  29742. * | ----- | ----------------------------------- | ----------- |
  29743. * | 0 | OPAQUE | |
  29744. * | 1 | ALPHATEST | |
  29745. * | 2 | ALPHABLEND | |
  29746. * | 3 | ALPHATESTANDBLEND | |
  29747. *
  29748. */
  29749. set transparencyMode(value: Nullable<number>);
  29750. /**
  29751. * Returns true if alpha blending should be disabled.
  29752. */
  29753. protected get _disableAlphaBlending(): boolean;
  29754. /**
  29755. * Specifies whether or not this material should be rendered in alpha blend mode.
  29756. * @returns a boolean specifying if alpha blending is needed
  29757. */
  29758. needAlphaBlending(): boolean;
  29759. /**
  29760. * Specifies if the mesh will require alpha blending
  29761. * @param mesh defines the mesh to check
  29762. * @returns a boolean specifying if alpha blending is needed for the mesh
  29763. */
  29764. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29765. /**
  29766. * Specifies whether or not this material should be rendered in alpha test mode.
  29767. * @returns a boolean specifying if an alpha test is needed.
  29768. */
  29769. needAlphaTesting(): boolean;
  29770. /**
  29771. * Specifies if material alpha testing should be turned on for the mesh
  29772. * @param mesh defines the mesh to check
  29773. */
  29774. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29775. /**
  29776. * Gets the texture used for the alpha test
  29777. * @returns the texture to use for alpha testing
  29778. */
  29779. getAlphaTestTexture(): Nullable<BaseTexture>;
  29780. /**
  29781. * Marks the material to indicate that it needs to be re-calculated
  29782. */
  29783. markDirty(): void;
  29784. /** @hidden */
  29785. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29786. /**
  29787. * Binds the material to the mesh
  29788. * @param world defines the world transformation matrix
  29789. * @param mesh defines the mesh to bind the material to
  29790. */
  29791. bind(world: Matrix, mesh?: Mesh): void;
  29792. /**
  29793. * Binds the submesh to the material
  29794. * @param world defines the world transformation matrix
  29795. * @param mesh defines the mesh containing the submesh
  29796. * @param subMesh defines the submesh to bind the material to
  29797. */
  29798. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29799. /**
  29800. * Binds the world matrix to the material
  29801. * @param world defines the world transformation matrix
  29802. */
  29803. bindOnlyWorldMatrix(world: Matrix): void;
  29804. /**
  29805. * Binds the scene's uniform buffer to the effect.
  29806. * @param effect defines the effect to bind to the scene uniform buffer
  29807. * @param sceneUbo defines the uniform buffer storing scene data
  29808. */
  29809. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29810. /**
  29811. * Binds the view matrix to the effect
  29812. * @param effect defines the effect to bind the view matrix to
  29813. */
  29814. bindView(effect: Effect): void;
  29815. /**
  29816. * Binds the view projection matrix to the effect
  29817. * @param effect defines the effect to bind the view projection matrix to
  29818. */
  29819. bindViewProjection(effect: Effect): void;
  29820. /**
  29821. * Processes to execute after binding the material to a mesh
  29822. * @param mesh defines the rendered mesh
  29823. */
  29824. protected _afterBind(mesh?: Mesh): void;
  29825. /**
  29826. * Unbinds the material from the mesh
  29827. */
  29828. unbind(): void;
  29829. /**
  29830. * Gets the active textures from the material
  29831. * @returns an array of textures
  29832. */
  29833. getActiveTextures(): BaseTexture[];
  29834. /**
  29835. * Specifies if the material uses a texture
  29836. * @param texture defines the texture to check against the material
  29837. * @returns a boolean specifying if the material uses the texture
  29838. */
  29839. hasTexture(texture: BaseTexture): boolean;
  29840. /**
  29841. * Makes a duplicate of the material, and gives it a new name
  29842. * @param name defines the new name for the duplicated material
  29843. * @returns the cloned material
  29844. */
  29845. clone(name: string): Nullable<Material>;
  29846. /**
  29847. * Gets the meshes bound to the material
  29848. * @returns an array of meshes bound to the material
  29849. */
  29850. getBindedMeshes(): AbstractMesh[];
  29851. /**
  29852. * Force shader compilation
  29853. * @param mesh defines the mesh associated with this material
  29854. * @param onCompiled defines a function to execute once the material is compiled
  29855. * @param options defines the options to configure the compilation
  29856. * @param onError defines a function to execute if the material fails compiling
  29857. */
  29858. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29859. /**
  29860. * Force shader compilation
  29861. * @param mesh defines the mesh that will use this material
  29862. * @param options defines additional options for compiling the shaders
  29863. * @returns a promise that resolves when the compilation completes
  29864. */
  29865. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29866. private static readonly _AllDirtyCallBack;
  29867. private static readonly _ImageProcessingDirtyCallBack;
  29868. private static readonly _TextureDirtyCallBack;
  29869. private static readonly _FresnelDirtyCallBack;
  29870. private static readonly _MiscDirtyCallBack;
  29871. private static readonly _PrePassDirtyCallBack;
  29872. private static readonly _LightsDirtyCallBack;
  29873. private static readonly _AttributeDirtyCallBack;
  29874. private static _FresnelAndMiscDirtyCallBack;
  29875. private static _TextureAndMiscDirtyCallBack;
  29876. private static readonly _DirtyCallbackArray;
  29877. private static readonly _RunDirtyCallBacks;
  29878. /**
  29879. * Marks a define in the material to indicate that it needs to be re-computed
  29880. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29881. */
  29882. markAsDirty(flag: number): void;
  29883. /**
  29884. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29885. * @param func defines a function which checks material defines against the submeshes
  29886. */
  29887. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29888. /**
  29889. * Indicates that the scene should check if the rendering now needs a prepass
  29890. */
  29891. protected _markScenePrePassDirty(): void;
  29892. /**
  29893. * Indicates that we need to re-calculated for all submeshes
  29894. */
  29895. protected _markAllSubMeshesAsAllDirty(): void;
  29896. /**
  29897. * Indicates that image processing needs to be re-calculated for all submeshes
  29898. */
  29899. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29900. /**
  29901. * Indicates that textures need to be re-calculated for all submeshes
  29902. */
  29903. protected _markAllSubMeshesAsTexturesDirty(): void;
  29904. /**
  29905. * Indicates that fresnel needs to be re-calculated for all submeshes
  29906. */
  29907. protected _markAllSubMeshesAsFresnelDirty(): void;
  29908. /**
  29909. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29910. */
  29911. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29912. /**
  29913. * Indicates that lights need to be re-calculated for all submeshes
  29914. */
  29915. protected _markAllSubMeshesAsLightsDirty(): void;
  29916. /**
  29917. * Indicates that attributes need to be re-calculated for all submeshes
  29918. */
  29919. protected _markAllSubMeshesAsAttributesDirty(): void;
  29920. /**
  29921. * Indicates that misc needs to be re-calculated for all submeshes
  29922. */
  29923. protected _markAllSubMeshesAsMiscDirty(): void;
  29924. /**
  29925. * Indicates that prepass needs to be re-calculated for all submeshes
  29926. */
  29927. protected _markAllSubMeshesAsPrePassDirty(): void;
  29928. /**
  29929. * Indicates that textures and misc need to be re-calculated for all submeshes
  29930. */
  29931. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29932. /**
  29933. * Sets the required values to the prepass renderer.
  29934. * @param prePassRenderer defines the prepass renderer to setup.
  29935. * @returns true if the pre pass is needed.
  29936. */
  29937. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29938. /**
  29939. * Disposes the material
  29940. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29941. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29942. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29943. */
  29944. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29945. /** @hidden */
  29946. private releaseVertexArrayObject;
  29947. /**
  29948. * Serializes this material
  29949. * @returns the serialized material object
  29950. */
  29951. serialize(): any;
  29952. /**
  29953. * Creates a material from parsed material data
  29954. * @param parsedMaterial defines parsed material data
  29955. * @param scene defines the hosting scene
  29956. * @param rootUrl defines the root URL to use to load textures
  29957. * @returns a new material
  29958. */
  29959. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29960. }
  29961. }
  29962. declare module BABYLON {
  29963. /**
  29964. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29965. * separate meshes. This can be use to improve performances.
  29966. * @see https://doc.babylonjs.com/how_to/multi_materials
  29967. */
  29968. export class MultiMaterial extends Material {
  29969. private _subMaterials;
  29970. /**
  29971. * Gets or Sets the list of Materials used within the multi material.
  29972. * They need to be ordered according to the submeshes order in the associated mesh
  29973. */
  29974. get subMaterials(): Nullable<Material>[];
  29975. set subMaterials(value: Nullable<Material>[]);
  29976. /**
  29977. * Function used to align with Node.getChildren()
  29978. * @returns the list of Materials used within the multi material
  29979. */
  29980. getChildren(): Nullable<Material>[];
  29981. /**
  29982. * Instantiates a new Multi Material
  29983. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29984. * separate meshes. This can be use to improve performances.
  29985. * @see https://doc.babylonjs.com/how_to/multi_materials
  29986. * @param name Define the name in the scene
  29987. * @param scene Define the scene the material belongs to
  29988. */
  29989. constructor(name: string, scene: Scene);
  29990. private _hookArray;
  29991. /**
  29992. * Get one of the submaterial by its index in the submaterials array
  29993. * @param index The index to look the sub material at
  29994. * @returns The Material if the index has been defined
  29995. */
  29996. getSubMaterial(index: number): Nullable<Material>;
  29997. /**
  29998. * Get the list of active textures for the whole sub materials list.
  29999. * @returns All the textures that will be used during the rendering
  30000. */
  30001. getActiveTextures(): BaseTexture[];
  30002. /**
  30003. * Specifies if any sub-materials of this multi-material use a given texture.
  30004. * @param texture Defines the texture to check against this multi-material's sub-materials.
  30005. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  30006. */
  30007. hasTexture(texture: BaseTexture): boolean;
  30008. /**
  30009. * Gets the current class name of the material e.g. "MultiMaterial"
  30010. * Mainly use in serialization.
  30011. * @returns the class name
  30012. */
  30013. getClassName(): string;
  30014. /**
  30015. * Checks if the material is ready to render the requested sub mesh
  30016. * @param mesh Define the mesh the submesh belongs to
  30017. * @param subMesh Define the sub mesh to look readyness for
  30018. * @param useInstances Define whether or not the material is used with instances
  30019. * @returns true if ready, otherwise false
  30020. */
  30021. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30022. /**
  30023. * Clones the current material and its related sub materials
  30024. * @param name Define the name of the newly cloned material
  30025. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30026. * @returns the cloned material
  30027. */
  30028. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30029. /**
  30030. * Serializes the materials into a JSON representation.
  30031. * @returns the JSON representation
  30032. */
  30033. serialize(): any;
  30034. /**
  30035. * Dispose the material and release its associated resources
  30036. * @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)
  30037. * @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)
  30038. * @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)
  30039. */
  30040. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30041. /**
  30042. * Creates a MultiMaterial from parsed MultiMaterial data.
  30043. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30044. * @param scene defines the hosting scene
  30045. * @returns a new MultiMaterial
  30046. */
  30047. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30048. }
  30049. }
  30050. declare module BABYLON {
  30051. /**
  30052. * Defines a subdivision inside a mesh
  30053. */
  30054. export class SubMesh implements ICullable {
  30055. /** the material index to use */
  30056. materialIndex: number;
  30057. /** vertex index start */
  30058. verticesStart: number;
  30059. /** vertices count */
  30060. verticesCount: number;
  30061. /** index start */
  30062. indexStart: number;
  30063. /** indices count */
  30064. indexCount: number;
  30065. /** @hidden */
  30066. _materialDefines: Nullable<MaterialDefines>;
  30067. /** @hidden */
  30068. _materialEffect: Nullable<Effect>;
  30069. /** @hidden */
  30070. _effectOverride: Nullable<Effect>;
  30071. /**
  30072. * Gets material defines used by the effect associated to the sub mesh
  30073. */
  30074. get materialDefines(): Nullable<MaterialDefines>;
  30075. /**
  30076. * Sets material defines used by the effect associated to the sub mesh
  30077. */
  30078. set materialDefines(defines: Nullable<MaterialDefines>);
  30079. /**
  30080. * Gets associated effect
  30081. */
  30082. get effect(): Nullable<Effect>;
  30083. /**
  30084. * Sets associated effect (effect used to render this submesh)
  30085. * @param effect defines the effect to associate with
  30086. * @param defines defines the set of defines used to compile this effect
  30087. */
  30088. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30089. /** @hidden */
  30090. _linesIndexCount: number;
  30091. private _mesh;
  30092. private _renderingMesh;
  30093. private _boundingInfo;
  30094. private _linesIndexBuffer;
  30095. /** @hidden */
  30096. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30097. /** @hidden */
  30098. _trianglePlanes: Plane[];
  30099. /** @hidden */
  30100. _lastColliderTransformMatrix: Nullable<Matrix>;
  30101. /** @hidden */
  30102. _renderId: number;
  30103. /** @hidden */
  30104. _alphaIndex: number;
  30105. /** @hidden */
  30106. _distanceToCamera: number;
  30107. /** @hidden */
  30108. _id: number;
  30109. private _currentMaterial;
  30110. /**
  30111. * Add a new submesh to a mesh
  30112. * @param materialIndex defines the material index to use
  30113. * @param verticesStart defines vertex index start
  30114. * @param verticesCount defines vertices count
  30115. * @param indexStart defines index start
  30116. * @param indexCount defines indices count
  30117. * @param mesh defines the parent mesh
  30118. * @param renderingMesh defines an optional rendering mesh
  30119. * @param createBoundingBox defines if bounding box should be created for this submesh
  30120. * @returns the new submesh
  30121. */
  30122. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30123. /**
  30124. * Creates a new submesh
  30125. * @param materialIndex defines the material index to use
  30126. * @param verticesStart defines vertex index start
  30127. * @param verticesCount defines vertices count
  30128. * @param indexStart defines index start
  30129. * @param indexCount defines indices count
  30130. * @param mesh defines the parent mesh
  30131. * @param renderingMesh defines an optional rendering mesh
  30132. * @param createBoundingBox defines if bounding box should be created for this submesh
  30133. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30134. */
  30135. constructor(
  30136. /** the material index to use */
  30137. materialIndex: number,
  30138. /** vertex index start */
  30139. verticesStart: number,
  30140. /** vertices count */
  30141. verticesCount: number,
  30142. /** index start */
  30143. indexStart: number,
  30144. /** indices count */
  30145. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30146. /**
  30147. * Returns true if this submesh covers the entire parent mesh
  30148. * @ignorenaming
  30149. */
  30150. get IsGlobal(): boolean;
  30151. /**
  30152. * Returns the submesh BoudingInfo object
  30153. * @returns current bounding info (or mesh's one if the submesh is global)
  30154. */
  30155. getBoundingInfo(): BoundingInfo;
  30156. /**
  30157. * Sets the submesh BoundingInfo
  30158. * @param boundingInfo defines the new bounding info to use
  30159. * @returns the SubMesh
  30160. */
  30161. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30162. /**
  30163. * Returns the mesh of the current submesh
  30164. * @return the parent mesh
  30165. */
  30166. getMesh(): AbstractMesh;
  30167. /**
  30168. * Returns the rendering mesh of the submesh
  30169. * @returns the rendering mesh (could be different from parent mesh)
  30170. */
  30171. getRenderingMesh(): Mesh;
  30172. /**
  30173. * Returns the replacement mesh of the submesh
  30174. * @returns the replacement mesh (could be different from parent mesh)
  30175. */
  30176. getReplacementMesh(): Nullable<AbstractMesh>;
  30177. /**
  30178. * Returns the effective mesh of the submesh
  30179. * @returns the effective mesh (could be different from parent mesh)
  30180. */
  30181. getEffectiveMesh(): AbstractMesh;
  30182. /**
  30183. * Returns the submesh material
  30184. * @returns null or the current material
  30185. */
  30186. getMaterial(): Nullable<Material>;
  30187. private _IsMultiMaterial;
  30188. /**
  30189. * Sets a new updated BoundingInfo object to the submesh
  30190. * @param data defines an optional position array to use to determine the bounding info
  30191. * @returns the SubMesh
  30192. */
  30193. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30194. /** @hidden */
  30195. _checkCollision(collider: Collider): boolean;
  30196. /**
  30197. * Updates the submesh BoundingInfo
  30198. * @param world defines the world matrix to use to update the bounding info
  30199. * @returns the submesh
  30200. */
  30201. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30202. /**
  30203. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30204. * @param frustumPlanes defines the frustum planes
  30205. * @returns true if the submesh is intersecting with the frustum
  30206. */
  30207. isInFrustum(frustumPlanes: Plane[]): boolean;
  30208. /**
  30209. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30210. * @param frustumPlanes defines the frustum planes
  30211. * @returns true if the submesh is inside the frustum
  30212. */
  30213. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30214. /**
  30215. * Renders the submesh
  30216. * @param enableAlphaMode defines if alpha needs to be used
  30217. * @returns the submesh
  30218. */
  30219. render(enableAlphaMode: boolean): SubMesh;
  30220. /**
  30221. * @hidden
  30222. */
  30223. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30224. /**
  30225. * Checks if the submesh intersects with a ray
  30226. * @param ray defines the ray to test
  30227. * @returns true is the passed ray intersects the submesh bounding box
  30228. */
  30229. canIntersects(ray: Ray): boolean;
  30230. /**
  30231. * Intersects current submesh with a ray
  30232. * @param ray defines the ray to test
  30233. * @param positions defines mesh's positions array
  30234. * @param indices defines mesh's indices array
  30235. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30236. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30237. * @returns intersection info or null if no intersection
  30238. */
  30239. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30240. /** @hidden */
  30241. private _intersectLines;
  30242. /** @hidden */
  30243. private _intersectUnIndexedLines;
  30244. /** @hidden */
  30245. private _intersectTriangles;
  30246. /** @hidden */
  30247. private _intersectUnIndexedTriangles;
  30248. /** @hidden */
  30249. _rebuild(): void;
  30250. /**
  30251. * Creates a new submesh from the passed mesh
  30252. * @param newMesh defines the new hosting mesh
  30253. * @param newRenderingMesh defines an optional rendering mesh
  30254. * @returns the new submesh
  30255. */
  30256. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30257. /**
  30258. * Release associated resources
  30259. */
  30260. dispose(): void;
  30261. /**
  30262. * Gets the class name
  30263. * @returns the string "SubMesh".
  30264. */
  30265. getClassName(): string;
  30266. /**
  30267. * Creates a new submesh from indices data
  30268. * @param materialIndex the index of the main mesh material
  30269. * @param startIndex the index where to start the copy in the mesh indices array
  30270. * @param indexCount the number of indices to copy then from the startIndex
  30271. * @param mesh the main mesh to create the submesh from
  30272. * @param renderingMesh the optional rendering mesh
  30273. * @returns a new submesh
  30274. */
  30275. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30276. }
  30277. }
  30278. declare module BABYLON {
  30279. /**
  30280. * Class used to represent data loading progression
  30281. */
  30282. export class SceneLoaderFlags {
  30283. private static _ForceFullSceneLoadingForIncremental;
  30284. private static _ShowLoadingScreen;
  30285. private static _CleanBoneMatrixWeights;
  30286. private static _loggingLevel;
  30287. /**
  30288. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30289. */
  30290. static get ForceFullSceneLoadingForIncremental(): boolean;
  30291. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30292. /**
  30293. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30294. */
  30295. static get ShowLoadingScreen(): boolean;
  30296. static set ShowLoadingScreen(value: boolean);
  30297. /**
  30298. * Defines the current logging level (while loading the scene)
  30299. * @ignorenaming
  30300. */
  30301. static get loggingLevel(): number;
  30302. static set loggingLevel(value: number);
  30303. /**
  30304. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30305. */
  30306. static get CleanBoneMatrixWeights(): boolean;
  30307. static set CleanBoneMatrixWeights(value: boolean);
  30308. }
  30309. }
  30310. declare module BABYLON {
  30311. /**
  30312. * Class used to store geometry data (vertex buffers + index buffer)
  30313. */
  30314. export class Geometry implements IGetSetVerticesData {
  30315. /**
  30316. * Gets or sets the ID of the geometry
  30317. */
  30318. id: string;
  30319. /**
  30320. * Gets or sets the unique ID of the geometry
  30321. */
  30322. uniqueId: number;
  30323. /**
  30324. * Gets the delay loading state of the geometry (none by default which means not delayed)
  30325. */
  30326. delayLoadState: number;
  30327. /**
  30328. * Gets the file containing the data to load when running in delay load state
  30329. */
  30330. delayLoadingFile: Nullable<string>;
  30331. /**
  30332. * Callback called when the geometry is updated
  30333. */
  30334. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  30335. private _scene;
  30336. private _engine;
  30337. private _meshes;
  30338. private _totalVertices;
  30339. /** @hidden */
  30340. _indices: IndicesArray;
  30341. /** @hidden */
  30342. _vertexBuffers: {
  30343. [key: string]: VertexBuffer;
  30344. };
  30345. private _isDisposed;
  30346. private _extend;
  30347. private _boundingBias;
  30348. /** @hidden */
  30349. _delayInfo: Array<string>;
  30350. private _indexBuffer;
  30351. private _indexBufferIsUpdatable;
  30352. /** @hidden */
  30353. _boundingInfo: Nullable<BoundingInfo>;
  30354. /** @hidden */
  30355. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  30356. /** @hidden */
  30357. _softwareSkinningFrameId: number;
  30358. private _vertexArrayObjects;
  30359. private _updatable;
  30360. /** @hidden */
  30361. _positions: Nullable<Vector3[]>;
  30362. private _positionsCache;
  30363. /**
  30364. * 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
  30365. */
  30366. get boundingBias(): Vector2;
  30367. /**
  30368. * 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
  30369. */
  30370. set boundingBias(value: Vector2);
  30371. /**
  30372. * Static function used to attach a new empty geometry to a mesh
  30373. * @param mesh defines the mesh to attach the geometry to
  30374. * @returns the new Geometry
  30375. */
  30376. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  30377. /** Get the list of meshes using this geometry */
  30378. get meshes(): Mesh[];
  30379. /**
  30380. * 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
  30381. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  30382. */
  30383. useBoundingInfoFromGeometry: boolean;
  30384. /**
  30385. * Creates a new geometry
  30386. * @param id defines the unique ID
  30387. * @param scene defines the hosting scene
  30388. * @param vertexData defines the VertexData used to get geometry data
  30389. * @param updatable defines if geometry must be updatable (false by default)
  30390. * @param mesh defines the mesh that will be associated with the geometry
  30391. */
  30392. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  30393. /**
  30394. * Gets the current extend of the geometry
  30395. */
  30396. get extend(): {
  30397. minimum: Vector3;
  30398. maximum: Vector3;
  30399. };
  30400. /**
  30401. * Gets the hosting scene
  30402. * @returns the hosting Scene
  30403. */
  30404. getScene(): Scene;
  30405. /**
  30406. * Gets the hosting engine
  30407. * @returns the hosting Engine
  30408. */
  30409. getEngine(): Engine;
  30410. /**
  30411. * Defines if the geometry is ready to use
  30412. * @returns true if the geometry is ready to be used
  30413. */
  30414. isReady(): boolean;
  30415. /**
  30416. * Gets a value indicating that the geometry should not be serialized
  30417. */
  30418. get doNotSerialize(): boolean;
  30419. /** @hidden */
  30420. _rebuild(): void;
  30421. /**
  30422. * Affects all geometry data in one call
  30423. * @param vertexData defines the geometry data
  30424. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  30425. */
  30426. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  30427. /**
  30428. * Set specific vertex data
  30429. * @param kind defines the data kind (Position, normal, etc...)
  30430. * @param data defines the vertex data to use
  30431. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30432. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30433. */
  30434. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  30435. /**
  30436. * Removes a specific vertex data
  30437. * @param kind defines the data kind (Position, normal, etc...)
  30438. */
  30439. removeVerticesData(kind: string): void;
  30440. /**
  30441. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30442. * @param buffer defines the vertex buffer to use
  30443. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30444. */
  30445. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30446. /**
  30447. * Update a specific vertex buffer
  30448. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30449. * It will do nothing if the buffer is not updatable
  30450. * @param kind defines the data kind (Position, normal, etc...)
  30451. * @param data defines the data to use
  30452. * @param offset defines the offset in the target buffer where to store the data
  30453. * @param useBytes set to true if the offset is in bytes
  30454. */
  30455. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30456. /**
  30457. * Update a specific vertex buffer
  30458. * This function will create a new buffer if the current one is not updatable
  30459. * @param kind defines the data kind (Position, normal, etc...)
  30460. * @param data defines the data to use
  30461. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30462. */
  30463. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30464. private _updateBoundingInfo;
  30465. /** @hidden */
  30466. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30467. /**
  30468. * Gets total number of vertices
  30469. * @returns the total number of vertices
  30470. */
  30471. getTotalVertices(): number;
  30472. /**
  30473. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30474. * @param kind defines the data kind (Position, normal, etc...)
  30475. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30476. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30477. * @returns a float array containing vertex data
  30478. */
  30479. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30480. /**
  30481. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30482. * @param kind defines the data kind (Position, normal, etc...)
  30483. * @returns true if the vertex buffer with the specified kind is updatable
  30484. */
  30485. isVertexBufferUpdatable(kind: string): boolean;
  30486. /**
  30487. * Gets a specific vertex buffer
  30488. * @param kind defines the data kind (Position, normal, etc...)
  30489. * @returns a VertexBuffer
  30490. */
  30491. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30492. /**
  30493. * Returns all vertex buffers
  30494. * @return an object holding all vertex buffers indexed by kind
  30495. */
  30496. getVertexBuffers(): Nullable<{
  30497. [key: string]: VertexBuffer;
  30498. }>;
  30499. /**
  30500. * Gets a boolean indicating if specific vertex buffer is present
  30501. * @param kind defines the data kind (Position, normal, etc...)
  30502. * @returns true if data is present
  30503. */
  30504. isVerticesDataPresent(kind: string): boolean;
  30505. /**
  30506. * Gets a list of all attached data kinds (Position, normal, etc...)
  30507. * @returns a list of string containing all kinds
  30508. */
  30509. getVerticesDataKinds(): string[];
  30510. /**
  30511. * Update index buffer
  30512. * @param indices defines the indices to store in the index buffer
  30513. * @param offset defines the offset in the target buffer where to store the data
  30514. * @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)
  30515. */
  30516. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30517. /**
  30518. * Creates a new index buffer
  30519. * @param indices defines the indices to store in the index buffer
  30520. * @param totalVertices defines the total number of vertices (could be null)
  30521. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30522. */
  30523. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30524. /**
  30525. * Return the total number of indices
  30526. * @returns the total number of indices
  30527. */
  30528. getTotalIndices(): number;
  30529. /**
  30530. * Gets the index buffer array
  30531. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30532. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30533. * @returns the index buffer array
  30534. */
  30535. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30536. /**
  30537. * Gets the index buffer
  30538. * @return the index buffer
  30539. */
  30540. getIndexBuffer(): Nullable<DataBuffer>;
  30541. /** @hidden */
  30542. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30543. /**
  30544. * Release the associated resources for a specific mesh
  30545. * @param mesh defines the source mesh
  30546. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30547. */
  30548. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30549. /**
  30550. * Apply current geometry to a given mesh
  30551. * @param mesh defines the mesh to apply geometry to
  30552. */
  30553. applyToMesh(mesh: Mesh): void;
  30554. private _updateExtend;
  30555. private _applyToMesh;
  30556. private notifyUpdate;
  30557. /**
  30558. * Load the geometry if it was flagged as delay loaded
  30559. * @param scene defines the hosting scene
  30560. * @param onLoaded defines a callback called when the geometry is loaded
  30561. */
  30562. load(scene: Scene, onLoaded?: () => void): void;
  30563. private _queueLoad;
  30564. /**
  30565. * Invert the geometry to move from a right handed system to a left handed one.
  30566. */
  30567. toLeftHanded(): void;
  30568. /** @hidden */
  30569. _resetPointsArrayCache(): void;
  30570. /** @hidden */
  30571. _generatePointsArray(): boolean;
  30572. /**
  30573. * Gets a value indicating if the geometry is disposed
  30574. * @returns true if the geometry was disposed
  30575. */
  30576. isDisposed(): boolean;
  30577. private _disposeVertexArrayObjects;
  30578. /**
  30579. * Free all associated resources
  30580. */
  30581. dispose(): void;
  30582. /**
  30583. * Clone the current geometry into a new geometry
  30584. * @param id defines the unique ID of the new geometry
  30585. * @returns a new geometry object
  30586. */
  30587. copy(id: string): Geometry;
  30588. /**
  30589. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30590. * @return a JSON representation of the current geometry data (without the vertices data)
  30591. */
  30592. serialize(): any;
  30593. private toNumberArray;
  30594. /**
  30595. * Serialize all vertices data into a JSON oject
  30596. * @returns a JSON representation of the current geometry data
  30597. */
  30598. serializeVerticeData(): any;
  30599. /**
  30600. * Extracts a clone of a mesh geometry
  30601. * @param mesh defines the source mesh
  30602. * @param id defines the unique ID of the new geometry object
  30603. * @returns the new geometry object
  30604. */
  30605. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30606. /**
  30607. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30608. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30609. * Be aware Math.random() could cause collisions, but:
  30610. * "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"
  30611. * @returns a string containing a new GUID
  30612. */
  30613. static RandomId(): string;
  30614. /** @hidden */
  30615. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30616. private static _CleanMatricesWeights;
  30617. /**
  30618. * Create a new geometry from persisted data (Using .babylon file format)
  30619. * @param parsedVertexData defines the persisted data
  30620. * @param scene defines the hosting scene
  30621. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30622. * @returns the new geometry object
  30623. */
  30624. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30625. }
  30626. }
  30627. declare module BABYLON {
  30628. /**
  30629. * Defines a target to use with MorphTargetManager
  30630. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30631. */
  30632. export class MorphTarget implements IAnimatable {
  30633. /** defines the name of the target */
  30634. name: string;
  30635. /**
  30636. * Gets or sets the list of animations
  30637. */
  30638. animations: Animation[];
  30639. private _scene;
  30640. private _positions;
  30641. private _normals;
  30642. private _tangents;
  30643. private _uvs;
  30644. private _influence;
  30645. private _uniqueId;
  30646. /**
  30647. * Observable raised when the influence changes
  30648. */
  30649. onInfluenceChanged: Observable<boolean>;
  30650. /** @hidden */
  30651. _onDataLayoutChanged: Observable<void>;
  30652. /**
  30653. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30654. */
  30655. get influence(): number;
  30656. set influence(influence: number);
  30657. /**
  30658. * Gets or sets the id of the morph Target
  30659. */
  30660. id: string;
  30661. private _animationPropertiesOverride;
  30662. /**
  30663. * Gets or sets the animation properties override
  30664. */
  30665. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30666. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30667. /**
  30668. * Creates a new MorphTarget
  30669. * @param name defines the name of the target
  30670. * @param influence defines the influence to use
  30671. * @param scene defines the scene the morphtarget belongs to
  30672. */
  30673. constructor(
  30674. /** defines the name of the target */
  30675. name: string, influence?: number, scene?: Nullable<Scene>);
  30676. /**
  30677. * Gets the unique ID of this manager
  30678. */
  30679. get uniqueId(): number;
  30680. /**
  30681. * Gets a boolean defining if the target contains position data
  30682. */
  30683. get hasPositions(): boolean;
  30684. /**
  30685. * Gets a boolean defining if the target contains normal data
  30686. */
  30687. get hasNormals(): boolean;
  30688. /**
  30689. * Gets a boolean defining if the target contains tangent data
  30690. */
  30691. get hasTangents(): boolean;
  30692. /**
  30693. * Gets a boolean defining if the target contains texture coordinates data
  30694. */
  30695. get hasUVs(): boolean;
  30696. /**
  30697. * Affects position data to this target
  30698. * @param data defines the position data to use
  30699. */
  30700. setPositions(data: Nullable<FloatArray>): void;
  30701. /**
  30702. * Gets the position data stored in this target
  30703. * @returns a FloatArray containing the position data (or null if not present)
  30704. */
  30705. getPositions(): Nullable<FloatArray>;
  30706. /**
  30707. * Affects normal data to this target
  30708. * @param data defines the normal data to use
  30709. */
  30710. setNormals(data: Nullable<FloatArray>): void;
  30711. /**
  30712. * Gets the normal data stored in this target
  30713. * @returns a FloatArray containing the normal data (or null if not present)
  30714. */
  30715. getNormals(): Nullable<FloatArray>;
  30716. /**
  30717. * Affects tangent data to this target
  30718. * @param data defines the tangent data to use
  30719. */
  30720. setTangents(data: Nullable<FloatArray>): void;
  30721. /**
  30722. * Gets the tangent data stored in this target
  30723. * @returns a FloatArray containing the tangent data (or null if not present)
  30724. */
  30725. getTangents(): Nullable<FloatArray>;
  30726. /**
  30727. * Affects texture coordinates data to this target
  30728. * @param data defines the texture coordinates data to use
  30729. */
  30730. setUVs(data: Nullable<FloatArray>): void;
  30731. /**
  30732. * Gets the texture coordinates data stored in this target
  30733. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  30734. */
  30735. getUVs(): Nullable<FloatArray>;
  30736. /**
  30737. * Clone the current target
  30738. * @returns a new MorphTarget
  30739. */
  30740. clone(): MorphTarget;
  30741. /**
  30742. * Serializes the current target into a Serialization object
  30743. * @returns the serialized object
  30744. */
  30745. serialize(): any;
  30746. /**
  30747. * Returns the string "MorphTarget"
  30748. * @returns "MorphTarget"
  30749. */
  30750. getClassName(): string;
  30751. /**
  30752. * Creates a new target from serialized data
  30753. * @param serializationObject defines the serialized data to use
  30754. * @returns a new MorphTarget
  30755. */
  30756. static Parse(serializationObject: any): MorphTarget;
  30757. /**
  30758. * Creates a MorphTarget from mesh data
  30759. * @param mesh defines the source mesh
  30760. * @param name defines the name to use for the new target
  30761. * @param influence defines the influence to attach to the target
  30762. * @returns a new MorphTarget
  30763. */
  30764. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30765. }
  30766. }
  30767. declare module BABYLON {
  30768. /**
  30769. * This class is used to deform meshes using morphing between different targets
  30770. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30771. */
  30772. export class MorphTargetManager {
  30773. private _targets;
  30774. private _targetInfluenceChangedObservers;
  30775. private _targetDataLayoutChangedObservers;
  30776. private _activeTargets;
  30777. private _scene;
  30778. private _influences;
  30779. private _supportsNormals;
  30780. private _supportsTangents;
  30781. private _supportsUVs;
  30782. private _vertexCount;
  30783. private _uniqueId;
  30784. private _tempInfluences;
  30785. /**
  30786. * Gets or sets a boolean indicating if normals must be morphed
  30787. */
  30788. enableNormalMorphing: boolean;
  30789. /**
  30790. * Gets or sets a boolean indicating if tangents must be morphed
  30791. */
  30792. enableTangentMorphing: boolean;
  30793. /**
  30794. * Gets or sets a boolean indicating if UV must be morphed
  30795. */
  30796. enableUVMorphing: boolean;
  30797. /**
  30798. * Creates a new MorphTargetManager
  30799. * @param scene defines the current scene
  30800. */
  30801. constructor(scene?: Nullable<Scene>);
  30802. /**
  30803. * Gets the unique ID of this manager
  30804. */
  30805. get uniqueId(): number;
  30806. /**
  30807. * Gets the number of vertices handled by this manager
  30808. */
  30809. get vertexCount(): number;
  30810. /**
  30811. * Gets a boolean indicating if this manager supports morphing of normals
  30812. */
  30813. get supportsNormals(): boolean;
  30814. /**
  30815. * Gets a boolean indicating if this manager supports morphing of tangents
  30816. */
  30817. get supportsTangents(): boolean;
  30818. /**
  30819. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  30820. */
  30821. get supportsUVs(): boolean;
  30822. /**
  30823. * Gets the number of targets stored in this manager
  30824. */
  30825. get numTargets(): number;
  30826. /**
  30827. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30828. */
  30829. get numInfluencers(): number;
  30830. /**
  30831. * Gets the list of influences (one per target)
  30832. */
  30833. get influences(): Float32Array;
  30834. /**
  30835. * Gets the active target at specified index. An active target is a target with an influence > 0
  30836. * @param index defines the index to check
  30837. * @returns the requested target
  30838. */
  30839. getActiveTarget(index: number): MorphTarget;
  30840. /**
  30841. * Gets the target at specified index
  30842. * @param index defines the index to check
  30843. * @returns the requested target
  30844. */
  30845. getTarget(index: number): MorphTarget;
  30846. /**
  30847. * Add a new target to this manager
  30848. * @param target defines the target to add
  30849. */
  30850. addTarget(target: MorphTarget): void;
  30851. /**
  30852. * Removes a target from the manager
  30853. * @param target defines the target to remove
  30854. */
  30855. removeTarget(target: MorphTarget): void;
  30856. /**
  30857. * Clone the current manager
  30858. * @returns a new MorphTargetManager
  30859. */
  30860. clone(): MorphTargetManager;
  30861. /**
  30862. * Serializes the current manager into a Serialization object
  30863. * @returns the serialized object
  30864. */
  30865. serialize(): any;
  30866. private _syncActiveTargets;
  30867. /**
  30868. * Syncrhonize the targets with all the meshes using this morph target manager
  30869. */
  30870. synchronize(): void;
  30871. /**
  30872. * Creates a new MorphTargetManager from serialized data
  30873. * @param serializationObject defines the serialized data
  30874. * @param scene defines the hosting scene
  30875. * @returns the new MorphTargetManager
  30876. */
  30877. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30878. }
  30879. }
  30880. declare module BABYLON {
  30881. /**
  30882. * Class used to represent a specific level of detail of a mesh
  30883. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  30884. */
  30885. export class MeshLODLevel {
  30886. /** Defines the distance where this level should start being displayed */
  30887. distance: number;
  30888. /** Defines the mesh to use to render this level */
  30889. mesh: Nullable<Mesh>;
  30890. /**
  30891. * Creates a new LOD level
  30892. * @param distance defines the distance where this level should star being displayed
  30893. * @param mesh defines the mesh to use to render this level
  30894. */
  30895. constructor(
  30896. /** Defines the distance where this level should start being displayed */
  30897. distance: number,
  30898. /** Defines the mesh to use to render this level */
  30899. mesh: Nullable<Mesh>);
  30900. }
  30901. }
  30902. declare module BABYLON {
  30903. /**
  30904. * Helper class used to generate a canvas to manipulate images
  30905. */
  30906. export class CanvasGenerator {
  30907. /**
  30908. * Create a new canvas (or offscreen canvas depending on the context)
  30909. * @param width defines the expected width
  30910. * @param height defines the expected height
  30911. * @return a new canvas or offscreen canvas
  30912. */
  30913. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  30914. }
  30915. }
  30916. declare module BABYLON {
  30917. /**
  30918. * Mesh representing the gorund
  30919. */
  30920. export class GroundMesh extends Mesh {
  30921. /** If octree should be generated */
  30922. generateOctree: boolean;
  30923. private _heightQuads;
  30924. /** @hidden */
  30925. _subdivisionsX: number;
  30926. /** @hidden */
  30927. _subdivisionsY: number;
  30928. /** @hidden */
  30929. _width: number;
  30930. /** @hidden */
  30931. _height: number;
  30932. /** @hidden */
  30933. _minX: number;
  30934. /** @hidden */
  30935. _maxX: number;
  30936. /** @hidden */
  30937. _minZ: number;
  30938. /** @hidden */
  30939. _maxZ: number;
  30940. constructor(name: string, scene: Scene);
  30941. /**
  30942. * "GroundMesh"
  30943. * @returns "GroundMesh"
  30944. */
  30945. getClassName(): string;
  30946. /**
  30947. * The minimum of x and y subdivisions
  30948. */
  30949. get subdivisions(): number;
  30950. /**
  30951. * X subdivisions
  30952. */
  30953. get subdivisionsX(): number;
  30954. /**
  30955. * Y subdivisions
  30956. */
  30957. get subdivisionsY(): number;
  30958. /**
  30959. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  30960. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  30961. * @param chunksCount the number of subdivisions for x and y
  30962. * @param octreeBlocksSize (Default: 32)
  30963. */
  30964. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  30965. /**
  30966. * Returns a height (y) value in the Worl system :
  30967. * the ground altitude at the coordinates (x, z) expressed in the World system.
  30968. * @param x x coordinate
  30969. * @param z z coordinate
  30970. * @returns the ground y position if (x, z) are outside the ground surface.
  30971. */
  30972. getHeightAtCoordinates(x: number, z: number): number;
  30973. /**
  30974. * Returns a normalized vector (Vector3) orthogonal to the ground
  30975. * at the ground coordinates (x, z) expressed in the World system.
  30976. * @param x x coordinate
  30977. * @param z z coordinate
  30978. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  30979. */
  30980. getNormalAtCoordinates(x: number, z: number): Vector3;
  30981. /**
  30982. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  30983. * at the ground coordinates (x, z) expressed in the World system.
  30984. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  30985. * @param x x coordinate
  30986. * @param z z coordinate
  30987. * @param ref vector to store the result
  30988. * @returns the GroundMesh.
  30989. */
  30990. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  30991. /**
  30992. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  30993. * if the ground has been updated.
  30994. * This can be used in the render loop.
  30995. * @returns the GroundMesh.
  30996. */
  30997. updateCoordinateHeights(): GroundMesh;
  30998. private _getFacetAt;
  30999. private _initHeightQuads;
  31000. private _computeHeightQuads;
  31001. /**
  31002. * Serializes this ground mesh
  31003. * @param serializationObject object to write serialization to
  31004. */
  31005. serialize(serializationObject: any): void;
  31006. /**
  31007. * Parses a serialized ground mesh
  31008. * @param parsedMesh the serialized mesh
  31009. * @param scene the scene to create the ground mesh in
  31010. * @returns the created ground mesh
  31011. */
  31012. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31013. }
  31014. }
  31015. declare module BABYLON {
  31016. /**
  31017. * Interface for Physics-Joint data
  31018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31019. */
  31020. export interface PhysicsJointData {
  31021. /**
  31022. * The main pivot of the joint
  31023. */
  31024. mainPivot?: Vector3;
  31025. /**
  31026. * The connected pivot of the joint
  31027. */
  31028. connectedPivot?: Vector3;
  31029. /**
  31030. * The main axis of the joint
  31031. */
  31032. mainAxis?: Vector3;
  31033. /**
  31034. * The connected axis of the joint
  31035. */
  31036. connectedAxis?: Vector3;
  31037. /**
  31038. * The collision of the joint
  31039. */
  31040. collision?: boolean;
  31041. /**
  31042. * Native Oimo/Cannon/Energy data
  31043. */
  31044. nativeParams?: any;
  31045. }
  31046. /**
  31047. * This is a holder class for the physics joint created by the physics plugin
  31048. * It holds a set of functions to control the underlying joint
  31049. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31050. */
  31051. export class PhysicsJoint {
  31052. /**
  31053. * The type of the physics joint
  31054. */
  31055. type: number;
  31056. /**
  31057. * The data for the physics joint
  31058. */
  31059. jointData: PhysicsJointData;
  31060. private _physicsJoint;
  31061. protected _physicsPlugin: IPhysicsEnginePlugin;
  31062. /**
  31063. * Initializes the physics joint
  31064. * @param type The type of the physics joint
  31065. * @param jointData The data for the physics joint
  31066. */
  31067. constructor(
  31068. /**
  31069. * The type of the physics joint
  31070. */
  31071. type: number,
  31072. /**
  31073. * The data for the physics joint
  31074. */
  31075. jointData: PhysicsJointData);
  31076. /**
  31077. * Gets the physics joint
  31078. */
  31079. get physicsJoint(): any;
  31080. /**
  31081. * Sets the physics joint
  31082. */
  31083. set physicsJoint(newJoint: any);
  31084. /**
  31085. * Sets the physics plugin
  31086. */
  31087. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31088. /**
  31089. * Execute a function that is physics-plugin specific.
  31090. * @param {Function} func the function that will be executed.
  31091. * It accepts two parameters: the physics world and the physics joint
  31092. */
  31093. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31094. /**
  31095. * Distance-Joint type
  31096. */
  31097. static DistanceJoint: number;
  31098. /**
  31099. * Hinge-Joint type
  31100. */
  31101. static HingeJoint: number;
  31102. /**
  31103. * Ball-and-Socket joint type
  31104. */
  31105. static BallAndSocketJoint: number;
  31106. /**
  31107. * Wheel-Joint type
  31108. */
  31109. static WheelJoint: number;
  31110. /**
  31111. * Slider-Joint type
  31112. */
  31113. static SliderJoint: number;
  31114. /**
  31115. * Prismatic-Joint type
  31116. */
  31117. static PrismaticJoint: number;
  31118. /**
  31119. * Universal-Joint type
  31120. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31121. */
  31122. static UniversalJoint: number;
  31123. /**
  31124. * Hinge-Joint 2 type
  31125. */
  31126. static Hinge2Joint: number;
  31127. /**
  31128. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31129. */
  31130. static PointToPointJoint: number;
  31131. /**
  31132. * Spring-Joint type
  31133. */
  31134. static SpringJoint: number;
  31135. /**
  31136. * Lock-Joint type
  31137. */
  31138. static LockJoint: number;
  31139. }
  31140. /**
  31141. * A class representing a physics distance joint
  31142. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31143. */
  31144. export class DistanceJoint extends PhysicsJoint {
  31145. /**
  31146. *
  31147. * @param jointData The data for the Distance-Joint
  31148. */
  31149. constructor(jointData: DistanceJointData);
  31150. /**
  31151. * Update the predefined distance.
  31152. * @param maxDistance The maximum preferred distance
  31153. * @param minDistance The minimum preferred distance
  31154. */
  31155. updateDistance(maxDistance: number, minDistance?: number): void;
  31156. }
  31157. /**
  31158. * Represents a Motor-Enabled Joint
  31159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31160. */
  31161. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31162. /**
  31163. * Initializes the Motor-Enabled Joint
  31164. * @param type The type of the joint
  31165. * @param jointData The physica joint data for the joint
  31166. */
  31167. constructor(type: number, jointData: PhysicsJointData);
  31168. /**
  31169. * Set the motor values.
  31170. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31171. * @param force the force to apply
  31172. * @param maxForce max force for this motor.
  31173. */
  31174. setMotor(force?: number, maxForce?: number): void;
  31175. /**
  31176. * Set the motor's limits.
  31177. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31178. * @param upperLimit The upper limit of the motor
  31179. * @param lowerLimit The lower limit of the motor
  31180. */
  31181. setLimit(upperLimit: number, lowerLimit?: number): void;
  31182. }
  31183. /**
  31184. * This class represents a single physics Hinge-Joint
  31185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31186. */
  31187. export class HingeJoint extends MotorEnabledJoint {
  31188. /**
  31189. * Initializes the Hinge-Joint
  31190. * @param jointData The joint data for the Hinge-Joint
  31191. */
  31192. constructor(jointData: PhysicsJointData);
  31193. /**
  31194. * Set the motor values.
  31195. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31196. * @param {number} force the force to apply
  31197. * @param {number} maxForce max force for this motor.
  31198. */
  31199. setMotor(force?: number, maxForce?: number): void;
  31200. /**
  31201. * Set the motor's limits.
  31202. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31203. * @param upperLimit The upper limit of the motor
  31204. * @param lowerLimit The lower limit of the motor
  31205. */
  31206. setLimit(upperLimit: number, lowerLimit?: number): void;
  31207. }
  31208. /**
  31209. * This class represents a dual hinge physics joint (same as wheel joint)
  31210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31211. */
  31212. export class Hinge2Joint extends MotorEnabledJoint {
  31213. /**
  31214. * Initializes the Hinge2-Joint
  31215. * @param jointData The joint data for the Hinge2-Joint
  31216. */
  31217. constructor(jointData: PhysicsJointData);
  31218. /**
  31219. * Set the motor values.
  31220. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31221. * @param {number} targetSpeed the speed the motor is to reach
  31222. * @param {number} maxForce max force for this motor.
  31223. * @param {motorIndex} the motor's index, 0 or 1.
  31224. */
  31225. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31226. /**
  31227. * Set the motor limits.
  31228. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31229. * @param {number} upperLimit the upper limit
  31230. * @param {number} lowerLimit lower limit
  31231. * @param {motorIndex} the motor's index, 0 or 1.
  31232. */
  31233. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31234. }
  31235. /**
  31236. * Interface for a motor enabled joint
  31237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31238. */
  31239. export interface IMotorEnabledJoint {
  31240. /**
  31241. * Physics joint
  31242. */
  31243. physicsJoint: any;
  31244. /**
  31245. * Sets the motor of the motor-enabled joint
  31246. * @param force The force of the motor
  31247. * @param maxForce The maximum force of the motor
  31248. * @param motorIndex The index of the motor
  31249. */
  31250. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31251. /**
  31252. * Sets the limit of the motor
  31253. * @param upperLimit The upper limit of the motor
  31254. * @param lowerLimit The lower limit of the motor
  31255. * @param motorIndex The index of the motor
  31256. */
  31257. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31258. }
  31259. /**
  31260. * Joint data for a Distance-Joint
  31261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31262. */
  31263. export interface DistanceJointData extends PhysicsJointData {
  31264. /**
  31265. * Max distance the 2 joint objects can be apart
  31266. */
  31267. maxDistance: number;
  31268. }
  31269. /**
  31270. * Joint data from a spring joint
  31271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31272. */
  31273. export interface SpringJointData extends PhysicsJointData {
  31274. /**
  31275. * Length of the spring
  31276. */
  31277. length: number;
  31278. /**
  31279. * Stiffness of the spring
  31280. */
  31281. stiffness: number;
  31282. /**
  31283. * Damping of the spring
  31284. */
  31285. damping: number;
  31286. /** this callback will be called when applying the force to the impostors. */
  31287. forceApplicationCallback: () => void;
  31288. }
  31289. }
  31290. declare module BABYLON {
  31291. /**
  31292. * Holds the data for the raycast result
  31293. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31294. */
  31295. export class PhysicsRaycastResult {
  31296. private _hasHit;
  31297. private _hitDistance;
  31298. private _hitNormalWorld;
  31299. private _hitPointWorld;
  31300. private _rayFromWorld;
  31301. private _rayToWorld;
  31302. /**
  31303. * Gets if there was a hit
  31304. */
  31305. get hasHit(): boolean;
  31306. /**
  31307. * Gets the distance from the hit
  31308. */
  31309. get hitDistance(): number;
  31310. /**
  31311. * Gets the hit normal/direction in the world
  31312. */
  31313. get hitNormalWorld(): Vector3;
  31314. /**
  31315. * Gets the hit point in the world
  31316. */
  31317. get hitPointWorld(): Vector3;
  31318. /**
  31319. * Gets the ray "start point" of the ray in the world
  31320. */
  31321. get rayFromWorld(): Vector3;
  31322. /**
  31323. * Gets the ray "end point" of the ray in the world
  31324. */
  31325. get rayToWorld(): Vector3;
  31326. /**
  31327. * Sets the hit data (normal & point in world space)
  31328. * @param hitNormalWorld defines the normal in world space
  31329. * @param hitPointWorld defines the point in world space
  31330. */
  31331. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31332. /**
  31333. * Sets the distance from the start point to the hit point
  31334. * @param distance
  31335. */
  31336. setHitDistance(distance: number): void;
  31337. /**
  31338. * Calculates the distance manually
  31339. */
  31340. calculateHitDistance(): void;
  31341. /**
  31342. * Resets all the values to default
  31343. * @param from The from point on world space
  31344. * @param to The to point on world space
  31345. */
  31346. reset(from?: Vector3, to?: Vector3): void;
  31347. }
  31348. /**
  31349. * Interface for the size containing width and height
  31350. */
  31351. interface IXYZ {
  31352. /**
  31353. * X
  31354. */
  31355. x: number;
  31356. /**
  31357. * Y
  31358. */
  31359. y: number;
  31360. /**
  31361. * Z
  31362. */
  31363. z: number;
  31364. }
  31365. }
  31366. declare module BABYLON {
  31367. /**
  31368. * Interface used to describe a physics joint
  31369. */
  31370. export interface PhysicsImpostorJoint {
  31371. /** Defines the main impostor to which the joint is linked */
  31372. mainImpostor: PhysicsImpostor;
  31373. /** Defines the impostor that is connected to the main impostor using this joint */
  31374. connectedImpostor: PhysicsImpostor;
  31375. /** Defines the joint itself */
  31376. joint: PhysicsJoint;
  31377. }
  31378. /** @hidden */
  31379. export interface IPhysicsEnginePlugin {
  31380. world: any;
  31381. name: string;
  31382. setGravity(gravity: Vector3): void;
  31383. setTimeStep(timeStep: number): void;
  31384. getTimeStep(): number;
  31385. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31386. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31387. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31388. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31389. removePhysicsBody(impostor: PhysicsImpostor): void;
  31390. generateJoint(joint: PhysicsImpostorJoint): void;
  31391. removeJoint(joint: PhysicsImpostorJoint): void;
  31392. isSupported(): boolean;
  31393. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31394. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31395. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31396. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31397. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31398. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31399. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31400. getBodyMass(impostor: PhysicsImpostor): number;
  31401. getBodyFriction(impostor: PhysicsImpostor): number;
  31402. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31403. getBodyRestitution(impostor: PhysicsImpostor): number;
  31404. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31405. getBodyPressure?(impostor: PhysicsImpostor): number;
  31406. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31407. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31408. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31409. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31410. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31411. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31412. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31413. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31414. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31415. sleepBody(impostor: PhysicsImpostor): void;
  31416. wakeUpBody(impostor: PhysicsImpostor): void;
  31417. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31418. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31419. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31420. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31421. getRadius(impostor: PhysicsImpostor): number;
  31422. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31423. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31424. dispose(): void;
  31425. }
  31426. /**
  31427. * Interface used to define a physics engine
  31428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31429. */
  31430. export interface IPhysicsEngine {
  31431. /**
  31432. * Gets the gravity vector used by the simulation
  31433. */
  31434. gravity: Vector3;
  31435. /**
  31436. * Sets the gravity vector used by the simulation
  31437. * @param gravity defines the gravity vector to use
  31438. */
  31439. setGravity(gravity: Vector3): void;
  31440. /**
  31441. * Set the time step of the physics engine.
  31442. * Default is 1/60.
  31443. * To slow it down, enter 1/600 for example.
  31444. * To speed it up, 1/30
  31445. * @param newTimeStep the new timestep to apply to this world.
  31446. */
  31447. setTimeStep(newTimeStep: number): void;
  31448. /**
  31449. * Get the time step of the physics engine.
  31450. * @returns the current time step
  31451. */
  31452. getTimeStep(): number;
  31453. /**
  31454. * Set the sub time step of the physics engine.
  31455. * Default is 0 meaning there is no sub steps
  31456. * To increase physics resolution precision, set a small value (like 1 ms)
  31457. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31458. */
  31459. setSubTimeStep(subTimeStep: number): void;
  31460. /**
  31461. * Get the sub time step of the physics engine.
  31462. * @returns the current sub time step
  31463. */
  31464. getSubTimeStep(): number;
  31465. /**
  31466. * Release all resources
  31467. */
  31468. dispose(): void;
  31469. /**
  31470. * Gets the name of the current physics plugin
  31471. * @returns the name of the plugin
  31472. */
  31473. getPhysicsPluginName(): string;
  31474. /**
  31475. * Adding a new impostor for the impostor tracking.
  31476. * This will be done by the impostor itself.
  31477. * @param impostor the impostor to add
  31478. */
  31479. addImpostor(impostor: PhysicsImpostor): void;
  31480. /**
  31481. * Remove an impostor from the engine.
  31482. * This impostor and its mesh will not longer be updated by the physics engine.
  31483. * @param impostor the impostor to remove
  31484. */
  31485. removeImpostor(impostor: PhysicsImpostor): void;
  31486. /**
  31487. * Add a joint to the physics engine
  31488. * @param mainImpostor defines the main impostor to which the joint is added.
  31489. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31490. * @param joint defines the joint that will connect both impostors.
  31491. */
  31492. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31493. /**
  31494. * Removes a joint from the simulation
  31495. * @param mainImpostor defines the impostor used with the joint
  31496. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31497. * @param joint defines the joint to remove
  31498. */
  31499. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31500. /**
  31501. * Gets the current plugin used to run the simulation
  31502. * @returns current plugin
  31503. */
  31504. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31505. /**
  31506. * Gets the list of physic impostors
  31507. * @returns an array of PhysicsImpostor
  31508. */
  31509. getImpostors(): Array<PhysicsImpostor>;
  31510. /**
  31511. * Gets the impostor for a physics enabled object
  31512. * @param object defines the object impersonated by the impostor
  31513. * @returns the PhysicsImpostor or null if not found
  31514. */
  31515. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31516. /**
  31517. * Gets the impostor for a physics body object
  31518. * @param body defines physics body used by the impostor
  31519. * @returns the PhysicsImpostor or null if not found
  31520. */
  31521. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31522. /**
  31523. * Does a raycast in the physics world
  31524. * @param from when should the ray start?
  31525. * @param to when should the ray end?
  31526. * @returns PhysicsRaycastResult
  31527. */
  31528. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31529. /**
  31530. * Called by the scene. No need to call it.
  31531. * @param delta defines the timespam between frames
  31532. */
  31533. _step(delta: number): void;
  31534. }
  31535. }
  31536. declare module BABYLON {
  31537. /**
  31538. * The interface for the physics imposter parameters
  31539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31540. */
  31541. export interface PhysicsImpostorParameters {
  31542. /**
  31543. * The mass of the physics imposter
  31544. */
  31545. mass: number;
  31546. /**
  31547. * The friction of the physics imposter
  31548. */
  31549. friction?: number;
  31550. /**
  31551. * The coefficient of restitution of the physics imposter
  31552. */
  31553. restitution?: number;
  31554. /**
  31555. * The native options of the physics imposter
  31556. */
  31557. nativeOptions?: any;
  31558. /**
  31559. * Specifies if the parent should be ignored
  31560. */
  31561. ignoreParent?: boolean;
  31562. /**
  31563. * Specifies if bi-directional transformations should be disabled
  31564. */
  31565. disableBidirectionalTransformation?: boolean;
  31566. /**
  31567. * The pressure inside the physics imposter, soft object only
  31568. */
  31569. pressure?: number;
  31570. /**
  31571. * The stiffness the physics imposter, soft object only
  31572. */
  31573. stiffness?: number;
  31574. /**
  31575. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  31576. */
  31577. velocityIterations?: number;
  31578. /**
  31579. * The number of iterations used in maintaining consistent vertex positions, soft object only
  31580. */
  31581. positionIterations?: number;
  31582. /**
  31583. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  31584. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  31585. * Add to fix multiple points
  31586. */
  31587. fixedPoints?: number;
  31588. /**
  31589. * The collision margin around a soft object
  31590. */
  31591. margin?: number;
  31592. /**
  31593. * The collision margin around a soft object
  31594. */
  31595. damping?: number;
  31596. /**
  31597. * The path for a rope based on an extrusion
  31598. */
  31599. path?: any;
  31600. /**
  31601. * The shape of an extrusion used for a rope based on an extrusion
  31602. */
  31603. shape?: any;
  31604. }
  31605. /**
  31606. * Interface for a physics-enabled object
  31607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31608. */
  31609. export interface IPhysicsEnabledObject {
  31610. /**
  31611. * The position of the physics-enabled object
  31612. */
  31613. position: Vector3;
  31614. /**
  31615. * The rotation of the physics-enabled object
  31616. */
  31617. rotationQuaternion: Nullable<Quaternion>;
  31618. /**
  31619. * The scale of the physics-enabled object
  31620. */
  31621. scaling: Vector3;
  31622. /**
  31623. * The rotation of the physics-enabled object
  31624. */
  31625. rotation?: Vector3;
  31626. /**
  31627. * The parent of the physics-enabled object
  31628. */
  31629. parent?: any;
  31630. /**
  31631. * The bounding info of the physics-enabled object
  31632. * @returns The bounding info of the physics-enabled object
  31633. */
  31634. getBoundingInfo(): BoundingInfo;
  31635. /**
  31636. * Computes the world matrix
  31637. * @param force Specifies if the world matrix should be computed by force
  31638. * @returns A world matrix
  31639. */
  31640. computeWorldMatrix(force: boolean): Matrix;
  31641. /**
  31642. * Gets the world matrix
  31643. * @returns A world matrix
  31644. */
  31645. getWorldMatrix?(): Matrix;
  31646. /**
  31647. * Gets the child meshes
  31648. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31649. * @returns An array of abstract meshes
  31650. */
  31651. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31652. /**
  31653. * Gets the vertex data
  31654. * @param kind The type of vertex data
  31655. * @returns A nullable array of numbers, or a float32 array
  31656. */
  31657. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31658. /**
  31659. * Gets the indices from the mesh
  31660. * @returns A nullable array of index arrays
  31661. */
  31662. getIndices?(): Nullable<IndicesArray>;
  31663. /**
  31664. * Gets the scene from the mesh
  31665. * @returns the indices array or null
  31666. */
  31667. getScene?(): Scene;
  31668. /**
  31669. * Gets the absolute position from the mesh
  31670. * @returns the absolute position
  31671. */
  31672. getAbsolutePosition(): Vector3;
  31673. /**
  31674. * Gets the absolute pivot point from the mesh
  31675. * @returns the absolute pivot point
  31676. */
  31677. getAbsolutePivotPoint(): Vector3;
  31678. /**
  31679. * Rotates the mesh
  31680. * @param axis The axis of rotation
  31681. * @param amount The amount of rotation
  31682. * @param space The space of the rotation
  31683. * @returns The rotation transform node
  31684. */
  31685. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31686. /**
  31687. * Translates the mesh
  31688. * @param axis The axis of translation
  31689. * @param distance The distance of translation
  31690. * @param space The space of the translation
  31691. * @returns The transform node
  31692. */
  31693. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31694. /**
  31695. * Sets the absolute position of the mesh
  31696. * @param absolutePosition The absolute position of the mesh
  31697. * @returns The transform node
  31698. */
  31699. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31700. /**
  31701. * Gets the class name of the mesh
  31702. * @returns The class name
  31703. */
  31704. getClassName(): string;
  31705. }
  31706. /**
  31707. * Represents a physics imposter
  31708. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31709. */
  31710. export class PhysicsImpostor {
  31711. /**
  31712. * The physics-enabled object used as the physics imposter
  31713. */
  31714. object: IPhysicsEnabledObject;
  31715. /**
  31716. * The type of the physics imposter
  31717. */
  31718. type: number;
  31719. private _options;
  31720. private _scene?;
  31721. /**
  31722. * The default object size of the imposter
  31723. */
  31724. static DEFAULT_OBJECT_SIZE: Vector3;
  31725. /**
  31726. * The identity quaternion of the imposter
  31727. */
  31728. static IDENTITY_QUATERNION: Quaternion;
  31729. /** @hidden */
  31730. _pluginData: any;
  31731. private _physicsEngine;
  31732. private _physicsBody;
  31733. private _bodyUpdateRequired;
  31734. private _onBeforePhysicsStepCallbacks;
  31735. private _onAfterPhysicsStepCallbacks;
  31736. /** @hidden */
  31737. _onPhysicsCollideCallbacks: Array<{
  31738. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  31739. otherImpostors: Array<PhysicsImpostor>;
  31740. }>;
  31741. private _deltaPosition;
  31742. private _deltaRotation;
  31743. private _deltaRotationConjugated;
  31744. /** @hidden */
  31745. _isFromLine: boolean;
  31746. private _parent;
  31747. private _isDisposed;
  31748. private static _tmpVecs;
  31749. private static _tmpQuat;
  31750. /**
  31751. * Specifies if the physics imposter is disposed
  31752. */
  31753. get isDisposed(): boolean;
  31754. /**
  31755. * Gets the mass of the physics imposter
  31756. */
  31757. get mass(): number;
  31758. set mass(value: number);
  31759. /**
  31760. * Gets the coefficient of friction
  31761. */
  31762. get friction(): number;
  31763. /**
  31764. * Sets the coefficient of friction
  31765. */
  31766. set friction(value: number);
  31767. /**
  31768. * Gets the coefficient of restitution
  31769. */
  31770. get restitution(): number;
  31771. /**
  31772. * Sets the coefficient of restitution
  31773. */
  31774. set restitution(value: number);
  31775. /**
  31776. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  31777. */
  31778. get pressure(): number;
  31779. /**
  31780. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  31781. */
  31782. set pressure(value: number);
  31783. /**
  31784. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31785. */
  31786. get stiffness(): number;
  31787. /**
  31788. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31789. */
  31790. set stiffness(value: number);
  31791. /**
  31792. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31793. */
  31794. get velocityIterations(): number;
  31795. /**
  31796. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31797. */
  31798. set velocityIterations(value: number);
  31799. /**
  31800. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31801. */
  31802. get positionIterations(): number;
  31803. /**
  31804. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31805. */
  31806. set positionIterations(value: number);
  31807. /**
  31808. * The unique id of the physics imposter
  31809. * set by the physics engine when adding this impostor to the array
  31810. */
  31811. uniqueId: number;
  31812. /**
  31813. * @hidden
  31814. */
  31815. soft: boolean;
  31816. /**
  31817. * @hidden
  31818. */
  31819. segments: number;
  31820. private _joints;
  31821. /**
  31822. * Initializes the physics imposter
  31823. * @param object The physics-enabled object used as the physics imposter
  31824. * @param type The type of the physics imposter
  31825. * @param _options The options for the physics imposter
  31826. * @param _scene The Babylon scene
  31827. */
  31828. constructor(
  31829. /**
  31830. * The physics-enabled object used as the physics imposter
  31831. */
  31832. object: IPhysicsEnabledObject,
  31833. /**
  31834. * The type of the physics imposter
  31835. */
  31836. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  31837. /**
  31838. * This function will completly initialize this impostor.
  31839. * It will create a new body - but only if this mesh has no parent.
  31840. * If it has, this impostor will not be used other than to define the impostor
  31841. * of the child mesh.
  31842. * @hidden
  31843. */
  31844. _init(): void;
  31845. private _getPhysicsParent;
  31846. /**
  31847. * Should a new body be generated.
  31848. * @returns boolean specifying if body initialization is required
  31849. */
  31850. isBodyInitRequired(): boolean;
  31851. /**
  31852. * Sets the updated scaling
  31853. * @param updated Specifies if the scaling is updated
  31854. */
  31855. setScalingUpdated(): void;
  31856. /**
  31857. * Force a regeneration of this or the parent's impostor's body.
  31858. * Use under cautious - This will remove all joints already implemented.
  31859. */
  31860. forceUpdate(): void;
  31861. /**
  31862. * Gets the body that holds this impostor. Either its own, or its parent.
  31863. */
  31864. get physicsBody(): any;
  31865. /**
  31866. * Get the parent of the physics imposter
  31867. * @returns Physics imposter or null
  31868. */
  31869. get parent(): Nullable<PhysicsImpostor>;
  31870. /**
  31871. * Sets the parent of the physics imposter
  31872. */
  31873. set parent(value: Nullable<PhysicsImpostor>);
  31874. /**
  31875. * Set the physics body. Used mainly by the physics engine/plugin
  31876. */
  31877. set physicsBody(physicsBody: any);
  31878. /**
  31879. * Resets the update flags
  31880. */
  31881. resetUpdateFlags(): void;
  31882. /**
  31883. * Gets the object extend size
  31884. * @returns the object extend size
  31885. */
  31886. getObjectExtendSize(): Vector3;
  31887. /**
  31888. * Gets the object center
  31889. * @returns The object center
  31890. */
  31891. getObjectCenter(): Vector3;
  31892. /**
  31893. * Get a specific parameter from the options parameters
  31894. * @param paramName The object parameter name
  31895. * @returns The object parameter
  31896. */
  31897. getParam(paramName: string): any;
  31898. /**
  31899. * Sets a specific parameter in the options given to the physics plugin
  31900. * @param paramName The parameter name
  31901. * @param value The value of the parameter
  31902. */
  31903. setParam(paramName: string, value: number): void;
  31904. /**
  31905. * Specifically change the body's mass option. Won't recreate the physics body object
  31906. * @param mass The mass of the physics imposter
  31907. */
  31908. setMass(mass: number): void;
  31909. /**
  31910. * Gets the linear velocity
  31911. * @returns linear velocity or null
  31912. */
  31913. getLinearVelocity(): Nullable<Vector3>;
  31914. /**
  31915. * Sets the linear velocity
  31916. * @param velocity linear velocity or null
  31917. */
  31918. setLinearVelocity(velocity: Nullable<Vector3>): void;
  31919. /**
  31920. * Gets the angular velocity
  31921. * @returns angular velocity or null
  31922. */
  31923. getAngularVelocity(): Nullable<Vector3>;
  31924. /**
  31925. * Sets the angular velocity
  31926. * @param velocity The velocity or null
  31927. */
  31928. setAngularVelocity(velocity: Nullable<Vector3>): void;
  31929. /**
  31930. * Execute a function with the physics plugin native code
  31931. * Provide a function the will have two variables - the world object and the physics body object
  31932. * @param func The function to execute with the physics plugin native code
  31933. */
  31934. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  31935. /**
  31936. * Register a function that will be executed before the physics world is stepping forward
  31937. * @param func The function to execute before the physics world is stepped forward
  31938. */
  31939. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31940. /**
  31941. * Unregister a function that will be executed before the physics world is stepping forward
  31942. * @param func The function to execute before the physics world is stepped forward
  31943. */
  31944. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31945. /**
  31946. * Register a function that will be executed after the physics step
  31947. * @param func The function to execute after physics step
  31948. */
  31949. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31950. /**
  31951. * Unregisters a function that will be executed after the physics step
  31952. * @param func The function to execute after physics step
  31953. */
  31954. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31955. /**
  31956. * register a function that will be executed when this impostor collides against a different body
  31957. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  31958. * @param func Callback that is executed on collision
  31959. */
  31960. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  31961. /**
  31962. * Unregisters the physics imposter on contact
  31963. * @param collideAgainst The physics object to collide against
  31964. * @param func Callback to execute on collision
  31965. */
  31966. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  31967. private _tmpQuat;
  31968. private _tmpQuat2;
  31969. /**
  31970. * Get the parent rotation
  31971. * @returns The parent rotation
  31972. */
  31973. getParentsRotation(): Quaternion;
  31974. /**
  31975. * this function is executed by the physics engine.
  31976. */
  31977. beforeStep: () => void;
  31978. /**
  31979. * this function is executed by the physics engine
  31980. */
  31981. afterStep: () => void;
  31982. /**
  31983. * Legacy collision detection event support
  31984. */
  31985. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  31986. /**
  31987. * event and body object due to cannon's event-based architecture.
  31988. */
  31989. onCollide: (e: {
  31990. body: any;
  31991. point: Nullable<Vector3>;
  31992. }) => void;
  31993. /**
  31994. * Apply a force
  31995. * @param force The force to apply
  31996. * @param contactPoint The contact point for the force
  31997. * @returns The physics imposter
  31998. */
  31999. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32000. /**
  32001. * Apply an impulse
  32002. * @param force The impulse force
  32003. * @param contactPoint The contact point for the impulse force
  32004. * @returns The physics imposter
  32005. */
  32006. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32007. /**
  32008. * A help function to create a joint
  32009. * @param otherImpostor A physics imposter used to create a joint
  32010. * @param jointType The type of joint
  32011. * @param jointData The data for the joint
  32012. * @returns The physics imposter
  32013. */
  32014. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32015. /**
  32016. * Add a joint to this impostor with a different impostor
  32017. * @param otherImpostor A physics imposter used to add a joint
  32018. * @param joint The joint to add
  32019. * @returns The physics imposter
  32020. */
  32021. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32022. /**
  32023. * Add an anchor to a cloth impostor
  32024. * @param otherImpostor rigid impostor to anchor to
  32025. * @param width ratio across width from 0 to 1
  32026. * @param height ratio up height from 0 to 1
  32027. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32028. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32029. * @returns impostor the soft imposter
  32030. */
  32031. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32032. /**
  32033. * Add a hook to a rope impostor
  32034. * @param otherImpostor rigid impostor to anchor to
  32035. * @param length ratio across rope from 0 to 1
  32036. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32037. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32038. * @returns impostor the rope imposter
  32039. */
  32040. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32041. /**
  32042. * Will keep this body still, in a sleep mode.
  32043. * @returns the physics imposter
  32044. */
  32045. sleep(): PhysicsImpostor;
  32046. /**
  32047. * Wake the body up.
  32048. * @returns The physics imposter
  32049. */
  32050. wakeUp(): PhysicsImpostor;
  32051. /**
  32052. * Clones the physics imposter
  32053. * @param newObject The physics imposter clones to this physics-enabled object
  32054. * @returns A nullable physics imposter
  32055. */
  32056. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32057. /**
  32058. * Disposes the physics imposter
  32059. */
  32060. dispose(): void;
  32061. /**
  32062. * Sets the delta position
  32063. * @param position The delta position amount
  32064. */
  32065. setDeltaPosition(position: Vector3): void;
  32066. /**
  32067. * Sets the delta rotation
  32068. * @param rotation The delta rotation amount
  32069. */
  32070. setDeltaRotation(rotation: Quaternion): void;
  32071. /**
  32072. * Gets the box size of the physics imposter and stores the result in the input parameter
  32073. * @param result Stores the box size
  32074. * @returns The physics imposter
  32075. */
  32076. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32077. /**
  32078. * Gets the radius of the physics imposter
  32079. * @returns Radius of the physics imposter
  32080. */
  32081. getRadius(): number;
  32082. /**
  32083. * Sync a bone with this impostor
  32084. * @param bone The bone to sync to the impostor.
  32085. * @param boneMesh The mesh that the bone is influencing.
  32086. * @param jointPivot The pivot of the joint / bone in local space.
  32087. * @param distToJoint Optional distance from the impostor to the joint.
  32088. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32089. */
  32090. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32091. /**
  32092. * Sync impostor to a bone
  32093. * @param bone The bone that the impostor will be synced to.
  32094. * @param boneMesh The mesh that the bone is influencing.
  32095. * @param jointPivot The pivot of the joint / bone in local space.
  32096. * @param distToJoint Optional distance from the impostor to the joint.
  32097. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32098. * @param boneAxis Optional vector3 axis the bone is aligned with
  32099. */
  32100. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32101. /**
  32102. * No-Imposter type
  32103. */
  32104. static NoImpostor: number;
  32105. /**
  32106. * Sphere-Imposter type
  32107. */
  32108. static SphereImpostor: number;
  32109. /**
  32110. * Box-Imposter type
  32111. */
  32112. static BoxImpostor: number;
  32113. /**
  32114. * Plane-Imposter type
  32115. */
  32116. static PlaneImpostor: number;
  32117. /**
  32118. * Mesh-imposter type
  32119. */
  32120. static MeshImpostor: number;
  32121. /**
  32122. * Capsule-Impostor type (Ammo.js plugin only)
  32123. */
  32124. static CapsuleImpostor: number;
  32125. /**
  32126. * Cylinder-Imposter type
  32127. */
  32128. static CylinderImpostor: number;
  32129. /**
  32130. * Particle-Imposter type
  32131. */
  32132. static ParticleImpostor: number;
  32133. /**
  32134. * Heightmap-Imposter type
  32135. */
  32136. static HeightmapImpostor: number;
  32137. /**
  32138. * ConvexHull-Impostor type (Ammo.js plugin only)
  32139. */
  32140. static ConvexHullImpostor: number;
  32141. /**
  32142. * Custom-Imposter type (Ammo.js plugin only)
  32143. */
  32144. static CustomImpostor: number;
  32145. /**
  32146. * Rope-Imposter type
  32147. */
  32148. static RopeImpostor: number;
  32149. /**
  32150. * Cloth-Imposter type
  32151. */
  32152. static ClothImpostor: number;
  32153. /**
  32154. * Softbody-Imposter type
  32155. */
  32156. static SoftbodyImpostor: number;
  32157. }
  32158. }
  32159. declare module BABYLON {
  32160. /**
  32161. * @hidden
  32162. **/
  32163. export class _CreationDataStorage {
  32164. closePath?: boolean;
  32165. closeArray?: boolean;
  32166. idx: number[];
  32167. dashSize: number;
  32168. gapSize: number;
  32169. path3D: Path3D;
  32170. pathArray: Vector3[][];
  32171. arc: number;
  32172. radius: number;
  32173. cap: number;
  32174. tessellation: number;
  32175. }
  32176. /**
  32177. * @hidden
  32178. **/
  32179. class _InstanceDataStorage {
  32180. visibleInstances: any;
  32181. batchCache: _InstancesBatch;
  32182. instancesBufferSize: number;
  32183. instancesBuffer: Nullable<Buffer>;
  32184. instancesData: Float32Array;
  32185. overridenInstanceCount: number;
  32186. isFrozen: boolean;
  32187. previousBatch: Nullable<_InstancesBatch>;
  32188. hardwareInstancedRendering: boolean;
  32189. sideOrientation: number;
  32190. manualUpdate: boolean;
  32191. previousRenderId: number;
  32192. }
  32193. /**
  32194. * @hidden
  32195. **/
  32196. export class _InstancesBatch {
  32197. mustReturn: boolean;
  32198. visibleInstances: Nullable<InstancedMesh[]>[];
  32199. renderSelf: boolean[];
  32200. hardwareInstancedRendering: boolean[];
  32201. }
  32202. /**
  32203. * @hidden
  32204. **/
  32205. class _ThinInstanceDataStorage {
  32206. instancesCount: number;
  32207. matrixBuffer: Nullable<Buffer>;
  32208. matrixBufferSize: number;
  32209. matrixData: Nullable<Float32Array>;
  32210. boundingVectors: Array<Vector3>;
  32211. worldMatrices: Nullable<Matrix[]>;
  32212. }
  32213. /**
  32214. * Class used to represent renderable models
  32215. */
  32216. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32217. /**
  32218. * Mesh side orientation : usually the external or front surface
  32219. */
  32220. static readonly FRONTSIDE: number;
  32221. /**
  32222. * Mesh side orientation : usually the internal or back surface
  32223. */
  32224. static readonly BACKSIDE: number;
  32225. /**
  32226. * Mesh side orientation : both internal and external or front and back surfaces
  32227. */
  32228. static readonly DOUBLESIDE: number;
  32229. /**
  32230. * Mesh side orientation : by default, `FRONTSIDE`
  32231. */
  32232. static readonly DEFAULTSIDE: number;
  32233. /**
  32234. * Mesh cap setting : no cap
  32235. */
  32236. static readonly NO_CAP: number;
  32237. /**
  32238. * Mesh cap setting : one cap at the beginning of the mesh
  32239. */
  32240. static readonly CAP_START: number;
  32241. /**
  32242. * Mesh cap setting : one cap at the end of the mesh
  32243. */
  32244. static readonly CAP_END: number;
  32245. /**
  32246. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32247. */
  32248. static readonly CAP_ALL: number;
  32249. /**
  32250. * Mesh pattern setting : no flip or rotate
  32251. */
  32252. static readonly NO_FLIP: number;
  32253. /**
  32254. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32255. */
  32256. static readonly FLIP_TILE: number;
  32257. /**
  32258. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32259. */
  32260. static readonly ROTATE_TILE: number;
  32261. /**
  32262. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32263. */
  32264. static readonly FLIP_ROW: number;
  32265. /**
  32266. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32267. */
  32268. static readonly ROTATE_ROW: number;
  32269. /**
  32270. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32271. */
  32272. static readonly FLIP_N_ROTATE_TILE: number;
  32273. /**
  32274. * Mesh pattern setting : rotate pattern and rotate
  32275. */
  32276. static readonly FLIP_N_ROTATE_ROW: number;
  32277. /**
  32278. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32279. */
  32280. static readonly CENTER: number;
  32281. /**
  32282. * Mesh tile positioning : part tiles on left
  32283. */
  32284. static readonly LEFT: number;
  32285. /**
  32286. * Mesh tile positioning : part tiles on right
  32287. */
  32288. static readonly RIGHT: number;
  32289. /**
  32290. * Mesh tile positioning : part tiles on top
  32291. */
  32292. static readonly TOP: number;
  32293. /**
  32294. * Mesh tile positioning : part tiles on bottom
  32295. */
  32296. static readonly BOTTOM: number;
  32297. /**
  32298. * Gets the default side orientation.
  32299. * @param orientation the orientation to value to attempt to get
  32300. * @returns the default orientation
  32301. * @hidden
  32302. */
  32303. static _GetDefaultSideOrientation(orientation?: number): number;
  32304. private _internalMeshDataInfo;
  32305. get computeBonesUsingShaders(): boolean;
  32306. set computeBonesUsingShaders(value: boolean);
  32307. /**
  32308. * An event triggered before rendering the mesh
  32309. */
  32310. get onBeforeRenderObservable(): Observable<Mesh>;
  32311. /**
  32312. * An event triggered before binding the mesh
  32313. */
  32314. get onBeforeBindObservable(): Observable<Mesh>;
  32315. /**
  32316. * An event triggered after rendering the mesh
  32317. */
  32318. get onAfterRenderObservable(): Observable<Mesh>;
  32319. /**
  32320. * An event triggered before drawing the mesh
  32321. */
  32322. get onBeforeDrawObservable(): Observable<Mesh>;
  32323. private _onBeforeDrawObserver;
  32324. /**
  32325. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32326. */
  32327. set onBeforeDraw(callback: () => void);
  32328. get hasInstances(): boolean;
  32329. get hasThinInstances(): boolean;
  32330. /**
  32331. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32332. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32333. */
  32334. delayLoadState: number;
  32335. /**
  32336. * Gets the list of instances created from this mesh
  32337. * it is not supposed to be modified manually.
  32338. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32339. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32340. */
  32341. instances: InstancedMesh[];
  32342. /**
  32343. * Gets the file containing delay loading data for this mesh
  32344. */
  32345. delayLoadingFile: string;
  32346. /** @hidden */
  32347. _binaryInfo: any;
  32348. /**
  32349. * User defined function used to change how LOD level selection is done
  32350. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32351. */
  32352. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32353. /**
  32354. * Gets or sets the morph target manager
  32355. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32356. */
  32357. get morphTargetManager(): Nullable<MorphTargetManager>;
  32358. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32359. /** @hidden */
  32360. _creationDataStorage: Nullable<_CreationDataStorage>;
  32361. /** @hidden */
  32362. _geometry: Nullable<Geometry>;
  32363. /** @hidden */
  32364. _delayInfo: Array<string>;
  32365. /** @hidden */
  32366. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32367. /** @hidden */
  32368. _instanceDataStorage: _InstanceDataStorage;
  32369. /** @hidden */
  32370. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32371. private _effectiveMaterial;
  32372. /** @hidden */
  32373. _shouldGenerateFlatShading: boolean;
  32374. /** @hidden */
  32375. _originalBuilderSideOrientation: number;
  32376. /**
  32377. * Use this property to change the original side orientation defined at construction time
  32378. */
  32379. overrideMaterialSideOrientation: Nullable<number>;
  32380. /**
  32381. * Gets the source mesh (the one used to clone this one from)
  32382. */
  32383. get source(): Nullable<Mesh>;
  32384. /**
  32385. * Gets the list of clones of this mesh
  32386. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32387. * Note that useClonedMeshMap=true is the default setting
  32388. */
  32389. get cloneMeshMap(): Nullable<{
  32390. [id: string]: Mesh | undefined;
  32391. }>;
  32392. /**
  32393. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32394. */
  32395. get isUnIndexed(): boolean;
  32396. set isUnIndexed(value: boolean);
  32397. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32398. get worldMatrixInstancedBuffer(): Float32Array;
  32399. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32400. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32401. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32402. /**
  32403. * @constructor
  32404. * @param name The value used by scene.getMeshByName() to do a lookup.
  32405. * @param scene The scene to add this mesh to.
  32406. * @param parent The parent of this mesh, if it has one
  32407. * @param source An optional Mesh from which geometry is shared, cloned.
  32408. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32409. * When false, achieved by calling a clone(), also passing False.
  32410. * This will make creation of children, recursive.
  32411. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32412. */
  32413. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32414. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32415. doNotInstantiate: boolean;
  32416. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32417. /**
  32418. * Gets the class name
  32419. * @returns the string "Mesh".
  32420. */
  32421. getClassName(): string;
  32422. /** @hidden */
  32423. get _isMesh(): boolean;
  32424. /**
  32425. * Returns a description of this mesh
  32426. * @param fullDetails define if full details about this mesh must be used
  32427. * @returns a descriptive string representing this mesh
  32428. */
  32429. toString(fullDetails?: boolean): string;
  32430. /** @hidden */
  32431. _unBindEffect(): void;
  32432. /**
  32433. * Gets a boolean indicating if this mesh has LOD
  32434. */
  32435. get hasLODLevels(): boolean;
  32436. /**
  32437. * Gets the list of MeshLODLevel associated with the current mesh
  32438. * @returns an array of MeshLODLevel
  32439. */
  32440. getLODLevels(): MeshLODLevel[];
  32441. private _sortLODLevels;
  32442. /**
  32443. * Add a mesh as LOD level triggered at the given distance.
  32444. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32445. * @param distance The distance from the center of the object to show this level
  32446. * @param mesh The mesh to be added as LOD level (can be null)
  32447. * @return This mesh (for chaining)
  32448. */
  32449. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32450. /**
  32451. * Returns the LOD level mesh at the passed distance or null if not found.
  32452. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32453. * @param distance The distance from the center of the object to show this level
  32454. * @returns a Mesh or `null`
  32455. */
  32456. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32457. /**
  32458. * Remove a mesh from the LOD array
  32459. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32460. * @param mesh defines the mesh to be removed
  32461. * @return This mesh (for chaining)
  32462. */
  32463. removeLODLevel(mesh: Mesh): Mesh;
  32464. /**
  32465. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32466. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32467. * @param camera defines the camera to use to compute distance
  32468. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32469. * @return This mesh (for chaining)
  32470. */
  32471. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32472. /**
  32473. * Gets the mesh internal Geometry object
  32474. */
  32475. get geometry(): Nullable<Geometry>;
  32476. /**
  32477. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32478. * @returns the total number of vertices
  32479. */
  32480. getTotalVertices(): number;
  32481. /**
  32482. * Returns the content of an associated vertex buffer
  32483. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32484. * - VertexBuffer.PositionKind
  32485. * - VertexBuffer.UVKind
  32486. * - VertexBuffer.UV2Kind
  32487. * - VertexBuffer.UV3Kind
  32488. * - VertexBuffer.UV4Kind
  32489. * - VertexBuffer.UV5Kind
  32490. * - VertexBuffer.UV6Kind
  32491. * - VertexBuffer.ColorKind
  32492. * - VertexBuffer.MatricesIndicesKind
  32493. * - VertexBuffer.MatricesIndicesExtraKind
  32494. * - VertexBuffer.MatricesWeightsKind
  32495. * - VertexBuffer.MatricesWeightsExtraKind
  32496. * @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
  32497. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32498. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32499. */
  32500. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32501. /**
  32502. * Returns the mesh VertexBuffer object from the requested `kind`
  32503. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32504. * - VertexBuffer.PositionKind
  32505. * - VertexBuffer.NormalKind
  32506. * - VertexBuffer.UVKind
  32507. * - VertexBuffer.UV2Kind
  32508. * - VertexBuffer.UV3Kind
  32509. * - VertexBuffer.UV4Kind
  32510. * - VertexBuffer.UV5Kind
  32511. * - VertexBuffer.UV6Kind
  32512. * - VertexBuffer.ColorKind
  32513. * - VertexBuffer.MatricesIndicesKind
  32514. * - VertexBuffer.MatricesIndicesExtraKind
  32515. * - VertexBuffer.MatricesWeightsKind
  32516. * - VertexBuffer.MatricesWeightsExtraKind
  32517. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  32518. */
  32519. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32520. /**
  32521. * Tests if a specific vertex buffer is associated with this mesh
  32522. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32523. * - VertexBuffer.PositionKind
  32524. * - VertexBuffer.NormalKind
  32525. * - VertexBuffer.UVKind
  32526. * - VertexBuffer.UV2Kind
  32527. * - VertexBuffer.UV3Kind
  32528. * - VertexBuffer.UV4Kind
  32529. * - VertexBuffer.UV5Kind
  32530. * - VertexBuffer.UV6Kind
  32531. * - VertexBuffer.ColorKind
  32532. * - VertexBuffer.MatricesIndicesKind
  32533. * - VertexBuffer.MatricesIndicesExtraKind
  32534. * - VertexBuffer.MatricesWeightsKind
  32535. * - VertexBuffer.MatricesWeightsExtraKind
  32536. * @returns a boolean
  32537. */
  32538. isVerticesDataPresent(kind: string): boolean;
  32539. /**
  32540. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  32541. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32542. * - VertexBuffer.PositionKind
  32543. * - VertexBuffer.UVKind
  32544. * - VertexBuffer.UV2Kind
  32545. * - VertexBuffer.UV3Kind
  32546. * - VertexBuffer.UV4Kind
  32547. * - VertexBuffer.UV5Kind
  32548. * - VertexBuffer.UV6Kind
  32549. * - VertexBuffer.ColorKind
  32550. * - VertexBuffer.MatricesIndicesKind
  32551. * - VertexBuffer.MatricesIndicesExtraKind
  32552. * - VertexBuffer.MatricesWeightsKind
  32553. * - VertexBuffer.MatricesWeightsExtraKind
  32554. * @returns a boolean
  32555. */
  32556. isVertexBufferUpdatable(kind: string): boolean;
  32557. /**
  32558. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  32559. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32560. * - VertexBuffer.PositionKind
  32561. * - VertexBuffer.NormalKind
  32562. * - VertexBuffer.UVKind
  32563. * - VertexBuffer.UV2Kind
  32564. * - VertexBuffer.UV3Kind
  32565. * - VertexBuffer.UV4Kind
  32566. * - VertexBuffer.UV5Kind
  32567. * - VertexBuffer.UV6Kind
  32568. * - VertexBuffer.ColorKind
  32569. * - VertexBuffer.MatricesIndicesKind
  32570. * - VertexBuffer.MatricesIndicesExtraKind
  32571. * - VertexBuffer.MatricesWeightsKind
  32572. * - VertexBuffer.MatricesWeightsExtraKind
  32573. * @returns an array of strings
  32574. */
  32575. getVerticesDataKinds(): string[];
  32576. /**
  32577. * Returns a positive integer : the total number of indices in this mesh geometry.
  32578. * @returns the numner of indices or zero if the mesh has no geometry.
  32579. */
  32580. getTotalIndices(): number;
  32581. /**
  32582. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  32583. * @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.
  32584. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32585. * @returns the indices array or an empty array if the mesh has no geometry
  32586. */
  32587. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32588. get isBlocked(): boolean;
  32589. /**
  32590. * Determine if the current mesh is ready to be rendered
  32591. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32592. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  32593. * @returns true if all associated assets are ready (material, textures, shaders)
  32594. */
  32595. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  32596. /**
  32597. * 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.
  32598. */
  32599. get areNormalsFrozen(): boolean;
  32600. /**
  32601. * 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.
  32602. * @returns the current mesh
  32603. */
  32604. freezeNormals(): Mesh;
  32605. /**
  32606. * 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
  32607. * @returns the current mesh
  32608. */
  32609. unfreezeNormals(): Mesh;
  32610. /**
  32611. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  32612. */
  32613. set overridenInstanceCount(count: number);
  32614. /** @hidden */
  32615. _preActivate(): Mesh;
  32616. /** @hidden */
  32617. _preActivateForIntermediateRendering(renderId: number): Mesh;
  32618. /** @hidden */
  32619. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  32620. protected _afterComputeWorldMatrix(): void;
  32621. /** @hidden */
  32622. _postActivate(): void;
  32623. /**
  32624. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32625. * This means the mesh underlying bounding box and sphere are recomputed.
  32626. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32627. * @returns the current mesh
  32628. */
  32629. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  32630. /** @hidden */
  32631. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  32632. /**
  32633. * This function will subdivide the mesh into multiple submeshes
  32634. * @param count defines the expected number of submeshes
  32635. */
  32636. subdivide(count: number): void;
  32637. /**
  32638. * Copy a FloatArray into a specific associated vertex buffer
  32639. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32640. * - VertexBuffer.PositionKind
  32641. * - VertexBuffer.UVKind
  32642. * - VertexBuffer.UV2Kind
  32643. * - VertexBuffer.UV3Kind
  32644. * - VertexBuffer.UV4Kind
  32645. * - VertexBuffer.UV5Kind
  32646. * - VertexBuffer.UV6Kind
  32647. * - VertexBuffer.ColorKind
  32648. * - VertexBuffer.MatricesIndicesKind
  32649. * - VertexBuffer.MatricesIndicesExtraKind
  32650. * - VertexBuffer.MatricesWeightsKind
  32651. * - VertexBuffer.MatricesWeightsExtraKind
  32652. * @param data defines the data source
  32653. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32654. * @param stride defines the data stride size (can be null)
  32655. * @returns the current mesh
  32656. */
  32657. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32658. /**
  32659. * Delete a vertex buffer associated with this mesh
  32660. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  32661. * - VertexBuffer.PositionKind
  32662. * - VertexBuffer.UVKind
  32663. * - VertexBuffer.UV2Kind
  32664. * - VertexBuffer.UV3Kind
  32665. * - VertexBuffer.UV4Kind
  32666. * - VertexBuffer.UV5Kind
  32667. * - VertexBuffer.UV6Kind
  32668. * - VertexBuffer.ColorKind
  32669. * - VertexBuffer.MatricesIndicesKind
  32670. * - VertexBuffer.MatricesIndicesExtraKind
  32671. * - VertexBuffer.MatricesWeightsKind
  32672. * - VertexBuffer.MatricesWeightsExtraKind
  32673. */
  32674. removeVerticesData(kind: string): void;
  32675. /**
  32676. * Flags an associated vertex buffer as updatable
  32677. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  32678. * - VertexBuffer.PositionKind
  32679. * - VertexBuffer.UVKind
  32680. * - VertexBuffer.UV2Kind
  32681. * - VertexBuffer.UV3Kind
  32682. * - VertexBuffer.UV4Kind
  32683. * - VertexBuffer.UV5Kind
  32684. * - VertexBuffer.UV6Kind
  32685. * - VertexBuffer.ColorKind
  32686. * - VertexBuffer.MatricesIndicesKind
  32687. * - VertexBuffer.MatricesIndicesExtraKind
  32688. * - VertexBuffer.MatricesWeightsKind
  32689. * - VertexBuffer.MatricesWeightsExtraKind
  32690. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32691. */
  32692. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  32693. /**
  32694. * Sets the mesh global Vertex Buffer
  32695. * @param buffer defines the buffer to use
  32696. * @returns the current mesh
  32697. */
  32698. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  32699. /**
  32700. * Update a specific associated vertex buffer
  32701. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32702. * - VertexBuffer.PositionKind
  32703. * - VertexBuffer.UVKind
  32704. * - VertexBuffer.UV2Kind
  32705. * - VertexBuffer.UV3Kind
  32706. * - VertexBuffer.UV4Kind
  32707. * - VertexBuffer.UV5Kind
  32708. * - VertexBuffer.UV6Kind
  32709. * - VertexBuffer.ColorKind
  32710. * - VertexBuffer.MatricesIndicesKind
  32711. * - VertexBuffer.MatricesIndicesExtraKind
  32712. * - VertexBuffer.MatricesWeightsKind
  32713. * - VertexBuffer.MatricesWeightsExtraKind
  32714. * @param data defines the data source
  32715. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  32716. * @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)
  32717. * @returns the current mesh
  32718. */
  32719. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32720. /**
  32721. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  32722. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  32723. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  32724. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  32725. * @returns the current mesh
  32726. */
  32727. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  32728. /**
  32729. * Creates a un-shared specific occurence of the geometry for the mesh.
  32730. * @returns the current mesh
  32731. */
  32732. makeGeometryUnique(): Mesh;
  32733. /**
  32734. * Set the index buffer of this mesh
  32735. * @param indices defines the source data
  32736. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  32737. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  32738. * @returns the current mesh
  32739. */
  32740. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  32741. /**
  32742. * Update the current index buffer
  32743. * @param indices defines the source data
  32744. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32745. * @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)
  32746. * @returns the current mesh
  32747. */
  32748. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32749. /**
  32750. * Invert the geometry to move from a right handed system to a left handed one.
  32751. * @returns the current mesh
  32752. */
  32753. toLeftHanded(): Mesh;
  32754. /** @hidden */
  32755. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  32756. /** @hidden */
  32757. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  32758. /**
  32759. * Registers for this mesh a javascript function called just before the rendering process
  32760. * @param func defines the function to call before rendering this mesh
  32761. * @returns the current mesh
  32762. */
  32763. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32764. /**
  32765. * Disposes a previously registered javascript function called before the rendering
  32766. * @param func defines the function to remove
  32767. * @returns the current mesh
  32768. */
  32769. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32770. /**
  32771. * Registers for this mesh a javascript function called just after the rendering is complete
  32772. * @param func defines the function to call after rendering this mesh
  32773. * @returns the current mesh
  32774. */
  32775. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32776. /**
  32777. * Disposes a previously registered javascript function called after the rendering.
  32778. * @param func defines the function to remove
  32779. * @returns the current mesh
  32780. */
  32781. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32782. /** @hidden */
  32783. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  32784. /** @hidden */
  32785. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  32786. /** @hidden */
  32787. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  32788. /** @hidden */
  32789. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  32790. /** @hidden */
  32791. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  32792. /** @hidden */
  32793. _rebuild(): void;
  32794. /** @hidden */
  32795. _freeze(): void;
  32796. /** @hidden */
  32797. _unFreeze(): void;
  32798. /**
  32799. * 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
  32800. * @param subMesh defines the subMesh to render
  32801. * @param enableAlphaMode defines if alpha mode can be changed
  32802. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  32803. * @returns the current mesh
  32804. */
  32805. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  32806. private _onBeforeDraw;
  32807. /**
  32808. * Renormalize the mesh and patch it up if there are no weights
  32809. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  32810. * However in the case of zero weights then we set just a single influence to 1.
  32811. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  32812. */
  32813. cleanMatrixWeights(): void;
  32814. private normalizeSkinFourWeights;
  32815. private normalizeSkinWeightsAndExtra;
  32816. /**
  32817. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  32818. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  32819. * the user know there was an issue with importing the mesh
  32820. * @returns a validation object with skinned, valid and report string
  32821. */
  32822. validateSkinning(): {
  32823. skinned: boolean;
  32824. valid: boolean;
  32825. report: string;
  32826. };
  32827. /** @hidden */
  32828. _checkDelayState(): Mesh;
  32829. private _queueLoad;
  32830. /**
  32831. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32832. * A mesh is in the frustum if its bounding box intersects the frustum
  32833. * @param frustumPlanes defines the frustum to test
  32834. * @returns true if the mesh is in the frustum planes
  32835. */
  32836. isInFrustum(frustumPlanes: Plane[]): boolean;
  32837. /**
  32838. * Sets the mesh material by the material or multiMaterial `id` property
  32839. * @param id is a string identifying the material or the multiMaterial
  32840. * @returns the current mesh
  32841. */
  32842. setMaterialByID(id: string): Mesh;
  32843. /**
  32844. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  32845. * @returns an array of IAnimatable
  32846. */
  32847. getAnimatables(): IAnimatable[];
  32848. /**
  32849. * Modifies the mesh geometry according to the passed transformation matrix.
  32850. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  32851. * The mesh normals are modified using the same transformation.
  32852. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32853. * @param transform defines the transform matrix to use
  32854. * @see https://doc.babylonjs.com/resources/baking_transformations
  32855. * @returns the current mesh
  32856. */
  32857. bakeTransformIntoVertices(transform: Matrix): Mesh;
  32858. /**
  32859. * Modifies the mesh geometry according to its own current World Matrix.
  32860. * The mesh World Matrix is then reset.
  32861. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  32862. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32863. * @see https://doc.babylonjs.com/resources/baking_transformations
  32864. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  32865. * @returns the current mesh
  32866. */
  32867. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  32868. /** @hidden */
  32869. get _positions(): Nullable<Vector3[]>;
  32870. /** @hidden */
  32871. _resetPointsArrayCache(): Mesh;
  32872. /** @hidden */
  32873. _generatePointsArray(): boolean;
  32874. /**
  32875. * Returns a new Mesh object generated from the current mesh properties.
  32876. * This method must not get confused with createInstance()
  32877. * @param name is a string, the name given to the new mesh
  32878. * @param newParent can be any Node object (default `null`)
  32879. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  32880. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  32881. * @returns a new mesh
  32882. */
  32883. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  32884. /**
  32885. * Releases resources associated with this mesh.
  32886. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32887. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32888. */
  32889. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32890. /** @hidden */
  32891. _disposeInstanceSpecificData(): void;
  32892. /** @hidden */
  32893. _disposeThinInstanceSpecificData(): void;
  32894. /**
  32895. * Modifies the mesh geometry according to a displacement map.
  32896. * 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.
  32897. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32898. * @param url is a string, the URL from the image file is to be downloaded.
  32899. * @param minHeight is the lower limit of the displacement.
  32900. * @param maxHeight is the upper limit of the displacement.
  32901. * @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.
  32902. * @param uvOffset is an optional vector2 used to offset UV.
  32903. * @param uvScale is an optional vector2 used to scale UV.
  32904. * @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.
  32905. * @returns the Mesh.
  32906. */
  32907. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32908. /**
  32909. * Modifies the mesh geometry according to a displacementMap buffer.
  32910. * 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.
  32911. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32912. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  32913. * @param heightMapWidth is the width of the buffer image.
  32914. * @param heightMapHeight is the height of the buffer image.
  32915. * @param minHeight is the lower limit of the displacement.
  32916. * @param maxHeight is the upper limit of the displacement.
  32917. * @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.
  32918. * @param uvOffset is an optional vector2 used to offset UV.
  32919. * @param uvScale is an optional vector2 used to scale UV.
  32920. * @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.
  32921. * @returns the Mesh.
  32922. */
  32923. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32924. /**
  32925. * Modify the mesh to get a flat shading rendering.
  32926. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  32927. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  32928. * @returns current mesh
  32929. */
  32930. convertToFlatShadedMesh(): Mesh;
  32931. /**
  32932. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  32933. * In other words, more vertices, no more indices and a single bigger VBO.
  32934. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  32935. * @returns current mesh
  32936. */
  32937. convertToUnIndexedMesh(): Mesh;
  32938. /**
  32939. * Inverses facet orientations.
  32940. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32941. * @param flipNormals will also inverts the normals
  32942. * @returns current mesh
  32943. */
  32944. flipFaces(flipNormals?: boolean): Mesh;
  32945. /**
  32946. * Increase the number of facets and hence vertices in a mesh
  32947. * Vertex normals are interpolated from existing vertex normals
  32948. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32949. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  32950. */
  32951. increaseVertices(numberPerEdge: number): void;
  32952. /**
  32953. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  32954. * This will undo any application of covertToFlatShadedMesh
  32955. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32956. */
  32957. forceSharedVertices(): void;
  32958. /** @hidden */
  32959. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  32960. /** @hidden */
  32961. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  32962. /**
  32963. * Creates a new InstancedMesh object from the mesh model.
  32964. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32965. * @param name defines the name of the new instance
  32966. * @returns a new InstancedMesh
  32967. */
  32968. createInstance(name: string): InstancedMesh;
  32969. /**
  32970. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  32971. * After this call, all the mesh instances have the same submeshes than the current mesh.
  32972. * @returns the current mesh
  32973. */
  32974. synchronizeInstances(): Mesh;
  32975. /**
  32976. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  32977. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  32978. * This should be used together with the simplification to avoid disappearing triangles.
  32979. * @param successCallback an optional success callback to be called after the optimization finished.
  32980. * @returns the current mesh
  32981. */
  32982. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  32983. /**
  32984. * Serialize current mesh
  32985. * @param serializationObject defines the object which will receive the serialization data
  32986. */
  32987. serialize(serializationObject: any): void;
  32988. /** @hidden */
  32989. _syncGeometryWithMorphTargetManager(): void;
  32990. /** @hidden */
  32991. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  32992. /**
  32993. * Returns a new Mesh object parsed from the source provided.
  32994. * @param parsedMesh is the source
  32995. * @param scene defines the hosting scene
  32996. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  32997. * @returns a new Mesh
  32998. */
  32999. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33000. /**
  33001. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33002. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33003. * @param name defines the name of the mesh to create
  33004. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33005. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33006. * @param closePath creates a seam between the first and the last points of each path of the path array
  33007. * @param offset is taken in account only if the `pathArray` is containing a single path
  33008. * @param scene defines the hosting scene
  33009. * @param updatable defines if the mesh must be flagged as updatable
  33010. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33011. * @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)
  33012. * @returns a new Mesh
  33013. */
  33014. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33015. /**
  33016. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33017. * @param name defines the name of the mesh to create
  33018. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33019. * @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
  33020. * @param scene defines the hosting scene
  33021. * @param updatable defines if the mesh must be flagged as updatable
  33022. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33023. * @returns a new Mesh
  33024. */
  33025. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33026. /**
  33027. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33028. * @param name defines the name of the mesh to create
  33029. * @param size sets the size (float) of each box side (default 1)
  33030. * @param scene defines the hosting scene
  33031. * @param updatable defines if the mesh must be flagged as updatable
  33032. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33033. * @returns a new Mesh
  33034. */
  33035. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33036. /**
  33037. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33038. * @param name defines the name of the mesh to create
  33039. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33040. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33041. * @param scene defines the hosting scene
  33042. * @param updatable defines if the mesh must be flagged as updatable
  33043. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33044. * @returns a new Mesh
  33045. */
  33046. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33047. /**
  33048. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33049. * @param name defines the name of the mesh to create
  33050. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33051. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33052. * @param scene defines the hosting scene
  33053. * @returns a new Mesh
  33054. */
  33055. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33056. /**
  33057. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33058. * @param name defines the name of the mesh to create
  33059. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33060. * @param diameterTop set the top cap diameter (floats, default 1)
  33061. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33062. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33063. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33064. * @param scene defines the hosting scene
  33065. * @param updatable defines if the mesh must be flagged as updatable
  33066. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33067. * @returns a new Mesh
  33068. */
  33069. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33070. /**
  33071. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33072. * @param name defines the name of the mesh to create
  33073. * @param diameter sets the diameter size (float) of the torus (default 1)
  33074. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33075. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33076. * @param scene defines the hosting scene
  33077. * @param updatable defines if the mesh must be flagged as updatable
  33078. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33079. * @returns a new Mesh
  33080. */
  33081. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33082. /**
  33083. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33084. * @param name defines the name of the mesh to create
  33085. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33086. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33087. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33088. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33089. * @param p the number of windings on X axis (positive integers, default 2)
  33090. * @param q the number of windings on Y axis (positive integers, default 3)
  33091. * @param scene defines the hosting scene
  33092. * @param updatable defines if the mesh must be flagged as updatable
  33093. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33094. * @returns a new Mesh
  33095. */
  33096. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33097. /**
  33098. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33099. * @param name defines the name of the mesh to create
  33100. * @param points is an array successive Vector3
  33101. * @param scene defines the hosting scene
  33102. * @param updatable defines if the mesh must be flagged as updatable
  33103. * @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).
  33104. * @returns a new Mesh
  33105. */
  33106. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33107. /**
  33108. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33109. * @param name defines the name of the mesh to create
  33110. * @param points is an array successive Vector3
  33111. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33112. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33113. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33114. * @param scene defines the hosting scene
  33115. * @param updatable defines if the mesh must be flagged as updatable
  33116. * @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)
  33117. * @returns a new Mesh
  33118. */
  33119. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33120. /**
  33121. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33122. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33123. * 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.
  33124. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33125. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33126. * Remember you can only change the shape positions, not their number when updating a polygon.
  33127. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33128. * @param name defines the name of the mesh to create
  33129. * @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
  33130. * @param scene defines the hosting scene
  33131. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33132. * @param updatable defines if the mesh must be flagged as updatable
  33133. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33134. * @param earcutInjection can be used to inject your own earcut reference
  33135. * @returns a new Mesh
  33136. */
  33137. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33138. /**
  33139. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33140. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33141. * @param name defines the name of the mesh to create
  33142. * @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
  33143. * @param depth defines the height of extrusion
  33144. * @param scene defines the hosting scene
  33145. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33146. * @param updatable defines if the mesh must be flagged as updatable
  33147. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33148. * @param earcutInjection can be used to inject your own earcut reference
  33149. * @returns a new Mesh
  33150. */
  33151. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33152. /**
  33153. * Creates an extruded shape mesh.
  33154. * 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
  33155. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33156. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33157. * @param name defines the name of the mesh to create
  33158. * @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
  33159. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33160. * @param scale is the value to scale the shape
  33161. * @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
  33162. * @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
  33163. * @param scene defines the hosting scene
  33164. * @param updatable defines if the mesh must be flagged as updatable
  33165. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33166. * @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)
  33167. * @returns a new Mesh
  33168. */
  33169. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33170. /**
  33171. * Creates an custom extruded shape mesh.
  33172. * The custom extrusion is a parametric shape.
  33173. * It has no predefined shape. Its final shape will depend on the input parameters.
  33174. * Please consider using the same method from the MeshBuilder class instead
  33175. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33176. * @param name defines the name of the mesh to create
  33177. * @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
  33178. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33179. * @param scaleFunction is a custom Javascript function called on each path point
  33180. * @param rotationFunction is a custom Javascript function called on each path point
  33181. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33182. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33183. * @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
  33184. * @param scene defines the hosting scene
  33185. * @param updatable defines if the mesh must be flagged as updatable
  33186. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33187. * @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)
  33188. * @returns a new Mesh
  33189. */
  33190. 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;
  33191. /**
  33192. * Creates lathe mesh.
  33193. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33194. * Please consider using the same method from the MeshBuilder class instead
  33195. * @param name defines the name of the mesh to create
  33196. * @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
  33197. * @param radius is the radius value of the lathe
  33198. * @param tessellation is the side number of the lathe.
  33199. * @param scene defines the hosting scene
  33200. * @param updatable defines if the mesh must be flagged as updatable
  33201. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33202. * @returns a new Mesh
  33203. */
  33204. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33205. /**
  33206. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33207. * @param name defines the name of the mesh to create
  33208. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33209. * @param scene defines the hosting scene
  33210. * @param updatable defines if the mesh must be flagged as updatable
  33211. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33212. * @returns a new Mesh
  33213. */
  33214. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33215. /**
  33216. * Creates a ground mesh.
  33217. * Please consider using the same method from the MeshBuilder class instead
  33218. * @param name defines the name of the mesh to create
  33219. * @param width set the width of the ground
  33220. * @param height set the height of the ground
  33221. * @param subdivisions sets the number of subdivisions per side
  33222. * @param scene defines the hosting scene
  33223. * @param updatable defines if the mesh must be flagged as updatable
  33224. * @returns a new Mesh
  33225. */
  33226. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33227. /**
  33228. * Creates a tiled ground mesh.
  33229. * Please consider using the same method from the MeshBuilder class instead
  33230. * @param name defines the name of the mesh to create
  33231. * @param xmin set the ground minimum X coordinate
  33232. * @param zmin set the ground minimum Y coordinate
  33233. * @param xmax set the ground maximum X coordinate
  33234. * @param zmax set the ground maximum Z coordinate
  33235. * @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
  33236. * @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
  33237. * @param scene defines the hosting scene
  33238. * @param updatable defines if the mesh must be flagged as updatable
  33239. * @returns a new Mesh
  33240. */
  33241. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33242. w: number;
  33243. h: number;
  33244. }, precision: {
  33245. w: number;
  33246. h: number;
  33247. }, scene: Scene, updatable?: boolean): Mesh;
  33248. /**
  33249. * Creates a ground mesh from a height map.
  33250. * Please consider using the same method from the MeshBuilder class instead
  33251. * @see https://doc.babylonjs.com/babylon101/height_map
  33252. * @param name defines the name of the mesh to create
  33253. * @param url sets the URL of the height map image resource
  33254. * @param width set the ground width size
  33255. * @param height set the ground height size
  33256. * @param subdivisions sets the number of subdivision per side
  33257. * @param minHeight is the minimum altitude on the ground
  33258. * @param maxHeight is the maximum altitude on the ground
  33259. * @param scene defines the hosting scene
  33260. * @param updatable defines if the mesh must be flagged as updatable
  33261. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33262. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33263. * @returns a new Mesh
  33264. */
  33265. 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;
  33266. /**
  33267. * Creates a tube mesh.
  33268. * The tube is a parametric shape.
  33269. * It has no predefined shape. Its final shape will depend on the input parameters.
  33270. * Please consider using the same method from the MeshBuilder class instead
  33271. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33272. * @param name defines the name of the mesh to create
  33273. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33274. * @param radius sets the tube radius size
  33275. * @param tessellation is the number of sides on the tubular surface
  33276. * @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
  33277. * @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
  33278. * @param scene defines the hosting scene
  33279. * @param updatable defines if the mesh must be flagged as updatable
  33280. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33281. * @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)
  33282. * @returns a new Mesh
  33283. */
  33284. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33285. (i: number, distance: number): number;
  33286. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33287. /**
  33288. * Creates a polyhedron mesh.
  33289. * Please consider using the same method from the MeshBuilder class instead.
  33290. * * 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
  33291. * * The parameter `size` (positive float, default 1) sets the polygon size
  33292. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33293. * * 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`
  33294. * * 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
  33295. * * 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)`)
  33296. * * 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
  33297. * * 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
  33298. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33299. * * 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
  33300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33301. * @param name defines the name of the mesh to create
  33302. * @param options defines the options used to create the mesh
  33303. * @param scene defines the hosting scene
  33304. * @returns a new Mesh
  33305. */
  33306. static CreatePolyhedron(name: string, options: {
  33307. type?: number;
  33308. size?: number;
  33309. sizeX?: number;
  33310. sizeY?: number;
  33311. sizeZ?: number;
  33312. custom?: any;
  33313. faceUV?: Vector4[];
  33314. faceColors?: Color4[];
  33315. updatable?: boolean;
  33316. sideOrientation?: number;
  33317. }, scene: Scene): Mesh;
  33318. /**
  33319. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33320. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33321. * * 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`)
  33322. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33323. * * 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
  33324. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33325. * * 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
  33326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33327. * @param name defines the name of the mesh
  33328. * @param options defines the options used to create the mesh
  33329. * @param scene defines the hosting scene
  33330. * @returns a new Mesh
  33331. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33332. */
  33333. static CreateIcoSphere(name: string, options: {
  33334. radius?: number;
  33335. flat?: boolean;
  33336. subdivisions?: number;
  33337. sideOrientation?: number;
  33338. updatable?: boolean;
  33339. }, scene: Scene): Mesh;
  33340. /**
  33341. * Creates a decal mesh.
  33342. * Please consider using the same method from the MeshBuilder class instead.
  33343. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33344. * @param name defines the name of the mesh
  33345. * @param sourceMesh defines the mesh receiving the decal
  33346. * @param position sets the position of the decal in world coordinates
  33347. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33348. * @param size sets the decal scaling
  33349. * @param angle sets the angle to rotate the decal
  33350. * @returns a new Mesh
  33351. */
  33352. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33353. /** Creates a Capsule Mesh
  33354. * @param name defines the name of the mesh.
  33355. * @param options the constructors options used to shape the mesh.
  33356. * @param scene defines the scene the mesh is scoped to.
  33357. * @returns the capsule mesh
  33358. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33359. */
  33360. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33361. /**
  33362. * Prepare internal position array for software CPU skinning
  33363. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33364. */
  33365. setPositionsForCPUSkinning(): Float32Array;
  33366. /**
  33367. * Prepare internal normal array for software CPU skinning
  33368. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33369. */
  33370. setNormalsForCPUSkinning(): Float32Array;
  33371. /**
  33372. * Updates the vertex buffer by applying transformation from the bones
  33373. * @param skeleton defines the skeleton to apply to current mesh
  33374. * @returns the current mesh
  33375. */
  33376. applySkeleton(skeleton: Skeleton): Mesh;
  33377. /**
  33378. * 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
  33379. * @param meshes defines the list of meshes to scan
  33380. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33381. */
  33382. static MinMax(meshes: AbstractMesh[]): {
  33383. min: Vector3;
  33384. max: Vector3;
  33385. };
  33386. /**
  33387. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33388. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33389. * @returns a vector3
  33390. */
  33391. static Center(meshesOrMinMaxVector: {
  33392. min: Vector3;
  33393. max: Vector3;
  33394. } | AbstractMesh[]): Vector3;
  33395. /**
  33396. * Merge the array of meshes into a single mesh for performance reasons.
  33397. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33398. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33399. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33400. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33401. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33402. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33403. * @returns a new mesh
  33404. */
  33405. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33406. /** @hidden */
  33407. addInstance(instance: InstancedMesh): void;
  33408. /** @hidden */
  33409. removeInstance(instance: InstancedMesh): void;
  33410. }
  33411. }
  33412. declare module BABYLON {
  33413. /**
  33414. * The options Interface for creating a Capsule Mesh
  33415. */
  33416. export interface ICreateCapsuleOptions {
  33417. /** The Orientation of the capsule. Default : Vector3.Up() */
  33418. orientation?: Vector3;
  33419. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  33420. subdivisions: number;
  33421. /** Number of cylindrical segments on the capsule. */
  33422. tessellation: number;
  33423. /** Height or Length of the capsule. */
  33424. height: number;
  33425. /** Radius of the capsule. */
  33426. radius: number;
  33427. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  33428. capSubdivisions: number;
  33429. /** Overwrite for the top radius. */
  33430. radiusTop?: number;
  33431. /** Overwrite for the bottom radius. */
  33432. radiusBottom?: number;
  33433. /** Overwrite for the top capSubdivisions. */
  33434. topCapSubdivisions?: number;
  33435. /** Overwrite for the bottom capSubdivisions. */
  33436. bottomCapSubdivisions?: number;
  33437. }
  33438. /**
  33439. * Class containing static functions to help procedurally build meshes
  33440. */
  33441. export class CapsuleBuilder {
  33442. /**
  33443. * Creates a capsule or a pill mesh
  33444. * @param name defines the name of the mesh
  33445. * @param options The constructors options.
  33446. * @param scene The scene the mesh is scoped to.
  33447. * @returns Capsule Mesh
  33448. */
  33449. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  33450. }
  33451. }
  33452. declare module BABYLON {
  33453. /**
  33454. * Define an interface for all classes that will get and set the data on vertices
  33455. */
  33456. export interface IGetSetVerticesData {
  33457. /**
  33458. * Gets a boolean indicating if specific vertex data is present
  33459. * @param kind defines the vertex data kind to use
  33460. * @returns true is data kind is present
  33461. */
  33462. isVerticesDataPresent(kind: string): boolean;
  33463. /**
  33464. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  33465. * @param kind defines the data kind (Position, normal, etc...)
  33466. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  33467. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33468. * @returns a float array containing vertex data
  33469. */
  33470. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33471. /**
  33472. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33473. * @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.
  33474. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33475. * @returns the indices array or an empty array if the mesh has no geometry
  33476. */
  33477. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33478. /**
  33479. * Set specific vertex data
  33480. * @param kind defines the data kind (Position, normal, etc...)
  33481. * @param data defines the vertex data to use
  33482. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  33483. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  33484. */
  33485. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  33486. /**
  33487. * Update a specific associated vertex buffer
  33488. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33489. * - VertexBuffer.PositionKind
  33490. * - VertexBuffer.UVKind
  33491. * - VertexBuffer.UV2Kind
  33492. * - VertexBuffer.UV3Kind
  33493. * - VertexBuffer.UV4Kind
  33494. * - VertexBuffer.UV5Kind
  33495. * - VertexBuffer.UV6Kind
  33496. * - VertexBuffer.ColorKind
  33497. * - VertexBuffer.MatricesIndicesKind
  33498. * - VertexBuffer.MatricesIndicesExtraKind
  33499. * - VertexBuffer.MatricesWeightsKind
  33500. * - VertexBuffer.MatricesWeightsExtraKind
  33501. * @param data defines the data source
  33502. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33503. * @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)
  33504. */
  33505. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  33506. /**
  33507. * Creates a new index buffer
  33508. * @param indices defines the indices to store in the index buffer
  33509. * @param totalVertices defines the total number of vertices (could be null)
  33510. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  33511. */
  33512. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  33513. }
  33514. /**
  33515. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  33516. */
  33517. export class VertexData {
  33518. /**
  33519. * Mesh side orientation : usually the external or front surface
  33520. */
  33521. static readonly FRONTSIDE: number;
  33522. /**
  33523. * Mesh side orientation : usually the internal or back surface
  33524. */
  33525. static readonly BACKSIDE: number;
  33526. /**
  33527. * Mesh side orientation : both internal and external or front and back surfaces
  33528. */
  33529. static readonly DOUBLESIDE: number;
  33530. /**
  33531. * Mesh side orientation : by default, `FRONTSIDE`
  33532. */
  33533. static readonly DEFAULTSIDE: number;
  33534. /**
  33535. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  33536. */
  33537. positions: Nullable<FloatArray>;
  33538. /**
  33539. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  33540. */
  33541. normals: Nullable<FloatArray>;
  33542. /**
  33543. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  33544. */
  33545. tangents: Nullable<FloatArray>;
  33546. /**
  33547. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33548. */
  33549. uvs: Nullable<FloatArray>;
  33550. /**
  33551. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33552. */
  33553. uvs2: Nullable<FloatArray>;
  33554. /**
  33555. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33556. */
  33557. uvs3: Nullable<FloatArray>;
  33558. /**
  33559. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33560. */
  33561. uvs4: Nullable<FloatArray>;
  33562. /**
  33563. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33564. */
  33565. uvs5: Nullable<FloatArray>;
  33566. /**
  33567. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33568. */
  33569. uvs6: Nullable<FloatArray>;
  33570. /**
  33571. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  33572. */
  33573. colors: Nullable<FloatArray>;
  33574. /**
  33575. * 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).
  33576. */
  33577. matricesIndices: Nullable<FloatArray>;
  33578. /**
  33579. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  33580. */
  33581. matricesWeights: Nullable<FloatArray>;
  33582. /**
  33583. * An array extending the number of possible indices
  33584. */
  33585. matricesIndicesExtra: Nullable<FloatArray>;
  33586. /**
  33587. * An array extending the number of possible weights when the number of indices is extended
  33588. */
  33589. matricesWeightsExtra: Nullable<FloatArray>;
  33590. /**
  33591. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  33592. */
  33593. indices: Nullable<IndicesArray>;
  33594. /**
  33595. * Uses the passed data array to set the set the values for the specified kind of data
  33596. * @param data a linear array of floating numbers
  33597. * @param kind the type of data that is being set, eg positions, colors etc
  33598. */
  33599. set(data: FloatArray, kind: string): void;
  33600. /**
  33601. * Associates the vertexData to the passed Mesh.
  33602. * Sets it as updatable or not (default `false`)
  33603. * @param mesh the mesh the vertexData is applied to
  33604. * @param updatable when used and having the value true allows new data to update the vertexData
  33605. * @returns the VertexData
  33606. */
  33607. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  33608. /**
  33609. * Associates the vertexData to the passed Geometry.
  33610. * Sets it as updatable or not (default `false`)
  33611. * @param geometry the geometry the vertexData is applied to
  33612. * @param updatable when used and having the value true allows new data to update the vertexData
  33613. * @returns VertexData
  33614. */
  33615. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  33616. /**
  33617. * Updates the associated mesh
  33618. * @param mesh the mesh to be updated
  33619. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33620. * @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
  33621. * @returns VertexData
  33622. */
  33623. updateMesh(mesh: Mesh): VertexData;
  33624. /**
  33625. * Updates the associated geometry
  33626. * @param geometry the geometry to be updated
  33627. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33628. * @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
  33629. * @returns VertexData.
  33630. */
  33631. updateGeometry(geometry: Geometry): VertexData;
  33632. private _applyTo;
  33633. private _update;
  33634. /**
  33635. * Transforms each position and each normal of the vertexData according to the passed Matrix
  33636. * @param matrix the transforming matrix
  33637. * @returns the VertexData
  33638. */
  33639. transform(matrix: Matrix): VertexData;
  33640. /**
  33641. * Merges the passed VertexData into the current one
  33642. * @param other the VertexData to be merged into the current one
  33643. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  33644. * @returns the modified VertexData
  33645. */
  33646. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  33647. private _mergeElement;
  33648. private _validate;
  33649. /**
  33650. * Serializes the VertexData
  33651. * @returns a serialized object
  33652. */
  33653. serialize(): any;
  33654. /**
  33655. * Extracts the vertexData from a mesh
  33656. * @param mesh the mesh from which to extract the VertexData
  33657. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  33658. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33659. * @returns the object VertexData associated to the passed mesh
  33660. */
  33661. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33662. /**
  33663. * Extracts the vertexData from the geometry
  33664. * @param geometry the geometry from which to extract the VertexData
  33665. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  33666. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33667. * @returns the object VertexData associated to the passed mesh
  33668. */
  33669. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33670. private static _ExtractFrom;
  33671. /**
  33672. * Creates the VertexData for a Ribbon
  33673. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  33674. * * pathArray array of paths, each of which an array of successive Vector3
  33675. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  33676. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  33677. * * 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
  33678. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33679. * * 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)
  33680. * * 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)
  33681. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  33682. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  33683. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  33684. * @returns the VertexData of the ribbon
  33685. */
  33686. static CreateRibbon(options: {
  33687. pathArray: Vector3[][];
  33688. closeArray?: boolean;
  33689. closePath?: boolean;
  33690. offset?: number;
  33691. sideOrientation?: number;
  33692. frontUVs?: Vector4;
  33693. backUVs?: Vector4;
  33694. invertUV?: boolean;
  33695. uvs?: Vector2[];
  33696. colors?: Color4[];
  33697. }): VertexData;
  33698. /**
  33699. * Creates the VertexData for a box
  33700. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33701. * * size sets the width, height and depth of the box to the value of size, optional default 1
  33702. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  33703. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  33704. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  33705. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33706. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33707. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33708. * * 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)
  33709. * * 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)
  33710. * @returns the VertexData of the box
  33711. */
  33712. static CreateBox(options: {
  33713. size?: number;
  33714. width?: number;
  33715. height?: number;
  33716. depth?: number;
  33717. faceUV?: Vector4[];
  33718. faceColors?: Color4[];
  33719. sideOrientation?: number;
  33720. frontUVs?: Vector4;
  33721. backUVs?: Vector4;
  33722. }): VertexData;
  33723. /**
  33724. * Creates the VertexData for a tiled box
  33725. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33726. * * faceTiles sets the pattern, tile size and number of tiles for a face
  33727. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33728. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33729. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33730. * @returns the VertexData of the box
  33731. */
  33732. static CreateTiledBox(options: {
  33733. pattern?: number;
  33734. width?: number;
  33735. height?: number;
  33736. depth?: number;
  33737. tileSize?: number;
  33738. tileWidth?: number;
  33739. tileHeight?: number;
  33740. alignHorizontal?: number;
  33741. alignVertical?: number;
  33742. faceUV?: Vector4[];
  33743. faceColors?: Color4[];
  33744. sideOrientation?: number;
  33745. }): VertexData;
  33746. /**
  33747. * Creates the VertexData for a tiled plane
  33748. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33749. * * pattern a limited pattern arrangement depending on the number
  33750. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  33751. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  33752. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  33753. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33754. * * 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)
  33755. * * 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)
  33756. * @returns the VertexData of the tiled plane
  33757. */
  33758. static CreateTiledPlane(options: {
  33759. pattern?: number;
  33760. tileSize?: number;
  33761. tileWidth?: number;
  33762. tileHeight?: number;
  33763. size?: number;
  33764. width?: number;
  33765. height?: number;
  33766. alignHorizontal?: number;
  33767. alignVertical?: number;
  33768. sideOrientation?: number;
  33769. frontUVs?: Vector4;
  33770. backUVs?: Vector4;
  33771. }): VertexData;
  33772. /**
  33773. * Creates the VertexData for an ellipsoid, defaults to a sphere
  33774. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33775. * * segments sets the number of horizontal strips optional, default 32
  33776. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  33777. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  33778. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  33779. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  33780. * * 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
  33781. * * 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
  33782. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33783. * * 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)
  33784. * * 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)
  33785. * @returns the VertexData of the ellipsoid
  33786. */
  33787. static CreateSphere(options: {
  33788. segments?: number;
  33789. diameter?: number;
  33790. diameterX?: number;
  33791. diameterY?: number;
  33792. diameterZ?: number;
  33793. arc?: number;
  33794. slice?: number;
  33795. sideOrientation?: number;
  33796. frontUVs?: Vector4;
  33797. backUVs?: Vector4;
  33798. }): VertexData;
  33799. /**
  33800. * Creates the VertexData for a cylinder, cone or prism
  33801. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33802. * * height sets the height (y direction) of the cylinder, optional, default 2
  33803. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  33804. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  33805. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  33806. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33807. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  33808. * * 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
  33809. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  33810. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  33811. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  33812. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  33813. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33814. * * 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)
  33815. * * 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)
  33816. * @returns the VertexData of the cylinder, cone or prism
  33817. */
  33818. static CreateCylinder(options: {
  33819. height?: number;
  33820. diameterTop?: number;
  33821. diameterBottom?: number;
  33822. diameter?: number;
  33823. tessellation?: number;
  33824. subdivisions?: number;
  33825. arc?: number;
  33826. faceColors?: Color4[];
  33827. faceUV?: Vector4[];
  33828. hasRings?: boolean;
  33829. enclose?: boolean;
  33830. sideOrientation?: number;
  33831. frontUVs?: Vector4;
  33832. backUVs?: Vector4;
  33833. }): VertexData;
  33834. /**
  33835. * Creates the VertexData for a torus
  33836. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33837. * * diameter the diameter of the torus, optional default 1
  33838. * * thickness the diameter of the tube forming the torus, optional default 0.5
  33839. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33840. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33841. * * 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)
  33842. * * 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)
  33843. * @returns the VertexData of the torus
  33844. */
  33845. static CreateTorus(options: {
  33846. diameter?: number;
  33847. thickness?: number;
  33848. tessellation?: number;
  33849. sideOrientation?: number;
  33850. frontUVs?: Vector4;
  33851. backUVs?: Vector4;
  33852. }): VertexData;
  33853. /**
  33854. * Creates the VertexData of the LineSystem
  33855. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  33856. * - lines an array of lines, each line being an array of successive Vector3
  33857. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  33858. * @returns the VertexData of the LineSystem
  33859. */
  33860. static CreateLineSystem(options: {
  33861. lines: Vector3[][];
  33862. colors?: Nullable<Color4[][]>;
  33863. }): VertexData;
  33864. /**
  33865. * Create the VertexData for a DashedLines
  33866. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  33867. * - points an array successive Vector3
  33868. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  33869. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  33870. * - dashNb the intended total number of dashes, optional, default 200
  33871. * @returns the VertexData for the DashedLines
  33872. */
  33873. static CreateDashedLines(options: {
  33874. points: Vector3[];
  33875. dashSize?: number;
  33876. gapSize?: number;
  33877. dashNb?: number;
  33878. }): VertexData;
  33879. /**
  33880. * Creates the VertexData for a Ground
  33881. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33882. * - width the width (x direction) of the ground, optional, default 1
  33883. * - height the height (z direction) of the ground, optional, default 1
  33884. * - subdivisions the number of subdivisions per side, optional, default 1
  33885. * @returns the VertexData of the Ground
  33886. */
  33887. static CreateGround(options: {
  33888. width?: number;
  33889. height?: number;
  33890. subdivisions?: number;
  33891. subdivisionsX?: number;
  33892. subdivisionsY?: number;
  33893. }): VertexData;
  33894. /**
  33895. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  33896. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33897. * * xmin the ground minimum X coordinate, optional, default -1
  33898. * * zmin the ground minimum Z coordinate, optional, default -1
  33899. * * xmax the ground maximum X coordinate, optional, default 1
  33900. * * zmax the ground maximum Z coordinate, optional, default 1
  33901. * * 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}
  33902. * * 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}
  33903. * @returns the VertexData of the TiledGround
  33904. */
  33905. static CreateTiledGround(options: {
  33906. xmin: number;
  33907. zmin: number;
  33908. xmax: number;
  33909. zmax: number;
  33910. subdivisions?: {
  33911. w: number;
  33912. h: number;
  33913. };
  33914. precision?: {
  33915. w: number;
  33916. h: number;
  33917. };
  33918. }): VertexData;
  33919. /**
  33920. * Creates the VertexData of the Ground designed from a heightmap
  33921. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  33922. * * width the width (x direction) of the ground
  33923. * * height the height (z direction) of the ground
  33924. * * subdivisions the number of subdivisions per side
  33925. * * minHeight the minimum altitude on the ground, optional, default 0
  33926. * * maxHeight the maximum altitude on the ground, optional default 1
  33927. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  33928. * * buffer the array holding the image color data
  33929. * * bufferWidth the width of image
  33930. * * bufferHeight the height of image
  33931. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  33932. * @returns the VertexData of the Ground designed from a heightmap
  33933. */
  33934. static CreateGroundFromHeightMap(options: {
  33935. width: number;
  33936. height: number;
  33937. subdivisions: number;
  33938. minHeight: number;
  33939. maxHeight: number;
  33940. colorFilter: Color3;
  33941. buffer: Uint8Array;
  33942. bufferWidth: number;
  33943. bufferHeight: number;
  33944. alphaFilter: number;
  33945. }): VertexData;
  33946. /**
  33947. * Creates the VertexData for a Plane
  33948. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  33949. * * size sets the width and height of the plane to the value of size, optional default 1
  33950. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  33951. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  33952. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33953. * * 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)
  33954. * * 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)
  33955. * @returns the VertexData of the box
  33956. */
  33957. static CreatePlane(options: {
  33958. size?: number;
  33959. width?: number;
  33960. height?: number;
  33961. sideOrientation?: number;
  33962. frontUVs?: Vector4;
  33963. backUVs?: Vector4;
  33964. }): VertexData;
  33965. /**
  33966. * Creates the VertexData of the Disc or regular Polygon
  33967. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  33968. * * radius the radius of the disc, optional default 0.5
  33969. * * tessellation the number of polygon sides, optional, default 64
  33970. * * 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
  33971. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33972. * * 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)
  33973. * * 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)
  33974. * @returns the VertexData of the box
  33975. */
  33976. static CreateDisc(options: {
  33977. radius?: number;
  33978. tessellation?: number;
  33979. arc?: number;
  33980. sideOrientation?: number;
  33981. frontUVs?: Vector4;
  33982. backUVs?: Vector4;
  33983. }): VertexData;
  33984. /**
  33985. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  33986. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  33987. * @param polygon a mesh built from polygonTriangulation.build()
  33988. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33989. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  33990. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  33991. * @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)
  33992. * @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)
  33993. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  33994. * @returns the VertexData of the Polygon
  33995. */
  33996. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  33997. /**
  33998. * Creates the VertexData of the IcoSphere
  33999. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  34000. * * radius the radius of the IcoSphere, optional default 1
  34001. * * radiusX allows stretching in the x direction, optional, default radius
  34002. * * radiusY allows stretching in the y direction, optional, default radius
  34003. * * radiusZ allows stretching in the z direction, optional, default radius
  34004. * * flat when true creates a flat shaded mesh, optional, default true
  34005. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34006. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34007. * * 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)
  34008. * * 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)
  34009. * @returns the VertexData of the IcoSphere
  34010. */
  34011. static CreateIcoSphere(options: {
  34012. radius?: number;
  34013. radiusX?: number;
  34014. radiusY?: number;
  34015. radiusZ?: number;
  34016. flat?: boolean;
  34017. subdivisions?: number;
  34018. sideOrientation?: number;
  34019. frontUVs?: Vector4;
  34020. backUVs?: Vector4;
  34021. }): VertexData;
  34022. /**
  34023. * Creates the VertexData for a Polyhedron
  34024. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  34025. * * type provided types are:
  34026. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  34027. * * 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)
  34028. * * size the size of the IcoSphere, optional default 1
  34029. * * sizeX allows stretching in the x direction, optional, default size
  34030. * * sizeY allows stretching in the y direction, optional, default size
  34031. * * sizeZ allows stretching in the z direction, optional, default size
  34032. * * 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
  34033. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34034. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34035. * * flat when true creates a flat shaded mesh, optional, default true
  34036. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34037. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34038. * * 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)
  34039. * * 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)
  34040. * @returns the VertexData of the Polyhedron
  34041. */
  34042. static CreatePolyhedron(options: {
  34043. type?: number;
  34044. size?: number;
  34045. sizeX?: number;
  34046. sizeY?: number;
  34047. sizeZ?: number;
  34048. custom?: any;
  34049. faceUV?: Vector4[];
  34050. faceColors?: Color4[];
  34051. flat?: boolean;
  34052. sideOrientation?: number;
  34053. frontUVs?: Vector4;
  34054. backUVs?: Vector4;
  34055. }): VertexData;
  34056. /**
  34057. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34058. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34059. * @returns the VertexData of the Capsule
  34060. */
  34061. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34062. /**
  34063. * Creates the VertexData for a TorusKnot
  34064. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34065. * * radius the radius of the torus knot, optional, default 2
  34066. * * tube the thickness of the tube, optional, default 0.5
  34067. * * radialSegments the number of sides on each tube segments, optional, default 32
  34068. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34069. * * p the number of windings around the z axis, optional, default 2
  34070. * * q the number of windings around the x axis, optional, default 3
  34071. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34072. * * 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)
  34073. * * 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)
  34074. * @returns the VertexData of the Torus Knot
  34075. */
  34076. static CreateTorusKnot(options: {
  34077. radius?: number;
  34078. tube?: number;
  34079. radialSegments?: number;
  34080. tubularSegments?: number;
  34081. p?: number;
  34082. q?: number;
  34083. sideOrientation?: number;
  34084. frontUVs?: Vector4;
  34085. backUVs?: Vector4;
  34086. }): VertexData;
  34087. /**
  34088. * Compute normals for given positions and indices
  34089. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34090. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34091. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34092. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34093. * * facetNormals : optional array of facet normals (vector3)
  34094. * * facetPositions : optional array of facet positions (vector3)
  34095. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34096. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34097. * * bInfo : optional bounding info, required for facetPartitioning computation
  34098. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34099. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34100. * * useRightHandedSystem: optional boolean to for right handed system computation
  34101. * * depthSort : optional boolean to enable the facet depth sort computation
  34102. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34103. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34104. */
  34105. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34106. facetNormals?: any;
  34107. facetPositions?: any;
  34108. facetPartitioning?: any;
  34109. ratio?: number;
  34110. bInfo?: any;
  34111. bbSize?: Vector3;
  34112. subDiv?: any;
  34113. useRightHandedSystem?: boolean;
  34114. depthSort?: boolean;
  34115. distanceTo?: Vector3;
  34116. depthSortedFacets?: any;
  34117. }): void;
  34118. /** @hidden */
  34119. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34120. /**
  34121. * Applies VertexData created from the imported parameters to the geometry
  34122. * @param parsedVertexData the parsed data from an imported file
  34123. * @param geometry the geometry to apply the VertexData to
  34124. */
  34125. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34126. }
  34127. }
  34128. declare module BABYLON {
  34129. /**
  34130. * Class containing static functions to help procedurally build meshes
  34131. */
  34132. export class DiscBuilder {
  34133. /**
  34134. * Creates a plane polygonal mesh. By default, this is a disc
  34135. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34136. * * 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
  34137. * * 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
  34138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34139. * * 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
  34140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34141. * @param name defines the name of the mesh
  34142. * @param options defines the options used to create the mesh
  34143. * @param scene defines the hosting scene
  34144. * @returns the plane polygonal mesh
  34145. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34146. */
  34147. static CreateDisc(name: string, options: {
  34148. radius?: number;
  34149. tessellation?: number;
  34150. arc?: number;
  34151. updatable?: boolean;
  34152. sideOrientation?: number;
  34153. frontUVs?: Vector4;
  34154. backUVs?: Vector4;
  34155. }, scene?: Nullable<Scene>): Mesh;
  34156. }
  34157. }
  34158. declare module BABYLON {
  34159. /**
  34160. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34161. *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.
  34162. * The SPS is also a particle system. It provides some methods to manage the particles.
  34163. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34164. *
  34165. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34166. */
  34167. export class SolidParticleSystem implements IDisposable {
  34168. /**
  34169. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34170. * Example : var p = SPS.particles[i];
  34171. */
  34172. particles: SolidParticle[];
  34173. /**
  34174. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34175. */
  34176. nbParticles: number;
  34177. /**
  34178. * If the particles must ever face the camera (default false). Useful for planar particles.
  34179. */
  34180. billboard: boolean;
  34181. /**
  34182. * Recompute normals when adding a shape
  34183. */
  34184. recomputeNormals: boolean;
  34185. /**
  34186. * This a counter ofr your own usage. It's not set by any SPS functions.
  34187. */
  34188. counter: number;
  34189. /**
  34190. * The SPS name. This name is also given to the underlying mesh.
  34191. */
  34192. name: string;
  34193. /**
  34194. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34195. */
  34196. mesh: Mesh;
  34197. /**
  34198. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34199. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34200. */
  34201. vars: any;
  34202. /**
  34203. * This array is populated when the SPS is set as 'pickable'.
  34204. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34205. * Each element of this array is an object `{idx: int, faceId: int}`.
  34206. * `idx` is the picked particle index in the `SPS.particles` array
  34207. * `faceId` is the picked face index counted within this particle.
  34208. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34209. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34210. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34211. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34212. */
  34213. pickedParticles: {
  34214. idx: number;
  34215. faceId: number;
  34216. }[];
  34217. /**
  34218. * This array is populated when the SPS is set as 'pickable'
  34219. * Each key of this array is a submesh index.
  34220. * Each element of this array is a second array defined like this :
  34221. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34222. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34223. * `idx` is the picked particle index in the `SPS.particles` array
  34224. * `faceId` is the picked face index counted within this particle.
  34225. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34226. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34227. */
  34228. pickedBySubMesh: {
  34229. idx: number;
  34230. faceId: number;
  34231. }[][];
  34232. /**
  34233. * This array is populated when `enableDepthSort` is set to true.
  34234. * Each element of this array is an instance of the class DepthSortedParticle.
  34235. */
  34236. depthSortedParticles: DepthSortedParticle[];
  34237. /**
  34238. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34239. * @hidden
  34240. */
  34241. _bSphereOnly: boolean;
  34242. /**
  34243. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34244. * @hidden
  34245. */
  34246. _bSphereRadiusFactor: number;
  34247. private _scene;
  34248. private _positions;
  34249. private _indices;
  34250. private _normals;
  34251. private _colors;
  34252. private _uvs;
  34253. private _indices32;
  34254. private _positions32;
  34255. private _normals32;
  34256. private _fixedNormal32;
  34257. private _colors32;
  34258. private _uvs32;
  34259. private _index;
  34260. private _updatable;
  34261. private _pickable;
  34262. private _isVisibilityBoxLocked;
  34263. private _alwaysVisible;
  34264. private _depthSort;
  34265. private _expandable;
  34266. private _shapeCounter;
  34267. private _copy;
  34268. private _color;
  34269. private _computeParticleColor;
  34270. private _computeParticleTexture;
  34271. private _computeParticleRotation;
  34272. private _computeParticleVertex;
  34273. private _computeBoundingBox;
  34274. private _depthSortParticles;
  34275. private _camera;
  34276. private _mustUnrotateFixedNormals;
  34277. private _particlesIntersect;
  34278. private _needs32Bits;
  34279. private _isNotBuilt;
  34280. private _lastParticleId;
  34281. private _idxOfId;
  34282. private _multimaterialEnabled;
  34283. private _useModelMaterial;
  34284. private _indicesByMaterial;
  34285. private _materialIndexes;
  34286. private _depthSortFunction;
  34287. private _materialSortFunction;
  34288. private _materials;
  34289. private _multimaterial;
  34290. private _materialIndexesById;
  34291. private _defaultMaterial;
  34292. private _autoUpdateSubMeshes;
  34293. private _tmpVertex;
  34294. /**
  34295. * Creates a SPS (Solid Particle System) object.
  34296. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34297. * @param scene (Scene) is the scene in which the SPS is added.
  34298. * @param options defines the options of the sps e.g.
  34299. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34300. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34301. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34302. * * 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.
  34303. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34304. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34305. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34306. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34307. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34308. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34309. */
  34310. constructor(name: string, scene: Scene, options?: {
  34311. updatable?: boolean;
  34312. isPickable?: boolean;
  34313. enableDepthSort?: boolean;
  34314. particleIntersection?: boolean;
  34315. boundingSphereOnly?: boolean;
  34316. bSphereRadiusFactor?: number;
  34317. expandable?: boolean;
  34318. useModelMaterial?: boolean;
  34319. enableMultiMaterial?: boolean;
  34320. });
  34321. /**
  34322. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34323. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34324. * @returns the created mesh
  34325. */
  34326. buildMesh(): Mesh;
  34327. /**
  34328. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34329. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34330. * Thus the particles generated from `digest()` have their property `position` set yet.
  34331. * @param mesh ( Mesh ) is the mesh to be digested
  34332. * @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
  34333. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34334. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34335. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34336. * @returns the current SPS
  34337. */
  34338. digest(mesh: Mesh, options?: {
  34339. facetNb?: number;
  34340. number?: number;
  34341. delta?: number;
  34342. storage?: [];
  34343. }): SolidParticleSystem;
  34344. /**
  34345. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34346. * @hidden
  34347. */
  34348. private _unrotateFixedNormals;
  34349. /**
  34350. * Resets the temporary working copy particle
  34351. * @hidden
  34352. */
  34353. private _resetCopy;
  34354. /**
  34355. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34356. * @param p the current index in the positions array to be updated
  34357. * @param ind the current index in the indices array
  34358. * @param shape a Vector3 array, the shape geometry
  34359. * @param positions the positions array to be updated
  34360. * @param meshInd the shape indices array
  34361. * @param indices the indices array to be updated
  34362. * @param meshUV the shape uv array
  34363. * @param uvs the uv array to be updated
  34364. * @param meshCol the shape color array
  34365. * @param colors the color array to be updated
  34366. * @param meshNor the shape normals array
  34367. * @param normals the normals array to be updated
  34368. * @param idx the particle index
  34369. * @param idxInShape the particle index in its shape
  34370. * @param options the addShape() method passed options
  34371. * @model the particle model
  34372. * @hidden
  34373. */
  34374. private _meshBuilder;
  34375. /**
  34376. * Returns a shape Vector3 array from positions float array
  34377. * @param positions float array
  34378. * @returns a vector3 array
  34379. * @hidden
  34380. */
  34381. private _posToShape;
  34382. /**
  34383. * Returns a shapeUV array from a float uvs (array deep copy)
  34384. * @param uvs as a float array
  34385. * @returns a shapeUV array
  34386. * @hidden
  34387. */
  34388. private _uvsToShapeUV;
  34389. /**
  34390. * Adds a new particle object in the particles array
  34391. * @param idx particle index in particles array
  34392. * @param id particle id
  34393. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34394. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34395. * @param model particle ModelShape object
  34396. * @param shapeId model shape identifier
  34397. * @param idxInShape index of the particle in the current model
  34398. * @param bInfo model bounding info object
  34399. * @param storage target storage array, if any
  34400. * @hidden
  34401. */
  34402. private _addParticle;
  34403. /**
  34404. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34405. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34406. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34407. * @param nb (positive integer) the number of particles to be created from this model
  34408. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34409. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34410. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34411. * @returns the number of shapes in the system
  34412. */
  34413. addShape(mesh: Mesh, nb: number, options?: {
  34414. positionFunction?: any;
  34415. vertexFunction?: any;
  34416. storage?: [];
  34417. }): number;
  34418. /**
  34419. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34420. * @hidden
  34421. */
  34422. private _rebuildParticle;
  34423. /**
  34424. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34425. * @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.
  34426. * @returns the SPS.
  34427. */
  34428. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34429. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34430. * Returns an array with the removed particles.
  34431. * 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.
  34432. * The SPS can't be empty so at least one particle needs to remain in place.
  34433. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34434. * @param start index of the first particle to remove
  34435. * @param end index of the last particle to remove (included)
  34436. * @returns an array populated with the removed particles
  34437. */
  34438. removeParticles(start: number, end: number): SolidParticle[];
  34439. /**
  34440. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34441. * @param solidParticleArray an array populated with Solid Particles objects
  34442. * @returns the SPS
  34443. */
  34444. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34445. /**
  34446. * Creates a new particle and modifies the SPS mesh geometry :
  34447. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34448. * - calls _addParticle() to populate the particle array
  34449. * factorized code from addShape() and insertParticlesFromArray()
  34450. * @param idx particle index in the particles array
  34451. * @param i particle index in its shape
  34452. * @param modelShape particle ModelShape object
  34453. * @param shape shape vertex array
  34454. * @param meshInd shape indices array
  34455. * @param meshUV shape uv array
  34456. * @param meshCol shape color array
  34457. * @param meshNor shape normals array
  34458. * @param bbInfo shape bounding info
  34459. * @param storage target particle storage
  34460. * @options addShape() passed options
  34461. * @hidden
  34462. */
  34463. private _insertNewParticle;
  34464. /**
  34465. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34466. * This method calls `updateParticle()` for each particle of the SPS.
  34467. * For an animated SPS, it is usually called within the render loop.
  34468. * 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.
  34469. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34470. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34471. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34472. * @returns the SPS.
  34473. */
  34474. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34475. /**
  34476. * Disposes the SPS.
  34477. */
  34478. dispose(): void;
  34479. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34480. * idx is the particle index in the SPS
  34481. * faceId is the picked face index counted within this particle.
  34482. * Returns null if the pickInfo can't identify a picked particle.
  34483. * @param pickingInfo (PickingInfo object)
  34484. * @returns {idx: number, faceId: number} or null
  34485. */
  34486. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34487. idx: number;
  34488. faceId: number;
  34489. }>;
  34490. /**
  34491. * Returns a SolidParticle object from its identifier : particle.id
  34492. * @param id (integer) the particle Id
  34493. * @returns the searched particle or null if not found in the SPS.
  34494. */
  34495. getParticleById(id: number): Nullable<SolidParticle>;
  34496. /**
  34497. * Returns a new array populated with the particles having the passed shapeId.
  34498. * @param shapeId (integer) the shape identifier
  34499. * @returns a new solid particle array
  34500. */
  34501. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34502. /**
  34503. * Populates the passed array "ref" with the particles having the passed shapeId.
  34504. * @param shapeId the shape identifier
  34505. * @returns the SPS
  34506. * @param ref
  34507. */
  34508. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34509. /**
  34510. * Computes the required SubMeshes according the materials assigned to the particles.
  34511. * @returns the solid particle system.
  34512. * Does nothing if called before the SPS mesh is built.
  34513. */
  34514. computeSubMeshes(): SolidParticleSystem;
  34515. /**
  34516. * Sorts the solid particles by material when MultiMaterial is enabled.
  34517. * Updates the indices32 array.
  34518. * Updates the indicesByMaterial array.
  34519. * Updates the mesh indices array.
  34520. * @returns the SPS
  34521. * @hidden
  34522. */
  34523. private _sortParticlesByMaterial;
  34524. /**
  34525. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34526. * @hidden
  34527. */
  34528. private _setMaterialIndexesById;
  34529. /**
  34530. * Returns an array with unique values of Materials from the passed array
  34531. * @param array the material array to be checked and filtered
  34532. * @hidden
  34533. */
  34534. private _filterUniqueMaterialId;
  34535. /**
  34536. * Sets a new Standard Material as _defaultMaterial if not already set.
  34537. * @hidden
  34538. */
  34539. private _setDefaultMaterial;
  34540. /**
  34541. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34542. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34543. * @returns the SPS.
  34544. */
  34545. refreshVisibleSize(): SolidParticleSystem;
  34546. /**
  34547. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34548. * @param size the size (float) of the visibility box
  34549. * note : this doesn't lock the SPS mesh bounding box.
  34550. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34551. */
  34552. setVisibilityBox(size: number): void;
  34553. /**
  34554. * Gets whether the SPS as always visible or not
  34555. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34556. */
  34557. get isAlwaysVisible(): boolean;
  34558. /**
  34559. * Sets the SPS as always visible or not
  34560. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34561. */
  34562. set isAlwaysVisible(val: boolean);
  34563. /**
  34564. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34565. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34566. */
  34567. set isVisibilityBoxLocked(val: boolean);
  34568. /**
  34569. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34570. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34571. */
  34572. get isVisibilityBoxLocked(): boolean;
  34573. /**
  34574. * Tells to `setParticles()` to compute the particle rotations or not.
  34575. * Default value : true. The SPS is faster when it's set to false.
  34576. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34577. */
  34578. set computeParticleRotation(val: boolean);
  34579. /**
  34580. * Tells to `setParticles()` to compute the particle colors or not.
  34581. * Default value : true. The SPS is faster when it's set to false.
  34582. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34583. */
  34584. set computeParticleColor(val: boolean);
  34585. set computeParticleTexture(val: boolean);
  34586. /**
  34587. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34588. * Default value : false. The SPS is faster when it's set to false.
  34589. * Note : the particle custom vertex positions aren't stored values.
  34590. */
  34591. set computeParticleVertex(val: boolean);
  34592. /**
  34593. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34594. */
  34595. set computeBoundingBox(val: boolean);
  34596. /**
  34597. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34598. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34599. * Default : `true`
  34600. */
  34601. set depthSortParticles(val: boolean);
  34602. /**
  34603. * Gets if `setParticles()` computes the particle rotations or not.
  34604. * Default value : true. The SPS is faster when it's set to false.
  34605. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34606. */
  34607. get computeParticleRotation(): boolean;
  34608. /**
  34609. * Gets if `setParticles()` computes the particle colors or not.
  34610. * Default value : true. The SPS is faster when it's set to false.
  34611. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34612. */
  34613. get computeParticleColor(): boolean;
  34614. /**
  34615. * Gets if `setParticles()` computes the particle textures or not.
  34616. * Default value : true. The SPS is faster when it's set to false.
  34617. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34618. */
  34619. get computeParticleTexture(): boolean;
  34620. /**
  34621. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34622. * Default value : false. The SPS is faster when it's set to false.
  34623. * Note : the particle custom vertex positions aren't stored values.
  34624. */
  34625. get computeParticleVertex(): boolean;
  34626. /**
  34627. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34628. */
  34629. get computeBoundingBox(): boolean;
  34630. /**
  34631. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34632. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34633. * Default : `true`
  34634. */
  34635. get depthSortParticles(): boolean;
  34636. /**
  34637. * Gets if the SPS is created as expandable at construction time.
  34638. * Default : `false`
  34639. */
  34640. get expandable(): boolean;
  34641. /**
  34642. * Gets if the SPS supports the Multi Materials
  34643. */
  34644. get multimaterialEnabled(): boolean;
  34645. /**
  34646. * Gets if the SPS uses the model materials for its own multimaterial.
  34647. */
  34648. get useModelMaterial(): boolean;
  34649. /**
  34650. * The SPS used material array.
  34651. */
  34652. get materials(): Material[];
  34653. /**
  34654. * Sets the SPS MultiMaterial from the passed materials.
  34655. * Note : the passed array is internally copied and not used then by reference.
  34656. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34657. */
  34658. setMultiMaterial(materials: Material[]): void;
  34659. /**
  34660. * The SPS computed multimaterial object
  34661. */
  34662. get multimaterial(): MultiMaterial;
  34663. set multimaterial(mm: MultiMaterial);
  34664. /**
  34665. * If the subMeshes must be updated on the next call to setParticles()
  34666. */
  34667. get autoUpdateSubMeshes(): boolean;
  34668. set autoUpdateSubMeshes(val: boolean);
  34669. /**
  34670. * This function does nothing. It may be overwritten to set all the particle first values.
  34671. * The SPS doesn't call this function, you may have to call it by your own.
  34672. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34673. */
  34674. initParticles(): void;
  34675. /**
  34676. * This function does nothing. It may be overwritten to recycle a particle.
  34677. * The SPS doesn't call this function, you may have to call it by your own.
  34678. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34679. * @param particle The particle to recycle
  34680. * @returns the recycled particle
  34681. */
  34682. recycleParticle(particle: SolidParticle): SolidParticle;
  34683. /**
  34684. * Updates a particle : this function should be overwritten by the user.
  34685. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34686. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34687. * @example : just set a particle position or velocity and recycle conditions
  34688. * @param particle The particle to update
  34689. * @returns the updated particle
  34690. */
  34691. updateParticle(particle: SolidParticle): SolidParticle;
  34692. /**
  34693. * Updates a vertex of a particle : it can be overwritten by the user.
  34694. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34695. * @param particle the current particle
  34696. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  34697. * @param pt the index of the current vertex in the particle shape
  34698. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  34699. * @example : just set a vertex particle position or color
  34700. * @returns the sps
  34701. */
  34702. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  34703. /**
  34704. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34705. * This does nothing and may be overwritten by the user.
  34706. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34707. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34708. * @param update the boolean update value actually passed to setParticles()
  34709. */
  34710. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34711. /**
  34712. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34713. * This will be passed three parameters.
  34714. * This does nothing and may be overwritten by the user.
  34715. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34716. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34717. * @param update the boolean update value actually passed to setParticles()
  34718. */
  34719. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34720. }
  34721. }
  34722. declare module BABYLON {
  34723. /**
  34724. * Represents one particle of a solid particle system.
  34725. */
  34726. export class SolidParticle {
  34727. /**
  34728. * particle global index
  34729. */
  34730. idx: number;
  34731. /**
  34732. * particle identifier
  34733. */
  34734. id: number;
  34735. /**
  34736. * The color of the particle
  34737. */
  34738. color: Nullable<Color4>;
  34739. /**
  34740. * The world space position of the particle.
  34741. */
  34742. position: Vector3;
  34743. /**
  34744. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  34745. */
  34746. rotation: Vector3;
  34747. /**
  34748. * The world space rotation quaternion of the particle.
  34749. */
  34750. rotationQuaternion: Nullable<Quaternion>;
  34751. /**
  34752. * The scaling of the particle.
  34753. */
  34754. scaling: Vector3;
  34755. /**
  34756. * The uvs of the particle.
  34757. */
  34758. uvs: Vector4;
  34759. /**
  34760. * The current speed of the particle.
  34761. */
  34762. velocity: Vector3;
  34763. /**
  34764. * The pivot point in the particle local space.
  34765. */
  34766. pivot: Vector3;
  34767. /**
  34768. * Must the particle be translated from its pivot point in its local space ?
  34769. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34770. * Default : false
  34771. */
  34772. translateFromPivot: boolean;
  34773. /**
  34774. * Is the particle active or not ?
  34775. */
  34776. alive: boolean;
  34777. /**
  34778. * Is the particle visible or not ?
  34779. */
  34780. isVisible: boolean;
  34781. /**
  34782. * Index of this particle in the global "positions" array (Internal use)
  34783. * @hidden
  34784. */
  34785. _pos: number;
  34786. /**
  34787. * @hidden Index of this particle in the global "indices" array (Internal use)
  34788. */
  34789. _ind: number;
  34790. /**
  34791. * @hidden ModelShape of this particle (Internal use)
  34792. */
  34793. _model: ModelShape;
  34794. /**
  34795. * ModelShape id of this particle
  34796. */
  34797. shapeId: number;
  34798. /**
  34799. * Index of the particle in its shape id
  34800. */
  34801. idxInShape: number;
  34802. /**
  34803. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34804. */
  34805. _modelBoundingInfo: BoundingInfo;
  34806. /**
  34807. * @hidden Particle BoundingInfo object (Internal use)
  34808. */
  34809. _boundingInfo: BoundingInfo;
  34810. /**
  34811. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34812. */
  34813. _sps: SolidParticleSystem;
  34814. /**
  34815. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34816. */
  34817. _stillInvisible: boolean;
  34818. /**
  34819. * @hidden Last computed particle rotation matrix
  34820. */
  34821. _rotationMatrix: number[];
  34822. /**
  34823. * Parent particle Id, if any.
  34824. * Default null.
  34825. */
  34826. parentId: Nullable<number>;
  34827. /**
  34828. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  34829. */
  34830. materialIndex: Nullable<number>;
  34831. /**
  34832. * Custom object or properties.
  34833. */
  34834. props: Nullable<any>;
  34835. /**
  34836. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  34837. * The possible values are :
  34838. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  34839. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34840. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  34841. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  34842. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34843. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  34844. * */
  34845. cullingStrategy: number;
  34846. /**
  34847. * @hidden Internal global position in the SPS.
  34848. */
  34849. _globalPosition: Vector3;
  34850. /**
  34851. * Creates a Solid Particle object.
  34852. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34853. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  34854. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  34855. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34856. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34857. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34858. * @param shapeId (integer) is the model shape identifier in the SPS.
  34859. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34860. * @param sps defines the sps it is associated to
  34861. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34862. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  34863. */
  34864. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  34865. /**
  34866. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  34867. * @param target the particle target
  34868. * @returns the current particle
  34869. */
  34870. copyToRef(target: SolidParticle): SolidParticle;
  34871. /**
  34872. * Legacy support, changed scale to scaling
  34873. */
  34874. get scale(): Vector3;
  34875. /**
  34876. * Legacy support, changed scale to scaling
  34877. */
  34878. set scale(scale: Vector3);
  34879. /**
  34880. * Legacy support, changed quaternion to rotationQuaternion
  34881. */
  34882. get quaternion(): Nullable<Quaternion>;
  34883. /**
  34884. * Legacy support, changed quaternion to rotationQuaternion
  34885. */
  34886. set quaternion(q: Nullable<Quaternion>);
  34887. /**
  34888. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34889. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34890. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34891. * @returns true if it intersects
  34892. */
  34893. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34894. /**
  34895. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  34896. * A particle is in the frustum if its bounding box intersects the frustum
  34897. * @param frustumPlanes defines the frustum to test
  34898. * @returns true if the particle is in the frustum planes
  34899. */
  34900. isInFrustum(frustumPlanes: Plane[]): boolean;
  34901. /**
  34902. * get the rotation matrix of the particle
  34903. * @hidden
  34904. */
  34905. getRotationMatrix(m: Matrix): void;
  34906. }
  34907. /**
  34908. * Represents the shape of the model used by one particle of a solid particle system.
  34909. * SPS internal tool, don't use it manually.
  34910. */
  34911. export class ModelShape {
  34912. /**
  34913. * The shape id
  34914. * @hidden
  34915. */
  34916. shapeID: number;
  34917. /**
  34918. * flat array of model positions (internal use)
  34919. * @hidden
  34920. */
  34921. _shape: Vector3[];
  34922. /**
  34923. * flat array of model UVs (internal use)
  34924. * @hidden
  34925. */
  34926. _shapeUV: number[];
  34927. /**
  34928. * color array of the model
  34929. * @hidden
  34930. */
  34931. _shapeColors: number[];
  34932. /**
  34933. * indices array of the model
  34934. * @hidden
  34935. */
  34936. _indices: number[];
  34937. /**
  34938. * normals array of the model
  34939. * @hidden
  34940. */
  34941. _normals: number[];
  34942. /**
  34943. * length of the shape in the model indices array (internal use)
  34944. * @hidden
  34945. */
  34946. _indicesLength: number;
  34947. /**
  34948. * Custom position function (internal use)
  34949. * @hidden
  34950. */
  34951. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  34952. /**
  34953. * Custom vertex function (internal use)
  34954. * @hidden
  34955. */
  34956. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  34957. /**
  34958. * Model material (internal use)
  34959. * @hidden
  34960. */
  34961. _material: Nullable<Material>;
  34962. /**
  34963. * 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.
  34964. * SPS internal tool, don't use it manually.
  34965. * @hidden
  34966. */
  34967. 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>);
  34968. }
  34969. /**
  34970. * Represents a Depth Sorted Particle in the solid particle system.
  34971. * @hidden
  34972. */
  34973. export class DepthSortedParticle {
  34974. /**
  34975. * Particle index
  34976. */
  34977. idx: number;
  34978. /**
  34979. * Index of the particle in the "indices" array
  34980. */
  34981. ind: number;
  34982. /**
  34983. * Length of the particle shape in the "indices" array
  34984. */
  34985. indicesLength: number;
  34986. /**
  34987. * Squared distance from the particle to the camera
  34988. */
  34989. sqDistance: number;
  34990. /**
  34991. * Material index when used with MultiMaterials
  34992. */
  34993. materialIndex: number;
  34994. /**
  34995. * Creates a new sorted particle
  34996. * @param materialIndex
  34997. */
  34998. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  34999. }
  35000. /**
  35001. * Represents a solid particle vertex
  35002. */
  35003. export class SolidParticleVertex {
  35004. /**
  35005. * Vertex position
  35006. */
  35007. position: Vector3;
  35008. /**
  35009. * Vertex color
  35010. */
  35011. color: Color4;
  35012. /**
  35013. * Vertex UV
  35014. */
  35015. uv: Vector2;
  35016. /**
  35017. * Creates a new solid particle vertex
  35018. */
  35019. constructor();
  35020. /** Vertex x coordinate */
  35021. get x(): number;
  35022. set x(val: number);
  35023. /** Vertex y coordinate */
  35024. get y(): number;
  35025. set y(val: number);
  35026. /** Vertex z coordinate */
  35027. get z(): number;
  35028. set z(val: number);
  35029. }
  35030. }
  35031. declare module BABYLON {
  35032. /**
  35033. * @hidden
  35034. */
  35035. export class _MeshCollisionData {
  35036. _checkCollisions: boolean;
  35037. _collisionMask: number;
  35038. _collisionGroup: number;
  35039. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35040. _collider: Nullable<Collider>;
  35041. _oldPositionForCollisions: Vector3;
  35042. _diffPositionForCollisions: Vector3;
  35043. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35044. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35045. _collisionResponse: boolean;
  35046. }
  35047. }
  35048. declare module BABYLON {
  35049. /** @hidden */
  35050. class _FacetDataStorage {
  35051. facetPositions: Vector3[];
  35052. facetNormals: Vector3[];
  35053. facetPartitioning: number[][];
  35054. facetNb: number;
  35055. partitioningSubdivisions: number;
  35056. partitioningBBoxRatio: number;
  35057. facetDataEnabled: boolean;
  35058. facetParameters: any;
  35059. bbSize: Vector3;
  35060. subDiv: {
  35061. max: number;
  35062. X: number;
  35063. Y: number;
  35064. Z: number;
  35065. };
  35066. facetDepthSort: boolean;
  35067. facetDepthSortEnabled: boolean;
  35068. depthSortedIndices: IndicesArray;
  35069. depthSortedFacets: {
  35070. ind: number;
  35071. sqDistance: number;
  35072. }[];
  35073. facetDepthSortFunction: (f1: {
  35074. ind: number;
  35075. sqDistance: number;
  35076. }, f2: {
  35077. ind: number;
  35078. sqDistance: number;
  35079. }) => number;
  35080. facetDepthSortFrom: Vector3;
  35081. facetDepthSortOrigin: Vector3;
  35082. invertedMatrix: Matrix;
  35083. }
  35084. /**
  35085. * @hidden
  35086. **/
  35087. class _InternalAbstractMeshDataInfo {
  35088. _hasVertexAlpha: boolean;
  35089. _useVertexColors: boolean;
  35090. _numBoneInfluencers: number;
  35091. _applyFog: boolean;
  35092. _receiveShadows: boolean;
  35093. _facetData: _FacetDataStorage;
  35094. _visibility: number;
  35095. _skeleton: Nullable<Skeleton>;
  35096. _layerMask: number;
  35097. _computeBonesUsingShaders: boolean;
  35098. _isActive: boolean;
  35099. _onlyForInstances: boolean;
  35100. _isActiveIntermediate: boolean;
  35101. _onlyForInstancesIntermediate: boolean;
  35102. _actAsRegularMesh: boolean;
  35103. _currentLOD: Nullable<AbstractMesh>;
  35104. _currentLODIsUpToDate: boolean;
  35105. }
  35106. /**
  35107. * Class used to store all common mesh properties
  35108. */
  35109. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35110. /** No occlusion */
  35111. static OCCLUSION_TYPE_NONE: number;
  35112. /** Occlusion set to optimisitic */
  35113. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35114. /** Occlusion set to strict */
  35115. static OCCLUSION_TYPE_STRICT: number;
  35116. /** Use an accurante occlusion algorithm */
  35117. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35118. /** Use a conservative occlusion algorithm */
  35119. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35120. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35121. * Test order :
  35122. * Is the bounding sphere outside the frustum ?
  35123. * If not, are the bounding box vertices outside the frustum ?
  35124. * It not, then the cullable object is in the frustum.
  35125. */
  35126. static readonly CULLINGSTRATEGY_STANDARD: number;
  35127. /** Culling strategy : Bounding Sphere Only.
  35128. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35129. * It's also less accurate than the standard because some not visible objects can still be selected.
  35130. * Test : is the bounding sphere outside the frustum ?
  35131. * If not, then the cullable object is in the frustum.
  35132. */
  35133. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35134. /** Culling strategy : Optimistic Inclusion.
  35135. * This in an inclusion test first, then the standard exclusion test.
  35136. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35137. * 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.
  35138. * Anyway, it's as accurate as the standard strategy.
  35139. * Test :
  35140. * Is the cullable object bounding sphere center in the frustum ?
  35141. * If not, apply the default culling strategy.
  35142. */
  35143. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35144. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35145. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35146. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35147. * 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.
  35148. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35149. * Test :
  35150. * Is the cullable object bounding sphere center in the frustum ?
  35151. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35152. */
  35153. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35154. /**
  35155. * No billboard
  35156. */
  35157. static get BILLBOARDMODE_NONE(): number;
  35158. /** Billboard on X axis */
  35159. static get BILLBOARDMODE_X(): number;
  35160. /** Billboard on Y axis */
  35161. static get BILLBOARDMODE_Y(): number;
  35162. /** Billboard on Z axis */
  35163. static get BILLBOARDMODE_Z(): number;
  35164. /** Billboard on all axes */
  35165. static get BILLBOARDMODE_ALL(): number;
  35166. /** Billboard on using position instead of orientation */
  35167. static get BILLBOARDMODE_USE_POSITION(): number;
  35168. /** @hidden */
  35169. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35170. /**
  35171. * The culling strategy to use to check whether the mesh must be rendered or not.
  35172. * This value can be changed at any time and will be used on the next render mesh selection.
  35173. * The possible values are :
  35174. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35175. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35176. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35177. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35178. * Please read each static variable documentation to get details about the culling process.
  35179. * */
  35180. cullingStrategy: number;
  35181. /**
  35182. * Gets the number of facets in the mesh
  35183. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35184. */
  35185. get facetNb(): number;
  35186. /**
  35187. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35188. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35189. */
  35190. get partitioningSubdivisions(): number;
  35191. set partitioningSubdivisions(nb: number);
  35192. /**
  35193. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35194. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35195. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35196. */
  35197. get partitioningBBoxRatio(): number;
  35198. set partitioningBBoxRatio(ratio: number);
  35199. /**
  35200. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35201. * Works only for updatable meshes.
  35202. * Doesn't work with multi-materials
  35203. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35204. */
  35205. get mustDepthSortFacets(): boolean;
  35206. set mustDepthSortFacets(sort: boolean);
  35207. /**
  35208. * The location (Vector3) where the facet depth sort must be computed from.
  35209. * By default, the active camera position.
  35210. * Used only when facet depth sort is enabled
  35211. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35212. */
  35213. get facetDepthSortFrom(): Vector3;
  35214. set facetDepthSortFrom(location: Vector3);
  35215. /**
  35216. * gets a boolean indicating if facetData is enabled
  35217. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35218. */
  35219. get isFacetDataEnabled(): boolean;
  35220. /** @hidden */
  35221. _updateNonUniformScalingState(value: boolean): boolean;
  35222. /**
  35223. * An event triggered when this mesh collides with another one
  35224. */
  35225. onCollideObservable: Observable<AbstractMesh>;
  35226. /** Set a function to call when this mesh collides with another one */
  35227. set onCollide(callback: () => void);
  35228. /**
  35229. * An event triggered when the collision's position changes
  35230. */
  35231. onCollisionPositionChangeObservable: Observable<Vector3>;
  35232. /** Set a function to call when the collision's position changes */
  35233. set onCollisionPositionChange(callback: () => void);
  35234. /**
  35235. * An event triggered when material is changed
  35236. */
  35237. onMaterialChangedObservable: Observable<AbstractMesh>;
  35238. /**
  35239. * Gets or sets the orientation for POV movement & rotation
  35240. */
  35241. definedFacingForward: boolean;
  35242. /** @hidden */
  35243. _occlusionQuery: Nullable<WebGLQuery>;
  35244. /** @hidden */
  35245. _renderingGroup: Nullable<RenderingGroup>;
  35246. /**
  35247. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35248. */
  35249. get visibility(): number;
  35250. /**
  35251. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35252. */
  35253. set visibility(value: number);
  35254. /** Gets or sets the alpha index used to sort transparent meshes
  35255. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35256. */
  35257. alphaIndex: number;
  35258. /**
  35259. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35260. */
  35261. isVisible: boolean;
  35262. /**
  35263. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35264. */
  35265. isPickable: boolean;
  35266. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35267. showSubMeshesBoundingBox: boolean;
  35268. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35269. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35270. */
  35271. isBlocker: boolean;
  35272. /**
  35273. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35274. */
  35275. enablePointerMoveEvents: boolean;
  35276. private _renderingGroupId;
  35277. /**
  35278. * Specifies the rendering group id for this mesh (0 by default)
  35279. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35280. */
  35281. get renderingGroupId(): number;
  35282. set renderingGroupId(value: number);
  35283. private _material;
  35284. /** Gets or sets current material */
  35285. get material(): Nullable<Material>;
  35286. set material(value: Nullable<Material>);
  35287. /**
  35288. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35289. * @see https://doc.babylonjs.com/babylon101/shadows
  35290. */
  35291. get receiveShadows(): boolean;
  35292. set receiveShadows(value: boolean);
  35293. /** Defines color to use when rendering outline */
  35294. outlineColor: Color3;
  35295. /** Define width to use when rendering outline */
  35296. outlineWidth: number;
  35297. /** Defines color to use when rendering overlay */
  35298. overlayColor: Color3;
  35299. /** Defines alpha to use when rendering overlay */
  35300. overlayAlpha: number;
  35301. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35302. get hasVertexAlpha(): boolean;
  35303. set hasVertexAlpha(value: boolean);
  35304. /** 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) */
  35305. get useVertexColors(): boolean;
  35306. set useVertexColors(value: boolean);
  35307. /**
  35308. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35309. */
  35310. get computeBonesUsingShaders(): boolean;
  35311. set computeBonesUsingShaders(value: boolean);
  35312. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35313. get numBoneInfluencers(): number;
  35314. set numBoneInfluencers(value: number);
  35315. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35316. get applyFog(): boolean;
  35317. set applyFog(value: boolean);
  35318. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35319. useOctreeForRenderingSelection: boolean;
  35320. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35321. useOctreeForPicking: boolean;
  35322. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35323. useOctreeForCollisions: boolean;
  35324. /**
  35325. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35326. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35327. */
  35328. get layerMask(): number;
  35329. set layerMask(value: number);
  35330. /**
  35331. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35332. */
  35333. alwaysSelectAsActiveMesh: boolean;
  35334. /**
  35335. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35336. */
  35337. doNotSyncBoundingInfo: boolean;
  35338. /**
  35339. * Gets or sets the current action manager
  35340. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35341. */
  35342. actionManager: Nullable<AbstractActionManager>;
  35343. private _meshCollisionData;
  35344. /**
  35345. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35346. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35347. */
  35348. ellipsoid: Vector3;
  35349. /**
  35350. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35351. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35352. */
  35353. ellipsoidOffset: Vector3;
  35354. /**
  35355. * Gets or sets a collision mask used to mask collisions (default is -1).
  35356. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35357. */
  35358. get collisionMask(): number;
  35359. set collisionMask(mask: number);
  35360. /**
  35361. * Gets or sets a collision response flag (default is true).
  35362. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35363. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35364. * to respond to the collision.
  35365. */
  35366. get collisionResponse(): boolean;
  35367. set collisionResponse(response: boolean);
  35368. /**
  35369. * Gets or sets the current collision group mask (-1 by default).
  35370. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35371. */
  35372. get collisionGroup(): number;
  35373. set collisionGroup(mask: number);
  35374. /**
  35375. * Gets or sets current surrounding meshes (null by default).
  35376. *
  35377. * By default collision detection is tested against every mesh in the scene.
  35378. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35379. * meshes will be tested for the collision.
  35380. *
  35381. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35382. */
  35383. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35384. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35385. /**
  35386. * Defines edge width used when edgesRenderer is enabled
  35387. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35388. */
  35389. edgesWidth: number;
  35390. /**
  35391. * Defines edge color used when edgesRenderer is enabled
  35392. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35393. */
  35394. edgesColor: Color4;
  35395. /** @hidden */
  35396. _edgesRenderer: Nullable<IEdgesRenderer>;
  35397. /** @hidden */
  35398. _masterMesh: Nullable<AbstractMesh>;
  35399. /** @hidden */
  35400. _boundingInfo: Nullable<BoundingInfo>;
  35401. /** @hidden */
  35402. _renderId: number;
  35403. /**
  35404. * Gets or sets the list of subMeshes
  35405. * @see https://doc.babylonjs.com/how_to/multi_materials
  35406. */
  35407. subMeshes: SubMesh[];
  35408. /** @hidden */
  35409. _intersectionsInProgress: AbstractMesh[];
  35410. /** @hidden */
  35411. _unIndexed: boolean;
  35412. /** @hidden */
  35413. _lightSources: Light[];
  35414. /** Gets the list of lights affecting that mesh */
  35415. get lightSources(): Light[];
  35416. /** @hidden */
  35417. get _positions(): Nullable<Vector3[]>;
  35418. /** @hidden */
  35419. _waitingData: {
  35420. lods: Nullable<any>;
  35421. actions: Nullable<any>;
  35422. freezeWorldMatrix: Nullable<boolean>;
  35423. };
  35424. /** @hidden */
  35425. _bonesTransformMatrices: Nullable<Float32Array>;
  35426. /** @hidden */
  35427. _transformMatrixTexture: Nullable<RawTexture>;
  35428. /**
  35429. * Gets or sets a skeleton to apply skining transformations
  35430. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35431. */
  35432. set skeleton(value: Nullable<Skeleton>);
  35433. get skeleton(): Nullable<Skeleton>;
  35434. /**
  35435. * An event triggered when the mesh is rebuilt.
  35436. */
  35437. onRebuildObservable: Observable<AbstractMesh>;
  35438. /**
  35439. * Creates a new AbstractMesh
  35440. * @param name defines the name of the mesh
  35441. * @param scene defines the hosting scene
  35442. */
  35443. constructor(name: string, scene?: Nullable<Scene>);
  35444. /**
  35445. * Returns the string "AbstractMesh"
  35446. * @returns "AbstractMesh"
  35447. */
  35448. getClassName(): string;
  35449. /**
  35450. * Gets a string representation of the current mesh
  35451. * @param fullDetails defines a boolean indicating if full details must be included
  35452. * @returns a string representation of the current mesh
  35453. */
  35454. toString(fullDetails?: boolean): string;
  35455. /**
  35456. * @hidden
  35457. */
  35458. protected _getEffectiveParent(): Nullable<Node>;
  35459. /** @hidden */
  35460. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35461. /** @hidden */
  35462. _rebuild(): void;
  35463. /** @hidden */
  35464. _resyncLightSources(): void;
  35465. /** @hidden */
  35466. _resyncLightSource(light: Light): void;
  35467. /** @hidden */
  35468. _unBindEffect(): void;
  35469. /** @hidden */
  35470. _removeLightSource(light: Light, dispose: boolean): void;
  35471. private _markSubMeshesAsDirty;
  35472. /** @hidden */
  35473. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35474. /** @hidden */
  35475. _markSubMeshesAsAttributesDirty(): void;
  35476. /** @hidden */
  35477. _markSubMeshesAsMiscDirty(): void;
  35478. /**
  35479. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35480. */
  35481. get scaling(): Vector3;
  35482. set scaling(newScaling: Vector3);
  35483. /**
  35484. * Returns true if the mesh is blocked. Implemented by child classes
  35485. */
  35486. get isBlocked(): boolean;
  35487. /**
  35488. * Returns the mesh itself by default. Implemented by child classes
  35489. * @param camera defines the camera to use to pick the right LOD level
  35490. * @returns the currentAbstractMesh
  35491. */
  35492. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35493. /**
  35494. * Returns 0 by default. Implemented by child classes
  35495. * @returns an integer
  35496. */
  35497. getTotalVertices(): number;
  35498. /**
  35499. * Returns a positive integer : the total number of indices in this mesh geometry.
  35500. * @returns the numner of indices or zero if the mesh has no geometry.
  35501. */
  35502. getTotalIndices(): number;
  35503. /**
  35504. * Returns null by default. Implemented by child classes
  35505. * @returns null
  35506. */
  35507. getIndices(): Nullable<IndicesArray>;
  35508. /**
  35509. * Returns the array of the requested vertex data kind. Implemented by child classes
  35510. * @param kind defines the vertex data kind to use
  35511. * @returns null
  35512. */
  35513. getVerticesData(kind: string): Nullable<FloatArray>;
  35514. /**
  35515. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35516. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35517. * Note that a new underlying VertexBuffer object is created each call.
  35518. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35519. * @param kind defines vertex data kind:
  35520. * * VertexBuffer.PositionKind
  35521. * * VertexBuffer.UVKind
  35522. * * VertexBuffer.UV2Kind
  35523. * * VertexBuffer.UV3Kind
  35524. * * VertexBuffer.UV4Kind
  35525. * * VertexBuffer.UV5Kind
  35526. * * VertexBuffer.UV6Kind
  35527. * * VertexBuffer.ColorKind
  35528. * * VertexBuffer.MatricesIndicesKind
  35529. * * VertexBuffer.MatricesIndicesExtraKind
  35530. * * VertexBuffer.MatricesWeightsKind
  35531. * * VertexBuffer.MatricesWeightsExtraKind
  35532. * @param data defines the data source
  35533. * @param updatable defines if the data must be flagged as updatable (or static)
  35534. * @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
  35535. * @returns the current mesh
  35536. */
  35537. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35538. /**
  35539. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35540. * If the mesh has no geometry, it is simply returned as it is.
  35541. * @param kind defines vertex data kind:
  35542. * * VertexBuffer.PositionKind
  35543. * * VertexBuffer.UVKind
  35544. * * VertexBuffer.UV2Kind
  35545. * * VertexBuffer.UV3Kind
  35546. * * VertexBuffer.UV4Kind
  35547. * * VertexBuffer.UV5Kind
  35548. * * VertexBuffer.UV6Kind
  35549. * * VertexBuffer.ColorKind
  35550. * * VertexBuffer.MatricesIndicesKind
  35551. * * VertexBuffer.MatricesIndicesExtraKind
  35552. * * VertexBuffer.MatricesWeightsKind
  35553. * * VertexBuffer.MatricesWeightsExtraKind
  35554. * @param data defines the data source
  35555. * @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
  35556. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35557. * @returns the current mesh
  35558. */
  35559. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35560. /**
  35561. * Sets the mesh indices,
  35562. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35563. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35564. * @param totalVertices Defines the total number of vertices
  35565. * @returns the current mesh
  35566. */
  35567. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35568. /**
  35569. * Gets a boolean indicating if specific vertex data is present
  35570. * @param kind defines the vertex data kind to use
  35571. * @returns true is data kind is present
  35572. */
  35573. isVerticesDataPresent(kind: string): boolean;
  35574. /**
  35575. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35576. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35577. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35578. * @returns a BoundingInfo
  35579. */
  35580. getBoundingInfo(): BoundingInfo;
  35581. /**
  35582. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35583. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35584. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35585. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35586. * @returns the current mesh
  35587. */
  35588. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35589. /**
  35590. * Overwrite the current bounding info
  35591. * @param boundingInfo defines the new bounding info
  35592. * @returns the current mesh
  35593. */
  35594. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35595. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35596. get useBones(): boolean;
  35597. /** @hidden */
  35598. _preActivate(): void;
  35599. /** @hidden */
  35600. _preActivateForIntermediateRendering(renderId: number): void;
  35601. /** @hidden */
  35602. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35603. /** @hidden */
  35604. _postActivate(): void;
  35605. /** @hidden */
  35606. _freeze(): void;
  35607. /** @hidden */
  35608. _unFreeze(): void;
  35609. /**
  35610. * Gets the current world matrix
  35611. * @returns a Matrix
  35612. */
  35613. getWorldMatrix(): Matrix;
  35614. /** @hidden */
  35615. _getWorldMatrixDeterminant(): number;
  35616. /**
  35617. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35618. */
  35619. get isAnInstance(): boolean;
  35620. /**
  35621. * Gets a boolean indicating if this mesh has instances
  35622. */
  35623. get hasInstances(): boolean;
  35624. /**
  35625. * Gets a boolean indicating if this mesh has thin instances
  35626. */
  35627. get hasThinInstances(): boolean;
  35628. /**
  35629. * Perform relative position change from the point of view of behind the front of the mesh.
  35630. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35631. * Supports definition of mesh facing forward or backward
  35632. * @param amountRight defines the distance on the right axis
  35633. * @param amountUp defines the distance on the up axis
  35634. * @param amountForward defines the distance on the forward axis
  35635. * @returns the current mesh
  35636. */
  35637. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35638. /**
  35639. * Calculate relative position change from the point of view of behind the front of the mesh.
  35640. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35641. * Supports definition of mesh facing forward or backward
  35642. * @param amountRight defines the distance on the right axis
  35643. * @param amountUp defines the distance on the up axis
  35644. * @param amountForward defines the distance on the forward axis
  35645. * @returns the new displacement vector
  35646. */
  35647. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35648. /**
  35649. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35650. * Supports definition of mesh facing forward or backward
  35651. * @param flipBack defines the flip
  35652. * @param twirlClockwise defines the twirl
  35653. * @param tiltRight defines the tilt
  35654. * @returns the current mesh
  35655. */
  35656. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35657. /**
  35658. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35659. * Supports definition of mesh facing forward or backward.
  35660. * @param flipBack defines the flip
  35661. * @param twirlClockwise defines the twirl
  35662. * @param tiltRight defines the tilt
  35663. * @returns the new rotation vector
  35664. */
  35665. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35666. /**
  35667. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35668. * This means the mesh underlying bounding box and sphere are recomputed.
  35669. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35670. * @returns the current mesh
  35671. */
  35672. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35673. /** @hidden */
  35674. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35675. /** @hidden */
  35676. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35677. /** @hidden */
  35678. _updateBoundingInfo(): AbstractMesh;
  35679. /** @hidden */
  35680. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35681. /** @hidden */
  35682. protected _afterComputeWorldMatrix(): void;
  35683. /** @hidden */
  35684. get _effectiveMesh(): AbstractMesh;
  35685. /**
  35686. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35687. * A mesh is in the frustum if its bounding box intersects the frustum
  35688. * @param frustumPlanes defines the frustum to test
  35689. * @returns true if the mesh is in the frustum planes
  35690. */
  35691. isInFrustum(frustumPlanes: Plane[]): boolean;
  35692. /**
  35693. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35694. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  35695. * @param frustumPlanes defines the frustum to test
  35696. * @returns true if the mesh is completely in the frustum planes
  35697. */
  35698. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  35699. /**
  35700. * True if the mesh intersects another mesh or a SolidParticle object
  35701. * @param mesh defines a target mesh or SolidParticle to test
  35702. * @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)
  35703. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  35704. * @returns true if there is an intersection
  35705. */
  35706. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  35707. /**
  35708. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  35709. * @param point defines the point to test
  35710. * @returns true if there is an intersection
  35711. */
  35712. intersectsPoint(point: Vector3): boolean;
  35713. /**
  35714. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  35715. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35716. */
  35717. get checkCollisions(): boolean;
  35718. set checkCollisions(collisionEnabled: boolean);
  35719. /**
  35720. * Gets Collider object used to compute collisions (not physics)
  35721. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35722. */
  35723. get collider(): Nullable<Collider>;
  35724. /**
  35725. * Move the mesh using collision engine
  35726. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35727. * @param displacement defines the requested displacement vector
  35728. * @returns the current mesh
  35729. */
  35730. moveWithCollisions(displacement: Vector3): AbstractMesh;
  35731. private _onCollisionPositionChange;
  35732. /** @hidden */
  35733. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  35734. /** @hidden */
  35735. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  35736. /** @hidden */
  35737. _checkCollision(collider: Collider): AbstractMesh;
  35738. /** @hidden */
  35739. _generatePointsArray(): boolean;
  35740. /**
  35741. * Checks if the passed Ray intersects with the mesh
  35742. * @param ray defines the ray to use
  35743. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  35744. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35745. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  35746. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  35747. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  35748. * @returns the picking info
  35749. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  35750. */
  35751. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  35752. /**
  35753. * Clones the current mesh
  35754. * @param name defines the mesh name
  35755. * @param newParent defines the new mesh parent
  35756. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  35757. * @returns the new mesh
  35758. */
  35759. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  35760. /**
  35761. * Disposes all the submeshes of the current meshnp
  35762. * @returns the current mesh
  35763. */
  35764. releaseSubMeshes(): AbstractMesh;
  35765. /**
  35766. * Releases resources associated with this abstract mesh.
  35767. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35768. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35769. */
  35770. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35771. /**
  35772. * Adds the passed mesh as a child to the current mesh
  35773. * @param mesh defines the child mesh
  35774. * @returns the current mesh
  35775. */
  35776. addChild(mesh: AbstractMesh): AbstractMesh;
  35777. /**
  35778. * Removes the passed mesh from the current mesh children list
  35779. * @param mesh defines the child mesh
  35780. * @returns the current mesh
  35781. */
  35782. removeChild(mesh: AbstractMesh): AbstractMesh;
  35783. /** @hidden */
  35784. private _initFacetData;
  35785. /**
  35786. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  35787. * This method can be called within the render loop.
  35788. * 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
  35789. * @returns the current mesh
  35790. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35791. */
  35792. updateFacetData(): AbstractMesh;
  35793. /**
  35794. * Returns the facetLocalNormals array.
  35795. * The normals are expressed in the mesh local spac
  35796. * @returns an array of Vector3
  35797. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35798. */
  35799. getFacetLocalNormals(): Vector3[];
  35800. /**
  35801. * Returns the facetLocalPositions array.
  35802. * The facet positions are expressed in the mesh local space
  35803. * @returns an array of Vector3
  35804. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35805. */
  35806. getFacetLocalPositions(): Vector3[];
  35807. /**
  35808. * Returns the facetLocalPartioning array
  35809. * @returns an array of array of numbers
  35810. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35811. */
  35812. getFacetLocalPartitioning(): number[][];
  35813. /**
  35814. * Returns the i-th facet position in the world system.
  35815. * This method allocates a new Vector3 per call
  35816. * @param i defines the facet index
  35817. * @returns a new Vector3
  35818. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35819. */
  35820. getFacetPosition(i: number): Vector3;
  35821. /**
  35822. * Sets the reference Vector3 with the i-th facet position in the world system
  35823. * @param i defines the facet index
  35824. * @param ref defines the target vector
  35825. * @returns the current mesh
  35826. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35827. */
  35828. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  35829. /**
  35830. * Returns the i-th facet normal in the world system.
  35831. * This method allocates a new Vector3 per call
  35832. * @param i defines the facet index
  35833. * @returns a new Vector3
  35834. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35835. */
  35836. getFacetNormal(i: number): Vector3;
  35837. /**
  35838. * Sets the reference Vector3 with the i-th facet normal in the world system
  35839. * @param i defines the facet index
  35840. * @param ref defines the target vector
  35841. * @returns the current mesh
  35842. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35843. */
  35844. getFacetNormalToRef(i: number, ref: Vector3): this;
  35845. /**
  35846. * 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)
  35847. * @param x defines x coordinate
  35848. * @param y defines y coordinate
  35849. * @param z defines z coordinate
  35850. * @returns the array of facet indexes
  35851. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35852. */
  35853. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  35854. /**
  35855. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  35856. * @param projected sets as the (x,y,z) world projection on the facet
  35857. * @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
  35858. * @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
  35859. * @param x defines x coordinate
  35860. * @param y defines y coordinate
  35861. * @param z defines z coordinate
  35862. * @returns the face index if found (or null instead)
  35863. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35864. */
  35865. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35866. /**
  35867. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  35868. * @param projected sets as the (x,y,z) local projection on the facet
  35869. * @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
  35870. * @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
  35871. * @param x defines x coordinate
  35872. * @param y defines y coordinate
  35873. * @param z defines z coordinate
  35874. * @returns the face index if found (or null instead)
  35875. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35876. */
  35877. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35878. /**
  35879. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  35880. * @returns the parameters
  35881. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35882. */
  35883. getFacetDataParameters(): any;
  35884. /**
  35885. * Disables the feature FacetData and frees the related memory
  35886. * @returns the current mesh
  35887. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35888. */
  35889. disableFacetData(): AbstractMesh;
  35890. /**
  35891. * Updates the AbstractMesh indices array
  35892. * @param indices defines the data source
  35893. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35894. * @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)
  35895. * @returns the current mesh
  35896. */
  35897. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35898. /**
  35899. * Creates new normals data for the mesh
  35900. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  35901. * @returns the current mesh
  35902. */
  35903. createNormals(updatable: boolean): AbstractMesh;
  35904. /**
  35905. * Align the mesh with a normal
  35906. * @param normal defines the normal to use
  35907. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  35908. * @returns the current mesh
  35909. */
  35910. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  35911. /** @hidden */
  35912. _checkOcclusionQuery(): boolean;
  35913. /**
  35914. * Disables the mesh edge rendering mode
  35915. * @returns the currentAbstractMesh
  35916. */
  35917. disableEdgesRendering(): AbstractMesh;
  35918. /**
  35919. * Enables the edge rendering mode on the mesh.
  35920. * This mode makes the mesh edges visible
  35921. * @param epsilon defines the maximal distance between two angles to detect a face
  35922. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35923. * @param options options to the edge renderer
  35924. * @returns the currentAbstractMesh
  35925. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35926. */
  35927. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  35928. /**
  35929. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  35930. * @returns an array of particle systems in the scene that use the mesh as an emitter
  35931. */
  35932. getConnectedParticleSystems(): IParticleSystem[];
  35933. }
  35934. }
  35935. declare module BABYLON {
  35936. /**
  35937. * Interface used to define ActionEvent
  35938. */
  35939. export interface IActionEvent {
  35940. /** The mesh or sprite that triggered the action */
  35941. source: any;
  35942. /** The X mouse cursor position at the time of the event */
  35943. pointerX: number;
  35944. /** The Y mouse cursor position at the time of the event */
  35945. pointerY: number;
  35946. /** The mesh that is currently pointed at (can be null) */
  35947. meshUnderPointer: Nullable<AbstractMesh>;
  35948. /** the original (browser) event that triggered the ActionEvent */
  35949. sourceEvent?: any;
  35950. /** additional data for the event */
  35951. additionalData?: any;
  35952. }
  35953. /**
  35954. * ActionEvent is the event being sent when an action is triggered.
  35955. */
  35956. export class ActionEvent implements IActionEvent {
  35957. /** The mesh or sprite that triggered the action */
  35958. source: any;
  35959. /** The X mouse cursor position at the time of the event */
  35960. pointerX: number;
  35961. /** The Y mouse cursor position at the time of the event */
  35962. pointerY: number;
  35963. /** The mesh that is currently pointed at (can be null) */
  35964. meshUnderPointer: Nullable<AbstractMesh>;
  35965. /** the original (browser) event that triggered the ActionEvent */
  35966. sourceEvent?: any;
  35967. /** additional data for the event */
  35968. additionalData?: any;
  35969. /**
  35970. * Creates a new ActionEvent
  35971. * @param source The mesh or sprite that triggered the action
  35972. * @param pointerX The X mouse cursor position at the time of the event
  35973. * @param pointerY The Y mouse cursor position at the time of the event
  35974. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  35975. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  35976. * @param additionalData additional data for the event
  35977. */
  35978. constructor(
  35979. /** The mesh or sprite that triggered the action */
  35980. source: any,
  35981. /** The X mouse cursor position at the time of the event */
  35982. pointerX: number,
  35983. /** The Y mouse cursor position at the time of the event */
  35984. pointerY: number,
  35985. /** The mesh that is currently pointed at (can be null) */
  35986. meshUnderPointer: Nullable<AbstractMesh>,
  35987. /** the original (browser) event that triggered the ActionEvent */
  35988. sourceEvent?: any,
  35989. /** additional data for the event */
  35990. additionalData?: any);
  35991. /**
  35992. * Helper function to auto-create an ActionEvent from a source mesh.
  35993. * @param source The source mesh that triggered the event
  35994. * @param evt The original (browser) event
  35995. * @param additionalData additional data for the event
  35996. * @returns the new ActionEvent
  35997. */
  35998. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  35999. /**
  36000. * Helper function to auto-create an ActionEvent from a source sprite
  36001. * @param source The source sprite that triggered the event
  36002. * @param scene Scene associated with the sprite
  36003. * @param evt The original (browser) event
  36004. * @param additionalData additional data for the event
  36005. * @returns the new ActionEvent
  36006. */
  36007. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36008. /**
  36009. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36010. * @param scene the scene where the event occurred
  36011. * @param evt The original (browser) event
  36012. * @returns the new ActionEvent
  36013. */
  36014. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36015. /**
  36016. * Helper function to auto-create an ActionEvent from a primitive
  36017. * @param prim defines the target primitive
  36018. * @param pointerPos defines the pointer position
  36019. * @param evt The original (browser) event
  36020. * @param additionalData additional data for the event
  36021. * @returns the new ActionEvent
  36022. */
  36023. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36024. }
  36025. }
  36026. declare module BABYLON {
  36027. /**
  36028. * Abstract class used to decouple action Manager from scene and meshes.
  36029. * Do not instantiate.
  36030. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36031. */
  36032. export abstract class AbstractActionManager implements IDisposable {
  36033. /** Gets the list of active triggers */
  36034. static Triggers: {
  36035. [key: string]: number;
  36036. };
  36037. /** Gets the cursor to use when hovering items */
  36038. hoverCursor: string;
  36039. /** Gets the list of actions */
  36040. actions: IAction[];
  36041. /**
  36042. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36043. */
  36044. isRecursive: boolean;
  36045. /**
  36046. * Releases all associated resources
  36047. */
  36048. abstract dispose(): void;
  36049. /**
  36050. * Does this action manager has pointer triggers
  36051. */
  36052. abstract get hasPointerTriggers(): boolean;
  36053. /**
  36054. * Does this action manager has pick triggers
  36055. */
  36056. abstract get hasPickTriggers(): boolean;
  36057. /**
  36058. * Process a specific trigger
  36059. * @param trigger defines the trigger to process
  36060. * @param evt defines the event details to be processed
  36061. */
  36062. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36063. /**
  36064. * Does this action manager handles actions of any of the given triggers
  36065. * @param triggers defines the triggers to be tested
  36066. * @return a boolean indicating whether one (or more) of the triggers is handled
  36067. */
  36068. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36069. /**
  36070. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36071. * speed.
  36072. * @param triggerA defines the trigger to be tested
  36073. * @param triggerB defines the trigger to be tested
  36074. * @return a boolean indicating whether one (or more) of the triggers is handled
  36075. */
  36076. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36077. /**
  36078. * Does this action manager handles actions of a given trigger
  36079. * @param trigger defines the trigger to be tested
  36080. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36081. * @return whether the trigger is handled
  36082. */
  36083. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36084. /**
  36085. * Serialize this manager to a JSON object
  36086. * @param name defines the property name to store this manager
  36087. * @returns a JSON representation of this manager
  36088. */
  36089. abstract serialize(name: string): any;
  36090. /**
  36091. * Registers an action to this action manager
  36092. * @param action defines the action to be registered
  36093. * @return the action amended (prepared) after registration
  36094. */
  36095. abstract registerAction(action: IAction): Nullable<IAction>;
  36096. /**
  36097. * Unregisters an action to this action manager
  36098. * @param action defines the action to be unregistered
  36099. * @return a boolean indicating whether the action has been unregistered
  36100. */
  36101. abstract unregisterAction(action: IAction): Boolean;
  36102. /**
  36103. * Does exist one action manager with at least one trigger
  36104. **/
  36105. static get HasTriggers(): boolean;
  36106. /**
  36107. * Does exist one action manager with at least one pick trigger
  36108. **/
  36109. static get HasPickTriggers(): boolean;
  36110. /**
  36111. * Does exist one action manager that handles actions of a given trigger
  36112. * @param trigger defines the trigger to be tested
  36113. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36114. **/
  36115. static HasSpecificTrigger(trigger: number): boolean;
  36116. }
  36117. }
  36118. declare module BABYLON {
  36119. /**
  36120. * Defines how a node can be built from a string name.
  36121. */
  36122. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36123. /**
  36124. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36125. */
  36126. export class Node implements IBehaviorAware<Node> {
  36127. /** @hidden */
  36128. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36129. private static _NodeConstructors;
  36130. /**
  36131. * Add a new node constructor
  36132. * @param type defines the type name of the node to construct
  36133. * @param constructorFunc defines the constructor function
  36134. */
  36135. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36136. /**
  36137. * Returns a node constructor based on type name
  36138. * @param type defines the type name
  36139. * @param name defines the new node name
  36140. * @param scene defines the hosting scene
  36141. * @param options defines optional options to transmit to constructors
  36142. * @returns the new constructor or null
  36143. */
  36144. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36145. /**
  36146. * Gets or sets the name of the node
  36147. */
  36148. name: string;
  36149. /**
  36150. * Gets or sets the id of the node
  36151. */
  36152. id: string;
  36153. /**
  36154. * Gets or sets the unique id of the node
  36155. */
  36156. uniqueId: number;
  36157. /**
  36158. * Gets or sets a string used to store user defined state for the node
  36159. */
  36160. state: string;
  36161. /**
  36162. * Gets or sets an object used to store user defined information for the node
  36163. */
  36164. metadata: any;
  36165. /**
  36166. * For internal use only. Please do not use.
  36167. */
  36168. reservedDataStore: any;
  36169. /**
  36170. * List of inspectable custom properties (used by the Inspector)
  36171. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36172. */
  36173. inspectableCustomProperties: IInspectable[];
  36174. private _doNotSerialize;
  36175. /**
  36176. * Gets or sets a boolean used to define if the node must be serialized
  36177. */
  36178. get doNotSerialize(): boolean;
  36179. set doNotSerialize(value: boolean);
  36180. /** @hidden */
  36181. _isDisposed: boolean;
  36182. /**
  36183. * Gets a list of Animations associated with the node
  36184. */
  36185. animations: Animation[];
  36186. protected _ranges: {
  36187. [name: string]: Nullable<AnimationRange>;
  36188. };
  36189. /**
  36190. * Callback raised when the node is ready to be used
  36191. */
  36192. onReady: Nullable<(node: Node) => void>;
  36193. private _isEnabled;
  36194. private _isParentEnabled;
  36195. private _isReady;
  36196. /** @hidden */
  36197. _currentRenderId: number;
  36198. private _parentUpdateId;
  36199. /** @hidden */
  36200. _childUpdateId: number;
  36201. /** @hidden */
  36202. _waitingParentId: Nullable<string>;
  36203. /** @hidden */
  36204. _scene: Scene;
  36205. /** @hidden */
  36206. _cache: any;
  36207. private _parentNode;
  36208. private _children;
  36209. /** @hidden */
  36210. _worldMatrix: Matrix;
  36211. /** @hidden */
  36212. _worldMatrixDeterminant: number;
  36213. /** @hidden */
  36214. _worldMatrixDeterminantIsDirty: boolean;
  36215. /** @hidden */
  36216. private _sceneRootNodesIndex;
  36217. /**
  36218. * Gets a boolean indicating if the node has been disposed
  36219. * @returns true if the node was disposed
  36220. */
  36221. isDisposed(): boolean;
  36222. /**
  36223. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36224. * @see https://doc.babylonjs.com/how_to/parenting
  36225. */
  36226. set parent(parent: Nullable<Node>);
  36227. get parent(): Nullable<Node>;
  36228. /** @hidden */
  36229. _addToSceneRootNodes(): void;
  36230. /** @hidden */
  36231. _removeFromSceneRootNodes(): void;
  36232. private _animationPropertiesOverride;
  36233. /**
  36234. * Gets or sets the animation properties override
  36235. */
  36236. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36237. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36238. /**
  36239. * Gets a string identifying the name of the class
  36240. * @returns "Node" string
  36241. */
  36242. getClassName(): string;
  36243. /** @hidden */
  36244. readonly _isNode: boolean;
  36245. /**
  36246. * An event triggered when the mesh is disposed
  36247. */
  36248. onDisposeObservable: Observable<Node>;
  36249. private _onDisposeObserver;
  36250. /**
  36251. * Sets a callback that will be raised when the node will be disposed
  36252. */
  36253. set onDispose(callback: () => void);
  36254. /**
  36255. * Creates a new Node
  36256. * @param name the name and id to be given to this node
  36257. * @param scene the scene this node will be added to
  36258. */
  36259. constructor(name: string, scene?: Nullable<Scene>);
  36260. /**
  36261. * Gets the scene of the node
  36262. * @returns a scene
  36263. */
  36264. getScene(): Scene;
  36265. /**
  36266. * Gets the engine of the node
  36267. * @returns a Engine
  36268. */
  36269. getEngine(): Engine;
  36270. private _behaviors;
  36271. /**
  36272. * Attach a behavior to the node
  36273. * @see https://doc.babylonjs.com/features/behaviour
  36274. * @param behavior defines the behavior to attach
  36275. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36276. * @returns the current Node
  36277. */
  36278. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36279. /**
  36280. * Remove an attached behavior
  36281. * @see https://doc.babylonjs.com/features/behaviour
  36282. * @param behavior defines the behavior to attach
  36283. * @returns the current Node
  36284. */
  36285. removeBehavior(behavior: Behavior<Node>): Node;
  36286. /**
  36287. * Gets the list of attached behaviors
  36288. * @see https://doc.babylonjs.com/features/behaviour
  36289. */
  36290. get behaviors(): Behavior<Node>[];
  36291. /**
  36292. * Gets an attached behavior by name
  36293. * @param name defines the name of the behavior to look for
  36294. * @see https://doc.babylonjs.com/features/behaviour
  36295. * @returns null if behavior was not found else the requested behavior
  36296. */
  36297. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36298. /**
  36299. * Returns the latest update of the World matrix
  36300. * @returns a Matrix
  36301. */
  36302. getWorldMatrix(): Matrix;
  36303. /** @hidden */
  36304. _getWorldMatrixDeterminant(): number;
  36305. /**
  36306. * Returns directly the latest state of the mesh World matrix.
  36307. * A Matrix is returned.
  36308. */
  36309. get worldMatrixFromCache(): Matrix;
  36310. /** @hidden */
  36311. _initCache(): void;
  36312. /** @hidden */
  36313. updateCache(force?: boolean): void;
  36314. /** @hidden */
  36315. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36316. /** @hidden */
  36317. _updateCache(ignoreParentClass?: boolean): void;
  36318. /** @hidden */
  36319. _isSynchronized(): boolean;
  36320. /** @hidden */
  36321. _markSyncedWithParent(): void;
  36322. /** @hidden */
  36323. isSynchronizedWithParent(): boolean;
  36324. /** @hidden */
  36325. isSynchronized(): boolean;
  36326. /**
  36327. * Is this node ready to be used/rendered
  36328. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36329. * @return true if the node is ready
  36330. */
  36331. isReady(completeCheck?: boolean): boolean;
  36332. /**
  36333. * Is this node enabled?
  36334. * 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
  36335. * @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
  36336. * @return whether this node (and its parent) is enabled
  36337. */
  36338. isEnabled(checkAncestors?: boolean): boolean;
  36339. /** @hidden */
  36340. protected _syncParentEnabledState(): void;
  36341. /**
  36342. * Set the enabled state of this node
  36343. * @param value defines the new enabled state
  36344. */
  36345. setEnabled(value: boolean): void;
  36346. /**
  36347. * Is this node a descendant of the given node?
  36348. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36349. * @param ancestor defines the parent node to inspect
  36350. * @returns a boolean indicating if this node is a descendant of the given node
  36351. */
  36352. isDescendantOf(ancestor: Node): boolean;
  36353. /** @hidden */
  36354. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36355. /**
  36356. * Will return all nodes that have this node as ascendant
  36357. * @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
  36358. * @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
  36359. * @return all children nodes of all types
  36360. */
  36361. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36362. /**
  36363. * Get all child-meshes of this node
  36364. * @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)
  36365. * @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
  36366. * @returns an array of AbstractMesh
  36367. */
  36368. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36369. /**
  36370. * Get all direct children of this node
  36371. * @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
  36372. * @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)
  36373. * @returns an array of Node
  36374. */
  36375. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36376. /** @hidden */
  36377. _setReady(state: boolean): void;
  36378. /**
  36379. * Get an animation by name
  36380. * @param name defines the name of the animation to look for
  36381. * @returns null if not found else the requested animation
  36382. */
  36383. getAnimationByName(name: string): Nullable<Animation>;
  36384. /**
  36385. * Creates an animation range for this node
  36386. * @param name defines the name of the range
  36387. * @param from defines the starting key
  36388. * @param to defines the end key
  36389. */
  36390. createAnimationRange(name: string, from: number, to: number): void;
  36391. /**
  36392. * Delete a specific animation range
  36393. * @param name defines the name of the range to delete
  36394. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36395. */
  36396. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36397. /**
  36398. * Get an animation range by name
  36399. * @param name defines the name of the animation range to look for
  36400. * @returns null if not found else the requested animation range
  36401. */
  36402. getAnimationRange(name: string): Nullable<AnimationRange>;
  36403. /**
  36404. * Gets the list of all animation ranges defined on this node
  36405. * @returns an array
  36406. */
  36407. getAnimationRanges(): Nullable<AnimationRange>[];
  36408. /**
  36409. * Will start the animation sequence
  36410. * @param name defines the range frames for animation sequence
  36411. * @param loop defines if the animation should loop (false by default)
  36412. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36413. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36414. * @returns the object created for this animation. If range does not exist, it will return null
  36415. */
  36416. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36417. /**
  36418. * Serialize animation ranges into a JSON compatible object
  36419. * @returns serialization object
  36420. */
  36421. serializeAnimationRanges(): any;
  36422. /**
  36423. * Computes the world matrix of the node
  36424. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36425. * @returns the world matrix
  36426. */
  36427. computeWorldMatrix(force?: boolean): Matrix;
  36428. /**
  36429. * Releases resources associated with this node.
  36430. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36431. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36432. */
  36433. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36434. /**
  36435. * Parse animation range data from a serialization object and store them into a given node
  36436. * @param node defines where to store the animation ranges
  36437. * @param parsedNode defines the serialization object to read data from
  36438. * @param scene defines the hosting scene
  36439. */
  36440. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36441. /**
  36442. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36443. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36444. * @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
  36445. * @returns the new bounding vectors
  36446. */
  36447. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36448. min: Vector3;
  36449. max: Vector3;
  36450. };
  36451. }
  36452. }
  36453. declare module BABYLON {
  36454. /**
  36455. * @hidden
  36456. */
  36457. export class _IAnimationState {
  36458. key: number;
  36459. repeatCount: number;
  36460. workValue?: any;
  36461. loopMode?: number;
  36462. offsetValue?: any;
  36463. highLimitValue?: any;
  36464. }
  36465. /**
  36466. * Class used to store any kind of animation
  36467. */
  36468. export class Animation {
  36469. /**Name of the animation */
  36470. name: string;
  36471. /**Property to animate */
  36472. targetProperty: string;
  36473. /**The frames per second of the animation */
  36474. framePerSecond: number;
  36475. /**The data type of the animation */
  36476. dataType: number;
  36477. /**The loop mode of the animation */
  36478. loopMode?: number | undefined;
  36479. /**Specifies if blending should be enabled */
  36480. enableBlending?: boolean | undefined;
  36481. /**
  36482. * Use matrix interpolation instead of using direct key value when animating matrices
  36483. */
  36484. static AllowMatricesInterpolation: boolean;
  36485. /**
  36486. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36487. */
  36488. static AllowMatrixDecomposeForInterpolation: boolean;
  36489. /** Define the Url to load snippets */
  36490. static SnippetUrl: string;
  36491. /** Snippet ID if the animation was created from the snippet server */
  36492. snippetId: string;
  36493. /**
  36494. * Stores the key frames of the animation
  36495. */
  36496. private _keys;
  36497. /**
  36498. * Stores the easing function of the animation
  36499. */
  36500. private _easingFunction;
  36501. /**
  36502. * @hidden Internal use only
  36503. */
  36504. _runtimeAnimations: RuntimeAnimation[];
  36505. /**
  36506. * The set of event that will be linked to this animation
  36507. */
  36508. private _events;
  36509. /**
  36510. * Stores an array of target property paths
  36511. */
  36512. targetPropertyPath: string[];
  36513. /**
  36514. * Stores the blending speed of the animation
  36515. */
  36516. blendingSpeed: number;
  36517. /**
  36518. * Stores the animation ranges for the animation
  36519. */
  36520. private _ranges;
  36521. /**
  36522. * @hidden Internal use
  36523. */
  36524. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36525. /**
  36526. * Sets up an animation
  36527. * @param property The property to animate
  36528. * @param animationType The animation type to apply
  36529. * @param framePerSecond The frames per second of the animation
  36530. * @param easingFunction The easing function used in the animation
  36531. * @returns The created animation
  36532. */
  36533. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36534. /**
  36535. * Create and start an animation on a node
  36536. * @param name defines the name of the global animation that will be run on all nodes
  36537. * @param node defines the root node where the animation will take place
  36538. * @param targetProperty defines property to animate
  36539. * @param framePerSecond defines the number of frame per second yo use
  36540. * @param totalFrame defines the number of frames in total
  36541. * @param from defines the initial value
  36542. * @param to defines the final value
  36543. * @param loopMode defines which loop mode you want to use (off by default)
  36544. * @param easingFunction defines the easing function to use (linear by default)
  36545. * @param onAnimationEnd defines the callback to call when animation end
  36546. * @returns the animatable created for this animation
  36547. */
  36548. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36549. /**
  36550. * Create and start an animation on a node and its descendants
  36551. * @param name defines the name of the global animation that will be run on all nodes
  36552. * @param node defines the root node where the animation will take place
  36553. * @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
  36554. * @param targetProperty defines property to animate
  36555. * @param framePerSecond defines the number of frame per second to use
  36556. * @param totalFrame defines the number of frames in total
  36557. * @param from defines the initial value
  36558. * @param to defines the final value
  36559. * @param loopMode defines which loop mode you want to use (off by default)
  36560. * @param easingFunction defines the easing function to use (linear by default)
  36561. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36562. * @returns the list of animatables created for all nodes
  36563. * @example https://www.babylonjs-playground.com/#MH0VLI
  36564. */
  36565. 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[]>;
  36566. /**
  36567. * Creates a new animation, merges it with the existing animations and starts it
  36568. * @param name Name of the animation
  36569. * @param node Node which contains the scene that begins the animations
  36570. * @param targetProperty Specifies which property to animate
  36571. * @param framePerSecond The frames per second of the animation
  36572. * @param totalFrame The total number of frames
  36573. * @param from The frame at the beginning of the animation
  36574. * @param to The frame at the end of the animation
  36575. * @param loopMode Specifies the loop mode of the animation
  36576. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36577. * @param onAnimationEnd Callback to run once the animation is complete
  36578. * @returns Nullable animation
  36579. */
  36580. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36581. /**
  36582. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36583. * @param sourceAnimation defines the Animation containing keyframes to convert
  36584. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36585. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36586. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36587. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36588. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36589. */
  36590. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36591. /**
  36592. * Transition property of an host to the target Value
  36593. * @param property The property to transition
  36594. * @param targetValue The target Value of the property
  36595. * @param host The object where the property to animate belongs
  36596. * @param scene Scene used to run the animation
  36597. * @param frameRate Framerate (in frame/s) to use
  36598. * @param transition The transition type we want to use
  36599. * @param duration The duration of the animation, in milliseconds
  36600. * @param onAnimationEnd Callback trigger at the end of the animation
  36601. * @returns Nullable animation
  36602. */
  36603. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36604. /**
  36605. * Return the array of runtime animations currently using this animation
  36606. */
  36607. get runtimeAnimations(): RuntimeAnimation[];
  36608. /**
  36609. * Specifies if any of the runtime animations are currently running
  36610. */
  36611. get hasRunningRuntimeAnimations(): boolean;
  36612. /**
  36613. * Initializes the animation
  36614. * @param name Name of the animation
  36615. * @param targetProperty Property to animate
  36616. * @param framePerSecond The frames per second of the animation
  36617. * @param dataType The data type of the animation
  36618. * @param loopMode The loop mode of the animation
  36619. * @param enableBlending Specifies if blending should be enabled
  36620. */
  36621. constructor(
  36622. /**Name of the animation */
  36623. name: string,
  36624. /**Property to animate */
  36625. targetProperty: string,
  36626. /**The frames per second of the animation */
  36627. framePerSecond: number,
  36628. /**The data type of the animation */
  36629. dataType: number,
  36630. /**The loop mode of the animation */
  36631. loopMode?: number | undefined,
  36632. /**Specifies if blending should be enabled */
  36633. enableBlending?: boolean | undefined);
  36634. /**
  36635. * Converts the animation to a string
  36636. * @param fullDetails support for multiple levels of logging within scene loading
  36637. * @returns String form of the animation
  36638. */
  36639. toString(fullDetails?: boolean): string;
  36640. /**
  36641. * Add an event to this animation
  36642. * @param event Event to add
  36643. */
  36644. addEvent(event: AnimationEvent): void;
  36645. /**
  36646. * Remove all events found at the given frame
  36647. * @param frame The frame to remove events from
  36648. */
  36649. removeEvents(frame: number): void;
  36650. /**
  36651. * Retrieves all the events from the animation
  36652. * @returns Events from the animation
  36653. */
  36654. getEvents(): AnimationEvent[];
  36655. /**
  36656. * Creates an animation range
  36657. * @param name Name of the animation range
  36658. * @param from Starting frame of the animation range
  36659. * @param to Ending frame of the animation
  36660. */
  36661. createRange(name: string, from: number, to: number): void;
  36662. /**
  36663. * Deletes an animation range by name
  36664. * @param name Name of the animation range to delete
  36665. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36666. */
  36667. deleteRange(name: string, deleteFrames?: boolean): void;
  36668. /**
  36669. * Gets the animation range by name, or null if not defined
  36670. * @param name Name of the animation range
  36671. * @returns Nullable animation range
  36672. */
  36673. getRange(name: string): Nullable<AnimationRange>;
  36674. /**
  36675. * Gets the key frames from the animation
  36676. * @returns The key frames of the animation
  36677. */
  36678. getKeys(): Array<IAnimationKey>;
  36679. /**
  36680. * Gets the highest frame rate of the animation
  36681. * @returns Highest frame rate of the animation
  36682. */
  36683. getHighestFrame(): number;
  36684. /**
  36685. * Gets the easing function of the animation
  36686. * @returns Easing function of the animation
  36687. */
  36688. getEasingFunction(): IEasingFunction;
  36689. /**
  36690. * Sets the easing function of the animation
  36691. * @param easingFunction A custom mathematical formula for animation
  36692. */
  36693. setEasingFunction(easingFunction: EasingFunction): void;
  36694. /**
  36695. * Interpolates a scalar linearly
  36696. * @param startValue Start value of the animation curve
  36697. * @param endValue End value of the animation curve
  36698. * @param gradient Scalar amount to interpolate
  36699. * @returns Interpolated scalar value
  36700. */
  36701. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  36702. /**
  36703. * Interpolates a scalar cubically
  36704. * @param startValue Start value of the animation curve
  36705. * @param outTangent End tangent of the animation
  36706. * @param endValue End value of the animation curve
  36707. * @param inTangent Start tangent of the animation curve
  36708. * @param gradient Scalar amount to interpolate
  36709. * @returns Interpolated scalar value
  36710. */
  36711. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  36712. /**
  36713. * Interpolates a quaternion using a spherical linear interpolation
  36714. * @param startValue Start value of the animation curve
  36715. * @param endValue End value of the animation curve
  36716. * @param gradient Scalar amount to interpolate
  36717. * @returns Interpolated quaternion value
  36718. */
  36719. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  36720. /**
  36721. * Interpolates a quaternion cubically
  36722. * @param startValue Start value of the animation curve
  36723. * @param outTangent End tangent of the animation curve
  36724. * @param endValue End value of the animation curve
  36725. * @param inTangent Start tangent of the animation curve
  36726. * @param gradient Scalar amount to interpolate
  36727. * @returns Interpolated quaternion value
  36728. */
  36729. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  36730. /**
  36731. * Interpolates a Vector3 linearl
  36732. * @param startValue Start value of the animation curve
  36733. * @param endValue End value of the animation curve
  36734. * @param gradient Scalar amount to interpolate
  36735. * @returns Interpolated scalar value
  36736. */
  36737. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  36738. /**
  36739. * Interpolates a Vector3 cubically
  36740. * @param startValue Start value of the animation curve
  36741. * @param outTangent End tangent of the animation
  36742. * @param endValue End value of the animation curve
  36743. * @param inTangent Start tangent of the animation curve
  36744. * @param gradient Scalar amount to interpolate
  36745. * @returns InterpolatedVector3 value
  36746. */
  36747. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  36748. /**
  36749. * Interpolates a Vector2 linearly
  36750. * @param startValue Start value of the animation curve
  36751. * @param endValue End value of the animation curve
  36752. * @param gradient Scalar amount to interpolate
  36753. * @returns Interpolated Vector2 value
  36754. */
  36755. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  36756. /**
  36757. * Interpolates a Vector2 cubically
  36758. * @param startValue Start value of the animation curve
  36759. * @param outTangent End tangent of the animation
  36760. * @param endValue End value of the animation curve
  36761. * @param inTangent Start tangent of the animation curve
  36762. * @param gradient Scalar amount to interpolate
  36763. * @returns Interpolated Vector2 value
  36764. */
  36765. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  36766. /**
  36767. * Interpolates a size linearly
  36768. * @param startValue Start value of the animation curve
  36769. * @param endValue End value of the animation curve
  36770. * @param gradient Scalar amount to interpolate
  36771. * @returns Interpolated Size value
  36772. */
  36773. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  36774. /**
  36775. * Interpolates a Color3 linearly
  36776. * @param startValue Start value of the animation curve
  36777. * @param endValue End value of the animation curve
  36778. * @param gradient Scalar amount to interpolate
  36779. * @returns Interpolated Color3 value
  36780. */
  36781. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  36782. /**
  36783. * Interpolates a Color4 linearly
  36784. * @param startValue Start value of the animation curve
  36785. * @param endValue End value of the animation curve
  36786. * @param gradient Scalar amount to interpolate
  36787. * @returns Interpolated Color3 value
  36788. */
  36789. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  36790. /**
  36791. * @hidden Internal use only
  36792. */
  36793. _getKeyValue(value: any): any;
  36794. /**
  36795. * @hidden Internal use only
  36796. */
  36797. _interpolate(currentFrame: number, state: _IAnimationState): any;
  36798. /**
  36799. * Defines the function to use to interpolate matrices
  36800. * @param startValue defines the start matrix
  36801. * @param endValue defines the end matrix
  36802. * @param gradient defines the gradient between both matrices
  36803. * @param result defines an optional target matrix where to store the interpolation
  36804. * @returns the interpolated matrix
  36805. */
  36806. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  36807. /**
  36808. * Makes a copy of the animation
  36809. * @returns Cloned animation
  36810. */
  36811. clone(): Animation;
  36812. /**
  36813. * Sets the key frames of the animation
  36814. * @param values The animation key frames to set
  36815. */
  36816. setKeys(values: Array<IAnimationKey>): void;
  36817. /**
  36818. * Serializes the animation to an object
  36819. * @returns Serialized object
  36820. */
  36821. serialize(): any;
  36822. /**
  36823. * Float animation type
  36824. */
  36825. static readonly ANIMATIONTYPE_FLOAT: number;
  36826. /**
  36827. * Vector3 animation type
  36828. */
  36829. static readonly ANIMATIONTYPE_VECTOR3: number;
  36830. /**
  36831. * Quaternion animation type
  36832. */
  36833. static readonly ANIMATIONTYPE_QUATERNION: number;
  36834. /**
  36835. * Matrix animation type
  36836. */
  36837. static readonly ANIMATIONTYPE_MATRIX: number;
  36838. /**
  36839. * Color3 animation type
  36840. */
  36841. static readonly ANIMATIONTYPE_COLOR3: number;
  36842. /**
  36843. * Color3 animation type
  36844. */
  36845. static readonly ANIMATIONTYPE_COLOR4: number;
  36846. /**
  36847. * Vector2 animation type
  36848. */
  36849. static readonly ANIMATIONTYPE_VECTOR2: number;
  36850. /**
  36851. * Size animation type
  36852. */
  36853. static readonly ANIMATIONTYPE_SIZE: number;
  36854. /**
  36855. * Relative Loop Mode
  36856. */
  36857. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  36858. /**
  36859. * Cycle Loop Mode
  36860. */
  36861. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  36862. /**
  36863. * Constant Loop Mode
  36864. */
  36865. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  36866. /** @hidden */
  36867. static _UniversalLerp(left: any, right: any, amount: number): any;
  36868. /**
  36869. * Parses an animation object and creates an animation
  36870. * @param parsedAnimation Parsed animation object
  36871. * @returns Animation object
  36872. */
  36873. static Parse(parsedAnimation: any): Animation;
  36874. /**
  36875. * Appends the serialized animations from the source animations
  36876. * @param source Source containing the animations
  36877. * @param destination Target to store the animations
  36878. */
  36879. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36880. /**
  36881. * Creates a new animation or an array of animations from a snippet saved in a remote file
  36882. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  36883. * @param url defines the url to load from
  36884. * @returns a promise that will resolve to the new animation or an array of animations
  36885. */
  36886. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  36887. /**
  36888. * Creates an animation or an array of animations from a snippet saved by the Inspector
  36889. * @param snippetId defines the snippet to load
  36890. * @returns a promise that will resolve to the new animation or a new array of animations
  36891. */
  36892. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  36893. }
  36894. }
  36895. declare module BABYLON {
  36896. /**
  36897. * Interface containing an array of animations
  36898. */
  36899. export interface IAnimatable {
  36900. /**
  36901. * Array of animations
  36902. */
  36903. animations: Nullable<Array<Animation>>;
  36904. }
  36905. }
  36906. declare module BABYLON {
  36907. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36908. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36909. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36910. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36911. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36912. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36913. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36914. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36915. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36916. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36917. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36918. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36919. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36920. /**
  36921. * Decorator used to define property that can be serialized as reference to a camera
  36922. * @param sourceName defines the name of the property to decorate
  36923. */
  36924. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36925. /**
  36926. * Class used to help serialization objects
  36927. */
  36928. export class SerializationHelper {
  36929. /** @hidden */
  36930. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  36931. /** @hidden */
  36932. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  36933. /** @hidden */
  36934. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  36935. /** @hidden */
  36936. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  36937. /**
  36938. * Appends the serialized animations from the source animations
  36939. * @param source Source containing the animations
  36940. * @param destination Target to store the animations
  36941. */
  36942. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36943. /**
  36944. * Static function used to serialized a specific entity
  36945. * @param entity defines the entity to serialize
  36946. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36947. * @returns a JSON compatible object representing the serialization of the entity
  36948. */
  36949. static Serialize<T>(entity: T, serializationObject?: any): any;
  36950. /**
  36951. * Creates a new entity from a serialization data object
  36952. * @param creationFunction defines a function used to instanciated the new entity
  36953. * @param source defines the source serialization data
  36954. * @param scene defines the hosting scene
  36955. * @param rootUrl defines the root url for resources
  36956. * @returns a new entity
  36957. */
  36958. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  36959. /**
  36960. * Clones an object
  36961. * @param creationFunction defines the function used to instanciate the new object
  36962. * @param source defines the source object
  36963. * @returns the cloned object
  36964. */
  36965. static Clone<T>(creationFunction: () => T, source: T): T;
  36966. /**
  36967. * Instanciates a new object based on a source one (some data will be shared between both object)
  36968. * @param creationFunction defines the function used to instanciate the new object
  36969. * @param source defines the source object
  36970. * @returns the new object
  36971. */
  36972. static Instanciate<T>(creationFunction: () => T, source: T): T;
  36973. }
  36974. }
  36975. declare module BABYLON {
  36976. /**
  36977. * This is the base class of all the camera used in the application.
  36978. * @see https://doc.babylonjs.com/features/cameras
  36979. */
  36980. export class Camera extends Node {
  36981. /** @hidden */
  36982. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  36983. /**
  36984. * This is the default projection mode used by the cameras.
  36985. * It helps recreating a feeling of perspective and better appreciate depth.
  36986. * This is the best way to simulate real life cameras.
  36987. */
  36988. static readonly PERSPECTIVE_CAMERA: number;
  36989. /**
  36990. * This helps creating camera with an orthographic mode.
  36991. * 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.
  36992. */
  36993. static readonly ORTHOGRAPHIC_CAMERA: number;
  36994. /**
  36995. * This is the default FOV mode for perspective cameras.
  36996. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  36997. */
  36998. static readonly FOVMODE_VERTICAL_FIXED: number;
  36999. /**
  37000. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  37001. */
  37002. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  37003. /**
  37004. * This specifies ther is no need for a camera rig.
  37005. * Basically only one eye is rendered corresponding to the camera.
  37006. */
  37007. static readonly RIG_MODE_NONE: number;
  37008. /**
  37009. * Simulates a camera Rig with one blue eye and one red eye.
  37010. * This can be use with 3d blue and red glasses.
  37011. */
  37012. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  37013. /**
  37014. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  37015. */
  37016. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  37017. /**
  37018. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  37019. */
  37020. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  37021. /**
  37022. * Defines that both eyes of the camera will be rendered over under each other.
  37023. */
  37024. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  37025. /**
  37026. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  37027. */
  37028. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  37029. /**
  37030. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  37031. */
  37032. static readonly RIG_MODE_VR: number;
  37033. /**
  37034. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  37035. */
  37036. static readonly RIG_MODE_WEBVR: number;
  37037. /**
  37038. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  37039. */
  37040. static readonly RIG_MODE_CUSTOM: number;
  37041. /**
  37042. * Defines if by default attaching controls should prevent the default javascript event to continue.
  37043. */
  37044. static ForceAttachControlToAlwaysPreventDefault: boolean;
  37045. /**
  37046. * Define the input manager associated with the camera.
  37047. */
  37048. inputs: CameraInputsManager<Camera>;
  37049. /** @hidden */
  37050. _position: Vector3;
  37051. /**
  37052. * Define the current local position of the camera in the scene
  37053. */
  37054. get position(): Vector3;
  37055. set position(newPosition: Vector3);
  37056. protected _upVector: Vector3;
  37057. /**
  37058. * The vector the camera should consider as up.
  37059. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37060. */
  37061. set upVector(vec: Vector3);
  37062. get upVector(): Vector3;
  37063. /**
  37064. * Define the current limit on the left side for an orthographic camera
  37065. * In scene unit
  37066. */
  37067. orthoLeft: Nullable<number>;
  37068. /**
  37069. * Define the current limit on the right side for an orthographic camera
  37070. * In scene unit
  37071. */
  37072. orthoRight: Nullable<number>;
  37073. /**
  37074. * Define the current limit on the bottom side for an orthographic camera
  37075. * In scene unit
  37076. */
  37077. orthoBottom: Nullable<number>;
  37078. /**
  37079. * Define the current limit on the top side for an orthographic camera
  37080. * In scene unit
  37081. */
  37082. orthoTop: Nullable<number>;
  37083. /**
  37084. * Field Of View is set in Radians. (default is 0.8)
  37085. */
  37086. fov: number;
  37087. /**
  37088. * Define the minimum distance the camera can see from.
  37089. * This is important to note that the depth buffer are not infinite and the closer it starts
  37090. * the more your scene might encounter depth fighting issue.
  37091. */
  37092. minZ: number;
  37093. /**
  37094. * Define the maximum distance the camera can see to.
  37095. * This is important to note that the depth buffer are not infinite and the further it end
  37096. * the more your scene might encounter depth fighting issue.
  37097. */
  37098. maxZ: number;
  37099. /**
  37100. * Define the default inertia of the camera.
  37101. * This helps giving a smooth feeling to the camera movement.
  37102. */
  37103. inertia: number;
  37104. /**
  37105. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37106. */
  37107. mode: number;
  37108. /**
  37109. * Define whether the camera is intermediate.
  37110. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  37111. */
  37112. isIntermediate: boolean;
  37113. /**
  37114. * Define the viewport of the camera.
  37115. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  37116. */
  37117. viewport: Viewport;
  37118. /**
  37119. * Restricts the camera to viewing objects with the same layerMask.
  37120. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  37121. */
  37122. layerMask: number;
  37123. /**
  37124. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  37125. */
  37126. fovMode: number;
  37127. /**
  37128. * Rig mode of the camera.
  37129. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37130. * This is normally controlled byt the camera themselves as internal use.
  37131. */
  37132. cameraRigMode: number;
  37133. /**
  37134. * Defines the distance between both "eyes" in case of a RIG
  37135. */
  37136. interaxialDistance: number;
  37137. /**
  37138. * Defines if stereoscopic rendering is done side by side or over under.
  37139. */
  37140. isStereoscopicSideBySide: boolean;
  37141. /**
  37142. * 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
  37143. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  37144. * else in the scene. (Eg. security camera)
  37145. *
  37146. * 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)
  37147. */
  37148. customRenderTargets: RenderTargetTexture[];
  37149. /**
  37150. * When set, the camera will render to this render target instead of the default canvas
  37151. *
  37152. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  37153. */
  37154. outputRenderTarget: Nullable<RenderTargetTexture>;
  37155. /**
  37156. * Observable triggered when the camera view matrix has changed.
  37157. */
  37158. onViewMatrixChangedObservable: Observable<Camera>;
  37159. /**
  37160. * Observable triggered when the camera Projection matrix has changed.
  37161. */
  37162. onProjectionMatrixChangedObservable: Observable<Camera>;
  37163. /**
  37164. * Observable triggered when the inputs have been processed.
  37165. */
  37166. onAfterCheckInputsObservable: Observable<Camera>;
  37167. /**
  37168. * Observable triggered when reset has been called and applied to the camera.
  37169. */
  37170. onRestoreStateObservable: Observable<Camera>;
  37171. /**
  37172. * Is this camera a part of a rig system?
  37173. */
  37174. isRigCamera: boolean;
  37175. /**
  37176. * If isRigCamera set to true this will be set with the parent camera.
  37177. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  37178. */
  37179. rigParent?: Camera;
  37180. /** @hidden */
  37181. _cameraRigParams: any;
  37182. /** @hidden */
  37183. _rigCameras: Camera[];
  37184. /** @hidden */
  37185. _rigPostProcess: Nullable<PostProcess>;
  37186. protected _webvrViewMatrix: Matrix;
  37187. /** @hidden */
  37188. _skipRendering: boolean;
  37189. /** @hidden */
  37190. _projectionMatrix: Matrix;
  37191. /** @hidden */
  37192. _postProcesses: Nullable<PostProcess>[];
  37193. /** @hidden */
  37194. _activeMeshes: SmartArray<AbstractMesh>;
  37195. protected _globalPosition: Vector3;
  37196. /** @hidden */
  37197. _computedViewMatrix: Matrix;
  37198. private _doNotComputeProjectionMatrix;
  37199. private _transformMatrix;
  37200. private _frustumPlanes;
  37201. private _refreshFrustumPlanes;
  37202. private _storedFov;
  37203. private _stateStored;
  37204. /**
  37205. * Instantiates a new camera object.
  37206. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  37207. * @see https://doc.babylonjs.com/features/cameras
  37208. * @param name Defines the name of the camera in the scene
  37209. * @param position Defines the position of the camera
  37210. * @param scene Defines the scene the camera belongs too
  37211. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  37212. */
  37213. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37214. /**
  37215. * Store current camera state (fov, position, etc..)
  37216. * @returns the camera
  37217. */
  37218. storeState(): Camera;
  37219. /**
  37220. * Restores the camera state values if it has been stored. You must call storeState() first
  37221. */
  37222. protected _restoreStateValues(): boolean;
  37223. /**
  37224. * Restored camera state. You must call storeState() first.
  37225. * @returns true if restored and false otherwise
  37226. */
  37227. restoreState(): boolean;
  37228. /**
  37229. * Gets the class name of the camera.
  37230. * @returns the class name
  37231. */
  37232. getClassName(): string;
  37233. /** @hidden */
  37234. readonly _isCamera: boolean;
  37235. /**
  37236. * Gets a string representation of the camera useful for debug purpose.
  37237. * @param fullDetails Defines that a more verboe level of logging is required
  37238. * @returns the string representation
  37239. */
  37240. toString(fullDetails?: boolean): string;
  37241. /**
  37242. * Gets the current world space position of the camera.
  37243. */
  37244. get globalPosition(): Vector3;
  37245. /**
  37246. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  37247. * @returns the active meshe list
  37248. */
  37249. getActiveMeshes(): SmartArray<AbstractMesh>;
  37250. /**
  37251. * Check whether a mesh is part of the current active mesh list of the camera
  37252. * @param mesh Defines the mesh to check
  37253. * @returns true if active, false otherwise
  37254. */
  37255. isActiveMesh(mesh: Mesh): boolean;
  37256. /**
  37257. * Is this camera ready to be used/rendered
  37258. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  37259. * @return true if the camera is ready
  37260. */
  37261. isReady(completeCheck?: boolean): boolean;
  37262. /** @hidden */
  37263. _initCache(): void;
  37264. /** @hidden */
  37265. _updateCache(ignoreParentClass?: boolean): void;
  37266. /** @hidden */
  37267. _isSynchronized(): boolean;
  37268. /** @hidden */
  37269. _isSynchronizedViewMatrix(): boolean;
  37270. /** @hidden */
  37271. _isSynchronizedProjectionMatrix(): boolean;
  37272. /**
  37273. * Attach the input controls to a specific dom element to get the input from.
  37274. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37275. */
  37276. attachControl(noPreventDefault?: boolean): void;
  37277. /**
  37278. * Attach the input controls to a specific dom element to get the input from.
  37279. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  37280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37281. * BACK COMPAT SIGNATURE ONLY.
  37282. */
  37283. attachControl(ignored: any, noPreventDefault?: boolean): void;
  37284. /**
  37285. * Detach the current controls from the specified dom element.
  37286. */
  37287. detachControl(): void;
  37288. /**
  37289. * Detach the current controls from the specified dom element.
  37290. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  37291. */
  37292. detachControl(ignored: any): void;
  37293. /**
  37294. * Update the camera state according to the different inputs gathered during the frame.
  37295. */
  37296. update(): void;
  37297. /** @hidden */
  37298. _checkInputs(): void;
  37299. /** @hidden */
  37300. get rigCameras(): Camera[];
  37301. /**
  37302. * Gets the post process used by the rig cameras
  37303. */
  37304. get rigPostProcess(): Nullable<PostProcess>;
  37305. /**
  37306. * Internal, gets the first post proces.
  37307. * @returns the first post process to be run on this camera.
  37308. */
  37309. _getFirstPostProcess(): Nullable<PostProcess>;
  37310. private _cascadePostProcessesToRigCams;
  37311. /**
  37312. * Attach a post process to the camera.
  37313. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37314. * @param postProcess The post process to attach to the camera
  37315. * @param insertAt The position of the post process in case several of them are in use in the scene
  37316. * @returns the position the post process has been inserted at
  37317. */
  37318. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  37319. /**
  37320. * Detach a post process to the camera.
  37321. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37322. * @param postProcess The post process to detach from the camera
  37323. */
  37324. detachPostProcess(postProcess: PostProcess): void;
  37325. /**
  37326. * Gets the current world matrix of the camera
  37327. */
  37328. getWorldMatrix(): Matrix;
  37329. /** @hidden */
  37330. _getViewMatrix(): Matrix;
  37331. /**
  37332. * Gets the current view matrix of the camera.
  37333. * @param force forces the camera to recompute the matrix without looking at the cached state
  37334. * @returns the view matrix
  37335. */
  37336. getViewMatrix(force?: boolean): Matrix;
  37337. /**
  37338. * Freeze the projection matrix.
  37339. * It will prevent the cache check of the camera projection compute and can speed up perf
  37340. * if no parameter of the camera are meant to change
  37341. * @param projection Defines manually a projection if necessary
  37342. */
  37343. freezeProjectionMatrix(projection?: Matrix): void;
  37344. /**
  37345. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  37346. */
  37347. unfreezeProjectionMatrix(): void;
  37348. /**
  37349. * Gets the current projection matrix of the camera.
  37350. * @param force forces the camera to recompute the matrix without looking at the cached state
  37351. * @returns the projection matrix
  37352. */
  37353. getProjectionMatrix(force?: boolean): Matrix;
  37354. /**
  37355. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  37356. * @returns a Matrix
  37357. */
  37358. getTransformationMatrix(): Matrix;
  37359. private _updateFrustumPlanes;
  37360. /**
  37361. * Checks if a cullable object (mesh...) is in the camera frustum
  37362. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  37363. * @param target The object to check
  37364. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  37365. * @returns true if the object is in frustum otherwise false
  37366. */
  37367. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  37368. /**
  37369. * Checks if a cullable object (mesh...) is in the camera frustum
  37370. * Unlike isInFrustum this cheks the full bounding box
  37371. * @param target The object to check
  37372. * @returns true if the object is in frustum otherwise false
  37373. */
  37374. isCompletelyInFrustum(target: ICullable): boolean;
  37375. /**
  37376. * Gets a ray in the forward direction from the camera.
  37377. * @param length Defines the length of the ray to create
  37378. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37379. * @param origin Defines the start point of the ray which defaults to the camera position
  37380. * @returns the forward ray
  37381. */
  37382. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37383. /**
  37384. * Gets a ray in the forward direction from the camera.
  37385. * @param refRay the ray to (re)use when setting the values
  37386. * @param length Defines the length of the ray to create
  37387. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37388. * @param origin Defines the start point of the ray which defaults to the camera position
  37389. * @returns the forward ray
  37390. */
  37391. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37392. /**
  37393. * Releases resources associated with this node.
  37394. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37395. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37396. */
  37397. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37398. /** @hidden */
  37399. _isLeftCamera: boolean;
  37400. /**
  37401. * Gets the left camera of a rig setup in case of Rigged Camera
  37402. */
  37403. get isLeftCamera(): boolean;
  37404. /** @hidden */
  37405. _isRightCamera: boolean;
  37406. /**
  37407. * Gets the right camera of a rig setup in case of Rigged Camera
  37408. */
  37409. get isRightCamera(): boolean;
  37410. /**
  37411. * Gets the left camera of a rig setup in case of Rigged Camera
  37412. */
  37413. get leftCamera(): Nullable<FreeCamera>;
  37414. /**
  37415. * Gets the right camera of a rig setup in case of Rigged Camera
  37416. */
  37417. get rightCamera(): Nullable<FreeCamera>;
  37418. /**
  37419. * Gets the left camera target of a rig setup in case of Rigged Camera
  37420. * @returns the target position
  37421. */
  37422. getLeftTarget(): Nullable<Vector3>;
  37423. /**
  37424. * Gets the right camera target of a rig setup in case of Rigged Camera
  37425. * @returns the target position
  37426. */
  37427. getRightTarget(): Nullable<Vector3>;
  37428. /**
  37429. * @hidden
  37430. */
  37431. setCameraRigMode(mode: number, rigParams: any): void;
  37432. /** @hidden */
  37433. static _setStereoscopicRigMode(camera: Camera): void;
  37434. /** @hidden */
  37435. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  37436. /** @hidden */
  37437. static _setVRRigMode(camera: Camera, rigParams: any): void;
  37438. /** @hidden */
  37439. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  37440. /** @hidden */
  37441. _getVRProjectionMatrix(): Matrix;
  37442. protected _updateCameraRotationMatrix(): void;
  37443. protected _updateWebVRCameraRotationMatrix(): void;
  37444. /**
  37445. * This function MUST be overwritten by the different WebVR cameras available.
  37446. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37447. * @hidden
  37448. */
  37449. _getWebVRProjectionMatrix(): Matrix;
  37450. /**
  37451. * This function MUST be overwritten by the different WebVR cameras available.
  37452. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37453. * @hidden
  37454. */
  37455. _getWebVRViewMatrix(): Matrix;
  37456. /** @hidden */
  37457. setCameraRigParameter(name: string, value: any): void;
  37458. /**
  37459. * needs to be overridden by children so sub has required properties to be copied
  37460. * @hidden
  37461. */
  37462. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  37463. /**
  37464. * May need to be overridden by children
  37465. * @hidden
  37466. */
  37467. _updateRigCameras(): void;
  37468. /** @hidden */
  37469. _setupInputs(): void;
  37470. /**
  37471. * Serialiaze the camera setup to a json represention
  37472. * @returns the JSON representation
  37473. */
  37474. serialize(): any;
  37475. /**
  37476. * Clones the current camera.
  37477. * @param name The cloned camera name
  37478. * @returns the cloned camera
  37479. */
  37480. clone(name: string): Camera;
  37481. /**
  37482. * Gets the direction of the camera relative to a given local axis.
  37483. * @param localAxis Defines the reference axis to provide a relative direction.
  37484. * @return the direction
  37485. */
  37486. getDirection(localAxis: Vector3): Vector3;
  37487. /**
  37488. * Returns the current camera absolute rotation
  37489. */
  37490. get absoluteRotation(): Quaternion;
  37491. /**
  37492. * Gets the direction of the camera relative to a given local axis into a passed vector.
  37493. * @param localAxis Defines the reference axis to provide a relative direction.
  37494. * @param result Defines the vector to store the result in
  37495. */
  37496. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  37497. /**
  37498. * Gets a camera constructor for a given camera type
  37499. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  37500. * @param name The name of the camera the result will be able to instantiate
  37501. * @param scene The scene the result will construct the camera in
  37502. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  37503. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  37504. * @returns a factory method to construc the camera
  37505. */
  37506. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  37507. /**
  37508. * Compute the world matrix of the camera.
  37509. * @returns the camera world matrix
  37510. */
  37511. computeWorldMatrix(): Matrix;
  37512. /**
  37513. * Parse a JSON and creates the camera from the parsed information
  37514. * @param parsedCamera The JSON to parse
  37515. * @param scene The scene to instantiate the camera in
  37516. * @returns the newly constructed camera
  37517. */
  37518. static Parse(parsedCamera: any, scene: Scene): Camera;
  37519. }
  37520. }
  37521. declare module BABYLON {
  37522. /**
  37523. * PostProcessManager is used to manage one or more post processes or post process pipelines
  37524. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  37525. */
  37526. export class PostProcessManager {
  37527. private _scene;
  37528. private _indexBuffer;
  37529. private _vertexBuffers;
  37530. /**
  37531. * Creates a new instance PostProcess
  37532. * @param scene The scene that the post process is associated with.
  37533. */
  37534. constructor(scene: Scene);
  37535. private _prepareBuffers;
  37536. private _buildIndexBuffer;
  37537. /**
  37538. * Rebuilds the vertex buffers of the manager.
  37539. * @hidden
  37540. */
  37541. _rebuild(): void;
  37542. /**
  37543. * Prepares a frame to be run through a post process.
  37544. * @param sourceTexture The input texture to the post procesess. (default: null)
  37545. * @param postProcesses An array of post processes to be run. (default: null)
  37546. * @returns True if the post processes were able to be run.
  37547. * @hidden
  37548. */
  37549. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  37550. /**
  37551. * Manually render a set of post processes to a texture.
  37552. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  37553. * @param postProcesses An array of post processes to be run.
  37554. * @param targetTexture The target texture to render to.
  37555. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  37556. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  37557. * @param lodLevel defines which lod of the texture to render to
  37558. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  37559. */
  37560. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  37561. /**
  37562. * Finalize the result of the output of the postprocesses.
  37563. * @param doNotPresent If true the result will not be displayed to the screen.
  37564. * @param targetTexture The target texture to render to.
  37565. * @param faceIndex The index of the face to bind the target texture to.
  37566. * @param postProcesses The array of post processes to render.
  37567. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  37568. * @hidden
  37569. */
  37570. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  37571. /**
  37572. * Disposes of the post process manager.
  37573. */
  37574. dispose(): void;
  37575. }
  37576. }
  37577. declare module BABYLON {
  37578. /**
  37579. * This Helps creating a texture that will be created from a camera in your scene.
  37580. * It is basically a dynamic texture that could be used to create special effects for instance.
  37581. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  37582. */
  37583. export class RenderTargetTexture extends Texture {
  37584. /**
  37585. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  37586. */
  37587. static readonly REFRESHRATE_RENDER_ONCE: number;
  37588. /**
  37589. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  37590. */
  37591. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37592. /**
  37593. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  37594. * the central point of your effect and can save a lot of performances.
  37595. */
  37596. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37597. /**
  37598. * Use this predicate to dynamically define the list of mesh you want to render.
  37599. * If set, the renderList property will be overwritten.
  37600. */
  37601. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  37602. private _renderList;
  37603. /**
  37604. * Use this list to define the list of mesh you want to render.
  37605. */
  37606. get renderList(): Nullable<Array<AbstractMesh>>;
  37607. set renderList(value: Nullable<Array<AbstractMesh>>);
  37608. /**
  37609. * Use this function to overload the renderList array at rendering time.
  37610. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  37611. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  37612. * the cube (if the RTT is a cube, else layerOrFace=0).
  37613. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  37614. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  37615. * hold dummy elements!
  37616. */
  37617. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  37618. private _hookArray;
  37619. /**
  37620. * Define if particles should be rendered in your texture.
  37621. */
  37622. renderParticles: boolean;
  37623. /**
  37624. * Define if sprites should be rendered in your texture.
  37625. */
  37626. renderSprites: boolean;
  37627. /**
  37628. * Define the camera used to render the texture.
  37629. */
  37630. activeCamera: Nullable<Camera>;
  37631. /**
  37632. * Override the mesh isReady function with your own one.
  37633. */
  37634. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  37635. /**
  37636. * Override the render function of the texture with your own one.
  37637. */
  37638. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  37639. /**
  37640. * Define if camera post processes should be use while rendering the texture.
  37641. */
  37642. useCameraPostProcesses: boolean;
  37643. /**
  37644. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  37645. */
  37646. ignoreCameraViewport: boolean;
  37647. private _postProcessManager;
  37648. private _postProcesses;
  37649. private _resizeObserver;
  37650. /**
  37651. * An event triggered when the texture is unbind.
  37652. */
  37653. onBeforeBindObservable: Observable<RenderTargetTexture>;
  37654. /**
  37655. * An event triggered when the texture is unbind.
  37656. */
  37657. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  37658. private _onAfterUnbindObserver;
  37659. /**
  37660. * Set a after unbind callback in the texture.
  37661. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  37662. */
  37663. set onAfterUnbind(callback: () => void);
  37664. /**
  37665. * An event triggered before rendering the texture
  37666. */
  37667. onBeforeRenderObservable: Observable<number>;
  37668. private _onBeforeRenderObserver;
  37669. /**
  37670. * Set a before render callback in the texture.
  37671. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  37672. */
  37673. set onBeforeRender(callback: (faceIndex: number) => void);
  37674. /**
  37675. * An event triggered after rendering the texture
  37676. */
  37677. onAfterRenderObservable: Observable<number>;
  37678. private _onAfterRenderObserver;
  37679. /**
  37680. * Set a after render callback in the texture.
  37681. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  37682. */
  37683. set onAfterRender(callback: (faceIndex: number) => void);
  37684. /**
  37685. * An event triggered after the texture clear
  37686. */
  37687. onClearObservable: Observable<Engine>;
  37688. private _onClearObserver;
  37689. /**
  37690. * Set a clear callback in the texture.
  37691. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  37692. */
  37693. set onClear(callback: (Engine: Engine) => void);
  37694. /**
  37695. * An event triggered when the texture is resized.
  37696. */
  37697. onResizeObservable: Observable<RenderTargetTexture>;
  37698. /**
  37699. * Define the clear color of the Render Target if it should be different from the scene.
  37700. */
  37701. clearColor: Color4;
  37702. protected _size: number | {
  37703. width: number;
  37704. height: number;
  37705. layers?: number;
  37706. };
  37707. protected _initialSizeParameter: number | {
  37708. width: number;
  37709. height: number;
  37710. } | {
  37711. ratio: number;
  37712. };
  37713. protected _sizeRatio: Nullable<number>;
  37714. /** @hidden */
  37715. _generateMipMaps: boolean;
  37716. protected _renderingManager: RenderingManager;
  37717. /** @hidden */
  37718. _waitingRenderList?: string[];
  37719. protected _doNotChangeAspectRatio: boolean;
  37720. protected _currentRefreshId: number;
  37721. protected _refreshRate: number;
  37722. protected _textureMatrix: Matrix;
  37723. protected _samples: number;
  37724. protected _renderTargetOptions: RenderTargetCreationOptions;
  37725. /**
  37726. * Gets render target creation options that were used.
  37727. */
  37728. get renderTargetOptions(): RenderTargetCreationOptions;
  37729. protected _onRatioRescale(): void;
  37730. /**
  37731. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  37732. * It must define where the camera used to render the texture is set
  37733. */
  37734. boundingBoxPosition: Vector3;
  37735. private _boundingBoxSize;
  37736. /**
  37737. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  37738. * When defined, the cubemap will switch to local mode
  37739. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37740. * @example https://www.babylonjs-playground.com/#RNASML
  37741. */
  37742. set boundingBoxSize(value: Vector3);
  37743. get boundingBoxSize(): Vector3;
  37744. /**
  37745. * In case the RTT has been created with a depth texture, get the associated
  37746. * depth texture.
  37747. * Otherwise, return null.
  37748. */
  37749. get depthStencilTexture(): Nullable<InternalTexture>;
  37750. /**
  37751. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  37752. * or used a shadow, depth texture...
  37753. * @param name The friendly name of the texture
  37754. * @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)
  37755. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  37756. * @param generateMipMaps True if mip maps need to be generated after render.
  37757. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  37758. * @param type The type of the buffer in the RTT (int, half float, float...)
  37759. * @param isCube True if a cube texture needs to be created
  37760. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  37761. * @param generateDepthBuffer True to generate a depth buffer
  37762. * @param generateStencilBuffer True to generate a stencil buffer
  37763. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  37764. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  37765. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37766. */
  37767. constructor(name: string, size: number | {
  37768. width: number;
  37769. height: number;
  37770. layers?: number;
  37771. } | {
  37772. ratio: number;
  37773. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  37774. /**
  37775. * Creates a depth stencil texture.
  37776. * This is only available in WebGL 2 or with the depth texture extension available.
  37777. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  37778. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  37779. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  37780. */
  37781. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  37782. private _processSizeParameter;
  37783. /**
  37784. * Define the number of samples to use in case of MSAA.
  37785. * It defaults to one meaning no MSAA has been enabled.
  37786. */
  37787. get samples(): number;
  37788. set samples(value: number);
  37789. /**
  37790. * Resets the refresh counter of the texture and start bak from scratch.
  37791. * Could be useful to regenerate the texture if it is setup to render only once.
  37792. */
  37793. resetRefreshCounter(): void;
  37794. /**
  37795. * Define the refresh rate of the texture or the rendering frequency.
  37796. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  37797. */
  37798. get refreshRate(): number;
  37799. set refreshRate(value: number);
  37800. /**
  37801. * Adds a post process to the render target rendering passes.
  37802. * @param postProcess define the post process to add
  37803. */
  37804. addPostProcess(postProcess: PostProcess): void;
  37805. /**
  37806. * Clear all the post processes attached to the render target
  37807. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  37808. */
  37809. clearPostProcesses(dispose?: boolean): void;
  37810. /**
  37811. * Remove one of the post process from the list of attached post processes to the texture
  37812. * @param postProcess define the post process to remove from the list
  37813. */
  37814. removePostProcess(postProcess: PostProcess): void;
  37815. /** @hidden */
  37816. _shouldRender(): boolean;
  37817. /**
  37818. * Gets the actual render size of the texture.
  37819. * @returns the width of the render size
  37820. */
  37821. getRenderSize(): number;
  37822. /**
  37823. * Gets the actual render width of the texture.
  37824. * @returns the width of the render size
  37825. */
  37826. getRenderWidth(): number;
  37827. /**
  37828. * Gets the actual render height of the texture.
  37829. * @returns the height of the render size
  37830. */
  37831. getRenderHeight(): number;
  37832. /**
  37833. * Gets the actual number of layers of the texture.
  37834. * @returns the number of layers
  37835. */
  37836. getRenderLayers(): number;
  37837. /**
  37838. * Get if the texture can be rescaled or not.
  37839. */
  37840. get canRescale(): boolean;
  37841. /**
  37842. * Resize the texture using a ratio.
  37843. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  37844. */
  37845. scale(ratio: number): void;
  37846. /**
  37847. * Get the texture reflection matrix used to rotate/transform the reflection.
  37848. * @returns the reflection matrix
  37849. */
  37850. getReflectionTextureMatrix(): Matrix;
  37851. /**
  37852. * Resize the texture to a new desired size.
  37853. * Be carrefull as it will recreate all the data in the new texture.
  37854. * @param size Define the new size. It can be:
  37855. * - a number for squared texture,
  37856. * - an object containing { width: number, height: number }
  37857. * - or an object containing a ratio { ratio: number }
  37858. */
  37859. resize(size: number | {
  37860. width: number;
  37861. height: number;
  37862. } | {
  37863. ratio: number;
  37864. }): void;
  37865. private _defaultRenderListPrepared;
  37866. /**
  37867. * Renders all the objects from the render list into the texture.
  37868. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  37869. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  37870. */
  37871. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  37872. private _bestReflectionRenderTargetDimension;
  37873. private _prepareRenderingManager;
  37874. /**
  37875. * @hidden
  37876. * @param faceIndex face index to bind to if this is a cubetexture
  37877. * @param layer defines the index of the texture to bind in the array
  37878. */
  37879. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  37880. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37881. private renderToTarget;
  37882. /**
  37883. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37884. * This allowed control for front to back rendering or reversly depending of the special needs.
  37885. *
  37886. * @param renderingGroupId The rendering group id corresponding to its index
  37887. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37888. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37889. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37890. */
  37891. 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;
  37892. /**
  37893. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37894. *
  37895. * @param renderingGroupId The rendering group id corresponding to its index
  37896. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37897. */
  37898. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  37899. /**
  37900. * Clones the texture.
  37901. * @returns the cloned texture
  37902. */
  37903. clone(): RenderTargetTexture;
  37904. /**
  37905. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  37906. * @returns The JSON representation of the texture
  37907. */
  37908. serialize(): any;
  37909. /**
  37910. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  37911. */
  37912. disposeFramebufferObjects(): void;
  37913. /**
  37914. * Dispose the texture and release its associated resources.
  37915. */
  37916. dispose(): void;
  37917. /** @hidden */
  37918. _rebuild(): void;
  37919. /**
  37920. * Clear the info related to rendering groups preventing retention point in material dispose.
  37921. */
  37922. freeRenderingGroups(): void;
  37923. /**
  37924. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  37925. * @returns the view count
  37926. */
  37927. getViewCount(): number;
  37928. }
  37929. }
  37930. declare module BABYLON {
  37931. /**
  37932. * Options to be used when creating an effect.
  37933. */
  37934. export interface IEffectCreationOptions {
  37935. /**
  37936. * Atrributes that will be used in the shader.
  37937. */
  37938. attributes: string[];
  37939. /**
  37940. * Uniform varible names that will be set in the shader.
  37941. */
  37942. uniformsNames: string[];
  37943. /**
  37944. * Uniform buffer variable names that will be set in the shader.
  37945. */
  37946. uniformBuffersNames: string[];
  37947. /**
  37948. * Sampler texture variable names that will be set in the shader.
  37949. */
  37950. samplers: string[];
  37951. /**
  37952. * Define statements that will be set in the shader.
  37953. */
  37954. defines: any;
  37955. /**
  37956. * Possible fallbacks for this effect to improve performance when needed.
  37957. */
  37958. fallbacks: Nullable<IEffectFallbacks>;
  37959. /**
  37960. * Callback that will be called when the shader is compiled.
  37961. */
  37962. onCompiled: Nullable<(effect: Effect) => void>;
  37963. /**
  37964. * Callback that will be called if an error occurs during shader compilation.
  37965. */
  37966. onError: Nullable<(effect: Effect, errors: string) => void>;
  37967. /**
  37968. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37969. */
  37970. indexParameters?: any;
  37971. /**
  37972. * Max number of lights that can be used in the shader.
  37973. */
  37974. maxSimultaneousLights?: number;
  37975. /**
  37976. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37977. */
  37978. transformFeedbackVaryings?: Nullable<string[]>;
  37979. /**
  37980. * 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
  37981. */
  37982. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37983. /**
  37984. * Is this effect rendering to several color attachments ?
  37985. */
  37986. multiTarget?: boolean;
  37987. }
  37988. /**
  37989. * Effect containing vertex and fragment shader that can be executed on an object.
  37990. */
  37991. export class Effect implements IDisposable {
  37992. /**
  37993. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37994. */
  37995. static ShadersRepository: string;
  37996. /**
  37997. * Enable logging of the shader code when a compilation error occurs
  37998. */
  37999. static LogShaderCodeOnCompilationError: boolean;
  38000. /**
  38001. * Name of the effect.
  38002. */
  38003. name: any;
  38004. /**
  38005. * String container all the define statements that should be set on the shader.
  38006. */
  38007. defines: string;
  38008. /**
  38009. * Callback that will be called when the shader is compiled.
  38010. */
  38011. onCompiled: Nullable<(effect: Effect) => void>;
  38012. /**
  38013. * Callback that will be called if an error occurs during shader compilation.
  38014. */
  38015. onError: Nullable<(effect: Effect, errors: string) => void>;
  38016. /**
  38017. * Callback that will be called when effect is bound.
  38018. */
  38019. onBind: Nullable<(effect: Effect) => void>;
  38020. /**
  38021. * Unique ID of the effect.
  38022. */
  38023. uniqueId: number;
  38024. /**
  38025. * Observable that will be called when the shader is compiled.
  38026. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38027. */
  38028. onCompileObservable: Observable<Effect>;
  38029. /**
  38030. * Observable that will be called if an error occurs during shader compilation.
  38031. */
  38032. onErrorObservable: Observable<Effect>;
  38033. /** @hidden */
  38034. _onBindObservable: Nullable<Observable<Effect>>;
  38035. /**
  38036. * @hidden
  38037. * Specifies if the effect was previously ready
  38038. */
  38039. _wasPreviouslyReady: boolean;
  38040. /**
  38041. * Observable that will be called when effect is bound.
  38042. */
  38043. get onBindObservable(): Observable<Effect>;
  38044. /** @hidden */
  38045. _bonesComputationForcedToCPU: boolean;
  38046. /** @hidden */
  38047. _multiTarget: boolean;
  38048. private static _uniqueIdSeed;
  38049. private _engine;
  38050. private _uniformBuffersNames;
  38051. private _uniformBuffersNamesList;
  38052. private _uniformsNames;
  38053. private _samplerList;
  38054. private _samplers;
  38055. private _isReady;
  38056. private _compilationError;
  38057. private _allFallbacksProcessed;
  38058. private _attributesNames;
  38059. private _attributes;
  38060. private _attributeLocationByName;
  38061. private _uniforms;
  38062. /**
  38063. * Key for the effect.
  38064. * @hidden
  38065. */
  38066. _key: string;
  38067. private _indexParameters;
  38068. private _fallbacks;
  38069. private _vertexSourceCode;
  38070. private _fragmentSourceCode;
  38071. private _vertexSourceCodeOverride;
  38072. private _fragmentSourceCodeOverride;
  38073. private _transformFeedbackVaryings;
  38074. private _rawVertexSourceCode;
  38075. private _rawFragmentSourceCode;
  38076. /**
  38077. * Compiled shader to webGL program.
  38078. * @hidden
  38079. */
  38080. _pipelineContext: Nullable<IPipelineContext>;
  38081. private _valueCache;
  38082. private static _baseCache;
  38083. /**
  38084. * Instantiates an effect.
  38085. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38086. * @param baseName Name of the effect.
  38087. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38088. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38089. * @param samplers List of sampler variables that will be passed to the shader.
  38090. * @param engine Engine to be used to render the effect
  38091. * @param defines Define statements to be added to the shader.
  38092. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38093. * @param onCompiled Callback that will be called when the shader is compiled.
  38094. * @param onError Callback that will be called if an error occurs during shader compilation.
  38095. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38096. */
  38097. 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);
  38098. private _useFinalCode;
  38099. /**
  38100. * Unique key for this effect
  38101. */
  38102. get key(): string;
  38103. /**
  38104. * If the effect has been compiled and prepared.
  38105. * @returns if the effect is compiled and prepared.
  38106. */
  38107. isReady(): boolean;
  38108. private _isReadyInternal;
  38109. /**
  38110. * The engine the effect was initialized with.
  38111. * @returns the engine.
  38112. */
  38113. getEngine(): Engine;
  38114. /**
  38115. * The pipeline context for this effect
  38116. * @returns the associated pipeline context
  38117. */
  38118. getPipelineContext(): Nullable<IPipelineContext>;
  38119. /**
  38120. * The set of names of attribute variables for the shader.
  38121. * @returns An array of attribute names.
  38122. */
  38123. getAttributesNames(): string[];
  38124. /**
  38125. * Returns the attribute at the given index.
  38126. * @param index The index of the attribute.
  38127. * @returns The location of the attribute.
  38128. */
  38129. getAttributeLocation(index: number): number;
  38130. /**
  38131. * Returns the attribute based on the name of the variable.
  38132. * @param name of the attribute to look up.
  38133. * @returns the attribute location.
  38134. */
  38135. getAttributeLocationByName(name: string): number;
  38136. /**
  38137. * The number of attributes.
  38138. * @returns the numnber of attributes.
  38139. */
  38140. getAttributesCount(): number;
  38141. /**
  38142. * Gets the index of a uniform variable.
  38143. * @param uniformName of the uniform to look up.
  38144. * @returns the index.
  38145. */
  38146. getUniformIndex(uniformName: string): number;
  38147. /**
  38148. * Returns the attribute based on the name of the variable.
  38149. * @param uniformName of the uniform to look up.
  38150. * @returns the location of the uniform.
  38151. */
  38152. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38153. /**
  38154. * Returns an array of sampler variable names
  38155. * @returns The array of sampler variable names.
  38156. */
  38157. getSamplers(): string[];
  38158. /**
  38159. * Returns an array of uniform variable names
  38160. * @returns The array of uniform variable names.
  38161. */
  38162. getUniformNames(): string[];
  38163. /**
  38164. * Returns an array of uniform buffer variable names
  38165. * @returns The array of uniform buffer variable names.
  38166. */
  38167. getUniformBuffersNames(): string[];
  38168. /**
  38169. * Returns the index parameters used to create the effect
  38170. * @returns The index parameters object
  38171. */
  38172. getIndexParameters(): any;
  38173. /**
  38174. * The error from the last compilation.
  38175. * @returns the error string.
  38176. */
  38177. getCompilationError(): string;
  38178. /**
  38179. * Gets a boolean indicating that all fallbacks were used during compilation
  38180. * @returns true if all fallbacks were used
  38181. */
  38182. allFallbacksProcessed(): boolean;
  38183. /**
  38184. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  38185. * @param func The callback to be used.
  38186. */
  38187. executeWhenCompiled(func: (effect: Effect) => void): void;
  38188. private _checkIsReady;
  38189. private _loadShader;
  38190. /**
  38191. * Gets the vertex shader source code of this effect
  38192. */
  38193. get vertexSourceCode(): string;
  38194. /**
  38195. * Gets the fragment shader source code of this effect
  38196. */
  38197. get fragmentSourceCode(): string;
  38198. /**
  38199. * Gets the vertex shader source code before it has been processed by the preprocessor
  38200. */
  38201. get rawVertexSourceCode(): string;
  38202. /**
  38203. * Gets the fragment shader source code before it has been processed by the preprocessor
  38204. */
  38205. get rawFragmentSourceCode(): string;
  38206. /**
  38207. * Recompiles the webGL program
  38208. * @param vertexSourceCode The source code for the vertex shader.
  38209. * @param fragmentSourceCode The source code for the fragment shader.
  38210. * @param onCompiled Callback called when completed.
  38211. * @param onError Callback called on error.
  38212. * @hidden
  38213. */
  38214. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  38215. /**
  38216. * Prepares the effect
  38217. * @hidden
  38218. */
  38219. _prepareEffect(): void;
  38220. private _getShaderCodeAndErrorLine;
  38221. private _processCompilationErrors;
  38222. /**
  38223. * Checks if the effect is supported. (Must be called after compilation)
  38224. */
  38225. get isSupported(): boolean;
  38226. /**
  38227. * Binds a texture to the engine to be used as output of the shader.
  38228. * @param channel Name of the output variable.
  38229. * @param texture Texture to bind.
  38230. * @hidden
  38231. */
  38232. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  38233. /**
  38234. * Sets a texture on the engine to be used in the shader.
  38235. * @param channel Name of the sampler variable.
  38236. * @param texture Texture to set.
  38237. */
  38238. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  38239. /**
  38240. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  38241. * @param channel Name of the sampler variable.
  38242. * @param texture Texture to set.
  38243. */
  38244. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  38245. /**
  38246. * Sets an array of textures on the engine to be used in the shader.
  38247. * @param channel Name of the variable.
  38248. * @param textures Textures to set.
  38249. */
  38250. setTextureArray(channel: string, textures: ThinTexture[]): void;
  38251. /**
  38252. * 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)
  38253. * @param channel Name of the sampler variable.
  38254. * @param postProcess Post process to get the input texture from.
  38255. */
  38256. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  38257. /**
  38258. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  38259. * 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)
  38260. * @param channel Name of the sampler variable.
  38261. * @param postProcess Post process to get the output texture from.
  38262. */
  38263. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  38264. /** @hidden */
  38265. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  38266. /** @hidden */
  38267. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  38268. /** @hidden */
  38269. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  38270. /** @hidden */
  38271. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  38272. /**
  38273. * Binds a buffer to a uniform.
  38274. * @param buffer Buffer to bind.
  38275. * @param name Name of the uniform variable to bind to.
  38276. */
  38277. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  38278. /**
  38279. * Binds block to a uniform.
  38280. * @param blockName Name of the block to bind.
  38281. * @param index Index to bind.
  38282. */
  38283. bindUniformBlock(blockName: string, index: number): void;
  38284. /**
  38285. * Sets an interger value on a uniform variable.
  38286. * @param uniformName Name of the variable.
  38287. * @param value Value to be set.
  38288. * @returns this effect.
  38289. */
  38290. setInt(uniformName: string, value: number): Effect;
  38291. /**
  38292. * Sets an int array on a uniform variable.
  38293. * @param uniformName Name of the variable.
  38294. * @param array array to be set.
  38295. * @returns this effect.
  38296. */
  38297. setIntArray(uniformName: string, array: Int32Array): Effect;
  38298. /**
  38299. * 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)
  38300. * @param uniformName Name of the variable.
  38301. * @param array array to be set.
  38302. * @returns this effect.
  38303. */
  38304. setIntArray2(uniformName: string, array: Int32Array): Effect;
  38305. /**
  38306. * 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)
  38307. * @param uniformName Name of the variable.
  38308. * @param array array to be set.
  38309. * @returns this effect.
  38310. */
  38311. setIntArray3(uniformName: string, array: Int32Array): Effect;
  38312. /**
  38313. * 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)
  38314. * @param uniformName Name of the variable.
  38315. * @param array array to be set.
  38316. * @returns this effect.
  38317. */
  38318. setIntArray4(uniformName: string, array: Int32Array): Effect;
  38319. /**
  38320. * Sets an float array on a uniform variable.
  38321. * @param uniformName Name of the variable.
  38322. * @param array array to be set.
  38323. * @returns this effect.
  38324. */
  38325. setFloatArray(uniformName: string, array: Float32Array): Effect;
  38326. /**
  38327. * 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)
  38328. * @param uniformName Name of the variable.
  38329. * @param array array to be set.
  38330. * @returns this effect.
  38331. */
  38332. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  38333. /**
  38334. * 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)
  38335. * @param uniformName Name of the variable.
  38336. * @param array array to be set.
  38337. * @returns this effect.
  38338. */
  38339. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  38340. /**
  38341. * 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)
  38342. * @param uniformName Name of the variable.
  38343. * @param array array to be set.
  38344. * @returns this effect.
  38345. */
  38346. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  38347. /**
  38348. * Sets an array on a uniform variable.
  38349. * @param uniformName Name of the variable.
  38350. * @param array array to be set.
  38351. * @returns this effect.
  38352. */
  38353. setArray(uniformName: string, array: number[]): Effect;
  38354. /**
  38355. * 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)
  38356. * @param uniformName Name of the variable.
  38357. * @param array array to be set.
  38358. * @returns this effect.
  38359. */
  38360. setArray2(uniformName: string, array: number[]): Effect;
  38361. /**
  38362. * 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)
  38363. * @param uniformName Name of the variable.
  38364. * @param array array to be set.
  38365. * @returns this effect.
  38366. */
  38367. setArray3(uniformName: string, array: number[]): Effect;
  38368. /**
  38369. * 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)
  38370. * @param uniformName Name of the variable.
  38371. * @param array array to be set.
  38372. * @returns this effect.
  38373. */
  38374. setArray4(uniformName: string, array: number[]): Effect;
  38375. /**
  38376. * Sets matrices on a uniform variable.
  38377. * @param uniformName Name of the variable.
  38378. * @param matrices matrices to be set.
  38379. * @returns this effect.
  38380. */
  38381. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  38382. /**
  38383. * Sets matrix on a uniform variable.
  38384. * @param uniformName Name of the variable.
  38385. * @param matrix matrix to be set.
  38386. * @returns this effect.
  38387. */
  38388. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  38389. /**
  38390. * 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)
  38391. * @param uniformName Name of the variable.
  38392. * @param matrix matrix to be set.
  38393. * @returns this effect.
  38394. */
  38395. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38396. /**
  38397. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  38398. * @param uniformName Name of the variable.
  38399. * @param matrix matrix to be set.
  38400. * @returns this effect.
  38401. */
  38402. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38403. /**
  38404. * Sets a float on a uniform variable.
  38405. * @param uniformName Name of the variable.
  38406. * @param value value to be set.
  38407. * @returns this effect.
  38408. */
  38409. setFloat(uniformName: string, value: number): Effect;
  38410. /**
  38411. * Sets a boolean on a uniform variable.
  38412. * @param uniformName Name of the variable.
  38413. * @param bool value to be set.
  38414. * @returns this effect.
  38415. */
  38416. setBool(uniformName: string, bool: boolean): Effect;
  38417. /**
  38418. * Sets a Vector2 on a uniform variable.
  38419. * @param uniformName Name of the variable.
  38420. * @param vector2 vector2 to be set.
  38421. * @returns this effect.
  38422. */
  38423. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  38424. /**
  38425. * Sets a float2 on a uniform variable.
  38426. * @param uniformName Name of the variable.
  38427. * @param x First float in float2.
  38428. * @param y Second float in float2.
  38429. * @returns this effect.
  38430. */
  38431. setFloat2(uniformName: string, x: number, y: number): Effect;
  38432. /**
  38433. * Sets a Vector3 on a uniform variable.
  38434. * @param uniformName Name of the variable.
  38435. * @param vector3 Value to be set.
  38436. * @returns this effect.
  38437. */
  38438. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  38439. /**
  38440. * Sets a float3 on a uniform variable.
  38441. * @param uniformName Name of the variable.
  38442. * @param x First float in float3.
  38443. * @param y Second float in float3.
  38444. * @param z Third float in float3.
  38445. * @returns this effect.
  38446. */
  38447. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  38448. /**
  38449. * Sets a Vector4 on a uniform variable.
  38450. * @param uniformName Name of the variable.
  38451. * @param vector4 Value to be set.
  38452. * @returns this effect.
  38453. */
  38454. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  38455. /**
  38456. * Sets a float4 on a uniform variable.
  38457. * @param uniformName Name of the variable.
  38458. * @param x First float in float4.
  38459. * @param y Second float in float4.
  38460. * @param z Third float in float4.
  38461. * @param w Fourth float in float4.
  38462. * @returns this effect.
  38463. */
  38464. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  38465. /**
  38466. * Sets a Color3 on a uniform variable.
  38467. * @param uniformName Name of the variable.
  38468. * @param color3 Value to be set.
  38469. * @returns this effect.
  38470. */
  38471. setColor3(uniformName: string, color3: IColor3Like): Effect;
  38472. /**
  38473. * Sets a Color4 on a uniform variable.
  38474. * @param uniformName Name of the variable.
  38475. * @param color3 Value to be set.
  38476. * @param alpha Alpha value to be set.
  38477. * @returns this effect.
  38478. */
  38479. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  38480. /**
  38481. * Sets a Color4 on a uniform variable
  38482. * @param uniformName defines the name of the variable
  38483. * @param color4 defines the value to be set
  38484. * @returns this effect.
  38485. */
  38486. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  38487. /** Release all associated resources */
  38488. dispose(): void;
  38489. /**
  38490. * This function will add a new shader to the shader store
  38491. * @param name the name of the shader
  38492. * @param pixelShader optional pixel shader content
  38493. * @param vertexShader optional vertex shader content
  38494. */
  38495. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  38496. /**
  38497. * Store of each shader (The can be looked up using effect.key)
  38498. */
  38499. static ShadersStore: {
  38500. [key: string]: string;
  38501. };
  38502. /**
  38503. * Store of each included file for a shader (The can be looked up using effect.key)
  38504. */
  38505. static IncludesShadersStore: {
  38506. [key: string]: string;
  38507. };
  38508. /**
  38509. * Resets the cache of effects.
  38510. */
  38511. static ResetCache(): void;
  38512. }
  38513. }
  38514. declare module BABYLON {
  38515. /**
  38516. * Interface used to describe the capabilities of the engine relatively to the current browser
  38517. */
  38518. export interface EngineCapabilities {
  38519. /** Maximum textures units per fragment shader */
  38520. maxTexturesImageUnits: number;
  38521. /** Maximum texture units per vertex shader */
  38522. maxVertexTextureImageUnits: number;
  38523. /** Maximum textures units in the entire pipeline */
  38524. maxCombinedTexturesImageUnits: number;
  38525. /** Maximum texture size */
  38526. maxTextureSize: number;
  38527. /** Maximum texture samples */
  38528. maxSamples?: number;
  38529. /** Maximum cube texture size */
  38530. maxCubemapTextureSize: number;
  38531. /** Maximum render texture size */
  38532. maxRenderTextureSize: number;
  38533. /** Maximum number of vertex attributes */
  38534. maxVertexAttribs: number;
  38535. /** Maximum number of varyings */
  38536. maxVaryingVectors: number;
  38537. /** Maximum number of uniforms per vertex shader */
  38538. maxVertexUniformVectors: number;
  38539. /** Maximum number of uniforms per fragment shader */
  38540. maxFragmentUniformVectors: number;
  38541. /** Defines if standard derivates (dx/dy) are supported */
  38542. standardDerivatives: boolean;
  38543. /** Defines if s3tc texture compression is supported */
  38544. s3tc?: WEBGL_compressed_texture_s3tc;
  38545. /** Defines if pvrtc texture compression is supported */
  38546. pvrtc: any;
  38547. /** Defines if etc1 texture compression is supported */
  38548. etc1: any;
  38549. /** Defines if etc2 texture compression is supported */
  38550. etc2: any;
  38551. /** Defines if astc texture compression is supported */
  38552. astc: any;
  38553. /** Defines if bptc texture compression is supported */
  38554. bptc: any;
  38555. /** Defines if float textures are supported */
  38556. textureFloat: boolean;
  38557. /** Defines if vertex array objects are supported */
  38558. vertexArrayObject: boolean;
  38559. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38560. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38561. /** Gets the maximum level of anisotropy supported */
  38562. maxAnisotropy: number;
  38563. /** Defines if instancing is supported */
  38564. instancedArrays: boolean;
  38565. /** Defines if 32 bits indices are supported */
  38566. uintIndices: boolean;
  38567. /** Defines if high precision shaders are supported */
  38568. highPrecisionShaderSupported: boolean;
  38569. /** Defines if depth reading in the fragment shader is supported */
  38570. fragmentDepthSupported: boolean;
  38571. /** Defines if float texture linear filtering is supported*/
  38572. textureFloatLinearFiltering: boolean;
  38573. /** Defines if rendering to float textures is supported */
  38574. textureFloatRender: boolean;
  38575. /** Defines if half float textures are supported*/
  38576. textureHalfFloat: boolean;
  38577. /** Defines if half float texture linear filtering is supported*/
  38578. textureHalfFloatLinearFiltering: boolean;
  38579. /** Defines if rendering to half float textures is supported */
  38580. textureHalfFloatRender: boolean;
  38581. /** Defines if textureLOD shader command is supported */
  38582. textureLOD: boolean;
  38583. /** Defines if draw buffers extension is supported */
  38584. drawBuffersExtension: boolean;
  38585. /** Defines if depth textures are supported */
  38586. depthTextureExtension: boolean;
  38587. /** Defines if float color buffer are supported */
  38588. colorBufferFloat: boolean;
  38589. /** Gets disjoint timer query extension (null if not supported) */
  38590. timerQuery?: EXT_disjoint_timer_query;
  38591. /** Defines if timestamp can be used with timer query */
  38592. canUseTimestampForTimerQuery: boolean;
  38593. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38594. multiview?: any;
  38595. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38596. oculusMultiview?: any;
  38597. /** Function used to let the system compiles shaders in background */
  38598. parallelShaderCompile?: {
  38599. COMPLETION_STATUS_KHR: number;
  38600. };
  38601. /** Max number of texture samples for MSAA */
  38602. maxMSAASamples: number;
  38603. /** Defines if the blend min max extension is supported */
  38604. blendMinMax: boolean;
  38605. }
  38606. }
  38607. declare module BABYLON {
  38608. /**
  38609. * @hidden
  38610. **/
  38611. export class DepthCullingState {
  38612. private _isDepthTestDirty;
  38613. private _isDepthMaskDirty;
  38614. private _isDepthFuncDirty;
  38615. private _isCullFaceDirty;
  38616. private _isCullDirty;
  38617. private _isZOffsetDirty;
  38618. private _isFrontFaceDirty;
  38619. private _depthTest;
  38620. private _depthMask;
  38621. private _depthFunc;
  38622. private _cull;
  38623. private _cullFace;
  38624. private _zOffset;
  38625. private _frontFace;
  38626. /**
  38627. * Initializes the state.
  38628. */
  38629. constructor();
  38630. get isDirty(): boolean;
  38631. get zOffset(): number;
  38632. set zOffset(value: number);
  38633. get cullFace(): Nullable<number>;
  38634. set cullFace(value: Nullable<number>);
  38635. get cull(): Nullable<boolean>;
  38636. set cull(value: Nullable<boolean>);
  38637. get depthFunc(): Nullable<number>;
  38638. set depthFunc(value: Nullable<number>);
  38639. get depthMask(): boolean;
  38640. set depthMask(value: boolean);
  38641. get depthTest(): boolean;
  38642. set depthTest(value: boolean);
  38643. get frontFace(): Nullable<number>;
  38644. set frontFace(value: Nullable<number>);
  38645. reset(): void;
  38646. apply(gl: WebGLRenderingContext): void;
  38647. }
  38648. }
  38649. declare module BABYLON {
  38650. /**
  38651. * @hidden
  38652. **/
  38653. export class StencilState {
  38654. /** 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 */
  38655. static readonly ALWAYS: number;
  38656. /** Passed to stencilOperation to specify that stencil value must be kept */
  38657. static readonly KEEP: number;
  38658. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38659. static readonly REPLACE: number;
  38660. private _isStencilTestDirty;
  38661. private _isStencilMaskDirty;
  38662. private _isStencilFuncDirty;
  38663. private _isStencilOpDirty;
  38664. private _stencilTest;
  38665. private _stencilMask;
  38666. private _stencilFunc;
  38667. private _stencilFuncRef;
  38668. private _stencilFuncMask;
  38669. private _stencilOpStencilFail;
  38670. private _stencilOpDepthFail;
  38671. private _stencilOpStencilDepthPass;
  38672. get isDirty(): boolean;
  38673. get stencilFunc(): number;
  38674. set stencilFunc(value: number);
  38675. get stencilFuncRef(): number;
  38676. set stencilFuncRef(value: number);
  38677. get stencilFuncMask(): number;
  38678. set stencilFuncMask(value: number);
  38679. get stencilOpStencilFail(): number;
  38680. set stencilOpStencilFail(value: number);
  38681. get stencilOpDepthFail(): number;
  38682. set stencilOpDepthFail(value: number);
  38683. get stencilOpStencilDepthPass(): number;
  38684. set stencilOpStencilDepthPass(value: number);
  38685. get stencilMask(): number;
  38686. set stencilMask(value: number);
  38687. get stencilTest(): boolean;
  38688. set stencilTest(value: boolean);
  38689. constructor();
  38690. reset(): void;
  38691. apply(gl: WebGLRenderingContext): void;
  38692. }
  38693. }
  38694. declare module BABYLON {
  38695. /**
  38696. * @hidden
  38697. **/
  38698. export class AlphaState {
  38699. private _isAlphaBlendDirty;
  38700. private _isBlendFunctionParametersDirty;
  38701. private _isBlendEquationParametersDirty;
  38702. private _isBlendConstantsDirty;
  38703. private _alphaBlend;
  38704. private _blendFunctionParameters;
  38705. private _blendEquationParameters;
  38706. private _blendConstants;
  38707. /**
  38708. * Initializes the state.
  38709. */
  38710. constructor();
  38711. get isDirty(): boolean;
  38712. get alphaBlend(): boolean;
  38713. set alphaBlend(value: boolean);
  38714. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38715. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38716. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38717. reset(): void;
  38718. apply(gl: WebGLRenderingContext): void;
  38719. }
  38720. }
  38721. declare module BABYLON {
  38722. /** @hidden */
  38723. export class WebGLShaderProcessor implements IShaderProcessor {
  38724. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38725. }
  38726. }
  38727. declare module BABYLON {
  38728. /** @hidden */
  38729. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38730. attributeProcessor(attribute: string): string;
  38731. varyingProcessor(varying: string, isFragment: boolean): string;
  38732. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38733. }
  38734. }
  38735. declare module BABYLON {
  38736. /**
  38737. * Interface for attribute information associated with buffer instanciation
  38738. */
  38739. export interface InstancingAttributeInfo {
  38740. /**
  38741. * Name of the GLSL attribute
  38742. * if attribute index is not specified, this is used to retrieve the index from the effect
  38743. */
  38744. attributeName: string;
  38745. /**
  38746. * Index/offset of the attribute in the vertex shader
  38747. * if not specified, this will be computes from the name.
  38748. */
  38749. index?: number;
  38750. /**
  38751. * size of the attribute, 1, 2, 3 or 4
  38752. */
  38753. attributeSize: number;
  38754. /**
  38755. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38756. */
  38757. offset: number;
  38758. /**
  38759. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38760. * default to 1
  38761. */
  38762. divisor?: number;
  38763. /**
  38764. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38765. * default is FLOAT
  38766. */
  38767. attributeType?: number;
  38768. /**
  38769. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38770. */
  38771. normalized?: boolean;
  38772. }
  38773. }
  38774. declare module BABYLON {
  38775. interface ThinEngine {
  38776. /**
  38777. * Update a video texture
  38778. * @param texture defines the texture to update
  38779. * @param video defines the video element to use
  38780. * @param invertY defines if data must be stored with Y axis inverted
  38781. */
  38782. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38783. }
  38784. }
  38785. declare module BABYLON {
  38786. interface ThinEngine {
  38787. /**
  38788. * Creates a dynamic texture
  38789. * @param width defines the width of the texture
  38790. * @param height defines the height of the texture
  38791. * @param generateMipMaps defines if the engine should generate the mip levels
  38792. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38793. * @returns the dynamic texture inside an InternalTexture
  38794. */
  38795. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38796. /**
  38797. * Update the content of a dynamic texture
  38798. * @param texture defines the texture to update
  38799. * @param source defines the source containing the data
  38800. * @param invertY defines if data must be stored with Y axis inverted
  38801. * @param premulAlpha defines if alpha is stored as premultiplied
  38802. * @param format defines the format of the data
  38803. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38804. */
  38805. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38806. }
  38807. }
  38808. declare module BABYLON {
  38809. /**
  38810. * Settings for finer control over video usage
  38811. */
  38812. export interface VideoTextureSettings {
  38813. /**
  38814. * Applies `autoplay` to video, if specified
  38815. */
  38816. autoPlay?: boolean;
  38817. /**
  38818. * Applies `muted` to video, if specified
  38819. */
  38820. muted?: boolean;
  38821. /**
  38822. * Applies `loop` to video, if specified
  38823. */
  38824. loop?: boolean;
  38825. /**
  38826. * Automatically updates internal texture from video at every frame in the render loop
  38827. */
  38828. autoUpdateTexture: boolean;
  38829. /**
  38830. * Image src displayed during the video loading or until the user interacts with the video.
  38831. */
  38832. poster?: string;
  38833. }
  38834. /**
  38835. * If you want to display a video in your scene, this is the special texture for that.
  38836. * This special texture works similar to other textures, with the exception of a few parameters.
  38837. * @see https://doc.babylonjs.com/how_to/video_texture
  38838. */
  38839. export class VideoTexture extends Texture {
  38840. /**
  38841. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38842. */
  38843. readonly autoUpdateTexture: boolean;
  38844. /**
  38845. * The video instance used by the texture internally
  38846. */
  38847. readonly video: HTMLVideoElement;
  38848. private _onUserActionRequestedObservable;
  38849. /**
  38850. * Event triggerd when a dom action is required by the user to play the video.
  38851. * This happens due to recent changes in browser policies preventing video to auto start.
  38852. */
  38853. get onUserActionRequestedObservable(): Observable<Texture>;
  38854. private _generateMipMaps;
  38855. private _stillImageCaptured;
  38856. private _displayingPosterTexture;
  38857. private _settings;
  38858. private _createInternalTextureOnEvent;
  38859. private _frameId;
  38860. private _currentSrc;
  38861. /**
  38862. * Creates a video texture.
  38863. * If you want to display a video in your scene, this is the special texture for that.
  38864. * This special texture works similar to other textures, with the exception of a few parameters.
  38865. * @see https://doc.babylonjs.com/how_to/video_texture
  38866. * @param name optional name, will detect from video source, if not defined
  38867. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38868. * @param scene is obviously the current scene.
  38869. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38870. * @param invertY is false by default but can be used to invert video on Y axis
  38871. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38872. * @param settings allows finer control over video usage
  38873. */
  38874. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38875. private _getName;
  38876. private _getVideo;
  38877. private _createInternalTexture;
  38878. private reset;
  38879. /**
  38880. * @hidden Internal method to initiate `update`.
  38881. */
  38882. _rebuild(): void;
  38883. /**
  38884. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38885. */
  38886. update(): void;
  38887. /**
  38888. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38889. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38890. */
  38891. updateTexture(isVisible: boolean): void;
  38892. protected _updateInternalTexture: () => void;
  38893. /**
  38894. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38895. * @param url New url.
  38896. */
  38897. updateURL(url: string): void;
  38898. /**
  38899. * Clones the texture.
  38900. * @returns the cloned texture
  38901. */
  38902. clone(): VideoTexture;
  38903. /**
  38904. * Dispose the texture and release its associated resources.
  38905. */
  38906. dispose(): void;
  38907. /**
  38908. * Creates a video texture straight from a stream.
  38909. * @param scene Define the scene the texture should be created in
  38910. * @param stream Define the stream the texture should be created from
  38911. * @returns The created video texture as a promise
  38912. */
  38913. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38914. /**
  38915. * Creates a video texture straight from your WebCam video feed.
  38916. * @param scene Define the scene the texture should be created in
  38917. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38918. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38919. * @returns The created video texture as a promise
  38920. */
  38921. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38922. minWidth: number;
  38923. maxWidth: number;
  38924. minHeight: number;
  38925. maxHeight: number;
  38926. deviceId: string;
  38927. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38928. /**
  38929. * Creates a video texture straight from your WebCam video feed.
  38930. * @param scene Define the scene the texture should be created in
  38931. * @param onReady Define a callback to triggered once the texture will be ready
  38932. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38933. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38934. */
  38935. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38936. minWidth: number;
  38937. maxWidth: number;
  38938. minHeight: number;
  38939. maxHeight: number;
  38940. deviceId: string;
  38941. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38942. }
  38943. }
  38944. declare module BABYLON {
  38945. /**
  38946. * Defines the interface used by objects working like Scene
  38947. * @hidden
  38948. */
  38949. export interface ISceneLike {
  38950. _addPendingData(data: any): void;
  38951. _removePendingData(data: any): void;
  38952. offlineProvider: IOfflineProvider;
  38953. }
  38954. /**
  38955. * Information about the current host
  38956. */
  38957. export interface HostInformation {
  38958. /**
  38959. * Defines if the current host is a mobile
  38960. */
  38961. isMobile: boolean;
  38962. }
  38963. /** Interface defining initialization parameters for Engine class */
  38964. export interface EngineOptions extends WebGLContextAttributes {
  38965. /**
  38966. * Defines if the engine should no exceed a specified device ratio
  38967. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38968. */
  38969. limitDeviceRatio?: number;
  38970. /**
  38971. * Defines if webvr should be enabled automatically
  38972. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38973. */
  38974. autoEnableWebVR?: boolean;
  38975. /**
  38976. * Defines if webgl2 should be turned off even if supported
  38977. * @see https://doc.babylonjs.com/features/webgl2
  38978. */
  38979. disableWebGL2Support?: boolean;
  38980. /**
  38981. * Defines if webaudio should be initialized as well
  38982. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38983. */
  38984. audioEngine?: boolean;
  38985. /**
  38986. * Defines if animations should run using a deterministic lock step
  38987. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38988. */
  38989. deterministicLockstep?: boolean;
  38990. /** Defines the maximum steps to use with deterministic lock step mode */
  38991. lockstepMaxSteps?: number;
  38992. /** Defines the seconds between each deterministic lock step */
  38993. timeStep?: number;
  38994. /**
  38995. * Defines that engine should ignore context lost events
  38996. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38997. */
  38998. doNotHandleContextLost?: boolean;
  38999. /**
  39000. * Defines that engine should ignore modifying touch action attribute and style
  39001. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39002. */
  39003. doNotHandleTouchAction?: boolean;
  39004. /**
  39005. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39006. */
  39007. useHighPrecisionFloats?: boolean;
  39008. /**
  39009. * Make the canvas XR Compatible for XR sessions
  39010. */
  39011. xrCompatible?: boolean;
  39012. /**
  39013. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39014. */
  39015. useHighPrecisionMatrix?: boolean;
  39016. /**
  39017. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39018. */
  39019. failIfMajorPerformanceCaveat?: boolean;
  39020. }
  39021. /**
  39022. * The base engine class (root of all engines)
  39023. */
  39024. export class ThinEngine {
  39025. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39026. static ExceptionList: ({
  39027. key: string;
  39028. capture: string;
  39029. captureConstraint: number;
  39030. targets: string[];
  39031. } | {
  39032. key: string;
  39033. capture: null;
  39034. captureConstraint: null;
  39035. targets: string[];
  39036. })[];
  39037. /** @hidden */
  39038. static _TextureLoaders: IInternalTextureLoader[];
  39039. /**
  39040. * Returns the current npm package of the sdk
  39041. */
  39042. static get NpmPackage(): string;
  39043. /**
  39044. * Returns the current version of the framework
  39045. */
  39046. static get Version(): string;
  39047. /**
  39048. * Returns a string describing the current engine
  39049. */
  39050. get description(): string;
  39051. /**
  39052. * Gets or sets the epsilon value used by collision engine
  39053. */
  39054. static CollisionsEpsilon: number;
  39055. /**
  39056. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39057. */
  39058. static get ShadersRepository(): string;
  39059. static set ShadersRepository(value: string);
  39060. /** @hidden */
  39061. _shaderProcessor: IShaderProcessor;
  39062. /**
  39063. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39064. */
  39065. forcePOTTextures: boolean;
  39066. /**
  39067. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39068. */
  39069. isFullscreen: boolean;
  39070. /**
  39071. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39072. */
  39073. cullBackFaces: boolean;
  39074. /**
  39075. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39076. */
  39077. renderEvenInBackground: boolean;
  39078. /**
  39079. * Gets or sets a boolean indicating that cache can be kept between frames
  39080. */
  39081. preventCacheWipeBetweenFrames: boolean;
  39082. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39083. validateShaderPrograms: boolean;
  39084. /**
  39085. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39086. * This can provide greater z depth for distant objects.
  39087. */
  39088. useReverseDepthBuffer: boolean;
  39089. /**
  39090. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39091. */
  39092. disableUniformBuffers: boolean;
  39093. /** @hidden */
  39094. _uniformBuffers: UniformBuffer[];
  39095. /**
  39096. * Gets a boolean indicating that the engine supports uniform buffers
  39097. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39098. */
  39099. get supportsUniformBuffers(): boolean;
  39100. /** @hidden */
  39101. _gl: WebGLRenderingContext;
  39102. /** @hidden */
  39103. _webGLVersion: number;
  39104. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39105. protected _windowIsBackground: boolean;
  39106. protected _creationOptions: EngineOptions;
  39107. protected _highPrecisionShadersAllowed: boolean;
  39108. /** @hidden */
  39109. get _shouldUseHighPrecisionShader(): boolean;
  39110. /**
  39111. * Gets a boolean indicating that only power of 2 textures are supported
  39112. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  39113. */
  39114. get needPOTTextures(): boolean;
  39115. /** @hidden */
  39116. _badOS: boolean;
  39117. /** @hidden */
  39118. _badDesktopOS: boolean;
  39119. private _hardwareScalingLevel;
  39120. /** @hidden */
  39121. _caps: EngineCapabilities;
  39122. private _isStencilEnable;
  39123. private _glVersion;
  39124. private _glRenderer;
  39125. private _glVendor;
  39126. /** @hidden */
  39127. _videoTextureSupported: boolean;
  39128. protected _renderingQueueLaunched: boolean;
  39129. protected _activeRenderLoops: (() => void)[];
  39130. /**
  39131. * Observable signaled when a context lost event is raised
  39132. */
  39133. onContextLostObservable: Observable<ThinEngine>;
  39134. /**
  39135. * Observable signaled when a context restored event is raised
  39136. */
  39137. onContextRestoredObservable: Observable<ThinEngine>;
  39138. private _onContextLost;
  39139. private _onContextRestored;
  39140. protected _contextWasLost: boolean;
  39141. /** @hidden */
  39142. _doNotHandleContextLost: boolean;
  39143. /**
  39144. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  39145. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  39146. */
  39147. get doNotHandleContextLost(): boolean;
  39148. set doNotHandleContextLost(value: boolean);
  39149. /**
  39150. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  39151. */
  39152. disableVertexArrayObjects: boolean;
  39153. /** @hidden */
  39154. protected _colorWrite: boolean;
  39155. /** @hidden */
  39156. protected _colorWriteChanged: boolean;
  39157. /** @hidden */
  39158. protected _depthCullingState: DepthCullingState;
  39159. /** @hidden */
  39160. protected _stencilState: StencilState;
  39161. /** @hidden */
  39162. _alphaState: AlphaState;
  39163. /** @hidden */
  39164. _alphaMode: number;
  39165. /** @hidden */
  39166. _alphaEquation: number;
  39167. /** @hidden */
  39168. _internalTexturesCache: InternalTexture[];
  39169. /** @hidden */
  39170. protected _activeChannel: number;
  39171. private _currentTextureChannel;
  39172. /** @hidden */
  39173. protected _boundTexturesCache: {
  39174. [key: string]: Nullable<InternalTexture>;
  39175. };
  39176. /** @hidden */
  39177. protected _currentEffect: Nullable<Effect>;
  39178. /** @hidden */
  39179. protected _currentProgram: Nullable<WebGLProgram>;
  39180. private _compiledEffects;
  39181. private _vertexAttribArraysEnabled;
  39182. /** @hidden */
  39183. protected _cachedViewport: Nullable<IViewportLike>;
  39184. private _cachedVertexArrayObject;
  39185. /** @hidden */
  39186. protected _cachedVertexBuffers: any;
  39187. /** @hidden */
  39188. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  39189. /** @hidden */
  39190. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  39191. /** @hidden */
  39192. _currentRenderTarget: Nullable<InternalTexture>;
  39193. private _uintIndicesCurrentlySet;
  39194. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  39195. /** @hidden */
  39196. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  39197. /** @hidden */
  39198. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  39199. private _currentBufferPointers;
  39200. private _currentInstanceLocations;
  39201. private _currentInstanceBuffers;
  39202. private _textureUnits;
  39203. /** @hidden */
  39204. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39205. /** @hidden */
  39206. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39207. /** @hidden */
  39208. _boundRenderFunction: any;
  39209. private _vaoRecordInProgress;
  39210. private _mustWipeVertexAttributes;
  39211. private _emptyTexture;
  39212. private _emptyCubeTexture;
  39213. private _emptyTexture3D;
  39214. private _emptyTexture2DArray;
  39215. /** @hidden */
  39216. _frameHandler: number;
  39217. private _nextFreeTextureSlots;
  39218. private _maxSimultaneousTextures;
  39219. private _activeRequests;
  39220. /** @hidden */
  39221. _transformTextureUrl: Nullable<(url: string) => string>;
  39222. /**
  39223. * Gets information about the current host
  39224. */
  39225. hostInformation: HostInformation;
  39226. protected get _supportsHardwareTextureRescaling(): boolean;
  39227. private _framebufferDimensionsObject;
  39228. /**
  39229. * sets the object from which width and height will be taken from when getting render width and height
  39230. * Will fallback to the gl object
  39231. * @param dimensions the framebuffer width and height that will be used.
  39232. */
  39233. set framebufferDimensionsObject(dimensions: Nullable<{
  39234. framebufferWidth: number;
  39235. framebufferHeight: number;
  39236. }>);
  39237. /**
  39238. * Gets the current viewport
  39239. */
  39240. get currentViewport(): Nullable<IViewportLike>;
  39241. /**
  39242. * Gets the default empty texture
  39243. */
  39244. get emptyTexture(): InternalTexture;
  39245. /**
  39246. * Gets the default empty 3D texture
  39247. */
  39248. get emptyTexture3D(): InternalTexture;
  39249. /**
  39250. * Gets the default empty 2D array texture
  39251. */
  39252. get emptyTexture2DArray(): InternalTexture;
  39253. /**
  39254. * Gets the default empty cube texture
  39255. */
  39256. get emptyCubeTexture(): InternalTexture;
  39257. /**
  39258. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  39259. */
  39260. readonly premultipliedAlpha: boolean;
  39261. /**
  39262. * Observable event triggered before each texture is initialized
  39263. */
  39264. onBeforeTextureInitObservable: Observable<Texture>;
  39265. /**
  39266. * Creates a new engine
  39267. * @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
  39268. * @param antialias defines enable antialiasing (default: false)
  39269. * @param options defines further options to be sent to the getContext() function
  39270. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39271. */
  39272. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39273. private _rebuildInternalTextures;
  39274. private _rebuildEffects;
  39275. /**
  39276. * Gets a boolean indicating if all created effects are ready
  39277. * @returns true if all effects are ready
  39278. */
  39279. areAllEffectsReady(): boolean;
  39280. protected _rebuildBuffers(): void;
  39281. protected _initGLContext(): void;
  39282. /**
  39283. * Gets version of the current webGL context
  39284. */
  39285. get webGLVersion(): number;
  39286. /**
  39287. * Gets a string identifying the name of the class
  39288. * @returns "Engine" string
  39289. */
  39290. getClassName(): string;
  39291. /**
  39292. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  39293. */
  39294. get isStencilEnable(): boolean;
  39295. /** @hidden */
  39296. _prepareWorkingCanvas(): void;
  39297. /**
  39298. * Reset the texture cache to empty state
  39299. */
  39300. resetTextureCache(): void;
  39301. /**
  39302. * Gets an object containing information about the current webGL context
  39303. * @returns an object containing the vender, the renderer and the version of the current webGL context
  39304. */
  39305. getGlInfo(): {
  39306. vendor: string;
  39307. renderer: string;
  39308. version: string;
  39309. };
  39310. /**
  39311. * Defines the hardware scaling level.
  39312. * By default the hardware scaling level is computed from the window device ratio.
  39313. * 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.
  39314. * @param level defines the level to use
  39315. */
  39316. setHardwareScalingLevel(level: number): void;
  39317. /**
  39318. * Gets the current hardware scaling level.
  39319. * By default the hardware scaling level is computed from the window device ratio.
  39320. * 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.
  39321. * @returns a number indicating the current hardware scaling level
  39322. */
  39323. getHardwareScalingLevel(): number;
  39324. /**
  39325. * Gets the list of loaded textures
  39326. * @returns an array containing all loaded textures
  39327. */
  39328. getLoadedTexturesCache(): InternalTexture[];
  39329. /**
  39330. * Gets the object containing all engine capabilities
  39331. * @returns the EngineCapabilities object
  39332. */
  39333. getCaps(): EngineCapabilities;
  39334. /**
  39335. * stop executing a render loop function and remove it from the execution array
  39336. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  39337. */
  39338. stopRenderLoop(renderFunction?: () => void): void;
  39339. /** @hidden */
  39340. _renderLoop(): void;
  39341. /**
  39342. * Gets the HTML canvas attached with the current webGL context
  39343. * @returns a HTML canvas
  39344. */
  39345. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  39346. /**
  39347. * Gets host window
  39348. * @returns the host window object
  39349. */
  39350. getHostWindow(): Nullable<Window>;
  39351. /**
  39352. * Gets the current render width
  39353. * @param useScreen defines if screen size must be used (or the current render target if any)
  39354. * @returns a number defining the current render width
  39355. */
  39356. getRenderWidth(useScreen?: boolean): number;
  39357. /**
  39358. * Gets the current render height
  39359. * @param useScreen defines if screen size must be used (or the current render target if any)
  39360. * @returns a number defining the current render height
  39361. */
  39362. getRenderHeight(useScreen?: boolean): number;
  39363. /**
  39364. * Can be used to override the current requestAnimationFrame requester.
  39365. * @hidden
  39366. */
  39367. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  39368. /**
  39369. * Register and execute a render loop. The engine can have more than one render function
  39370. * @param renderFunction defines the function to continuously execute
  39371. */
  39372. runRenderLoop(renderFunction: () => void): void;
  39373. /**
  39374. * Clear the current render buffer or the current render target (if any is set up)
  39375. * @param color defines the color to use
  39376. * @param backBuffer defines if the back buffer must be cleared
  39377. * @param depth defines if the depth buffer must be cleared
  39378. * @param stencil defines if the stencil buffer must be cleared
  39379. */
  39380. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39381. private _viewportCached;
  39382. /** @hidden */
  39383. _viewport(x: number, y: number, width: number, height: number): void;
  39384. /**
  39385. * Set the WebGL's viewport
  39386. * @param viewport defines the viewport element to be used
  39387. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  39388. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  39389. */
  39390. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  39391. /**
  39392. * Begin a new frame
  39393. */
  39394. beginFrame(): void;
  39395. /**
  39396. * Enf the current frame
  39397. */
  39398. endFrame(): void;
  39399. /**
  39400. * Resize the view according to the canvas' size
  39401. */
  39402. resize(): void;
  39403. /**
  39404. * Force a specific size of the canvas
  39405. * @param width defines the new canvas' width
  39406. * @param height defines the new canvas' height
  39407. * @returns true if the size was changed
  39408. */
  39409. setSize(width: number, height: number): boolean;
  39410. /**
  39411. * Binds the frame buffer to the specified texture.
  39412. * @param texture The texture to render to or null for the default canvas
  39413. * @param faceIndex The face of the texture to render to in case of cube texture
  39414. * @param requiredWidth The width of the target to render to
  39415. * @param requiredHeight The height of the target to render to
  39416. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  39417. * @param lodLevel defines the lod level to bind to the frame buffer
  39418. * @param layer defines the 2d array index to bind to frame buffer to
  39419. */
  39420. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  39421. /** @hidden */
  39422. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  39423. /**
  39424. * Unbind the current render target texture from the webGL context
  39425. * @param texture defines the render target texture to unbind
  39426. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  39427. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  39428. */
  39429. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39430. /**
  39431. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  39432. */
  39433. flushFramebuffer(): void;
  39434. /**
  39435. * Unbind the current render target and bind the default framebuffer
  39436. */
  39437. restoreDefaultFramebuffer(): void;
  39438. /** @hidden */
  39439. protected _resetVertexBufferBinding(): void;
  39440. /**
  39441. * Creates a vertex buffer
  39442. * @param data the data for the vertex buffer
  39443. * @returns the new WebGL static buffer
  39444. */
  39445. createVertexBuffer(data: DataArray): DataBuffer;
  39446. private _createVertexBuffer;
  39447. /**
  39448. * Creates a dynamic vertex buffer
  39449. * @param data the data for the dynamic vertex buffer
  39450. * @returns the new WebGL dynamic buffer
  39451. */
  39452. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  39453. protected _resetIndexBufferBinding(): void;
  39454. /**
  39455. * Creates a new index buffer
  39456. * @param indices defines the content of the index buffer
  39457. * @param updatable defines if the index buffer must be updatable
  39458. * @returns a new webGL buffer
  39459. */
  39460. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  39461. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  39462. /**
  39463. * Bind a webGL buffer to the webGL context
  39464. * @param buffer defines the buffer to bind
  39465. */
  39466. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  39467. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  39468. private bindBuffer;
  39469. /**
  39470. * update the bound buffer with the given data
  39471. * @param data defines the data to update
  39472. */
  39473. updateArrayBuffer(data: Float32Array): void;
  39474. private _vertexAttribPointer;
  39475. /** @hidden */
  39476. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  39477. private _bindVertexBuffersAttributes;
  39478. /**
  39479. * Records a vertex array object
  39480. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39481. * @param vertexBuffers defines the list of vertex buffers to store
  39482. * @param indexBuffer defines the index buffer to store
  39483. * @param effect defines the effect to store
  39484. * @returns the new vertex array object
  39485. */
  39486. recordVertexArrayObject(vertexBuffers: {
  39487. [key: string]: VertexBuffer;
  39488. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  39489. /**
  39490. * Bind a specific vertex array object
  39491. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39492. * @param vertexArrayObject defines the vertex array object to bind
  39493. * @param indexBuffer defines the index buffer to bind
  39494. */
  39495. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  39496. /**
  39497. * Bind webGl buffers directly to the webGL context
  39498. * @param vertexBuffer defines the vertex buffer to bind
  39499. * @param indexBuffer defines the index buffer to bind
  39500. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  39501. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  39502. * @param effect defines the effect associated with the vertex buffer
  39503. */
  39504. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  39505. private _unbindVertexArrayObject;
  39506. /**
  39507. * Bind a list of vertex buffers to the webGL context
  39508. * @param vertexBuffers defines the list of vertex buffers to bind
  39509. * @param indexBuffer defines the index buffer to bind
  39510. * @param effect defines the effect associated with the vertex buffers
  39511. */
  39512. bindBuffers(vertexBuffers: {
  39513. [key: string]: Nullable<VertexBuffer>;
  39514. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  39515. /**
  39516. * Unbind all instance attributes
  39517. */
  39518. unbindInstanceAttributes(): void;
  39519. /**
  39520. * Release and free the memory of a vertex array object
  39521. * @param vao defines the vertex array object to delete
  39522. */
  39523. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  39524. /** @hidden */
  39525. _releaseBuffer(buffer: DataBuffer): boolean;
  39526. protected _deleteBuffer(buffer: DataBuffer): void;
  39527. /**
  39528. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  39529. * @param instancesBuffer defines the webGL buffer to update and bind
  39530. * @param data defines the data to store in the buffer
  39531. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  39532. */
  39533. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  39534. /**
  39535. * Bind the content of a webGL buffer used with instantiation
  39536. * @param instancesBuffer defines the webGL buffer to bind
  39537. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  39538. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  39539. */
  39540. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  39541. /**
  39542. * Disable the instance attribute corresponding to the name in parameter
  39543. * @param name defines the name of the attribute to disable
  39544. */
  39545. disableInstanceAttributeByName(name: string): void;
  39546. /**
  39547. * Disable the instance attribute corresponding to the location in parameter
  39548. * @param attributeLocation defines the attribute location of the attribute to disable
  39549. */
  39550. disableInstanceAttribute(attributeLocation: number): void;
  39551. /**
  39552. * Disable the attribute corresponding to the location in parameter
  39553. * @param attributeLocation defines the attribute location of the attribute to disable
  39554. */
  39555. disableAttributeByIndex(attributeLocation: number): void;
  39556. /**
  39557. * Send a draw order
  39558. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39559. * @param indexStart defines the starting index
  39560. * @param indexCount defines the number of index to draw
  39561. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39562. */
  39563. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39564. /**
  39565. * Draw a list of points
  39566. * @param verticesStart defines the index of first vertex to draw
  39567. * @param verticesCount defines the count of vertices to draw
  39568. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39569. */
  39570. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39571. /**
  39572. * Draw a list of unindexed primitives
  39573. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39574. * @param verticesStart defines the index of first vertex to draw
  39575. * @param verticesCount defines the count of vertices to draw
  39576. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39577. */
  39578. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39579. /**
  39580. * Draw a list of indexed primitives
  39581. * @param fillMode defines the primitive to use
  39582. * @param indexStart defines the starting index
  39583. * @param indexCount defines the number of index to draw
  39584. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39585. */
  39586. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39587. /**
  39588. * Draw a list of unindexed primitives
  39589. * @param fillMode defines the primitive to use
  39590. * @param verticesStart defines the index of first vertex to draw
  39591. * @param verticesCount defines the count of vertices to draw
  39592. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39593. */
  39594. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39595. private _drawMode;
  39596. /** @hidden */
  39597. protected _reportDrawCall(): void;
  39598. /** @hidden */
  39599. _releaseEffect(effect: Effect): void;
  39600. /** @hidden */
  39601. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39602. /**
  39603. * Create a new effect (used to store vertex/fragment shaders)
  39604. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39605. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39606. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39607. * @param samplers defines an array of string used to represent textures
  39608. * @param defines defines the string containing the defines to use to compile the shaders
  39609. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39610. * @param onCompiled defines a function to call when the effect creation is successful
  39611. * @param onError defines a function to call when the effect creation has failed
  39612. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39613. * @returns the new Effect
  39614. */
  39615. 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;
  39616. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39617. private _compileShader;
  39618. private _compileRawShader;
  39619. /** @hidden */
  39620. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39621. /**
  39622. * Directly creates a webGL program
  39623. * @param pipelineContext defines the pipeline context to attach to
  39624. * @param vertexCode defines the vertex shader code to use
  39625. * @param fragmentCode defines the fragment shader code to use
  39626. * @param context defines the webGL context to use (if not set, the current one will be used)
  39627. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39628. * @returns the new webGL program
  39629. */
  39630. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39631. /**
  39632. * Creates a webGL program
  39633. * @param pipelineContext defines the pipeline context to attach to
  39634. * @param vertexCode defines the vertex shader code to use
  39635. * @param fragmentCode defines the fragment shader code to use
  39636. * @param defines defines the string containing the defines to use to compile the shaders
  39637. * @param context defines the webGL context to use (if not set, the current one will be used)
  39638. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39639. * @returns the new webGL program
  39640. */
  39641. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39642. /**
  39643. * Creates a new pipeline context
  39644. * @returns the new pipeline
  39645. */
  39646. createPipelineContext(): IPipelineContext;
  39647. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39648. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39649. /** @hidden */
  39650. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39651. /** @hidden */
  39652. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39653. /** @hidden */
  39654. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39655. /**
  39656. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39657. * @param pipelineContext defines the pipeline context to use
  39658. * @param uniformsNames defines the list of uniform names
  39659. * @returns an array of webGL uniform locations
  39660. */
  39661. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39662. /**
  39663. * Gets the lsit of active attributes for a given webGL program
  39664. * @param pipelineContext defines the pipeline context to use
  39665. * @param attributesNames defines the list of attribute names to get
  39666. * @returns an array of indices indicating the offset of each attribute
  39667. */
  39668. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39669. /**
  39670. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39671. * @param effect defines the effect to activate
  39672. */
  39673. enableEffect(effect: Nullable<Effect>): void;
  39674. /**
  39675. * Set the value of an uniform to a number (int)
  39676. * @param uniform defines the webGL uniform location where to store the value
  39677. * @param value defines the int number to store
  39678. * @returns true if the value was set
  39679. */
  39680. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39681. /**
  39682. * Set the value of an uniform to an array of int32
  39683. * @param uniform defines the webGL uniform location where to store the value
  39684. * @param array defines the array of int32 to store
  39685. * @returns true if the value was set
  39686. */
  39687. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39688. /**
  39689. * Set the value of an uniform to an array of int32 (stored as vec2)
  39690. * @param uniform defines the webGL uniform location where to store the value
  39691. * @param array defines the array of int32 to store
  39692. * @returns true if the value was set
  39693. */
  39694. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39695. /**
  39696. * Set the value of an uniform to an array of int32 (stored as vec3)
  39697. * @param uniform defines the webGL uniform location where to store the value
  39698. * @param array defines the array of int32 to store
  39699. * @returns true if the value was set
  39700. */
  39701. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39702. /**
  39703. * Set the value of an uniform to an array of int32 (stored as vec4)
  39704. * @param uniform defines the webGL uniform location where to store the value
  39705. * @param array defines the array of int32 to store
  39706. * @returns true if the value was set
  39707. */
  39708. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39709. /**
  39710. * Set the value of an uniform to an array of number
  39711. * @param uniform defines the webGL uniform location where to store the value
  39712. * @param array defines the array of number to store
  39713. * @returns true if the value was set
  39714. */
  39715. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39716. /**
  39717. * Set the value of an uniform to an array of number (stored as vec2)
  39718. * @param uniform defines the webGL uniform location where to store the value
  39719. * @param array defines the array of number to store
  39720. * @returns true if the value was set
  39721. */
  39722. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39723. /**
  39724. * Set the value of an uniform to an array of number (stored as vec3)
  39725. * @param uniform defines the webGL uniform location where to store the value
  39726. * @param array defines the array of number to store
  39727. * @returns true if the value was set
  39728. */
  39729. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39730. /**
  39731. * Set the value of an uniform to an array of number (stored as vec4)
  39732. * @param uniform defines the webGL uniform location where to store the value
  39733. * @param array defines the array of number to store
  39734. * @returns true if the value was set
  39735. */
  39736. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39737. /**
  39738. * Set the value of an uniform to an array of float32 (stored as matrices)
  39739. * @param uniform defines the webGL uniform location where to store the value
  39740. * @param matrices defines the array of float32 to store
  39741. * @returns true if the value was set
  39742. */
  39743. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39744. /**
  39745. * Set the value of an uniform to a matrix (3x3)
  39746. * @param uniform defines the webGL uniform location where to store the value
  39747. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39748. * @returns true if the value was set
  39749. */
  39750. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39751. /**
  39752. * Set the value of an uniform to a matrix (2x2)
  39753. * @param uniform defines the webGL uniform location where to store the value
  39754. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39755. * @returns true if the value was set
  39756. */
  39757. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39758. /**
  39759. * Set the value of an uniform to a number (float)
  39760. * @param uniform defines the webGL uniform location where to store the value
  39761. * @param value defines the float number to store
  39762. * @returns true if the value was transfered
  39763. */
  39764. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39765. /**
  39766. * Set the value of an uniform to a vec2
  39767. * @param uniform defines the webGL uniform location where to store the value
  39768. * @param x defines the 1st component of the value
  39769. * @param y defines the 2nd component of the value
  39770. * @returns true if the value was set
  39771. */
  39772. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39773. /**
  39774. * Set the value of an uniform to a vec3
  39775. * @param uniform defines the webGL uniform location where to store the value
  39776. * @param x defines the 1st component of the value
  39777. * @param y defines the 2nd component of the value
  39778. * @param z defines the 3rd component of the value
  39779. * @returns true if the value was set
  39780. */
  39781. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39782. /**
  39783. * Set the value of an uniform to a vec4
  39784. * @param uniform defines the webGL uniform location where to store the value
  39785. * @param x defines the 1st component of the value
  39786. * @param y defines the 2nd component of the value
  39787. * @param z defines the 3rd component of the value
  39788. * @param w defines the 4th component of the value
  39789. * @returns true if the value was set
  39790. */
  39791. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39792. /**
  39793. * Apply all cached states (depth, culling, stencil and alpha)
  39794. */
  39795. applyStates(): void;
  39796. /**
  39797. * Enable or disable color writing
  39798. * @param enable defines the state to set
  39799. */
  39800. setColorWrite(enable: boolean): void;
  39801. /**
  39802. * Gets a boolean indicating if color writing is enabled
  39803. * @returns the current color writing state
  39804. */
  39805. getColorWrite(): boolean;
  39806. /**
  39807. * Gets the depth culling state manager
  39808. */
  39809. get depthCullingState(): DepthCullingState;
  39810. /**
  39811. * Gets the alpha state manager
  39812. */
  39813. get alphaState(): AlphaState;
  39814. /**
  39815. * Gets the stencil state manager
  39816. */
  39817. get stencilState(): StencilState;
  39818. /**
  39819. * Clears the list of texture accessible through engine.
  39820. * This can help preventing texture load conflict due to name collision.
  39821. */
  39822. clearInternalTexturesCache(): void;
  39823. /**
  39824. * Force the entire cache to be cleared
  39825. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39826. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39827. */
  39828. wipeCaches(bruteForce?: boolean): void;
  39829. /** @hidden */
  39830. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39831. min: number;
  39832. mag: number;
  39833. };
  39834. /** @hidden */
  39835. _createTexture(): WebGLTexture;
  39836. /**
  39837. * Usually called from Texture.ts.
  39838. * Passed information to create a WebGLTexture
  39839. * @param url defines a value which contains one of the following:
  39840. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39841. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39842. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39843. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39844. * @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)
  39845. * @param scene needed for loading to the correct scene
  39846. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39847. * @param onLoad optional callback to be called upon successful completion
  39848. * @param onError optional callback to be called upon failure
  39849. * @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
  39850. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39851. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39852. * @param forcedExtension defines the extension to use to pick the right loader
  39853. * @param mimeType defines an optional mime type
  39854. * @param loaderOptions options to be passed to the loader
  39855. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39856. */
  39857. 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;
  39858. /**
  39859. * Loads an image as an HTMLImageElement.
  39860. * @param input url string, ArrayBuffer, or Blob to load
  39861. * @param onLoad callback called when the image successfully loads
  39862. * @param onError callback called when the image fails to load
  39863. * @param offlineProvider offline provider for caching
  39864. * @param mimeType optional mime type
  39865. * @returns the HTMLImageElement of the loaded image
  39866. * @hidden
  39867. */
  39868. 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>;
  39869. /**
  39870. * @hidden
  39871. */
  39872. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39873. private _unpackFlipYCached;
  39874. /**
  39875. * In case you are sharing the context with other applications, it might
  39876. * be interested to not cache the unpack flip y state to ensure a consistent
  39877. * value would be set.
  39878. */
  39879. enableUnpackFlipYCached: boolean;
  39880. /** @hidden */
  39881. _unpackFlipY(value: boolean): void;
  39882. /** @hidden */
  39883. _getUnpackAlignement(): number;
  39884. private _getTextureTarget;
  39885. /**
  39886. * Update the sampling mode of a given texture
  39887. * @param samplingMode defines the required sampling mode
  39888. * @param texture defines the texture to update
  39889. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39890. */
  39891. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39892. /**
  39893. * Update the sampling mode of a given texture
  39894. * @param texture defines the texture to update
  39895. * @param wrapU defines the texture wrap mode of the u coordinates
  39896. * @param wrapV defines the texture wrap mode of the v coordinates
  39897. * @param wrapR defines the texture wrap mode of the r coordinates
  39898. */
  39899. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39900. /** @hidden */
  39901. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39902. width: number;
  39903. height: number;
  39904. layers?: number;
  39905. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39906. /** @hidden */
  39907. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39908. /** @hidden */
  39909. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39910. /**
  39911. * Update a portion of an internal texture
  39912. * @param texture defines the texture to update
  39913. * @param imageData defines the data to store into the texture
  39914. * @param xOffset defines the x coordinates of the update rectangle
  39915. * @param yOffset defines the y coordinates of the update rectangle
  39916. * @param width defines the width of the update rectangle
  39917. * @param height defines the height of the update rectangle
  39918. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39919. * @param lod defines the lod level to update (0 by default)
  39920. */
  39921. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39922. /** @hidden */
  39923. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39924. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39925. private _prepareWebGLTexture;
  39926. /** @hidden */
  39927. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39928. private _getDepthStencilBuffer;
  39929. /** @hidden */
  39930. _releaseFramebufferObjects(texture: InternalTexture): void;
  39931. /** @hidden */
  39932. _releaseTexture(texture: InternalTexture): void;
  39933. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39934. protected _setProgram(program: WebGLProgram): void;
  39935. protected _boundUniforms: {
  39936. [key: number]: WebGLUniformLocation;
  39937. };
  39938. /**
  39939. * Binds an effect to the webGL context
  39940. * @param effect defines the effect to bind
  39941. */
  39942. bindSamplers(effect: Effect): void;
  39943. private _activateCurrentTexture;
  39944. /** @hidden */
  39945. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39946. /** @hidden */
  39947. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39948. /**
  39949. * Unbind all textures from the webGL context
  39950. */
  39951. unbindAllTextures(): void;
  39952. /**
  39953. * Sets a texture to the according uniform.
  39954. * @param channel The texture channel
  39955. * @param uniform The uniform to set
  39956. * @param texture The texture to apply
  39957. */
  39958. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  39959. private _bindSamplerUniformToChannel;
  39960. private _getTextureWrapMode;
  39961. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39962. /**
  39963. * Sets an array of texture to the webGL context
  39964. * @param channel defines the channel where the texture array must be set
  39965. * @param uniform defines the associated uniform location
  39966. * @param textures defines the array of textures to bind
  39967. */
  39968. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  39969. /** @hidden */
  39970. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39971. private _setTextureParameterFloat;
  39972. private _setTextureParameterInteger;
  39973. /**
  39974. * Unbind all vertex attributes from the webGL context
  39975. */
  39976. unbindAllAttributes(): void;
  39977. /**
  39978. * 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
  39979. */
  39980. releaseEffects(): void;
  39981. /**
  39982. * Dispose and release all associated resources
  39983. */
  39984. dispose(): void;
  39985. /**
  39986. * Attach a new callback raised when context lost event is fired
  39987. * @param callback defines the callback to call
  39988. */
  39989. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39990. /**
  39991. * Attach a new callback raised when context restored event is fired
  39992. * @param callback defines the callback to call
  39993. */
  39994. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39995. /**
  39996. * Get the current error code of the webGL context
  39997. * @returns the error code
  39998. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39999. */
  40000. getError(): number;
  40001. private _canRenderToFloatFramebuffer;
  40002. private _canRenderToHalfFloatFramebuffer;
  40003. private _canRenderToFramebuffer;
  40004. /** @hidden */
  40005. _getWebGLTextureType(type: number): number;
  40006. /** @hidden */
  40007. _getInternalFormat(format: number): number;
  40008. /** @hidden */
  40009. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40010. /** @hidden */
  40011. _getRGBAMultiSampleBufferFormat(type: number): number;
  40012. /** @hidden */
  40013. _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;
  40014. /**
  40015. * Loads a file from a url
  40016. * @param url url to load
  40017. * @param onSuccess callback called when the file successfully loads
  40018. * @param onProgress callback called while file is loading (if the server supports this mode)
  40019. * @param offlineProvider defines the offline provider for caching
  40020. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  40021. * @param onError callback called when the file fails to load
  40022. * @returns a file request object
  40023. * @hidden
  40024. */
  40025. 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;
  40026. /**
  40027. * Reads pixels from the current frame buffer. Please note that this function can be slow
  40028. * @param x defines the x coordinate of the rectangle where pixels must be read
  40029. * @param y defines the y coordinate of the rectangle where pixels must be read
  40030. * @param width defines the width of the rectangle where pixels must be read
  40031. * @param height defines the height of the rectangle where pixels must be read
  40032. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  40033. * @returns a Uint8Array containing RGBA colors
  40034. */
  40035. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  40036. private static _IsSupported;
  40037. private static _HasMajorPerformanceCaveat;
  40038. /**
  40039. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40040. */
  40041. static get IsSupported(): boolean;
  40042. /**
  40043. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40044. * @returns true if the engine can be created
  40045. * @ignorenaming
  40046. */
  40047. static isSupported(): boolean;
  40048. /**
  40049. * 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)
  40050. */
  40051. static get HasMajorPerformanceCaveat(): boolean;
  40052. /**
  40053. * Find the next highest power of two.
  40054. * @param x Number to start search from.
  40055. * @return Next highest power of two.
  40056. */
  40057. static CeilingPOT(x: number): number;
  40058. /**
  40059. * Find the next lowest power of two.
  40060. * @param x Number to start search from.
  40061. * @return Next lowest power of two.
  40062. */
  40063. static FloorPOT(x: number): number;
  40064. /**
  40065. * Find the nearest power of two.
  40066. * @param x Number to start search from.
  40067. * @return Next nearest power of two.
  40068. */
  40069. static NearestPOT(x: number): number;
  40070. /**
  40071. * Get the closest exponent of two
  40072. * @param value defines the value to approximate
  40073. * @param max defines the maximum value to return
  40074. * @param mode defines how to define the closest value
  40075. * @returns closest exponent of two of the given value
  40076. */
  40077. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40078. /**
  40079. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40080. * @param func - the function to be called
  40081. * @param requester - the object that will request the next frame. Falls back to window.
  40082. * @returns frame number
  40083. */
  40084. static QueueNewFrame(func: () => void, requester?: any): number;
  40085. /**
  40086. * Gets host document
  40087. * @returns the host document object
  40088. */
  40089. getHostDocument(): Nullable<Document>;
  40090. }
  40091. }
  40092. declare module BABYLON {
  40093. /**
  40094. * Defines the source of the internal texture
  40095. */
  40096. export enum InternalTextureSource {
  40097. /**
  40098. * The source of the texture data is unknown
  40099. */
  40100. Unknown = 0,
  40101. /**
  40102. * Texture data comes from an URL
  40103. */
  40104. Url = 1,
  40105. /**
  40106. * Texture data is only used for temporary storage
  40107. */
  40108. Temp = 2,
  40109. /**
  40110. * Texture data comes from raw data (ArrayBuffer)
  40111. */
  40112. Raw = 3,
  40113. /**
  40114. * Texture content is dynamic (video or dynamic texture)
  40115. */
  40116. Dynamic = 4,
  40117. /**
  40118. * Texture content is generated by rendering to it
  40119. */
  40120. RenderTarget = 5,
  40121. /**
  40122. * Texture content is part of a multi render target process
  40123. */
  40124. MultiRenderTarget = 6,
  40125. /**
  40126. * Texture data comes from a cube data file
  40127. */
  40128. Cube = 7,
  40129. /**
  40130. * Texture data comes from a raw cube data
  40131. */
  40132. CubeRaw = 8,
  40133. /**
  40134. * Texture data come from a prefiltered cube data file
  40135. */
  40136. CubePrefiltered = 9,
  40137. /**
  40138. * Texture content is raw 3D data
  40139. */
  40140. Raw3D = 10,
  40141. /**
  40142. * Texture content is raw 2D array data
  40143. */
  40144. Raw2DArray = 11,
  40145. /**
  40146. * Texture content is a depth texture
  40147. */
  40148. Depth = 12,
  40149. /**
  40150. * Texture data comes from a raw cube data encoded with RGBD
  40151. */
  40152. CubeRawRGBD = 13
  40153. }
  40154. /**
  40155. * Class used to store data associated with WebGL texture data for the engine
  40156. * This class should not be used directly
  40157. */
  40158. export class InternalTexture {
  40159. /** @hidden */
  40160. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  40161. /**
  40162. * Defines if the texture is ready
  40163. */
  40164. isReady: boolean;
  40165. /**
  40166. * Defines if the texture is a cube texture
  40167. */
  40168. isCube: boolean;
  40169. /**
  40170. * Defines if the texture contains 3D data
  40171. */
  40172. is3D: boolean;
  40173. /**
  40174. * Defines if the texture contains 2D array data
  40175. */
  40176. is2DArray: boolean;
  40177. /**
  40178. * Defines if the texture contains multiview data
  40179. */
  40180. isMultiview: boolean;
  40181. /**
  40182. * Gets the URL used to load this texture
  40183. */
  40184. url: string;
  40185. /** @hidden */
  40186. _originalUrl: string;
  40187. /**
  40188. * Gets the sampling mode of the texture
  40189. */
  40190. samplingMode: number;
  40191. /**
  40192. * Gets a boolean indicating if the texture needs mipmaps generation
  40193. */
  40194. generateMipMaps: boolean;
  40195. /**
  40196. * Gets the number of samples used by the texture (WebGL2+ only)
  40197. */
  40198. samples: number;
  40199. /**
  40200. * Gets the type of the texture (int, float...)
  40201. */
  40202. type: number;
  40203. /**
  40204. * Gets the format of the texture (RGB, RGBA...)
  40205. */
  40206. format: number;
  40207. /**
  40208. * Observable called when the texture is loaded
  40209. */
  40210. onLoadedObservable: Observable<InternalTexture>;
  40211. /**
  40212. * Gets the width of the texture
  40213. */
  40214. width: number;
  40215. /**
  40216. * Gets the height of the texture
  40217. */
  40218. height: number;
  40219. /**
  40220. * Gets the depth of the texture
  40221. */
  40222. depth: number;
  40223. /**
  40224. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  40225. */
  40226. baseWidth: number;
  40227. /**
  40228. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  40229. */
  40230. baseHeight: number;
  40231. /**
  40232. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  40233. */
  40234. baseDepth: number;
  40235. /**
  40236. * Gets a boolean indicating if the texture is inverted on Y axis
  40237. */
  40238. invertY: boolean;
  40239. /** @hidden */
  40240. _invertVScale: boolean;
  40241. /** @hidden */
  40242. _associatedChannel: number;
  40243. /** @hidden */
  40244. _source: InternalTextureSource;
  40245. /** @hidden */
  40246. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  40247. /** @hidden */
  40248. _bufferView: Nullable<ArrayBufferView>;
  40249. /** @hidden */
  40250. _bufferViewArray: Nullable<ArrayBufferView[]>;
  40251. /** @hidden */
  40252. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  40253. /** @hidden */
  40254. _size: number;
  40255. /** @hidden */
  40256. _extension: string;
  40257. /** @hidden */
  40258. _files: Nullable<string[]>;
  40259. /** @hidden */
  40260. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40261. /** @hidden */
  40262. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40263. /** @hidden */
  40264. _framebuffer: Nullable<WebGLFramebuffer>;
  40265. /** @hidden */
  40266. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  40267. /** @hidden */
  40268. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  40269. /** @hidden */
  40270. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  40271. /** @hidden */
  40272. _attachments: Nullable<number[]>;
  40273. /** @hidden */
  40274. _textureArray: Nullable<InternalTexture[]>;
  40275. /** @hidden */
  40276. _cachedCoordinatesMode: Nullable<number>;
  40277. /** @hidden */
  40278. _cachedWrapU: Nullable<number>;
  40279. /** @hidden */
  40280. _cachedWrapV: Nullable<number>;
  40281. /** @hidden */
  40282. _cachedWrapR: Nullable<number>;
  40283. /** @hidden */
  40284. _cachedAnisotropicFilteringLevel: Nullable<number>;
  40285. /** @hidden */
  40286. _isDisabled: boolean;
  40287. /** @hidden */
  40288. _compression: Nullable<string>;
  40289. /** @hidden */
  40290. _generateStencilBuffer: boolean;
  40291. /** @hidden */
  40292. _generateDepthBuffer: boolean;
  40293. /** @hidden */
  40294. _comparisonFunction: number;
  40295. /** @hidden */
  40296. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  40297. /** @hidden */
  40298. _lodGenerationScale: number;
  40299. /** @hidden */
  40300. _lodGenerationOffset: number;
  40301. /** @hidden */
  40302. _depthStencilTexture: Nullable<InternalTexture>;
  40303. /** @hidden */
  40304. _colorTextureArray: Nullable<WebGLTexture>;
  40305. /** @hidden */
  40306. _depthStencilTextureArray: Nullable<WebGLTexture>;
  40307. /** @hidden */
  40308. _lodTextureHigh: Nullable<BaseTexture>;
  40309. /** @hidden */
  40310. _lodTextureMid: Nullable<BaseTexture>;
  40311. /** @hidden */
  40312. _lodTextureLow: Nullable<BaseTexture>;
  40313. /** @hidden */
  40314. _isRGBD: boolean;
  40315. /** @hidden */
  40316. _linearSpecularLOD: boolean;
  40317. /** @hidden */
  40318. _irradianceTexture: Nullable<BaseTexture>;
  40319. /** @hidden */
  40320. _webGLTexture: Nullable<WebGLTexture>;
  40321. /** @hidden */
  40322. _references: number;
  40323. /** @hidden */
  40324. _gammaSpace: Nullable<boolean>;
  40325. private _engine;
  40326. /**
  40327. * Gets the Engine the texture belongs to.
  40328. * @returns The babylon engine
  40329. */
  40330. getEngine(): ThinEngine;
  40331. /**
  40332. * Gets the data source type of the texture
  40333. */
  40334. get source(): InternalTextureSource;
  40335. /**
  40336. * Creates a new InternalTexture
  40337. * @param engine defines the engine to use
  40338. * @param source defines the type of data that will be used
  40339. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40340. */
  40341. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  40342. /**
  40343. * Increments the number of references (ie. the number of Texture that point to it)
  40344. */
  40345. incrementReferences(): void;
  40346. /**
  40347. * Change the size of the texture (not the size of the content)
  40348. * @param width defines the new width
  40349. * @param height defines the new height
  40350. * @param depth defines the new depth (1 by default)
  40351. */
  40352. updateSize(width: int, height: int, depth?: int): void;
  40353. /** @hidden */
  40354. _rebuild(): void;
  40355. /** @hidden */
  40356. _swapAndDie(target: InternalTexture): void;
  40357. /**
  40358. * Dispose the current allocated resources
  40359. */
  40360. dispose(): void;
  40361. }
  40362. }
  40363. declare module BABYLON {
  40364. /**
  40365. * Interface used to present a loading screen while loading a scene
  40366. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40367. */
  40368. export interface ILoadingScreen {
  40369. /**
  40370. * Function called to display the loading screen
  40371. */
  40372. displayLoadingUI: () => void;
  40373. /**
  40374. * Function called to hide the loading screen
  40375. */
  40376. hideLoadingUI: () => void;
  40377. /**
  40378. * Gets or sets the color to use for the background
  40379. */
  40380. loadingUIBackgroundColor: string;
  40381. /**
  40382. * Gets or sets the text to display while loading
  40383. */
  40384. loadingUIText: string;
  40385. }
  40386. /**
  40387. * Class used for the default loading screen
  40388. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40389. */
  40390. export class DefaultLoadingScreen implements ILoadingScreen {
  40391. private _renderingCanvas;
  40392. private _loadingText;
  40393. private _loadingDivBackgroundColor;
  40394. private _loadingDiv;
  40395. private _loadingTextDiv;
  40396. /** Gets or sets the logo url to use for the default loading screen */
  40397. static DefaultLogoUrl: string;
  40398. /** Gets or sets the spinner url to use for the default loading screen */
  40399. static DefaultSpinnerUrl: string;
  40400. /**
  40401. * Creates a new default loading screen
  40402. * @param _renderingCanvas defines the canvas used to render the scene
  40403. * @param _loadingText defines the default text to display
  40404. * @param _loadingDivBackgroundColor defines the default background color
  40405. */
  40406. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40407. /**
  40408. * Function called to display the loading screen
  40409. */
  40410. displayLoadingUI(): void;
  40411. /**
  40412. * Function called to hide the loading screen
  40413. */
  40414. hideLoadingUI(): void;
  40415. /**
  40416. * Gets or sets the text to display while loading
  40417. */
  40418. set loadingUIText(text: string);
  40419. get loadingUIText(): string;
  40420. /**
  40421. * Gets or sets the color to use for the background
  40422. */
  40423. get loadingUIBackgroundColor(): string;
  40424. set loadingUIBackgroundColor(color: string);
  40425. private _resizeLoadingUI;
  40426. }
  40427. }
  40428. declare module BABYLON {
  40429. /**
  40430. * Interface for any object that can request an animation frame
  40431. */
  40432. export interface ICustomAnimationFrameRequester {
  40433. /**
  40434. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40435. */
  40436. renderFunction?: Function;
  40437. /**
  40438. * Called to request the next frame to render to
  40439. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40440. */
  40441. requestAnimationFrame: Function;
  40442. /**
  40443. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40444. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40445. */
  40446. requestID?: number;
  40447. }
  40448. }
  40449. declare module BABYLON {
  40450. /**
  40451. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40452. */
  40453. export class PerformanceMonitor {
  40454. private _enabled;
  40455. private _rollingFrameTime;
  40456. private _lastFrameTimeMs;
  40457. /**
  40458. * constructor
  40459. * @param frameSampleSize The number of samples required to saturate the sliding window
  40460. */
  40461. constructor(frameSampleSize?: number);
  40462. /**
  40463. * Samples current frame
  40464. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40465. */
  40466. sampleFrame(timeMs?: number): void;
  40467. /**
  40468. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40469. */
  40470. get averageFrameTime(): number;
  40471. /**
  40472. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40473. */
  40474. get averageFrameTimeVariance(): number;
  40475. /**
  40476. * Returns the frame time of the most recent frame
  40477. */
  40478. get instantaneousFrameTime(): number;
  40479. /**
  40480. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40481. */
  40482. get averageFPS(): number;
  40483. /**
  40484. * Returns the average framerate in frames per second using the most recent frame time
  40485. */
  40486. get instantaneousFPS(): number;
  40487. /**
  40488. * Returns true if enough samples have been taken to completely fill the sliding window
  40489. */
  40490. get isSaturated(): boolean;
  40491. /**
  40492. * Enables contributions to the sliding window sample set
  40493. */
  40494. enable(): void;
  40495. /**
  40496. * Disables contributions to the sliding window sample set
  40497. * Samples will not be interpolated over the disabled period
  40498. */
  40499. disable(): void;
  40500. /**
  40501. * Returns true if sampling is enabled
  40502. */
  40503. get isEnabled(): boolean;
  40504. /**
  40505. * Resets performance monitor
  40506. */
  40507. reset(): void;
  40508. }
  40509. /**
  40510. * RollingAverage
  40511. *
  40512. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40513. */
  40514. export class RollingAverage {
  40515. /**
  40516. * Current average
  40517. */
  40518. average: number;
  40519. /**
  40520. * Current variance
  40521. */
  40522. variance: number;
  40523. protected _samples: Array<number>;
  40524. protected _sampleCount: number;
  40525. protected _pos: number;
  40526. protected _m2: number;
  40527. /**
  40528. * constructor
  40529. * @param length The number of samples required to saturate the sliding window
  40530. */
  40531. constructor(length: number);
  40532. /**
  40533. * Adds a sample to the sample set
  40534. * @param v The sample value
  40535. */
  40536. add(v: number): void;
  40537. /**
  40538. * Returns previously added values or null if outside of history or outside the sliding window domain
  40539. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40540. * @return Value previously recorded with add() or null if outside of range
  40541. */
  40542. history(i: number): number;
  40543. /**
  40544. * Returns true if enough samples have been taken to completely fill the sliding window
  40545. * @return true if sample-set saturated
  40546. */
  40547. isSaturated(): boolean;
  40548. /**
  40549. * Resets the rolling average (equivalent to 0 samples taken so far)
  40550. */
  40551. reset(): void;
  40552. /**
  40553. * Wraps a value around the sample range boundaries
  40554. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40555. * @return Wrapped position in sample range
  40556. */
  40557. protected _wrapPosition(i: number): number;
  40558. }
  40559. }
  40560. declare module BABYLON {
  40561. /**
  40562. * This class is used to track a performance counter which is number based.
  40563. * The user has access to many properties which give statistics of different nature.
  40564. *
  40565. * The implementer can track two kinds of Performance Counter: time and count.
  40566. * 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.
  40567. * 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.
  40568. */
  40569. export class PerfCounter {
  40570. /**
  40571. * Gets or sets a global boolean to turn on and off all the counters
  40572. */
  40573. static Enabled: boolean;
  40574. /**
  40575. * Returns the smallest value ever
  40576. */
  40577. get min(): number;
  40578. /**
  40579. * Returns the biggest value ever
  40580. */
  40581. get max(): number;
  40582. /**
  40583. * Returns the average value since the performance counter is running
  40584. */
  40585. get average(): number;
  40586. /**
  40587. * Returns the average value of the last second the counter was monitored
  40588. */
  40589. get lastSecAverage(): number;
  40590. /**
  40591. * Returns the current value
  40592. */
  40593. get current(): number;
  40594. /**
  40595. * Gets the accumulated total
  40596. */
  40597. get total(): number;
  40598. /**
  40599. * Gets the total value count
  40600. */
  40601. get count(): number;
  40602. /**
  40603. * Creates a new counter
  40604. */
  40605. constructor();
  40606. /**
  40607. * Call this method to start monitoring a new frame.
  40608. * 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.
  40609. */
  40610. fetchNewFrame(): void;
  40611. /**
  40612. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40613. * @param newCount the count value to add to the monitored count
  40614. * @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.
  40615. */
  40616. addCount(newCount: number, fetchResult: boolean): void;
  40617. /**
  40618. * Start monitoring this performance counter
  40619. */
  40620. beginMonitoring(): void;
  40621. /**
  40622. * Compute the time lapsed since the previous beginMonitoring() call.
  40623. * @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
  40624. */
  40625. endMonitoring(newFrame?: boolean): void;
  40626. private _fetchResult;
  40627. private _startMonitoringTime;
  40628. private _min;
  40629. private _max;
  40630. private _average;
  40631. private _current;
  40632. private _totalValueCount;
  40633. private _totalAccumulated;
  40634. private _lastSecAverage;
  40635. private _lastSecAccumulated;
  40636. private _lastSecTime;
  40637. private _lastSecValueCount;
  40638. }
  40639. }
  40640. declare module BABYLON {
  40641. interface ThinEngine {
  40642. /** @hidden */
  40643. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40644. }
  40645. }
  40646. declare module BABYLON {
  40647. /**
  40648. * Class used to work with sound analyzer using fast fourier transform (FFT)
  40649. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40650. */
  40651. export class Analyser {
  40652. /**
  40653. * Gets or sets the smoothing
  40654. * @ignorenaming
  40655. */
  40656. SMOOTHING: number;
  40657. /**
  40658. * Gets or sets the FFT table size
  40659. * @ignorenaming
  40660. */
  40661. FFT_SIZE: number;
  40662. /**
  40663. * Gets or sets the bar graph amplitude
  40664. * @ignorenaming
  40665. */
  40666. BARGRAPHAMPLITUDE: number;
  40667. /**
  40668. * Gets or sets the position of the debug canvas
  40669. * @ignorenaming
  40670. */
  40671. DEBUGCANVASPOS: {
  40672. x: number;
  40673. y: number;
  40674. };
  40675. /**
  40676. * Gets or sets the debug canvas size
  40677. * @ignorenaming
  40678. */
  40679. DEBUGCANVASSIZE: {
  40680. width: number;
  40681. height: number;
  40682. };
  40683. private _byteFreqs;
  40684. private _byteTime;
  40685. private _floatFreqs;
  40686. private _webAudioAnalyser;
  40687. private _debugCanvas;
  40688. private _debugCanvasContext;
  40689. private _scene;
  40690. private _registerFunc;
  40691. private _audioEngine;
  40692. /**
  40693. * Creates a new analyser
  40694. * @param scene defines hosting scene
  40695. */
  40696. constructor(scene: Scene);
  40697. /**
  40698. * Get the number of data values you will have to play with for the visualization
  40699. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  40700. * @returns a number
  40701. */
  40702. getFrequencyBinCount(): number;
  40703. /**
  40704. * Gets the current frequency data as a byte array
  40705. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40706. * @returns a Uint8Array
  40707. */
  40708. getByteFrequencyData(): Uint8Array;
  40709. /**
  40710. * Gets the current waveform as a byte array
  40711. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  40712. * @returns a Uint8Array
  40713. */
  40714. getByteTimeDomainData(): Uint8Array;
  40715. /**
  40716. * Gets the current frequency data as a float array
  40717. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40718. * @returns a Float32Array
  40719. */
  40720. getFloatFrequencyData(): Float32Array;
  40721. /**
  40722. * Renders the debug canvas
  40723. */
  40724. drawDebugCanvas(): void;
  40725. /**
  40726. * Stops rendering the debug canvas and removes it
  40727. */
  40728. stopDebugCanvas(): void;
  40729. /**
  40730. * Connects two audio nodes
  40731. * @param inputAudioNode defines first node to connect
  40732. * @param outputAudioNode defines second node to connect
  40733. */
  40734. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  40735. /**
  40736. * Releases all associated resources
  40737. */
  40738. dispose(): void;
  40739. }
  40740. }
  40741. declare module BABYLON {
  40742. /**
  40743. * This represents an audio engine and it is responsible
  40744. * to play, synchronize and analyse sounds throughout the application.
  40745. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40746. */
  40747. export interface IAudioEngine extends IDisposable {
  40748. /**
  40749. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40750. */
  40751. readonly canUseWebAudio: boolean;
  40752. /**
  40753. * Gets the current AudioContext if available.
  40754. */
  40755. readonly audioContext: Nullable<AudioContext>;
  40756. /**
  40757. * The master gain node defines the global audio volume of your audio engine.
  40758. */
  40759. readonly masterGain: GainNode;
  40760. /**
  40761. * Gets whether or not mp3 are supported by your browser.
  40762. */
  40763. readonly isMP3supported: boolean;
  40764. /**
  40765. * Gets whether or not ogg are supported by your browser.
  40766. */
  40767. readonly isOGGsupported: boolean;
  40768. /**
  40769. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40770. * @ignoreNaming
  40771. */
  40772. WarnedWebAudioUnsupported: boolean;
  40773. /**
  40774. * Defines if the audio engine relies on a custom unlocked button.
  40775. * In this case, the embedded button will not be displayed.
  40776. */
  40777. useCustomUnlockedButton: boolean;
  40778. /**
  40779. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  40780. */
  40781. readonly unlocked: boolean;
  40782. /**
  40783. * Event raised when audio has been unlocked on the browser.
  40784. */
  40785. onAudioUnlockedObservable: Observable<IAudioEngine>;
  40786. /**
  40787. * Event raised when audio has been locked on the browser.
  40788. */
  40789. onAudioLockedObservable: Observable<IAudioEngine>;
  40790. /**
  40791. * Flags the audio engine in Locked state.
  40792. * This happens due to new browser policies preventing audio to autoplay.
  40793. */
  40794. lock(): void;
  40795. /**
  40796. * Unlocks the audio engine once a user action has been done on the dom.
  40797. * This is helpful to resume play once browser policies have been satisfied.
  40798. */
  40799. unlock(): void;
  40800. /**
  40801. * Gets the global volume sets on the master gain.
  40802. * @returns the global volume if set or -1 otherwise
  40803. */
  40804. getGlobalVolume(): number;
  40805. /**
  40806. * Sets the global volume of your experience (sets on the master gain).
  40807. * @param newVolume Defines the new global volume of the application
  40808. */
  40809. setGlobalVolume(newVolume: number): void;
  40810. /**
  40811. * Connect the audio engine to an audio analyser allowing some amazing
  40812. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40813. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40814. * @param analyser The analyser to connect to the engine
  40815. */
  40816. connectToAnalyser(analyser: Analyser): void;
  40817. }
  40818. }
  40819. declare module BABYLON {
  40820. /**
  40821. * Defines the interface used by display changed events
  40822. */
  40823. export interface IDisplayChangedEventArgs {
  40824. /** Gets the vrDisplay object (if any) */
  40825. vrDisplay: Nullable<any>;
  40826. /** Gets a boolean indicating if webVR is supported */
  40827. vrSupported: boolean;
  40828. }
  40829. /**
  40830. * Defines the interface used by objects containing a viewport (like a camera)
  40831. */
  40832. interface IViewportOwnerLike {
  40833. /**
  40834. * Gets or sets the viewport
  40835. */
  40836. viewport: IViewportLike;
  40837. }
  40838. /**
  40839. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40840. */
  40841. export class Engine extends ThinEngine {
  40842. /** Defines that alpha blending is disabled */
  40843. static readonly ALPHA_DISABLE: number;
  40844. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40845. static readonly ALPHA_ADD: number;
  40846. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40847. static readonly ALPHA_COMBINE: number;
  40848. /** Defines that alpha blending to DEST - SRC * DEST */
  40849. static readonly ALPHA_SUBTRACT: number;
  40850. /** Defines that alpha blending to SRC * DEST */
  40851. static readonly ALPHA_MULTIPLY: number;
  40852. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40853. static readonly ALPHA_MAXIMIZED: number;
  40854. /** Defines that alpha blending to SRC + DEST */
  40855. static readonly ALPHA_ONEONE: number;
  40856. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40857. static readonly ALPHA_PREMULTIPLIED: number;
  40858. /**
  40859. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40860. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40861. */
  40862. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40863. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40864. static readonly ALPHA_INTERPOLATE: number;
  40865. /**
  40866. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40867. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40868. */
  40869. static readonly ALPHA_SCREENMODE: number;
  40870. /** Defines that the ressource is not delayed*/
  40871. static readonly DELAYLOADSTATE_NONE: number;
  40872. /** Defines that the ressource was successfully delay loaded */
  40873. static readonly DELAYLOADSTATE_LOADED: number;
  40874. /** Defines that the ressource is currently delay loading */
  40875. static readonly DELAYLOADSTATE_LOADING: number;
  40876. /** Defines that the ressource is delayed and has not started loading */
  40877. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40878. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40879. static readonly NEVER: number;
  40880. /** 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 */
  40881. static readonly ALWAYS: number;
  40882. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40883. static readonly LESS: number;
  40884. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40885. static readonly EQUAL: number;
  40886. /** 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 */
  40887. static readonly LEQUAL: number;
  40888. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40889. static readonly GREATER: number;
  40890. /** 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 */
  40891. static readonly GEQUAL: number;
  40892. /** 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 */
  40893. static readonly NOTEQUAL: number;
  40894. /** Passed to stencilOperation to specify that stencil value must be kept */
  40895. static readonly KEEP: number;
  40896. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40897. static readonly REPLACE: number;
  40898. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40899. static readonly INCR: number;
  40900. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40901. static readonly DECR: number;
  40902. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40903. static readonly INVERT: number;
  40904. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40905. static readonly INCR_WRAP: number;
  40906. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40907. static readonly DECR_WRAP: number;
  40908. /** Texture is not repeating outside of 0..1 UVs */
  40909. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40910. /** Texture is repeating outside of 0..1 UVs */
  40911. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40912. /** Texture is repeating and mirrored */
  40913. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40914. /** ALPHA */
  40915. static readonly TEXTUREFORMAT_ALPHA: number;
  40916. /** LUMINANCE */
  40917. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40918. /** LUMINANCE_ALPHA */
  40919. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40920. /** RGB */
  40921. static readonly TEXTUREFORMAT_RGB: number;
  40922. /** RGBA */
  40923. static readonly TEXTUREFORMAT_RGBA: number;
  40924. /** RED */
  40925. static readonly TEXTUREFORMAT_RED: number;
  40926. /** RED (2nd reference) */
  40927. static readonly TEXTUREFORMAT_R: number;
  40928. /** RG */
  40929. static readonly TEXTUREFORMAT_RG: number;
  40930. /** RED_INTEGER */
  40931. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40932. /** RED_INTEGER (2nd reference) */
  40933. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40934. /** RG_INTEGER */
  40935. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40936. /** RGB_INTEGER */
  40937. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40938. /** RGBA_INTEGER */
  40939. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40940. /** UNSIGNED_BYTE */
  40941. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40942. /** UNSIGNED_BYTE (2nd reference) */
  40943. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40944. /** FLOAT */
  40945. static readonly TEXTURETYPE_FLOAT: number;
  40946. /** HALF_FLOAT */
  40947. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40948. /** BYTE */
  40949. static readonly TEXTURETYPE_BYTE: number;
  40950. /** SHORT */
  40951. static readonly TEXTURETYPE_SHORT: number;
  40952. /** UNSIGNED_SHORT */
  40953. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40954. /** INT */
  40955. static readonly TEXTURETYPE_INT: number;
  40956. /** UNSIGNED_INT */
  40957. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40958. /** UNSIGNED_SHORT_4_4_4_4 */
  40959. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40960. /** UNSIGNED_SHORT_5_5_5_1 */
  40961. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40962. /** UNSIGNED_SHORT_5_6_5 */
  40963. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40964. /** UNSIGNED_INT_2_10_10_10_REV */
  40965. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40966. /** UNSIGNED_INT_24_8 */
  40967. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40968. /** UNSIGNED_INT_10F_11F_11F_REV */
  40969. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40970. /** UNSIGNED_INT_5_9_9_9_REV */
  40971. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40972. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40973. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40974. /** nearest is mag = nearest and min = nearest and mip = linear */
  40975. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40976. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40977. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40978. /** Trilinear is mag = linear and min = linear and mip = linear */
  40979. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40980. /** nearest is mag = nearest and min = nearest and mip = linear */
  40981. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40982. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40983. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40984. /** Trilinear is mag = linear and min = linear and mip = linear */
  40985. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40986. /** mag = nearest and min = nearest and mip = nearest */
  40987. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40988. /** mag = nearest and min = linear and mip = nearest */
  40989. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40990. /** mag = nearest and min = linear and mip = linear */
  40991. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40992. /** mag = nearest and min = linear and mip = none */
  40993. static readonly TEXTURE_NEAREST_LINEAR: number;
  40994. /** mag = nearest and min = nearest and mip = none */
  40995. static readonly TEXTURE_NEAREST_NEAREST: number;
  40996. /** mag = linear and min = nearest and mip = nearest */
  40997. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40998. /** mag = linear and min = nearest and mip = linear */
  40999. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  41000. /** mag = linear and min = linear and mip = none */
  41001. static readonly TEXTURE_LINEAR_LINEAR: number;
  41002. /** mag = linear and min = nearest and mip = none */
  41003. static readonly TEXTURE_LINEAR_NEAREST: number;
  41004. /** Explicit coordinates mode */
  41005. static readonly TEXTURE_EXPLICIT_MODE: number;
  41006. /** Spherical coordinates mode */
  41007. static readonly TEXTURE_SPHERICAL_MODE: number;
  41008. /** Planar coordinates mode */
  41009. static readonly TEXTURE_PLANAR_MODE: number;
  41010. /** Cubic coordinates mode */
  41011. static readonly TEXTURE_CUBIC_MODE: number;
  41012. /** Projection coordinates mode */
  41013. static readonly TEXTURE_PROJECTION_MODE: number;
  41014. /** Skybox coordinates mode */
  41015. static readonly TEXTURE_SKYBOX_MODE: number;
  41016. /** Inverse Cubic coordinates mode */
  41017. static readonly TEXTURE_INVCUBIC_MODE: number;
  41018. /** Equirectangular coordinates mode */
  41019. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  41020. /** Equirectangular Fixed coordinates mode */
  41021. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  41022. /** Equirectangular Fixed Mirrored coordinates mode */
  41023. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  41024. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  41025. static readonly SCALEMODE_FLOOR: number;
  41026. /** Defines that texture rescaling will look for the nearest power of 2 size */
  41027. static readonly SCALEMODE_NEAREST: number;
  41028. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  41029. static readonly SCALEMODE_CEILING: number;
  41030. /**
  41031. * Returns the current npm package of the sdk
  41032. */
  41033. static get NpmPackage(): string;
  41034. /**
  41035. * Returns the current version of the framework
  41036. */
  41037. static get Version(): string;
  41038. /** Gets the list of created engines */
  41039. static get Instances(): Engine[];
  41040. /**
  41041. * Gets the latest created engine
  41042. */
  41043. static get LastCreatedEngine(): Nullable<Engine>;
  41044. /**
  41045. * Gets the latest created scene
  41046. */
  41047. static get LastCreatedScene(): Nullable<Scene>;
  41048. /**
  41049. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  41050. * @param flag defines which part of the materials must be marked as dirty
  41051. * @param predicate defines a predicate used to filter which materials should be affected
  41052. */
  41053. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41054. /**
  41055. * Method called to create the default loading screen.
  41056. * This can be overriden in your own app.
  41057. * @param canvas The rendering canvas element
  41058. * @returns The loading screen
  41059. */
  41060. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  41061. /**
  41062. * Method called to create the default rescale post process on each engine.
  41063. */
  41064. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  41065. /**
  41066. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  41067. **/
  41068. enableOfflineSupport: boolean;
  41069. /**
  41070. * 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)
  41071. **/
  41072. disableManifestCheck: boolean;
  41073. /**
  41074. * Gets the list of created scenes
  41075. */
  41076. scenes: Scene[];
  41077. /**
  41078. * Event raised when a new scene is created
  41079. */
  41080. onNewSceneAddedObservable: Observable<Scene>;
  41081. /**
  41082. * Gets the list of created postprocesses
  41083. */
  41084. postProcesses: PostProcess[];
  41085. /**
  41086. * Gets a boolean indicating if the pointer is currently locked
  41087. */
  41088. isPointerLock: boolean;
  41089. /**
  41090. * Observable event triggered each time the rendering canvas is resized
  41091. */
  41092. onResizeObservable: Observable<Engine>;
  41093. /**
  41094. * Observable event triggered each time the canvas loses focus
  41095. */
  41096. onCanvasBlurObservable: Observable<Engine>;
  41097. /**
  41098. * Observable event triggered each time the canvas gains focus
  41099. */
  41100. onCanvasFocusObservable: Observable<Engine>;
  41101. /**
  41102. * Observable event triggered each time the canvas receives pointerout event
  41103. */
  41104. onCanvasPointerOutObservable: Observable<PointerEvent>;
  41105. /**
  41106. * Observable raised when the engine begins a new frame
  41107. */
  41108. onBeginFrameObservable: Observable<Engine>;
  41109. /**
  41110. * If set, will be used to request the next animation frame for the render loop
  41111. */
  41112. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  41113. /**
  41114. * Observable raised when the engine ends the current frame
  41115. */
  41116. onEndFrameObservable: Observable<Engine>;
  41117. /**
  41118. * Observable raised when the engine is about to compile a shader
  41119. */
  41120. onBeforeShaderCompilationObservable: Observable<Engine>;
  41121. /**
  41122. * Observable raised when the engine has jsut compiled a shader
  41123. */
  41124. onAfterShaderCompilationObservable: Observable<Engine>;
  41125. /**
  41126. * Gets the audio engine
  41127. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41128. * @ignorenaming
  41129. */
  41130. static audioEngine: IAudioEngine;
  41131. /**
  41132. * Default AudioEngine factory responsible of creating the Audio Engine.
  41133. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  41134. */
  41135. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  41136. /**
  41137. * Default offline support factory responsible of creating a tool used to store data locally.
  41138. * By default, this will create a Database object if the workload has been embedded.
  41139. */
  41140. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  41141. private _loadingScreen;
  41142. private _pointerLockRequested;
  41143. private _rescalePostProcess;
  41144. private _deterministicLockstep;
  41145. private _lockstepMaxSteps;
  41146. private _timeStep;
  41147. protected get _supportsHardwareTextureRescaling(): boolean;
  41148. private _fps;
  41149. private _deltaTime;
  41150. /** @hidden */
  41151. _drawCalls: PerfCounter;
  41152. /** 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 */
  41153. canvasTabIndex: number;
  41154. /**
  41155. * Turn this value on if you want to pause FPS computation when in background
  41156. */
  41157. disablePerformanceMonitorInBackground: boolean;
  41158. private _performanceMonitor;
  41159. /**
  41160. * Gets the performance monitor attached to this engine
  41161. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41162. */
  41163. get performanceMonitor(): PerformanceMonitor;
  41164. private _onFocus;
  41165. private _onBlur;
  41166. private _onCanvasPointerOut;
  41167. private _onCanvasBlur;
  41168. private _onCanvasFocus;
  41169. private _onFullscreenChange;
  41170. private _onPointerLockChange;
  41171. /**
  41172. * Gets the HTML element used to attach event listeners
  41173. * @returns a HTML element
  41174. */
  41175. getInputElement(): Nullable<HTMLElement>;
  41176. /**
  41177. * Creates a new engine
  41178. * @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
  41179. * @param antialias defines enable antialiasing (default: false)
  41180. * @param options defines further options to be sent to the getContext() function
  41181. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  41182. */
  41183. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  41184. /**
  41185. * Gets current aspect ratio
  41186. * @param viewportOwner defines the camera to use to get the aspect ratio
  41187. * @param useScreen defines if screen size must be used (or the current render target if any)
  41188. * @returns a number defining the aspect ratio
  41189. */
  41190. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  41191. /**
  41192. * Gets current screen aspect ratio
  41193. * @returns a number defining the aspect ratio
  41194. */
  41195. getScreenAspectRatio(): number;
  41196. /**
  41197. * Gets the client rect of the HTML canvas attached with the current webGL context
  41198. * @returns a client rectanglee
  41199. */
  41200. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  41201. /**
  41202. * Gets the client rect of the HTML element used for events
  41203. * @returns a client rectanglee
  41204. */
  41205. getInputElementClientRect(): Nullable<ClientRect>;
  41206. /**
  41207. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  41208. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41209. * @returns true if engine is in deterministic lock step mode
  41210. */
  41211. isDeterministicLockStep(): boolean;
  41212. /**
  41213. * Gets the max steps when engine is running in deterministic lock step
  41214. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41215. * @returns the max steps
  41216. */
  41217. getLockstepMaxSteps(): number;
  41218. /**
  41219. * Returns the time in ms between steps when using deterministic lock step.
  41220. * @returns time step in (ms)
  41221. */
  41222. getTimeStep(): number;
  41223. /**
  41224. * Force the mipmap generation for the given render target texture
  41225. * @param texture defines the render target texture to use
  41226. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  41227. */
  41228. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  41229. /** States */
  41230. /**
  41231. * Set various states to the webGL context
  41232. * @param culling defines backface culling state
  41233. * @param zOffset defines the value to apply to zOffset (0 by default)
  41234. * @param force defines if states must be applied even if cache is up to date
  41235. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  41236. */
  41237. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41238. /**
  41239. * Set the z offset to apply to current rendering
  41240. * @param value defines the offset to apply
  41241. */
  41242. setZOffset(value: number): void;
  41243. /**
  41244. * Gets the current value of the zOffset
  41245. * @returns the current zOffset state
  41246. */
  41247. getZOffset(): number;
  41248. /**
  41249. * Enable or disable depth buffering
  41250. * @param enable defines the state to set
  41251. */
  41252. setDepthBuffer(enable: boolean): void;
  41253. /**
  41254. * Gets a boolean indicating if depth writing is enabled
  41255. * @returns the current depth writing state
  41256. */
  41257. getDepthWrite(): boolean;
  41258. /**
  41259. * Enable or disable depth writing
  41260. * @param enable defines the state to set
  41261. */
  41262. setDepthWrite(enable: boolean): void;
  41263. /**
  41264. * Gets a boolean indicating if stencil buffer is enabled
  41265. * @returns the current stencil buffer state
  41266. */
  41267. getStencilBuffer(): boolean;
  41268. /**
  41269. * Enable or disable the stencil buffer
  41270. * @param enable defines if the stencil buffer must be enabled or disabled
  41271. */
  41272. setStencilBuffer(enable: boolean): void;
  41273. /**
  41274. * Gets the current stencil mask
  41275. * @returns a number defining the new stencil mask to use
  41276. */
  41277. getStencilMask(): number;
  41278. /**
  41279. * Sets the current stencil mask
  41280. * @param mask defines the new stencil mask to use
  41281. */
  41282. setStencilMask(mask: number): void;
  41283. /**
  41284. * Gets the current stencil function
  41285. * @returns a number defining the stencil function to use
  41286. */
  41287. getStencilFunction(): number;
  41288. /**
  41289. * Gets the current stencil reference value
  41290. * @returns a number defining the stencil reference value to use
  41291. */
  41292. getStencilFunctionReference(): number;
  41293. /**
  41294. * Gets the current stencil mask
  41295. * @returns a number defining the stencil mask to use
  41296. */
  41297. getStencilFunctionMask(): number;
  41298. /**
  41299. * Sets the current stencil function
  41300. * @param stencilFunc defines the new stencil function to use
  41301. */
  41302. setStencilFunction(stencilFunc: number): void;
  41303. /**
  41304. * Sets the current stencil reference
  41305. * @param reference defines the new stencil reference to use
  41306. */
  41307. setStencilFunctionReference(reference: number): void;
  41308. /**
  41309. * Sets the current stencil mask
  41310. * @param mask defines the new stencil mask to use
  41311. */
  41312. setStencilFunctionMask(mask: number): void;
  41313. /**
  41314. * Gets the current stencil operation when stencil fails
  41315. * @returns a number defining stencil operation to use when stencil fails
  41316. */
  41317. getStencilOperationFail(): number;
  41318. /**
  41319. * Gets the current stencil operation when depth fails
  41320. * @returns a number defining stencil operation to use when depth fails
  41321. */
  41322. getStencilOperationDepthFail(): number;
  41323. /**
  41324. * Gets the current stencil operation when stencil passes
  41325. * @returns a number defining stencil operation to use when stencil passes
  41326. */
  41327. getStencilOperationPass(): number;
  41328. /**
  41329. * Sets the stencil operation to use when stencil fails
  41330. * @param operation defines the stencil operation to use when stencil fails
  41331. */
  41332. setStencilOperationFail(operation: number): void;
  41333. /**
  41334. * Sets the stencil operation to use when depth fails
  41335. * @param operation defines the stencil operation to use when depth fails
  41336. */
  41337. setStencilOperationDepthFail(operation: number): void;
  41338. /**
  41339. * Sets the stencil operation to use when stencil passes
  41340. * @param operation defines the stencil operation to use when stencil passes
  41341. */
  41342. setStencilOperationPass(operation: number): void;
  41343. /**
  41344. * Sets a boolean indicating if the dithering state is enabled or disabled
  41345. * @param value defines the dithering state
  41346. */
  41347. setDitheringState(value: boolean): void;
  41348. /**
  41349. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  41350. * @param value defines the rasterizer state
  41351. */
  41352. setRasterizerState(value: boolean): void;
  41353. /**
  41354. * Gets the current depth function
  41355. * @returns a number defining the depth function
  41356. */
  41357. getDepthFunction(): Nullable<number>;
  41358. /**
  41359. * Sets the current depth function
  41360. * @param depthFunc defines the function to use
  41361. */
  41362. setDepthFunction(depthFunc: number): void;
  41363. /**
  41364. * Sets the current depth function to GREATER
  41365. */
  41366. setDepthFunctionToGreater(): void;
  41367. /**
  41368. * Sets the current depth function to GEQUAL
  41369. */
  41370. setDepthFunctionToGreaterOrEqual(): void;
  41371. /**
  41372. * Sets the current depth function to LESS
  41373. */
  41374. setDepthFunctionToLess(): void;
  41375. /**
  41376. * Sets the current depth function to LEQUAL
  41377. */
  41378. setDepthFunctionToLessOrEqual(): void;
  41379. private _cachedStencilBuffer;
  41380. private _cachedStencilFunction;
  41381. private _cachedStencilMask;
  41382. private _cachedStencilOperationPass;
  41383. private _cachedStencilOperationFail;
  41384. private _cachedStencilOperationDepthFail;
  41385. private _cachedStencilReference;
  41386. /**
  41387. * Caches the the state of the stencil buffer
  41388. */
  41389. cacheStencilState(): void;
  41390. /**
  41391. * Restores the state of the stencil buffer
  41392. */
  41393. restoreStencilState(): void;
  41394. /**
  41395. * Directly set the WebGL Viewport
  41396. * @param x defines the x coordinate of the viewport (in screen space)
  41397. * @param y defines the y coordinate of the viewport (in screen space)
  41398. * @param width defines the width of the viewport (in screen space)
  41399. * @param height defines the height of the viewport (in screen space)
  41400. * @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
  41401. */
  41402. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  41403. /**
  41404. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  41405. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41406. * @param y defines the y-coordinate of the corner of the clear rectangle
  41407. * @param width defines the width of the clear rectangle
  41408. * @param height defines the height of the clear rectangle
  41409. * @param clearColor defines the clear color
  41410. */
  41411. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  41412. /**
  41413. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  41414. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41415. * @param y defines the y-coordinate of the corner of the clear rectangle
  41416. * @param width defines the width of the clear rectangle
  41417. * @param height defines the height of the clear rectangle
  41418. */
  41419. enableScissor(x: number, y: number, width: number, height: number): void;
  41420. /**
  41421. * Disable previously set scissor test rectangle
  41422. */
  41423. disableScissor(): void;
  41424. protected _reportDrawCall(): void;
  41425. /**
  41426. * Initializes a webVR display and starts listening to display change events
  41427. * The onVRDisplayChangedObservable will be notified upon these changes
  41428. * @returns The onVRDisplayChangedObservable
  41429. */
  41430. initWebVR(): Observable<IDisplayChangedEventArgs>;
  41431. /** @hidden */
  41432. _prepareVRComponent(): void;
  41433. /** @hidden */
  41434. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  41435. /** @hidden */
  41436. _submitVRFrame(): void;
  41437. /**
  41438. * Call this function to leave webVR mode
  41439. * Will do nothing if webVR is not supported or if there is no webVR device
  41440. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41441. */
  41442. disableVR(): void;
  41443. /**
  41444. * Gets a boolean indicating that the system is in VR mode and is presenting
  41445. * @returns true if VR mode is engaged
  41446. */
  41447. isVRPresenting(): boolean;
  41448. /** @hidden */
  41449. _requestVRFrame(): void;
  41450. /** @hidden */
  41451. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41452. /**
  41453. * Gets the source code of the vertex shader associated with a specific webGL program
  41454. * @param program defines the program to use
  41455. * @returns a string containing the source code of the vertex shader associated with the program
  41456. */
  41457. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41458. /**
  41459. * Gets the source code of the fragment shader associated with a specific webGL program
  41460. * @param program defines the program to use
  41461. * @returns a string containing the source code of the fragment shader associated with the program
  41462. */
  41463. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41464. /**
  41465. * Sets a depth stencil texture from a render target to the according uniform.
  41466. * @param channel The texture channel
  41467. * @param uniform The uniform to set
  41468. * @param texture The render target texture containing the depth stencil texture to apply
  41469. */
  41470. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41471. /**
  41472. * Sets a texture to the webGL context from a postprocess
  41473. * @param channel defines the channel to use
  41474. * @param postProcess defines the source postprocess
  41475. */
  41476. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41477. /**
  41478. * Binds the output of the passed in post process to the texture channel specified
  41479. * @param channel The channel the texture should be bound to
  41480. * @param postProcess The post process which's output should be bound
  41481. */
  41482. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41483. protected _rebuildBuffers(): void;
  41484. /** @hidden */
  41485. _renderFrame(): void;
  41486. _renderLoop(): void;
  41487. /** @hidden */
  41488. _renderViews(): boolean;
  41489. /**
  41490. * Toggle full screen mode
  41491. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41492. */
  41493. switchFullscreen(requestPointerLock: boolean): void;
  41494. /**
  41495. * Enters full screen mode
  41496. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41497. */
  41498. enterFullscreen(requestPointerLock: boolean): void;
  41499. /**
  41500. * Exits full screen mode
  41501. */
  41502. exitFullscreen(): void;
  41503. /**
  41504. * Enters Pointerlock mode
  41505. */
  41506. enterPointerlock(): void;
  41507. /**
  41508. * Exits Pointerlock mode
  41509. */
  41510. exitPointerlock(): void;
  41511. /**
  41512. * Begin a new frame
  41513. */
  41514. beginFrame(): void;
  41515. /**
  41516. * Enf the current frame
  41517. */
  41518. endFrame(): void;
  41519. resize(): void;
  41520. /**
  41521. * Force a specific size of the canvas
  41522. * @param width defines the new canvas' width
  41523. * @param height defines the new canvas' height
  41524. * @returns true if the size was changed
  41525. */
  41526. setSize(width: number, height: number): boolean;
  41527. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41528. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41529. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41530. _releaseTexture(texture: InternalTexture): void;
  41531. /**
  41532. * @hidden
  41533. * Rescales a texture
  41534. * @param source input texutre
  41535. * @param destination destination texture
  41536. * @param scene scene to use to render the resize
  41537. * @param internalFormat format to use when resizing
  41538. * @param onComplete callback to be called when resize has completed
  41539. */
  41540. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41541. /**
  41542. * Gets the current framerate
  41543. * @returns a number representing the framerate
  41544. */
  41545. getFps(): number;
  41546. /**
  41547. * Gets the time spent between current and previous frame
  41548. * @returns a number representing the delta time in ms
  41549. */
  41550. getDeltaTime(): number;
  41551. private _measureFps;
  41552. /** @hidden */
  41553. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41554. /**
  41555. * Updates the sample count of a render target texture
  41556. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41557. * @param texture defines the texture to update
  41558. * @param samples defines the sample count to set
  41559. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41560. */
  41561. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41562. /**
  41563. * Updates a depth texture Comparison Mode and Function.
  41564. * If the comparison Function is equal to 0, the mode will be set to none.
  41565. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41566. * @param texture The texture to set the comparison function for
  41567. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41568. */
  41569. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41570. /**
  41571. * Creates a webGL buffer to use with instanciation
  41572. * @param capacity defines the size of the buffer
  41573. * @returns the webGL buffer
  41574. */
  41575. createInstancesBuffer(capacity: number): DataBuffer;
  41576. /**
  41577. * Delete a webGL buffer used with instanciation
  41578. * @param buffer defines the webGL buffer to delete
  41579. */
  41580. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41581. private _clientWaitAsync;
  41582. /** @hidden */
  41583. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41584. dispose(): void;
  41585. private _disableTouchAction;
  41586. /**
  41587. * Display the loading screen
  41588. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41589. */
  41590. displayLoadingUI(): void;
  41591. /**
  41592. * Hide the loading screen
  41593. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41594. */
  41595. hideLoadingUI(): void;
  41596. /**
  41597. * Gets the current loading screen object
  41598. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41599. */
  41600. get loadingScreen(): ILoadingScreen;
  41601. /**
  41602. * Sets the current loading screen object
  41603. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41604. */
  41605. set loadingScreen(loadingScreen: ILoadingScreen);
  41606. /**
  41607. * Sets the current loading screen text
  41608. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41609. */
  41610. set loadingUIText(text: string);
  41611. /**
  41612. * Sets the current loading screen background color
  41613. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41614. */
  41615. set loadingUIBackgroundColor(color: string);
  41616. /** Pointerlock and fullscreen */
  41617. /**
  41618. * Ask the browser to promote the current element to pointerlock mode
  41619. * @param element defines the DOM element to promote
  41620. */
  41621. static _RequestPointerlock(element: HTMLElement): void;
  41622. /**
  41623. * Asks the browser to exit pointerlock mode
  41624. */
  41625. static _ExitPointerlock(): void;
  41626. /**
  41627. * Ask the browser to promote the current element to fullscreen rendering mode
  41628. * @param element defines the DOM element to promote
  41629. */
  41630. static _RequestFullscreen(element: HTMLElement): void;
  41631. /**
  41632. * Asks the browser to exit fullscreen mode
  41633. */
  41634. static _ExitFullscreen(): void;
  41635. }
  41636. }
  41637. declare module BABYLON {
  41638. /**
  41639. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41640. * during the life time of the application.
  41641. */
  41642. export class EngineStore {
  41643. /** Gets the list of created engines */
  41644. static Instances: Engine[];
  41645. /** @hidden */
  41646. static _LastCreatedScene: Nullable<Scene>;
  41647. /**
  41648. * Gets the latest created engine
  41649. */
  41650. static get LastCreatedEngine(): Nullable<Engine>;
  41651. /**
  41652. * Gets the latest created scene
  41653. */
  41654. static get LastCreatedScene(): Nullable<Scene>;
  41655. /**
  41656. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41657. * @ignorenaming
  41658. */
  41659. static UseFallbackTexture: boolean;
  41660. /**
  41661. * Texture content used if a texture cannot loaded
  41662. * @ignorenaming
  41663. */
  41664. static FallbackTexture: string;
  41665. }
  41666. }
  41667. declare module BABYLON {
  41668. /**
  41669. * Helper class that provides a small promise polyfill
  41670. */
  41671. export class PromisePolyfill {
  41672. /**
  41673. * Static function used to check if the polyfill is required
  41674. * If this is the case then the function will inject the polyfill to window.Promise
  41675. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41676. */
  41677. static Apply(force?: boolean): void;
  41678. }
  41679. }
  41680. declare module BABYLON {
  41681. /**
  41682. * Interface for screenshot methods with describe argument called `size` as object with options
  41683. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41684. */
  41685. export interface IScreenshotSize {
  41686. /**
  41687. * number in pixels for canvas height
  41688. */
  41689. height?: number;
  41690. /**
  41691. * multiplier allowing render at a higher or lower resolution
  41692. * If value is defined then height and width will be ignored and taken from camera
  41693. */
  41694. precision?: number;
  41695. /**
  41696. * number in pixels for canvas width
  41697. */
  41698. width?: number;
  41699. }
  41700. }
  41701. declare module BABYLON {
  41702. interface IColor4Like {
  41703. r: float;
  41704. g: float;
  41705. b: float;
  41706. a: float;
  41707. }
  41708. /**
  41709. * Class containing a set of static utilities functions
  41710. */
  41711. export class Tools {
  41712. /**
  41713. * Gets or sets the base URL to use to load assets
  41714. */
  41715. static get BaseUrl(): string;
  41716. static set BaseUrl(value: string);
  41717. /**
  41718. * Enable/Disable Custom HTTP Request Headers globally.
  41719. * default = false
  41720. * @see CustomRequestHeaders
  41721. */
  41722. static UseCustomRequestHeaders: boolean;
  41723. /**
  41724. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41725. * i.e. when loading files, where the server/service expects an Authorization header
  41726. */
  41727. static CustomRequestHeaders: {
  41728. [key: string]: string;
  41729. };
  41730. /**
  41731. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41732. */
  41733. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41734. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41735. /**
  41736. * Default behaviour for cors in the application.
  41737. * It can be a string if the expected behavior is identical in the entire app.
  41738. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41739. */
  41740. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41741. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41742. /**
  41743. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41744. * @ignorenaming
  41745. */
  41746. static get UseFallbackTexture(): boolean;
  41747. static set UseFallbackTexture(value: boolean);
  41748. /**
  41749. * Use this object to register external classes like custom textures or material
  41750. * to allow the laoders to instantiate them
  41751. */
  41752. static get RegisteredExternalClasses(): {
  41753. [key: string]: Object;
  41754. };
  41755. static set RegisteredExternalClasses(classes: {
  41756. [key: string]: Object;
  41757. });
  41758. /**
  41759. * Texture content used if a texture cannot loaded
  41760. * @ignorenaming
  41761. */
  41762. static get fallbackTexture(): string;
  41763. static set fallbackTexture(value: string);
  41764. /**
  41765. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41766. * @param u defines the coordinate on X axis
  41767. * @param v defines the coordinate on Y axis
  41768. * @param width defines the width of the source data
  41769. * @param height defines the height of the source data
  41770. * @param pixels defines the source byte array
  41771. * @param color defines the output color
  41772. */
  41773. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41774. /**
  41775. * Interpolates between a and b via alpha
  41776. * @param a The lower value (returned when alpha = 0)
  41777. * @param b The upper value (returned when alpha = 1)
  41778. * @param alpha The interpolation-factor
  41779. * @return The mixed value
  41780. */
  41781. static Mix(a: number, b: number, alpha: number): number;
  41782. /**
  41783. * Tries to instantiate a new object from a given class name
  41784. * @param className defines the class name to instantiate
  41785. * @returns the new object or null if the system was not able to do the instantiation
  41786. */
  41787. static Instantiate(className: string): any;
  41788. /**
  41789. * Provides a slice function that will work even on IE
  41790. * @param data defines the array to slice
  41791. * @param start defines the start of the data (optional)
  41792. * @param end defines the end of the data (optional)
  41793. * @returns the new sliced array
  41794. */
  41795. static Slice<T>(data: T, start?: number, end?: number): T;
  41796. /**
  41797. * Provides a slice function that will work even on IE
  41798. * The difference between this and Slice is that this will force-convert to array
  41799. * @param data defines the array to slice
  41800. * @param start defines the start of the data (optional)
  41801. * @param end defines the end of the data (optional)
  41802. * @returns the new sliced array
  41803. */
  41804. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41805. /**
  41806. * Polyfill for setImmediate
  41807. * @param action defines the action to execute after the current execution block
  41808. */
  41809. static SetImmediate(action: () => void): void;
  41810. /**
  41811. * Function indicating if a number is an exponent of 2
  41812. * @param value defines the value to test
  41813. * @returns true if the value is an exponent of 2
  41814. */
  41815. static IsExponentOfTwo(value: number): boolean;
  41816. private static _tmpFloatArray;
  41817. /**
  41818. * Returns the nearest 32-bit single precision float representation of a Number
  41819. * @param value A Number. If the parameter is of a different type, it will get converted
  41820. * to a number or to NaN if it cannot be converted
  41821. * @returns number
  41822. */
  41823. static FloatRound(value: number): number;
  41824. /**
  41825. * Extracts the filename from a path
  41826. * @param path defines the path to use
  41827. * @returns the filename
  41828. */
  41829. static GetFilename(path: string): string;
  41830. /**
  41831. * Extracts the "folder" part of a path (everything before the filename).
  41832. * @param uri The URI to extract the info from
  41833. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41834. * @returns The "folder" part of the path
  41835. */
  41836. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41837. /**
  41838. * Extracts text content from a DOM element hierarchy
  41839. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41840. */
  41841. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41842. /**
  41843. * Convert an angle in radians to degrees
  41844. * @param angle defines the angle to convert
  41845. * @returns the angle in degrees
  41846. */
  41847. static ToDegrees(angle: number): number;
  41848. /**
  41849. * Convert an angle in degrees to radians
  41850. * @param angle defines the angle to convert
  41851. * @returns the angle in radians
  41852. */
  41853. static ToRadians(angle: number): number;
  41854. /**
  41855. * Returns an array if obj is not an array
  41856. * @param obj defines the object to evaluate as an array
  41857. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41858. * @returns either obj directly if obj is an array or a new array containing obj
  41859. */
  41860. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41861. /**
  41862. * Gets the pointer prefix to use
  41863. * @param engine defines the engine we are finding the prefix for
  41864. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41865. */
  41866. static GetPointerPrefix(engine: Engine): string;
  41867. /**
  41868. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41869. * @param url define the url we are trying
  41870. * @param element define the dom element where to configure the cors policy
  41871. */
  41872. static SetCorsBehavior(url: string | string[], element: {
  41873. crossOrigin: string | null;
  41874. }): void;
  41875. /**
  41876. * Removes unwanted characters from an url
  41877. * @param url defines the url to clean
  41878. * @returns the cleaned url
  41879. */
  41880. static CleanUrl(url: string): string;
  41881. /**
  41882. * Gets or sets a function used to pre-process url before using them to load assets
  41883. */
  41884. static get PreprocessUrl(): (url: string) => string;
  41885. static set PreprocessUrl(processor: (url: string) => string);
  41886. /**
  41887. * Loads an image as an HTMLImageElement.
  41888. * @param input url string, ArrayBuffer, or Blob to load
  41889. * @param onLoad callback called when the image successfully loads
  41890. * @param onError callback called when the image fails to load
  41891. * @param offlineProvider offline provider for caching
  41892. * @param mimeType optional mime type
  41893. * @returns the HTMLImageElement of the loaded image
  41894. */
  41895. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41896. /**
  41897. * Loads a file from a url
  41898. * @param url url string, ArrayBuffer, or Blob to load
  41899. * @param onSuccess callback called when the file successfully loads
  41900. * @param onProgress callback called while file is loading (if the server supports this mode)
  41901. * @param offlineProvider defines the offline provider for caching
  41902. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41903. * @param onError callback called when the file fails to load
  41904. * @returns a file request object
  41905. */
  41906. 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;
  41907. /**
  41908. * Loads a file from a url
  41909. * @param url the file url to load
  41910. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41911. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41912. */
  41913. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41914. /**
  41915. * Load a script (identified by an url). When the url returns, the
  41916. * content of this file is added into a new script element, attached to the DOM (body element)
  41917. * @param scriptUrl defines the url of the script to laod
  41918. * @param onSuccess defines the callback called when the script is loaded
  41919. * @param onError defines the callback to call if an error occurs
  41920. * @param scriptId defines the id of the script element
  41921. */
  41922. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41923. /**
  41924. * Load an asynchronous script (identified by an url). When the url returns, the
  41925. * content of this file is added into a new script element, attached to the DOM (body element)
  41926. * @param scriptUrl defines the url of the script to laod
  41927. * @param scriptId defines the id of the script element
  41928. * @returns a promise request object
  41929. */
  41930. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41931. /**
  41932. * Loads a file from a blob
  41933. * @param fileToLoad defines the blob to use
  41934. * @param callback defines the callback to call when data is loaded
  41935. * @param progressCallback defines the callback to call during loading process
  41936. * @returns a file request object
  41937. */
  41938. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41939. /**
  41940. * Reads a file from a File object
  41941. * @param file defines the file to load
  41942. * @param onSuccess defines the callback to call when data is loaded
  41943. * @param onProgress defines the callback to call during loading process
  41944. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41945. * @param onError defines the callback to call when an error occurs
  41946. * @returns a file request object
  41947. */
  41948. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41949. /**
  41950. * Creates a data url from a given string content
  41951. * @param content defines the content to convert
  41952. * @returns the new data url link
  41953. */
  41954. static FileAsURL(content: string): string;
  41955. /**
  41956. * Format the given number to a specific decimal format
  41957. * @param value defines the number to format
  41958. * @param decimals defines the number of decimals to use
  41959. * @returns the formatted string
  41960. */
  41961. static Format(value: number, decimals?: number): string;
  41962. /**
  41963. * Tries to copy an object by duplicating every property
  41964. * @param source defines the source object
  41965. * @param destination defines the target object
  41966. * @param doNotCopyList defines a list of properties to avoid
  41967. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41968. */
  41969. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41970. /**
  41971. * Gets a boolean indicating if the given object has no own property
  41972. * @param obj defines the object to test
  41973. * @returns true if object has no own property
  41974. */
  41975. static IsEmpty(obj: any): boolean;
  41976. /**
  41977. * Function used to register events at window level
  41978. * @param windowElement defines the Window object to use
  41979. * @param events defines the events to register
  41980. */
  41981. static RegisterTopRootEvents(windowElement: Window, events: {
  41982. name: string;
  41983. handler: Nullable<(e: FocusEvent) => any>;
  41984. }[]): void;
  41985. /**
  41986. * Function used to unregister events from window level
  41987. * @param windowElement defines the Window object to use
  41988. * @param events defines the events to unregister
  41989. */
  41990. static UnregisterTopRootEvents(windowElement: Window, events: {
  41991. name: string;
  41992. handler: Nullable<(e: FocusEvent) => any>;
  41993. }[]): void;
  41994. /**
  41995. * @ignore
  41996. */
  41997. static _ScreenshotCanvas: HTMLCanvasElement;
  41998. /**
  41999. * Dumps the current bound framebuffer
  42000. * @param width defines the rendering width
  42001. * @param height defines the rendering height
  42002. * @param engine defines the hosting engine
  42003. * @param successCallback defines the callback triggered once the data are available
  42004. * @param mimeType defines the mime type of the result
  42005. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  42006. */
  42007. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42008. /**
  42009. * Converts the canvas data to blob.
  42010. * This acts as a polyfill for browsers not supporting the to blob function.
  42011. * @param canvas Defines the canvas to extract the data from
  42012. * @param successCallback Defines the callback triggered once the data are available
  42013. * @param mimeType Defines the mime type of the result
  42014. */
  42015. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  42016. /**
  42017. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  42018. * @param successCallback defines the callback triggered once the data are available
  42019. * @param mimeType defines the mime type of the result
  42020. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  42021. */
  42022. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42023. /**
  42024. * Downloads a blob in the browser
  42025. * @param blob defines the blob to download
  42026. * @param fileName defines the name of the downloaded file
  42027. */
  42028. static Download(blob: Blob, fileName: string): void;
  42029. /**
  42030. * Will return the right value of the noPreventDefault variable
  42031. * Needed to keep backwards compatibility to the old API.
  42032. *
  42033. * @param args arguments passed to the attachControl function
  42034. * @returns the correct value for noPreventDefault
  42035. */
  42036. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  42037. /**
  42038. * Captures a screenshot of the current rendering
  42039. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42040. * @param engine defines the rendering engine
  42041. * @param camera defines the source camera
  42042. * @param size This parameter can be set to a single number or to an object with the
  42043. * following (optional) properties: precision, width, height. If a single number is passed,
  42044. * it will be used for both width and height. If an object is passed, the screenshot size
  42045. * will be derived from the parameters. The precision property is a multiplier allowing
  42046. * rendering at a higher or lower resolution
  42047. * @param successCallback defines the callback receives a single parameter which contains the
  42048. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42049. * src parameter of an <img> to display it
  42050. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42051. * Check your browser for supported MIME types
  42052. */
  42053. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  42054. /**
  42055. * Captures a screenshot of the current rendering
  42056. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42057. * @param engine defines the rendering engine
  42058. * @param camera defines the source camera
  42059. * @param size This parameter can be set to a single number or to an object with the
  42060. * following (optional) properties: precision, width, height. If a single number is passed,
  42061. * it will be used for both width and height. If an object is passed, the screenshot size
  42062. * will be derived from the parameters. The precision property is a multiplier allowing
  42063. * rendering at a higher or lower resolution
  42064. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42065. * Check your browser for supported MIME types
  42066. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42067. * to the src parameter of an <img> to display it
  42068. */
  42069. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  42070. /**
  42071. * Generates an image screenshot from the specified camera.
  42072. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42073. * @param engine The engine to use for rendering
  42074. * @param camera The camera to use for rendering
  42075. * @param size This parameter can be set to a single number or to an object with the
  42076. * following (optional) properties: precision, width, height. If a single number is passed,
  42077. * it will be used for both width and height. If an object is passed, the screenshot size
  42078. * will be derived from the parameters. The precision property is a multiplier allowing
  42079. * rendering at a higher or lower resolution
  42080. * @param successCallback The callback receives a single parameter which contains the
  42081. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42082. * src parameter of an <img> to display it
  42083. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42084. * Check your browser for supported MIME types
  42085. * @param samples Texture samples (default: 1)
  42086. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42087. * @param fileName A name for for the downloaded file.
  42088. */
  42089. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  42090. /**
  42091. * Generates an image screenshot from the specified camera.
  42092. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42093. * @param engine The engine to use for rendering
  42094. * @param camera The camera to use for rendering
  42095. * @param size This parameter can be set to a single number or to an object with the
  42096. * following (optional) properties: precision, width, height. If a single number is passed,
  42097. * it will be used for both width and height. If an object is passed, the screenshot size
  42098. * will be derived from the parameters. The precision property is a multiplier allowing
  42099. * rendering at a higher or lower resolution
  42100. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42101. * Check your browser for supported MIME types
  42102. * @param samples Texture samples (default: 1)
  42103. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42104. * @param fileName A name for for the downloaded file.
  42105. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42106. * to the src parameter of an <img> to display it
  42107. */
  42108. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  42109. /**
  42110. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  42111. * Be aware Math.random() could cause collisions, but:
  42112. * "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"
  42113. * @returns a pseudo random id
  42114. */
  42115. static RandomId(): string;
  42116. /**
  42117. * Test if the given uri is a base64 string
  42118. * @param uri The uri to test
  42119. * @return True if the uri is a base64 string or false otherwise
  42120. */
  42121. static IsBase64(uri: string): boolean;
  42122. /**
  42123. * Decode the given base64 uri.
  42124. * @param uri The uri to decode
  42125. * @return The decoded base64 data.
  42126. */
  42127. static DecodeBase64(uri: string): ArrayBuffer;
  42128. /**
  42129. * Gets the absolute url.
  42130. * @param url the input url
  42131. * @return the absolute url
  42132. */
  42133. static GetAbsoluteUrl(url: string): string;
  42134. /**
  42135. * No log
  42136. */
  42137. static readonly NoneLogLevel: number;
  42138. /**
  42139. * Only message logs
  42140. */
  42141. static readonly MessageLogLevel: number;
  42142. /**
  42143. * Only warning logs
  42144. */
  42145. static readonly WarningLogLevel: number;
  42146. /**
  42147. * Only error logs
  42148. */
  42149. static readonly ErrorLogLevel: number;
  42150. /**
  42151. * All logs
  42152. */
  42153. static readonly AllLogLevel: number;
  42154. /**
  42155. * Gets a value indicating the number of loading errors
  42156. * @ignorenaming
  42157. */
  42158. static get errorsCount(): number;
  42159. /**
  42160. * Callback called when a new log is added
  42161. */
  42162. static OnNewCacheEntry: (entry: string) => void;
  42163. /**
  42164. * Log a message to the console
  42165. * @param message defines the message to log
  42166. */
  42167. static Log(message: string): void;
  42168. /**
  42169. * Write a warning message to the console
  42170. * @param message defines the message to log
  42171. */
  42172. static Warn(message: string): void;
  42173. /**
  42174. * Write an error message to the console
  42175. * @param message defines the message to log
  42176. */
  42177. static Error(message: string): void;
  42178. /**
  42179. * Gets current log cache (list of logs)
  42180. */
  42181. static get LogCache(): string;
  42182. /**
  42183. * Clears the log cache
  42184. */
  42185. static ClearLogCache(): void;
  42186. /**
  42187. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  42188. */
  42189. static set LogLevels(level: number);
  42190. /**
  42191. * Checks if the window object exists
  42192. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  42193. */
  42194. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  42195. /**
  42196. * No performance log
  42197. */
  42198. static readonly PerformanceNoneLogLevel: number;
  42199. /**
  42200. * Use user marks to log performance
  42201. */
  42202. static readonly PerformanceUserMarkLogLevel: number;
  42203. /**
  42204. * Log performance to the console
  42205. */
  42206. static readonly PerformanceConsoleLogLevel: number;
  42207. private static _performance;
  42208. /**
  42209. * Sets the current performance log level
  42210. */
  42211. static set PerformanceLogLevel(level: number);
  42212. private static _StartPerformanceCounterDisabled;
  42213. private static _EndPerformanceCounterDisabled;
  42214. private static _StartUserMark;
  42215. private static _EndUserMark;
  42216. private static _StartPerformanceConsole;
  42217. private static _EndPerformanceConsole;
  42218. /**
  42219. * Starts a performance counter
  42220. */
  42221. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42222. /**
  42223. * Ends a specific performance coutner
  42224. */
  42225. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42226. /**
  42227. * Gets either window.performance.now() if supported or Date.now() else
  42228. */
  42229. static get Now(): number;
  42230. /**
  42231. * This method will return the name of the class used to create the instance of the given object.
  42232. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  42233. * @param object the object to get the class name from
  42234. * @param isType defines if the object is actually a type
  42235. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  42236. */
  42237. static GetClassName(object: any, isType?: boolean): string;
  42238. /**
  42239. * Gets the first element of an array satisfying a given predicate
  42240. * @param array defines the array to browse
  42241. * @param predicate defines the predicate to use
  42242. * @returns null if not found or the element
  42243. */
  42244. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  42245. /**
  42246. * This method will return the name of the full name of the class, including its owning module (if any).
  42247. * 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).
  42248. * @param object the object to get the class name from
  42249. * @param isType defines if the object is actually a type
  42250. * @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.
  42251. * @ignorenaming
  42252. */
  42253. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  42254. /**
  42255. * Returns a promise that resolves after the given amount of time.
  42256. * @param delay Number of milliseconds to delay
  42257. * @returns Promise that resolves after the given amount of time
  42258. */
  42259. static DelayAsync(delay: number): Promise<void>;
  42260. /**
  42261. * Utility function to detect if the current user agent is Safari
  42262. * @returns whether or not the current user agent is safari
  42263. */
  42264. static IsSafari(): boolean;
  42265. }
  42266. /**
  42267. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  42268. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  42269. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  42270. * @param name The name of the class, case should be preserved
  42271. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  42272. */
  42273. export function className(name: string, module?: string): (target: Object) => void;
  42274. /**
  42275. * An implementation of a loop for asynchronous functions.
  42276. */
  42277. export class AsyncLoop {
  42278. /**
  42279. * Defines the number of iterations for the loop
  42280. */
  42281. iterations: number;
  42282. /**
  42283. * Defines the current index of the loop.
  42284. */
  42285. index: number;
  42286. private _done;
  42287. private _fn;
  42288. private _successCallback;
  42289. /**
  42290. * Constructor.
  42291. * @param iterations the number of iterations.
  42292. * @param func the function to run each iteration
  42293. * @param successCallback the callback that will be called upon succesful execution
  42294. * @param offset starting offset.
  42295. */
  42296. constructor(
  42297. /**
  42298. * Defines the number of iterations for the loop
  42299. */
  42300. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  42301. /**
  42302. * Execute the next iteration. Must be called after the last iteration was finished.
  42303. */
  42304. executeNext(): void;
  42305. /**
  42306. * Break the loop and run the success callback.
  42307. */
  42308. breakLoop(): void;
  42309. /**
  42310. * Create and run an async loop.
  42311. * @param iterations the number of iterations.
  42312. * @param fn the function to run each iteration
  42313. * @param successCallback the callback that will be called upon succesful execution
  42314. * @param offset starting offset.
  42315. * @returns the created async loop object
  42316. */
  42317. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  42318. /**
  42319. * A for-loop that will run a given number of iterations synchronous and the rest async.
  42320. * @param iterations total number of iterations
  42321. * @param syncedIterations number of synchronous iterations in each async iteration.
  42322. * @param fn the function to call each iteration.
  42323. * @param callback a success call back that will be called when iterating stops.
  42324. * @param breakFunction a break condition (optional)
  42325. * @param timeout timeout settings for the setTimeout function. default - 0.
  42326. * @returns the created async loop object
  42327. */
  42328. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  42329. }
  42330. }
  42331. declare module BABYLON {
  42332. /**
  42333. * This class implement a typical dictionary using a string as key and the generic type T as value.
  42334. * The underlying implementation relies on an associative array to ensure the best performances.
  42335. * The value can be anything including 'null' but except 'undefined'
  42336. */
  42337. export class StringDictionary<T> {
  42338. /**
  42339. * This will clear this dictionary and copy the content from the 'source' one.
  42340. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  42341. * @param source the dictionary to take the content from and copy to this dictionary
  42342. */
  42343. copyFrom(source: StringDictionary<T>): void;
  42344. /**
  42345. * Get a value based from its key
  42346. * @param key the given key to get the matching value from
  42347. * @return the value if found, otherwise undefined is returned
  42348. */
  42349. get(key: string): T | undefined;
  42350. /**
  42351. * Get a value from its key or add it if it doesn't exist.
  42352. * This method will ensure you that a given key/data will be present in the dictionary.
  42353. * @param key the given key to get the matching value from
  42354. * @param factory the factory that will create the value if the key is not present in the dictionary.
  42355. * The factory will only be invoked if there's no data for the given key.
  42356. * @return the value corresponding to the key.
  42357. */
  42358. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  42359. /**
  42360. * Get a value from its key if present in the dictionary otherwise add it
  42361. * @param key the key to get the value from
  42362. * @param val if there's no such key/value pair in the dictionary add it with this value
  42363. * @return the value corresponding to the key
  42364. */
  42365. getOrAdd(key: string, val: T): T;
  42366. /**
  42367. * Check if there's a given key in the dictionary
  42368. * @param key the key to check for
  42369. * @return true if the key is present, false otherwise
  42370. */
  42371. contains(key: string): boolean;
  42372. /**
  42373. * Add a new key and its corresponding value
  42374. * @param key the key to add
  42375. * @param value the value corresponding to the key
  42376. * @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
  42377. */
  42378. add(key: string, value: T): boolean;
  42379. /**
  42380. * Update a specific value associated to a key
  42381. * @param key defines the key to use
  42382. * @param value defines the value to store
  42383. * @returns true if the value was updated (or false if the key was not found)
  42384. */
  42385. set(key: string, value: T): boolean;
  42386. /**
  42387. * Get the element of the given key and remove it from the dictionary
  42388. * @param key defines the key to search
  42389. * @returns the value associated with the key or null if not found
  42390. */
  42391. getAndRemove(key: string): Nullable<T>;
  42392. /**
  42393. * Remove a key/value from the dictionary.
  42394. * @param key the key to remove
  42395. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  42396. */
  42397. remove(key: string): boolean;
  42398. /**
  42399. * Clear the whole content of the dictionary
  42400. */
  42401. clear(): void;
  42402. /**
  42403. * Gets the current count
  42404. */
  42405. get count(): number;
  42406. /**
  42407. * Execute a callback on each key/val of the dictionary.
  42408. * Note that you can remove any element in this dictionary in the callback implementation
  42409. * @param callback the callback to execute on a given key/value pair
  42410. */
  42411. forEach(callback: (key: string, val: T) => void): void;
  42412. /**
  42413. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  42414. * If the callback returns null or undefined the method will iterate to the next key/value pair
  42415. * Note that you can remove any element in this dictionary in the callback implementation
  42416. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  42417. * @returns the first item
  42418. */
  42419. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  42420. private _count;
  42421. private _data;
  42422. }
  42423. }
  42424. declare module BABYLON {
  42425. /** @hidden */
  42426. export interface ICollisionCoordinator {
  42427. createCollider(): Collider;
  42428. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42429. init(scene: Scene): void;
  42430. }
  42431. /** @hidden */
  42432. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  42433. private _scene;
  42434. private _scaledPosition;
  42435. private _scaledVelocity;
  42436. private _finalPosition;
  42437. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42438. createCollider(): Collider;
  42439. init(scene: Scene): void;
  42440. private _collideWithWorld;
  42441. }
  42442. }
  42443. declare module BABYLON {
  42444. /**
  42445. * Class used to manage all inputs for the scene.
  42446. */
  42447. export class InputManager {
  42448. /** The distance in pixel that you have to move to prevent some events */
  42449. static DragMovementThreshold: number;
  42450. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42451. static LongPressDelay: number;
  42452. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42453. static DoubleClickDelay: number;
  42454. /** If you need to check double click without raising a single click at first click, enable this flag */
  42455. static ExclusiveDoubleClickMode: boolean;
  42456. /** 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. */
  42457. private _alreadyAttached;
  42458. private _alreadyAttachedTo;
  42459. private _wheelEventName;
  42460. private _onPointerMove;
  42461. private _onPointerDown;
  42462. private _onPointerUp;
  42463. private _initClickEvent;
  42464. private _initActionManager;
  42465. private _delayedSimpleClick;
  42466. private _delayedSimpleClickTimeout;
  42467. private _previousDelayedSimpleClickTimeout;
  42468. private _meshPickProceed;
  42469. private _previousButtonPressed;
  42470. private _currentPickResult;
  42471. private _previousPickResult;
  42472. private _totalPointersPressed;
  42473. private _doubleClickOccured;
  42474. private _pointerOverMesh;
  42475. private _pickedDownMesh;
  42476. private _pickedUpMesh;
  42477. private _pointerX;
  42478. private _pointerY;
  42479. private _unTranslatedPointerX;
  42480. private _unTranslatedPointerY;
  42481. private _startingPointerPosition;
  42482. private _previousStartingPointerPosition;
  42483. private _startingPointerTime;
  42484. private _previousStartingPointerTime;
  42485. private _pointerCaptures;
  42486. private _meshUnderPointerId;
  42487. private _onKeyDown;
  42488. private _onKeyUp;
  42489. private _keyboardIsAttached;
  42490. private _onCanvasFocusObserver;
  42491. private _onCanvasBlurObserver;
  42492. private _scene;
  42493. /**
  42494. * Creates a new InputManager
  42495. * @param scene defines the hosting scene
  42496. */
  42497. constructor(scene: Scene);
  42498. /**
  42499. * Gets the mesh that is currently under the pointer
  42500. */
  42501. get meshUnderPointer(): Nullable<AbstractMesh>;
  42502. /**
  42503. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42504. * @param pointerId the pointer id to use
  42505. * @returns The mesh under this pointer id or null if not found
  42506. */
  42507. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42508. /**
  42509. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42510. */
  42511. get unTranslatedPointer(): Vector2;
  42512. /**
  42513. * Gets or sets the current on-screen X position of the pointer
  42514. */
  42515. get pointerX(): number;
  42516. set pointerX(value: number);
  42517. /**
  42518. * Gets or sets the current on-screen Y position of the pointer
  42519. */
  42520. get pointerY(): number;
  42521. set pointerY(value: number);
  42522. private _updatePointerPosition;
  42523. private _processPointerMove;
  42524. private _setRayOnPointerInfo;
  42525. private _checkPrePointerObservable;
  42526. /**
  42527. * Use this method to simulate a pointer move on a mesh
  42528. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42529. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42530. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42531. */
  42532. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42533. /**
  42534. * Use this method to simulate a pointer down on a mesh
  42535. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42536. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42537. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42538. */
  42539. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42540. private _processPointerDown;
  42541. /** @hidden */
  42542. _isPointerSwiping(): boolean;
  42543. /**
  42544. * Use this method to simulate a pointer up on a mesh
  42545. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42546. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42547. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42548. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42549. */
  42550. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42551. private _processPointerUp;
  42552. /**
  42553. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42554. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42555. * @returns true if the pointer was captured
  42556. */
  42557. isPointerCaptured(pointerId?: number): boolean;
  42558. /**
  42559. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42560. * @param attachUp defines if you want to attach events to pointerup
  42561. * @param attachDown defines if you want to attach events to pointerdown
  42562. * @param attachMove defines if you want to attach events to pointermove
  42563. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42564. */
  42565. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42566. /**
  42567. * Detaches all event handlers
  42568. */
  42569. detachControl(): void;
  42570. /**
  42571. * Force the value of meshUnderPointer
  42572. * @param mesh defines the mesh to use
  42573. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42574. */
  42575. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42576. /**
  42577. * Gets the mesh under the pointer
  42578. * @returns a Mesh or null if no mesh is under the pointer
  42579. */
  42580. getPointerOverMesh(): Nullable<AbstractMesh>;
  42581. }
  42582. }
  42583. declare module BABYLON {
  42584. /**
  42585. * This class defines the direct association between an animation and a target
  42586. */
  42587. export class TargetedAnimation {
  42588. /**
  42589. * Animation to perform
  42590. */
  42591. animation: Animation;
  42592. /**
  42593. * Target to animate
  42594. */
  42595. target: any;
  42596. /**
  42597. * Returns the string "TargetedAnimation"
  42598. * @returns "TargetedAnimation"
  42599. */
  42600. getClassName(): string;
  42601. /**
  42602. * Serialize the object
  42603. * @returns the JSON object representing the current entity
  42604. */
  42605. serialize(): any;
  42606. }
  42607. /**
  42608. * Use this class to create coordinated animations on multiple targets
  42609. */
  42610. export class AnimationGroup implements IDisposable {
  42611. /** The name of the animation group */
  42612. name: string;
  42613. private _scene;
  42614. private _targetedAnimations;
  42615. private _animatables;
  42616. private _from;
  42617. private _to;
  42618. private _isStarted;
  42619. private _isPaused;
  42620. private _speedRatio;
  42621. private _loopAnimation;
  42622. private _isAdditive;
  42623. /**
  42624. * Gets or sets the unique id of the node
  42625. */
  42626. uniqueId: number;
  42627. /**
  42628. * This observable will notify when one animation have ended
  42629. */
  42630. onAnimationEndObservable: Observable<TargetedAnimation>;
  42631. /**
  42632. * Observer raised when one animation loops
  42633. */
  42634. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42635. /**
  42636. * Observer raised when all animations have looped
  42637. */
  42638. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42639. /**
  42640. * This observable will notify when all animations have ended.
  42641. */
  42642. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42643. /**
  42644. * This observable will notify when all animations have paused.
  42645. */
  42646. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42647. /**
  42648. * This observable will notify when all animations are playing.
  42649. */
  42650. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42651. /**
  42652. * Gets the first frame
  42653. */
  42654. get from(): number;
  42655. /**
  42656. * Gets the last frame
  42657. */
  42658. get to(): number;
  42659. /**
  42660. * Define if the animations are started
  42661. */
  42662. get isStarted(): boolean;
  42663. /**
  42664. * Gets a value indicating that the current group is playing
  42665. */
  42666. get isPlaying(): boolean;
  42667. /**
  42668. * Gets or sets the speed ratio to use for all animations
  42669. */
  42670. get speedRatio(): number;
  42671. /**
  42672. * Gets or sets the speed ratio to use for all animations
  42673. */
  42674. set speedRatio(value: number);
  42675. /**
  42676. * Gets or sets if all animations should loop or not
  42677. */
  42678. get loopAnimation(): boolean;
  42679. set loopAnimation(value: boolean);
  42680. /**
  42681. * Gets or sets if all animations should be evaluated additively
  42682. */
  42683. get isAdditive(): boolean;
  42684. set isAdditive(value: boolean);
  42685. /**
  42686. * Gets the targeted animations for this animation group
  42687. */
  42688. get targetedAnimations(): Array<TargetedAnimation>;
  42689. /**
  42690. * returning the list of animatables controlled by this animation group.
  42691. */
  42692. get animatables(): Array<Animatable>;
  42693. /**
  42694. * Gets the list of target animations
  42695. */
  42696. get children(): TargetedAnimation[];
  42697. /**
  42698. * Instantiates a new Animation Group.
  42699. * This helps managing several animations at once.
  42700. * @see https://doc.babylonjs.com/how_to/group
  42701. * @param name Defines the name of the group
  42702. * @param scene Defines the scene the group belongs to
  42703. */
  42704. constructor(
  42705. /** The name of the animation group */
  42706. name: string, scene?: Nullable<Scene>);
  42707. /**
  42708. * Add an animation (with its target) in the group
  42709. * @param animation defines the animation we want to add
  42710. * @param target defines the target of the animation
  42711. * @returns the TargetedAnimation object
  42712. */
  42713. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42714. /**
  42715. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42716. * It can add constant keys at begin or end
  42717. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42718. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42719. * @returns the animation group
  42720. */
  42721. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42722. private _animationLoopCount;
  42723. private _animationLoopFlags;
  42724. private _processLoop;
  42725. /**
  42726. * Start all animations on given targets
  42727. * @param loop defines if animations must loop
  42728. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42729. * @param from defines the from key (optional)
  42730. * @param to defines the to key (optional)
  42731. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42732. * @returns the current animation group
  42733. */
  42734. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42735. /**
  42736. * Pause all animations
  42737. * @returns the animation group
  42738. */
  42739. pause(): AnimationGroup;
  42740. /**
  42741. * Play all animations to initial state
  42742. * This function will start() the animations if they were not started or will restart() them if they were paused
  42743. * @param loop defines if animations must loop
  42744. * @returns the animation group
  42745. */
  42746. play(loop?: boolean): AnimationGroup;
  42747. /**
  42748. * Reset all animations to initial state
  42749. * @returns the animation group
  42750. */
  42751. reset(): AnimationGroup;
  42752. /**
  42753. * Restart animations from key 0
  42754. * @returns the animation group
  42755. */
  42756. restart(): AnimationGroup;
  42757. /**
  42758. * Stop all animations
  42759. * @returns the animation group
  42760. */
  42761. stop(): AnimationGroup;
  42762. /**
  42763. * Set animation weight for all animatables
  42764. * @param weight defines the weight to use
  42765. * @return the animationGroup
  42766. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42767. */
  42768. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42769. /**
  42770. * Synchronize and normalize all animatables with a source animatable
  42771. * @param root defines the root animatable to synchronize with
  42772. * @return the animationGroup
  42773. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42774. */
  42775. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42776. /**
  42777. * Goes to a specific frame in this animation group
  42778. * @param frame the frame number to go to
  42779. * @return the animationGroup
  42780. */
  42781. goToFrame(frame: number): AnimationGroup;
  42782. /**
  42783. * Dispose all associated resources
  42784. */
  42785. dispose(): void;
  42786. private _checkAnimationGroupEnded;
  42787. /**
  42788. * Clone the current animation group and returns a copy
  42789. * @param newName defines the name of the new group
  42790. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42791. * @returns the new aniamtion group
  42792. */
  42793. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42794. /**
  42795. * Serializes the animationGroup to an object
  42796. * @returns Serialized object
  42797. */
  42798. serialize(): any;
  42799. /**
  42800. * Returns a new AnimationGroup object parsed from the source provided.
  42801. * @param parsedAnimationGroup defines the source
  42802. * @param scene defines the scene that will receive the animationGroup
  42803. * @returns a new AnimationGroup
  42804. */
  42805. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42806. /**
  42807. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42808. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42809. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42810. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42811. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42812. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42813. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42814. */
  42815. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42816. /**
  42817. * Returns the string "AnimationGroup"
  42818. * @returns "AnimationGroup"
  42819. */
  42820. getClassName(): string;
  42821. /**
  42822. * Creates a detailled string about the object
  42823. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42824. * @returns a string representing the object
  42825. */
  42826. toString(fullDetails?: boolean): string;
  42827. }
  42828. }
  42829. declare module BABYLON {
  42830. /**
  42831. * Define an interface for all classes that will hold resources
  42832. */
  42833. export interface IDisposable {
  42834. /**
  42835. * Releases all held resources
  42836. */
  42837. dispose(): void;
  42838. }
  42839. /** Interface defining initialization parameters for Scene class */
  42840. export interface SceneOptions {
  42841. /**
  42842. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42843. * It will improve performance when the number of geometries becomes important.
  42844. */
  42845. useGeometryUniqueIdsMap?: boolean;
  42846. /**
  42847. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42848. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42849. */
  42850. useMaterialMeshMap?: boolean;
  42851. /**
  42852. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42853. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42854. */
  42855. useClonedMeshMap?: boolean;
  42856. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42857. virtual?: boolean;
  42858. }
  42859. /**
  42860. * Represents a scene to be rendered by the engine.
  42861. * @see https://doc.babylonjs.com/features/scene
  42862. */
  42863. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42864. /** The fog is deactivated */
  42865. static readonly FOGMODE_NONE: number;
  42866. /** The fog density is following an exponential function */
  42867. static readonly FOGMODE_EXP: number;
  42868. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42869. static readonly FOGMODE_EXP2: number;
  42870. /** The fog density is following a linear function. */
  42871. static readonly FOGMODE_LINEAR: number;
  42872. /**
  42873. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42874. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42875. */
  42876. static MinDeltaTime: number;
  42877. /**
  42878. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42879. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42880. */
  42881. static MaxDeltaTime: number;
  42882. /**
  42883. * Factory used to create the default material.
  42884. * @param name The name of the material to create
  42885. * @param scene The scene to create the material for
  42886. * @returns The default material
  42887. */
  42888. static DefaultMaterialFactory(scene: Scene): Material;
  42889. /**
  42890. * Factory used to create the a collision coordinator.
  42891. * @returns The collision coordinator
  42892. */
  42893. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42894. /** @hidden */
  42895. _inputManager: InputManager;
  42896. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42897. cameraToUseForPointers: Nullable<Camera>;
  42898. /** @hidden */
  42899. readonly _isScene: boolean;
  42900. /** @hidden */
  42901. _blockEntityCollection: boolean;
  42902. /**
  42903. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42904. */
  42905. autoClear: boolean;
  42906. /**
  42907. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42908. */
  42909. autoClearDepthAndStencil: boolean;
  42910. /**
  42911. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42912. */
  42913. clearColor: Color4;
  42914. /**
  42915. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42916. */
  42917. ambientColor: Color3;
  42918. /**
  42919. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42920. * It should only be one of the following (if not the default embedded one):
  42921. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42922. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42923. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42924. * The material properties need to be setup according to the type of texture in use.
  42925. */
  42926. environmentBRDFTexture: BaseTexture;
  42927. /**
  42928. * Texture used in all pbr material as the reflection texture.
  42929. * As in the majority of the scene they are the same (exception for multi room and so on),
  42930. * this is easier to reference from here than from all the materials.
  42931. */
  42932. get environmentTexture(): Nullable<BaseTexture>;
  42933. /**
  42934. * Texture used in all pbr material as the reflection texture.
  42935. * As in the majority of the scene they are the same (exception for multi room and so on),
  42936. * this is easier to set here than in all the materials.
  42937. */
  42938. set environmentTexture(value: Nullable<BaseTexture>);
  42939. /** @hidden */
  42940. protected _environmentIntensity: number;
  42941. /**
  42942. * Intensity of the environment in all pbr material.
  42943. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42944. * As in the majority of the scene they are the same (exception for multi room and so on),
  42945. * this is easier to reference from here than from all the materials.
  42946. */
  42947. get environmentIntensity(): number;
  42948. /**
  42949. * Intensity of the environment in all pbr material.
  42950. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42951. * As in the majority of the scene they are the same (exception for multi room and so on),
  42952. * this is easier to set here than in all the materials.
  42953. */
  42954. set environmentIntensity(value: number);
  42955. /** @hidden */
  42956. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42957. /**
  42958. * Default image processing configuration used either in the rendering
  42959. * Forward main pass or through the imageProcessingPostProcess if present.
  42960. * As in the majority of the scene they are the same (exception for multi camera),
  42961. * this is easier to reference from here than from all the materials and post process.
  42962. *
  42963. * No setter as we it is a shared configuration, you can set the values instead.
  42964. */
  42965. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42966. private _forceWireframe;
  42967. /**
  42968. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42969. */
  42970. set forceWireframe(value: boolean);
  42971. get forceWireframe(): boolean;
  42972. private _skipFrustumClipping;
  42973. /**
  42974. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42975. */
  42976. set skipFrustumClipping(value: boolean);
  42977. get skipFrustumClipping(): boolean;
  42978. private _forcePointsCloud;
  42979. /**
  42980. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42981. */
  42982. set forcePointsCloud(value: boolean);
  42983. get forcePointsCloud(): boolean;
  42984. /**
  42985. * Gets or sets the active clipplane 1
  42986. */
  42987. clipPlane: Nullable<Plane>;
  42988. /**
  42989. * Gets or sets the active clipplane 2
  42990. */
  42991. clipPlane2: Nullable<Plane>;
  42992. /**
  42993. * Gets or sets the active clipplane 3
  42994. */
  42995. clipPlane3: Nullable<Plane>;
  42996. /**
  42997. * Gets or sets the active clipplane 4
  42998. */
  42999. clipPlane4: Nullable<Plane>;
  43000. /**
  43001. * Gets or sets the active clipplane 5
  43002. */
  43003. clipPlane5: Nullable<Plane>;
  43004. /**
  43005. * Gets or sets the active clipplane 6
  43006. */
  43007. clipPlane6: Nullable<Plane>;
  43008. /**
  43009. * Gets or sets a boolean indicating if animations are enabled
  43010. */
  43011. animationsEnabled: boolean;
  43012. private _animationPropertiesOverride;
  43013. /**
  43014. * Gets or sets the animation properties override
  43015. */
  43016. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  43017. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  43018. /**
  43019. * Gets or sets a boolean indicating if a constant deltatime has to be used
  43020. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  43021. */
  43022. useConstantAnimationDeltaTime: boolean;
  43023. /**
  43024. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  43025. * Please note that it requires to run a ray cast through the scene on every frame
  43026. */
  43027. constantlyUpdateMeshUnderPointer: boolean;
  43028. /**
  43029. * Defines the HTML cursor to use when hovering over interactive elements
  43030. */
  43031. hoverCursor: string;
  43032. /**
  43033. * Defines the HTML default cursor to use (empty by default)
  43034. */
  43035. defaultCursor: string;
  43036. /**
  43037. * Defines whether cursors are handled by the scene.
  43038. */
  43039. doNotHandleCursors: boolean;
  43040. /**
  43041. * This is used to call preventDefault() on pointer down
  43042. * in order to block unwanted artifacts like system double clicks
  43043. */
  43044. preventDefaultOnPointerDown: boolean;
  43045. /**
  43046. * This is used to call preventDefault() on pointer up
  43047. * in order to block unwanted artifacts like system double clicks
  43048. */
  43049. preventDefaultOnPointerUp: boolean;
  43050. /**
  43051. * Gets or sets user defined metadata
  43052. */
  43053. metadata: any;
  43054. /**
  43055. * For internal use only. Please do not use.
  43056. */
  43057. reservedDataStore: any;
  43058. /**
  43059. * Gets the name of the plugin used to load this scene (null by default)
  43060. */
  43061. loadingPluginName: string;
  43062. /**
  43063. * Use this array to add regular expressions used to disable offline support for specific urls
  43064. */
  43065. disableOfflineSupportExceptionRules: RegExp[];
  43066. /**
  43067. * An event triggered when the scene is disposed.
  43068. */
  43069. onDisposeObservable: Observable<Scene>;
  43070. private _onDisposeObserver;
  43071. /** Sets a function to be executed when this scene is disposed. */
  43072. set onDispose(callback: () => void);
  43073. /**
  43074. * An event triggered before rendering the scene (right after animations and physics)
  43075. */
  43076. onBeforeRenderObservable: Observable<Scene>;
  43077. private _onBeforeRenderObserver;
  43078. /** Sets a function to be executed before rendering this scene */
  43079. set beforeRender(callback: Nullable<() => void>);
  43080. /**
  43081. * An event triggered after rendering the scene
  43082. */
  43083. onAfterRenderObservable: Observable<Scene>;
  43084. /**
  43085. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  43086. */
  43087. onAfterRenderCameraObservable: Observable<Camera>;
  43088. private _onAfterRenderObserver;
  43089. /** Sets a function to be executed after rendering this scene */
  43090. set afterRender(callback: Nullable<() => void>);
  43091. /**
  43092. * An event triggered before animating the scene
  43093. */
  43094. onBeforeAnimationsObservable: Observable<Scene>;
  43095. /**
  43096. * An event triggered after animations processing
  43097. */
  43098. onAfterAnimationsObservable: Observable<Scene>;
  43099. /**
  43100. * An event triggered before draw calls are ready to be sent
  43101. */
  43102. onBeforeDrawPhaseObservable: Observable<Scene>;
  43103. /**
  43104. * An event triggered after draw calls have been sent
  43105. */
  43106. onAfterDrawPhaseObservable: Observable<Scene>;
  43107. /**
  43108. * An event triggered when the scene is ready
  43109. */
  43110. onReadyObservable: Observable<Scene>;
  43111. /**
  43112. * An event triggered before rendering a camera
  43113. */
  43114. onBeforeCameraRenderObservable: Observable<Camera>;
  43115. private _onBeforeCameraRenderObserver;
  43116. /** Sets a function to be executed before rendering a camera*/
  43117. set beforeCameraRender(callback: () => void);
  43118. /**
  43119. * An event triggered after rendering a camera
  43120. */
  43121. onAfterCameraRenderObservable: Observable<Camera>;
  43122. private _onAfterCameraRenderObserver;
  43123. /** Sets a function to be executed after rendering a camera*/
  43124. set afterCameraRender(callback: () => void);
  43125. /**
  43126. * An event triggered when active meshes evaluation is about to start
  43127. */
  43128. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  43129. /**
  43130. * An event triggered when active meshes evaluation is done
  43131. */
  43132. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  43133. /**
  43134. * An event triggered when particles rendering is about to start
  43135. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43136. */
  43137. onBeforeParticlesRenderingObservable: Observable<Scene>;
  43138. /**
  43139. * An event triggered when particles rendering is done
  43140. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43141. */
  43142. onAfterParticlesRenderingObservable: Observable<Scene>;
  43143. /**
  43144. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  43145. */
  43146. onDataLoadedObservable: Observable<Scene>;
  43147. /**
  43148. * An event triggered when a camera is created
  43149. */
  43150. onNewCameraAddedObservable: Observable<Camera>;
  43151. /**
  43152. * An event triggered when a camera is removed
  43153. */
  43154. onCameraRemovedObservable: Observable<Camera>;
  43155. /**
  43156. * An event triggered when a light is created
  43157. */
  43158. onNewLightAddedObservable: Observable<Light>;
  43159. /**
  43160. * An event triggered when a light is removed
  43161. */
  43162. onLightRemovedObservable: Observable<Light>;
  43163. /**
  43164. * An event triggered when a geometry is created
  43165. */
  43166. onNewGeometryAddedObservable: Observable<Geometry>;
  43167. /**
  43168. * An event triggered when a geometry is removed
  43169. */
  43170. onGeometryRemovedObservable: Observable<Geometry>;
  43171. /**
  43172. * An event triggered when a transform node is created
  43173. */
  43174. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  43175. /**
  43176. * An event triggered when a transform node is removed
  43177. */
  43178. onTransformNodeRemovedObservable: Observable<TransformNode>;
  43179. /**
  43180. * An event triggered when a mesh is created
  43181. */
  43182. onNewMeshAddedObservable: Observable<AbstractMesh>;
  43183. /**
  43184. * An event triggered when a mesh is removed
  43185. */
  43186. onMeshRemovedObservable: Observable<AbstractMesh>;
  43187. /**
  43188. * An event triggered when a skeleton is created
  43189. */
  43190. onNewSkeletonAddedObservable: Observable<Skeleton>;
  43191. /**
  43192. * An event triggered when a skeleton is removed
  43193. */
  43194. onSkeletonRemovedObservable: Observable<Skeleton>;
  43195. /**
  43196. * An event triggered when a material is created
  43197. */
  43198. onNewMaterialAddedObservable: Observable<Material>;
  43199. /**
  43200. * An event triggered when a multi material is created
  43201. */
  43202. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  43203. /**
  43204. * An event triggered when a material is removed
  43205. */
  43206. onMaterialRemovedObservable: Observable<Material>;
  43207. /**
  43208. * An event triggered when a multi material is removed
  43209. */
  43210. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  43211. /**
  43212. * An event triggered when a texture is created
  43213. */
  43214. onNewTextureAddedObservable: Observable<BaseTexture>;
  43215. /**
  43216. * An event triggered when a texture is removed
  43217. */
  43218. onTextureRemovedObservable: Observable<BaseTexture>;
  43219. /**
  43220. * An event triggered when render targets are about to be rendered
  43221. * Can happen multiple times per frame.
  43222. */
  43223. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  43224. /**
  43225. * An event triggered when render targets were rendered.
  43226. * Can happen multiple times per frame.
  43227. */
  43228. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  43229. /**
  43230. * An event triggered before calculating deterministic simulation step
  43231. */
  43232. onBeforeStepObservable: Observable<Scene>;
  43233. /**
  43234. * An event triggered after calculating deterministic simulation step
  43235. */
  43236. onAfterStepObservable: Observable<Scene>;
  43237. /**
  43238. * An event triggered when the activeCamera property is updated
  43239. */
  43240. onActiveCameraChanged: Observable<Scene>;
  43241. /**
  43242. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  43243. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43244. * 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)
  43245. */
  43246. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43247. /**
  43248. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  43249. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43250. * 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)
  43251. */
  43252. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43253. /**
  43254. * This Observable will when a mesh has been imported into the scene.
  43255. */
  43256. onMeshImportedObservable: Observable<AbstractMesh>;
  43257. /**
  43258. * This Observable will when an animation file has been imported into the scene.
  43259. */
  43260. onAnimationFileImportedObservable: Observable<Scene>;
  43261. /**
  43262. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  43263. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  43264. */
  43265. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  43266. /** @hidden */
  43267. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  43268. /**
  43269. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  43270. */
  43271. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  43272. /**
  43273. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  43274. */
  43275. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  43276. /**
  43277. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  43278. */
  43279. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  43280. /** Callback called when a pointer move is detected */
  43281. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43282. /** Callback called when a pointer down is detected */
  43283. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43284. /** Callback called when a pointer up is detected */
  43285. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  43286. /** Callback called when a pointer pick is detected */
  43287. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  43288. /**
  43289. * 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).
  43290. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  43291. */
  43292. onPrePointerObservable: Observable<PointerInfoPre>;
  43293. /**
  43294. * Observable event triggered each time an input event is received from the rendering canvas
  43295. */
  43296. onPointerObservable: Observable<PointerInfo>;
  43297. /**
  43298. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  43299. */
  43300. get unTranslatedPointer(): Vector2;
  43301. /**
  43302. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  43303. */
  43304. static get DragMovementThreshold(): number;
  43305. static set DragMovementThreshold(value: number);
  43306. /**
  43307. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  43308. */
  43309. static get LongPressDelay(): number;
  43310. static set LongPressDelay(value: number);
  43311. /**
  43312. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  43313. */
  43314. static get DoubleClickDelay(): number;
  43315. static set DoubleClickDelay(value: number);
  43316. /** If you need to check double click without raising a single click at first click, enable this flag */
  43317. static get ExclusiveDoubleClickMode(): boolean;
  43318. static set ExclusiveDoubleClickMode(value: boolean);
  43319. /** @hidden */
  43320. _mirroredCameraPosition: Nullable<Vector3>;
  43321. /**
  43322. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  43323. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  43324. */
  43325. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  43326. /**
  43327. * Observable event triggered each time an keyboard event is received from the hosting window
  43328. */
  43329. onKeyboardObservable: Observable<KeyboardInfo>;
  43330. private _useRightHandedSystem;
  43331. /**
  43332. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  43333. */
  43334. set useRightHandedSystem(value: boolean);
  43335. get useRightHandedSystem(): boolean;
  43336. private _timeAccumulator;
  43337. private _currentStepId;
  43338. private _currentInternalStep;
  43339. /**
  43340. * Sets the step Id used by deterministic lock step
  43341. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43342. * @param newStepId defines the step Id
  43343. */
  43344. setStepId(newStepId: number): void;
  43345. /**
  43346. * Gets the step Id used by deterministic lock step
  43347. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43348. * @returns the step Id
  43349. */
  43350. getStepId(): number;
  43351. /**
  43352. * Gets the internal step used by deterministic lock step
  43353. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43354. * @returns the internal step
  43355. */
  43356. getInternalStep(): number;
  43357. private _fogEnabled;
  43358. /**
  43359. * Gets or sets a boolean indicating if fog is enabled on this scene
  43360. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43361. * (Default is true)
  43362. */
  43363. set fogEnabled(value: boolean);
  43364. get fogEnabled(): boolean;
  43365. private _fogMode;
  43366. /**
  43367. * Gets or sets the fog mode to use
  43368. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43369. * | mode | value |
  43370. * | --- | --- |
  43371. * | FOGMODE_NONE | 0 |
  43372. * | FOGMODE_EXP | 1 |
  43373. * | FOGMODE_EXP2 | 2 |
  43374. * | FOGMODE_LINEAR | 3 |
  43375. */
  43376. set fogMode(value: number);
  43377. get fogMode(): number;
  43378. /**
  43379. * Gets or sets the fog color to use
  43380. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43381. * (Default is Color3(0.2, 0.2, 0.3))
  43382. */
  43383. fogColor: Color3;
  43384. /**
  43385. * Gets or sets the fog density to use
  43386. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43387. * (Default is 0.1)
  43388. */
  43389. fogDensity: number;
  43390. /**
  43391. * Gets or sets the fog start distance to use
  43392. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43393. * (Default is 0)
  43394. */
  43395. fogStart: number;
  43396. /**
  43397. * Gets or sets the fog end distance to use
  43398. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43399. * (Default is 1000)
  43400. */
  43401. fogEnd: number;
  43402. /**
  43403. * Flag indicating that the frame buffer binding is handled by another component
  43404. */
  43405. prePass: boolean;
  43406. private _shadowsEnabled;
  43407. /**
  43408. * Gets or sets a boolean indicating if shadows are enabled on this scene
  43409. */
  43410. set shadowsEnabled(value: boolean);
  43411. get shadowsEnabled(): boolean;
  43412. private _lightsEnabled;
  43413. /**
  43414. * Gets or sets a boolean indicating if lights are enabled on this scene
  43415. */
  43416. set lightsEnabled(value: boolean);
  43417. get lightsEnabled(): boolean;
  43418. /** All of the active cameras added to this scene. */
  43419. activeCameras: Camera[];
  43420. /** @hidden */
  43421. _activeCamera: Nullable<Camera>;
  43422. /** Gets or sets the current active camera */
  43423. get activeCamera(): Nullable<Camera>;
  43424. set activeCamera(value: Nullable<Camera>);
  43425. private _defaultMaterial;
  43426. /** The default material used on meshes when no material is affected */
  43427. get defaultMaterial(): Material;
  43428. /** The default material used on meshes when no material is affected */
  43429. set defaultMaterial(value: Material);
  43430. private _texturesEnabled;
  43431. /**
  43432. * Gets or sets a boolean indicating if textures are enabled on this scene
  43433. */
  43434. set texturesEnabled(value: boolean);
  43435. get texturesEnabled(): boolean;
  43436. /**
  43437. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  43438. */
  43439. physicsEnabled: boolean;
  43440. /**
  43441. * Gets or sets a boolean indicating if particles are enabled on this scene
  43442. */
  43443. particlesEnabled: boolean;
  43444. /**
  43445. * Gets or sets a boolean indicating if sprites are enabled on this scene
  43446. */
  43447. spritesEnabled: boolean;
  43448. private _skeletonsEnabled;
  43449. /**
  43450. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  43451. */
  43452. set skeletonsEnabled(value: boolean);
  43453. get skeletonsEnabled(): boolean;
  43454. /**
  43455. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  43456. */
  43457. lensFlaresEnabled: boolean;
  43458. /**
  43459. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43460. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43461. */
  43462. collisionsEnabled: boolean;
  43463. private _collisionCoordinator;
  43464. /** @hidden */
  43465. get collisionCoordinator(): ICollisionCoordinator;
  43466. /**
  43467. * Defines the gravity applied to this scene (used only for collisions)
  43468. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43469. */
  43470. gravity: Vector3;
  43471. /**
  43472. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43473. */
  43474. postProcessesEnabled: boolean;
  43475. /**
  43476. * Gets the current postprocess manager
  43477. */
  43478. postProcessManager: PostProcessManager;
  43479. /**
  43480. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43481. */
  43482. renderTargetsEnabled: boolean;
  43483. /**
  43484. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43485. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43486. */
  43487. dumpNextRenderTargets: boolean;
  43488. /**
  43489. * The list of user defined render targets added to the scene
  43490. */
  43491. customRenderTargets: RenderTargetTexture[];
  43492. /**
  43493. * Defines if texture loading must be delayed
  43494. * If true, textures will only be loaded when they need to be rendered
  43495. */
  43496. useDelayedTextureLoading: boolean;
  43497. /**
  43498. * Gets the list of meshes imported to the scene through SceneLoader
  43499. */
  43500. importedMeshesFiles: String[];
  43501. /**
  43502. * Gets or sets a boolean indicating if probes are enabled on this scene
  43503. */
  43504. probesEnabled: boolean;
  43505. /**
  43506. * Gets or sets the current offline provider to use to store scene data
  43507. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43508. */
  43509. offlineProvider: IOfflineProvider;
  43510. /**
  43511. * Gets or sets the action manager associated with the scene
  43512. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43513. */
  43514. actionManager: AbstractActionManager;
  43515. private _meshesForIntersections;
  43516. /**
  43517. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43518. */
  43519. proceduralTexturesEnabled: boolean;
  43520. private _engine;
  43521. private _totalVertices;
  43522. /** @hidden */
  43523. _activeIndices: PerfCounter;
  43524. /** @hidden */
  43525. _activeParticles: PerfCounter;
  43526. /** @hidden */
  43527. _activeBones: PerfCounter;
  43528. private _animationRatio;
  43529. /** @hidden */
  43530. _animationTimeLast: number;
  43531. /** @hidden */
  43532. _animationTime: number;
  43533. /**
  43534. * Gets or sets a general scale for animation speed
  43535. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43536. */
  43537. animationTimeScale: number;
  43538. /** @hidden */
  43539. _cachedMaterial: Nullable<Material>;
  43540. /** @hidden */
  43541. _cachedEffect: Nullable<Effect>;
  43542. /** @hidden */
  43543. _cachedVisibility: Nullable<number>;
  43544. private _renderId;
  43545. private _frameId;
  43546. private _executeWhenReadyTimeoutId;
  43547. private _intermediateRendering;
  43548. private _viewUpdateFlag;
  43549. private _projectionUpdateFlag;
  43550. /** @hidden */
  43551. _toBeDisposed: Nullable<IDisposable>[];
  43552. private _activeRequests;
  43553. /** @hidden */
  43554. _pendingData: any[];
  43555. private _isDisposed;
  43556. /**
  43557. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43558. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43559. */
  43560. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43561. private _activeMeshes;
  43562. private _processedMaterials;
  43563. private _renderTargets;
  43564. /** @hidden */
  43565. _activeParticleSystems: SmartArray<IParticleSystem>;
  43566. private _activeSkeletons;
  43567. private _softwareSkinnedMeshes;
  43568. private _renderingManager;
  43569. /** @hidden */
  43570. _activeAnimatables: Animatable[];
  43571. private _transformMatrix;
  43572. private _sceneUbo;
  43573. /** @hidden */
  43574. _viewMatrix: Matrix;
  43575. private _projectionMatrix;
  43576. /** @hidden */
  43577. _forcedViewPosition: Nullable<Vector3>;
  43578. /** @hidden */
  43579. _frustumPlanes: Plane[];
  43580. /**
  43581. * Gets the list of frustum planes (built from the active camera)
  43582. */
  43583. get frustumPlanes(): Plane[];
  43584. /**
  43585. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43586. * This is useful if there are more lights that the maximum simulteanous authorized
  43587. */
  43588. requireLightSorting: boolean;
  43589. /** @hidden */
  43590. readonly useMaterialMeshMap: boolean;
  43591. /** @hidden */
  43592. readonly useClonedMeshMap: boolean;
  43593. private _externalData;
  43594. private _uid;
  43595. /**
  43596. * @hidden
  43597. * Backing store of defined scene components.
  43598. */
  43599. _components: ISceneComponent[];
  43600. /**
  43601. * @hidden
  43602. * Backing store of defined scene components.
  43603. */
  43604. _serializableComponents: ISceneSerializableComponent[];
  43605. /**
  43606. * List of components to register on the next registration step.
  43607. */
  43608. private _transientComponents;
  43609. /**
  43610. * Registers the transient components if needed.
  43611. */
  43612. private _registerTransientComponents;
  43613. /**
  43614. * @hidden
  43615. * Add a component to the scene.
  43616. * Note that the ccomponent could be registered on th next frame if this is called after
  43617. * the register component stage.
  43618. * @param component Defines the component to add to the scene
  43619. */
  43620. _addComponent(component: ISceneComponent): void;
  43621. /**
  43622. * @hidden
  43623. * Gets a component from the scene.
  43624. * @param name defines the name of the component to retrieve
  43625. * @returns the component or null if not present
  43626. */
  43627. _getComponent(name: string): Nullable<ISceneComponent>;
  43628. /**
  43629. * @hidden
  43630. * Defines the actions happening before camera updates.
  43631. */
  43632. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43633. /**
  43634. * @hidden
  43635. * Defines the actions happening before clear the canvas.
  43636. */
  43637. _beforeClearStage: Stage<SimpleStageAction>;
  43638. /**
  43639. * @hidden
  43640. * Defines the actions when collecting render targets for the frame.
  43641. */
  43642. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43643. /**
  43644. * @hidden
  43645. * Defines the actions happening for one camera in the frame.
  43646. */
  43647. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43648. /**
  43649. * @hidden
  43650. * Defines the actions happening during the per mesh ready checks.
  43651. */
  43652. _isReadyForMeshStage: Stage<MeshStageAction>;
  43653. /**
  43654. * @hidden
  43655. * Defines the actions happening before evaluate active mesh checks.
  43656. */
  43657. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43658. /**
  43659. * @hidden
  43660. * Defines the actions happening during the evaluate sub mesh checks.
  43661. */
  43662. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43663. /**
  43664. * @hidden
  43665. * Defines the actions happening during the active mesh stage.
  43666. */
  43667. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43668. /**
  43669. * @hidden
  43670. * Defines the actions happening during the per camera render target step.
  43671. */
  43672. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43673. /**
  43674. * @hidden
  43675. * Defines the actions happening just before the active camera is drawing.
  43676. */
  43677. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43678. /**
  43679. * @hidden
  43680. * Defines the actions happening just before a render target is drawing.
  43681. */
  43682. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43683. /**
  43684. * @hidden
  43685. * Defines the actions happening just before a rendering group is drawing.
  43686. */
  43687. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43688. /**
  43689. * @hidden
  43690. * Defines the actions happening just before a mesh is drawing.
  43691. */
  43692. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43693. /**
  43694. * @hidden
  43695. * Defines the actions happening just after a mesh has been drawn.
  43696. */
  43697. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43698. /**
  43699. * @hidden
  43700. * Defines the actions happening just after a rendering group has been drawn.
  43701. */
  43702. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43703. /**
  43704. * @hidden
  43705. * Defines the actions happening just after the active camera has been drawn.
  43706. */
  43707. _afterCameraDrawStage: Stage<CameraStageAction>;
  43708. /**
  43709. * @hidden
  43710. * Defines the actions happening just after a render target has been drawn.
  43711. */
  43712. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43713. /**
  43714. * @hidden
  43715. * Defines the actions happening just after rendering all cameras and computing intersections.
  43716. */
  43717. _afterRenderStage: Stage<SimpleStageAction>;
  43718. /**
  43719. * @hidden
  43720. * Defines the actions happening when a pointer move event happens.
  43721. */
  43722. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43723. /**
  43724. * @hidden
  43725. * Defines the actions happening when a pointer down event happens.
  43726. */
  43727. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43728. /**
  43729. * @hidden
  43730. * Defines the actions happening when a pointer up event happens.
  43731. */
  43732. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43733. /**
  43734. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43735. */
  43736. private geometriesByUniqueId;
  43737. /**
  43738. * Creates a new Scene
  43739. * @param engine defines the engine to use to render this scene
  43740. * @param options defines the scene options
  43741. */
  43742. constructor(engine: Engine, options?: SceneOptions);
  43743. /**
  43744. * Gets a string identifying the name of the class
  43745. * @returns "Scene" string
  43746. */
  43747. getClassName(): string;
  43748. private _defaultMeshCandidates;
  43749. /**
  43750. * @hidden
  43751. */
  43752. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43753. private _defaultSubMeshCandidates;
  43754. /**
  43755. * @hidden
  43756. */
  43757. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43758. /**
  43759. * Sets the default candidate providers for the scene.
  43760. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43761. * and getCollidingSubMeshCandidates to their default function
  43762. */
  43763. setDefaultCandidateProviders(): void;
  43764. /**
  43765. * Gets the mesh that is currently under the pointer
  43766. */
  43767. get meshUnderPointer(): Nullable<AbstractMesh>;
  43768. /**
  43769. * Gets or sets the current on-screen X position of the pointer
  43770. */
  43771. get pointerX(): number;
  43772. set pointerX(value: number);
  43773. /**
  43774. * Gets or sets the current on-screen Y position of the pointer
  43775. */
  43776. get pointerY(): number;
  43777. set pointerY(value: number);
  43778. /**
  43779. * Gets the cached material (ie. the latest rendered one)
  43780. * @returns the cached material
  43781. */
  43782. getCachedMaterial(): Nullable<Material>;
  43783. /**
  43784. * Gets the cached effect (ie. the latest rendered one)
  43785. * @returns the cached effect
  43786. */
  43787. getCachedEffect(): Nullable<Effect>;
  43788. /**
  43789. * Gets the cached visibility state (ie. the latest rendered one)
  43790. * @returns the cached visibility state
  43791. */
  43792. getCachedVisibility(): Nullable<number>;
  43793. /**
  43794. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43795. * @param material defines the current material
  43796. * @param effect defines the current effect
  43797. * @param visibility defines the current visibility state
  43798. * @returns true if one parameter is not cached
  43799. */
  43800. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43801. /**
  43802. * Gets the engine associated with the scene
  43803. * @returns an Engine
  43804. */
  43805. getEngine(): Engine;
  43806. /**
  43807. * Gets the total number of vertices rendered per frame
  43808. * @returns the total number of vertices rendered per frame
  43809. */
  43810. getTotalVertices(): number;
  43811. /**
  43812. * Gets the performance counter for total vertices
  43813. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43814. */
  43815. get totalVerticesPerfCounter(): PerfCounter;
  43816. /**
  43817. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43818. * @returns the total number of active indices rendered per frame
  43819. */
  43820. getActiveIndices(): number;
  43821. /**
  43822. * Gets the performance counter for active indices
  43823. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43824. */
  43825. get totalActiveIndicesPerfCounter(): PerfCounter;
  43826. /**
  43827. * Gets the total number of active particles rendered per frame
  43828. * @returns the total number of active particles rendered per frame
  43829. */
  43830. getActiveParticles(): number;
  43831. /**
  43832. * Gets the performance counter for active particles
  43833. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43834. */
  43835. get activeParticlesPerfCounter(): PerfCounter;
  43836. /**
  43837. * Gets the total number of active bones rendered per frame
  43838. * @returns the total number of active bones rendered per frame
  43839. */
  43840. getActiveBones(): number;
  43841. /**
  43842. * Gets the performance counter for active bones
  43843. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43844. */
  43845. get activeBonesPerfCounter(): PerfCounter;
  43846. /**
  43847. * Gets the array of active meshes
  43848. * @returns an array of AbstractMesh
  43849. */
  43850. getActiveMeshes(): SmartArray<AbstractMesh>;
  43851. /**
  43852. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43853. * @returns a number
  43854. */
  43855. getAnimationRatio(): number;
  43856. /**
  43857. * Gets an unique Id for the current render phase
  43858. * @returns a number
  43859. */
  43860. getRenderId(): number;
  43861. /**
  43862. * Gets an unique Id for the current frame
  43863. * @returns a number
  43864. */
  43865. getFrameId(): number;
  43866. /** Call this function if you want to manually increment the render Id*/
  43867. incrementRenderId(): void;
  43868. private _createUbo;
  43869. /**
  43870. * Use this method to simulate a pointer move on a mesh
  43871. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43872. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43873. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43874. * @returns the current scene
  43875. */
  43876. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43877. /**
  43878. * Use this method to simulate a pointer down on a mesh
  43879. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43880. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43881. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43882. * @returns the current scene
  43883. */
  43884. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43885. /**
  43886. * Use this method to simulate a pointer up on a mesh
  43887. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43888. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43889. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43890. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43891. * @returns the current scene
  43892. */
  43893. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43894. /**
  43895. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43896. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43897. * @returns true if the pointer was captured
  43898. */
  43899. isPointerCaptured(pointerId?: number): boolean;
  43900. /**
  43901. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43902. * @param attachUp defines if you want to attach events to pointerup
  43903. * @param attachDown defines if you want to attach events to pointerdown
  43904. * @param attachMove defines if you want to attach events to pointermove
  43905. */
  43906. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43907. /** Detaches all event handlers*/
  43908. detachControl(): void;
  43909. /**
  43910. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43911. * Delay loaded resources are not taking in account
  43912. * @return true if all required resources are ready
  43913. */
  43914. isReady(): boolean;
  43915. /** Resets all cached information relative to material (including effect and visibility) */
  43916. resetCachedMaterial(): void;
  43917. /**
  43918. * Registers a function to be called before every frame render
  43919. * @param func defines the function to register
  43920. */
  43921. registerBeforeRender(func: () => void): void;
  43922. /**
  43923. * Unregisters a function called before every frame render
  43924. * @param func defines the function to unregister
  43925. */
  43926. unregisterBeforeRender(func: () => void): void;
  43927. /**
  43928. * Registers a function to be called after every frame render
  43929. * @param func defines the function to register
  43930. */
  43931. registerAfterRender(func: () => void): void;
  43932. /**
  43933. * Unregisters a function called after every frame render
  43934. * @param func defines the function to unregister
  43935. */
  43936. unregisterAfterRender(func: () => void): void;
  43937. private _executeOnceBeforeRender;
  43938. /**
  43939. * The provided function will run before render once and will be disposed afterwards.
  43940. * A timeout delay can be provided so that the function will be executed in N ms.
  43941. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43942. * @param func The function to be executed.
  43943. * @param timeout optional delay in ms
  43944. */
  43945. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43946. /** @hidden */
  43947. _addPendingData(data: any): void;
  43948. /** @hidden */
  43949. _removePendingData(data: any): void;
  43950. /**
  43951. * Returns the number of items waiting to be loaded
  43952. * @returns the number of items waiting to be loaded
  43953. */
  43954. getWaitingItemsCount(): number;
  43955. /**
  43956. * Returns a boolean indicating if the scene is still loading data
  43957. */
  43958. get isLoading(): boolean;
  43959. /**
  43960. * Registers a function to be executed when the scene is ready
  43961. * @param {Function} func - the function to be executed
  43962. */
  43963. executeWhenReady(func: () => void): void;
  43964. /**
  43965. * Returns a promise that resolves when the scene is ready
  43966. * @returns A promise that resolves when the scene is ready
  43967. */
  43968. whenReadyAsync(): Promise<void>;
  43969. /** @hidden */
  43970. _checkIsReady(): void;
  43971. /**
  43972. * Gets all animatable attached to the scene
  43973. */
  43974. get animatables(): Animatable[];
  43975. /**
  43976. * Resets the last animation time frame.
  43977. * Useful to override when animations start running when loading a scene for the first time.
  43978. */
  43979. resetLastAnimationTimeFrame(): void;
  43980. /**
  43981. * Gets the current view matrix
  43982. * @returns a Matrix
  43983. */
  43984. getViewMatrix(): Matrix;
  43985. /**
  43986. * Gets the current projection matrix
  43987. * @returns a Matrix
  43988. */
  43989. getProjectionMatrix(): Matrix;
  43990. /**
  43991. * Gets the current transform matrix
  43992. * @returns a Matrix made of View * Projection
  43993. */
  43994. getTransformMatrix(): Matrix;
  43995. /**
  43996. * Sets the current transform matrix
  43997. * @param viewL defines the View matrix to use
  43998. * @param projectionL defines the Projection matrix to use
  43999. * @param viewR defines the right View matrix to use (if provided)
  44000. * @param projectionR defines the right Projection matrix to use (if provided)
  44001. */
  44002. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  44003. /**
  44004. * Gets the uniform buffer used to store scene data
  44005. * @returns a UniformBuffer
  44006. */
  44007. getSceneUniformBuffer(): UniformBuffer;
  44008. /**
  44009. * Gets an unique (relatively to the current scene) Id
  44010. * @returns an unique number for the scene
  44011. */
  44012. getUniqueId(): number;
  44013. /**
  44014. * Add a mesh to the list of scene's meshes
  44015. * @param newMesh defines the mesh to add
  44016. * @param recursive if all child meshes should also be added to the scene
  44017. */
  44018. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  44019. /**
  44020. * Remove a mesh for the list of scene's meshes
  44021. * @param toRemove defines the mesh to remove
  44022. * @param recursive if all child meshes should also be removed from the scene
  44023. * @returns the index where the mesh was in the mesh list
  44024. */
  44025. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  44026. /**
  44027. * Add a transform node to the list of scene's transform nodes
  44028. * @param newTransformNode defines the transform node to add
  44029. */
  44030. addTransformNode(newTransformNode: TransformNode): void;
  44031. /**
  44032. * Remove a transform node for the list of scene's transform nodes
  44033. * @param toRemove defines the transform node to remove
  44034. * @returns the index where the transform node was in the transform node list
  44035. */
  44036. removeTransformNode(toRemove: TransformNode): number;
  44037. /**
  44038. * Remove a skeleton for the list of scene's skeletons
  44039. * @param toRemove defines the skeleton to remove
  44040. * @returns the index where the skeleton was in the skeleton list
  44041. */
  44042. removeSkeleton(toRemove: Skeleton): number;
  44043. /**
  44044. * Remove a morph target for the list of scene's morph targets
  44045. * @param toRemove defines the morph target to remove
  44046. * @returns the index where the morph target was in the morph target list
  44047. */
  44048. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  44049. /**
  44050. * Remove a light for the list of scene's lights
  44051. * @param toRemove defines the light to remove
  44052. * @returns the index where the light was in the light list
  44053. */
  44054. removeLight(toRemove: Light): number;
  44055. /**
  44056. * Remove a camera for the list of scene's cameras
  44057. * @param toRemove defines the camera to remove
  44058. * @returns the index where the camera was in the camera list
  44059. */
  44060. removeCamera(toRemove: Camera): number;
  44061. /**
  44062. * Remove a particle system for the list of scene's particle systems
  44063. * @param toRemove defines the particle system to remove
  44064. * @returns the index where the particle system was in the particle system list
  44065. */
  44066. removeParticleSystem(toRemove: IParticleSystem): number;
  44067. /**
  44068. * Remove a animation for the list of scene's animations
  44069. * @param toRemove defines the animation to remove
  44070. * @returns the index where the animation was in the animation list
  44071. */
  44072. removeAnimation(toRemove: Animation): number;
  44073. /**
  44074. * Will stop the animation of the given target
  44075. * @param target - the target
  44076. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  44077. * @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)
  44078. */
  44079. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  44080. /**
  44081. * Removes the given animation group from this scene.
  44082. * @param toRemove The animation group to remove
  44083. * @returns The index of the removed animation group
  44084. */
  44085. removeAnimationGroup(toRemove: AnimationGroup): number;
  44086. /**
  44087. * Removes the given multi-material from this scene.
  44088. * @param toRemove The multi-material to remove
  44089. * @returns The index of the removed multi-material
  44090. */
  44091. removeMultiMaterial(toRemove: MultiMaterial): number;
  44092. /**
  44093. * Removes the given material from this scene.
  44094. * @param toRemove The material to remove
  44095. * @returns The index of the removed material
  44096. */
  44097. removeMaterial(toRemove: Material): number;
  44098. /**
  44099. * Removes the given action manager from this scene.
  44100. * @param toRemove The action manager to remove
  44101. * @returns The index of the removed action manager
  44102. */
  44103. removeActionManager(toRemove: AbstractActionManager): number;
  44104. /**
  44105. * Removes the given texture from this scene.
  44106. * @param toRemove The texture to remove
  44107. * @returns The index of the removed texture
  44108. */
  44109. removeTexture(toRemove: BaseTexture): number;
  44110. /**
  44111. * Adds the given light to this scene
  44112. * @param newLight The light to add
  44113. */
  44114. addLight(newLight: Light): void;
  44115. /**
  44116. * Sorts the list list based on light priorities
  44117. */
  44118. sortLightsByPriority(): void;
  44119. /**
  44120. * Adds the given camera to this scene
  44121. * @param newCamera The camera to add
  44122. */
  44123. addCamera(newCamera: Camera): void;
  44124. /**
  44125. * Adds the given skeleton to this scene
  44126. * @param newSkeleton The skeleton to add
  44127. */
  44128. addSkeleton(newSkeleton: Skeleton): void;
  44129. /**
  44130. * Adds the given particle system to this scene
  44131. * @param newParticleSystem The particle system to add
  44132. */
  44133. addParticleSystem(newParticleSystem: IParticleSystem): void;
  44134. /**
  44135. * Adds the given animation to this scene
  44136. * @param newAnimation The animation to add
  44137. */
  44138. addAnimation(newAnimation: Animation): void;
  44139. /**
  44140. * Adds the given animation group to this scene.
  44141. * @param newAnimationGroup The animation group to add
  44142. */
  44143. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  44144. /**
  44145. * Adds the given multi-material to this scene
  44146. * @param newMultiMaterial The multi-material to add
  44147. */
  44148. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  44149. /**
  44150. * Adds the given material to this scene
  44151. * @param newMaterial The material to add
  44152. */
  44153. addMaterial(newMaterial: Material): void;
  44154. /**
  44155. * Adds the given morph target to this scene
  44156. * @param newMorphTargetManager The morph target to add
  44157. */
  44158. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  44159. /**
  44160. * Adds the given geometry to this scene
  44161. * @param newGeometry The geometry to add
  44162. */
  44163. addGeometry(newGeometry: Geometry): void;
  44164. /**
  44165. * Adds the given action manager to this scene
  44166. * @param newActionManager The action manager to add
  44167. */
  44168. addActionManager(newActionManager: AbstractActionManager): void;
  44169. /**
  44170. * Adds the given texture to this scene.
  44171. * @param newTexture The texture to add
  44172. */
  44173. addTexture(newTexture: BaseTexture): void;
  44174. /**
  44175. * Switch active camera
  44176. * @param newCamera defines the new active camera
  44177. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  44178. */
  44179. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  44180. /**
  44181. * sets the active camera of the scene using its ID
  44182. * @param id defines the camera's ID
  44183. * @return the new active camera or null if none found.
  44184. */
  44185. setActiveCameraByID(id: string): Nullable<Camera>;
  44186. /**
  44187. * sets the active camera of the scene using its name
  44188. * @param name defines the camera's name
  44189. * @returns the new active camera or null if none found.
  44190. */
  44191. setActiveCameraByName(name: string): Nullable<Camera>;
  44192. /**
  44193. * get an animation group using its name
  44194. * @param name defines the material's name
  44195. * @return the animation group or null if none found.
  44196. */
  44197. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  44198. /**
  44199. * Get a material using its unique id
  44200. * @param uniqueId defines the material's unique id
  44201. * @return the material or null if none found.
  44202. */
  44203. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  44204. /**
  44205. * get a material using its id
  44206. * @param id defines the material's ID
  44207. * @return the material or null if none found.
  44208. */
  44209. getMaterialByID(id: string): Nullable<Material>;
  44210. /**
  44211. * Gets a the last added material using a given id
  44212. * @param id defines the material's ID
  44213. * @return the last material with the given id or null if none found.
  44214. */
  44215. getLastMaterialByID(id: string): Nullable<Material>;
  44216. /**
  44217. * Gets a material using its name
  44218. * @param name defines the material's name
  44219. * @return the material or null if none found.
  44220. */
  44221. getMaterialByName(name: string): Nullable<Material>;
  44222. /**
  44223. * Get a texture using its unique id
  44224. * @param uniqueId defines the texture's unique id
  44225. * @return the texture or null if none found.
  44226. */
  44227. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  44228. /**
  44229. * Gets a camera using its id
  44230. * @param id defines the id to look for
  44231. * @returns the camera or null if not found
  44232. */
  44233. getCameraByID(id: string): Nullable<Camera>;
  44234. /**
  44235. * Gets a camera using its unique id
  44236. * @param uniqueId defines the unique id to look for
  44237. * @returns the camera or null if not found
  44238. */
  44239. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  44240. /**
  44241. * Gets a camera using its name
  44242. * @param name defines the camera's name
  44243. * @return the camera or null if none found.
  44244. */
  44245. getCameraByName(name: string): Nullable<Camera>;
  44246. /**
  44247. * Gets a bone using its id
  44248. * @param id defines the bone's id
  44249. * @return the bone or null if not found
  44250. */
  44251. getBoneByID(id: string): Nullable<Bone>;
  44252. /**
  44253. * Gets a bone using its id
  44254. * @param name defines the bone's name
  44255. * @return the bone or null if not found
  44256. */
  44257. getBoneByName(name: string): Nullable<Bone>;
  44258. /**
  44259. * Gets a light node using its name
  44260. * @param name defines the the light's name
  44261. * @return the light or null if none found.
  44262. */
  44263. getLightByName(name: string): Nullable<Light>;
  44264. /**
  44265. * Gets a light node using its id
  44266. * @param id defines the light's id
  44267. * @return the light or null if none found.
  44268. */
  44269. getLightByID(id: string): Nullable<Light>;
  44270. /**
  44271. * Gets a light node using its scene-generated unique ID
  44272. * @param uniqueId defines the light's unique id
  44273. * @return the light or null if none found.
  44274. */
  44275. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  44276. /**
  44277. * Gets a particle system by id
  44278. * @param id defines the particle system id
  44279. * @return the corresponding system or null if none found
  44280. */
  44281. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  44282. /**
  44283. * Gets a geometry using its ID
  44284. * @param id defines the geometry's id
  44285. * @return the geometry or null if none found.
  44286. */
  44287. getGeometryByID(id: string): Nullable<Geometry>;
  44288. private _getGeometryByUniqueID;
  44289. /**
  44290. * Add a new geometry to this scene
  44291. * @param geometry defines the geometry to be added to the scene.
  44292. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  44293. * @return a boolean defining if the geometry was added or not
  44294. */
  44295. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  44296. /**
  44297. * Removes an existing geometry
  44298. * @param geometry defines the geometry to be removed from the scene
  44299. * @return a boolean defining if the geometry was removed or not
  44300. */
  44301. removeGeometry(geometry: Geometry): boolean;
  44302. /**
  44303. * Gets the list of geometries attached to the scene
  44304. * @returns an array of Geometry
  44305. */
  44306. getGeometries(): Geometry[];
  44307. /**
  44308. * Gets the first added mesh found of a given ID
  44309. * @param id defines the id to search for
  44310. * @return the mesh found or null if not found at all
  44311. */
  44312. getMeshByID(id: string): Nullable<AbstractMesh>;
  44313. /**
  44314. * Gets a list of meshes using their id
  44315. * @param id defines the id to search for
  44316. * @returns a list of meshes
  44317. */
  44318. getMeshesByID(id: string): Array<AbstractMesh>;
  44319. /**
  44320. * Gets the first added transform node found of a given ID
  44321. * @param id defines the id to search for
  44322. * @return the found transform node or null if not found at all.
  44323. */
  44324. getTransformNodeByID(id: string): Nullable<TransformNode>;
  44325. /**
  44326. * Gets a transform node with its auto-generated unique id
  44327. * @param uniqueId efines the unique id to search for
  44328. * @return the found transform node or null if not found at all.
  44329. */
  44330. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  44331. /**
  44332. * Gets a list of transform nodes using their id
  44333. * @param id defines the id to search for
  44334. * @returns a list of transform nodes
  44335. */
  44336. getTransformNodesByID(id: string): Array<TransformNode>;
  44337. /**
  44338. * Gets a mesh with its auto-generated unique id
  44339. * @param uniqueId defines the unique id to search for
  44340. * @return the found mesh or null if not found at all.
  44341. */
  44342. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  44343. /**
  44344. * Gets a the last added mesh using a given id
  44345. * @param id defines the id to search for
  44346. * @return the found mesh or null if not found at all.
  44347. */
  44348. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  44349. /**
  44350. * Gets a the last added node (Mesh, Camera, Light) using a given id
  44351. * @param id defines the id to search for
  44352. * @return the found node or null if not found at all
  44353. */
  44354. getLastEntryByID(id: string): Nullable<Node>;
  44355. /**
  44356. * Gets a node (Mesh, Camera, Light) using a given id
  44357. * @param id defines the id to search for
  44358. * @return the found node or null if not found at all
  44359. */
  44360. getNodeByID(id: string): Nullable<Node>;
  44361. /**
  44362. * Gets a node (Mesh, Camera, Light) using a given name
  44363. * @param name defines the name to search for
  44364. * @return the found node or null if not found at all.
  44365. */
  44366. getNodeByName(name: string): Nullable<Node>;
  44367. /**
  44368. * Gets a mesh using a given name
  44369. * @param name defines the name to search for
  44370. * @return the found mesh or null if not found at all.
  44371. */
  44372. getMeshByName(name: string): Nullable<AbstractMesh>;
  44373. /**
  44374. * Gets a transform node using a given name
  44375. * @param name defines the name to search for
  44376. * @return the found transform node or null if not found at all.
  44377. */
  44378. getTransformNodeByName(name: string): Nullable<TransformNode>;
  44379. /**
  44380. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  44381. * @param id defines the id to search for
  44382. * @return the found skeleton or null if not found at all.
  44383. */
  44384. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  44385. /**
  44386. * Gets a skeleton using a given auto generated unique id
  44387. * @param uniqueId defines the unique id to search for
  44388. * @return the found skeleton or null if not found at all.
  44389. */
  44390. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  44391. /**
  44392. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  44393. * @param id defines the id to search for
  44394. * @return the found skeleton or null if not found at all.
  44395. */
  44396. getSkeletonById(id: string): Nullable<Skeleton>;
  44397. /**
  44398. * Gets a skeleton using a given name
  44399. * @param name defines the name to search for
  44400. * @return the found skeleton or null if not found at all.
  44401. */
  44402. getSkeletonByName(name: string): Nullable<Skeleton>;
  44403. /**
  44404. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  44405. * @param id defines the id to search for
  44406. * @return the found morph target manager or null if not found at all.
  44407. */
  44408. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  44409. /**
  44410. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  44411. * @param id defines the id to search for
  44412. * @return the found morph target or null if not found at all.
  44413. */
  44414. getMorphTargetById(id: string): Nullable<MorphTarget>;
  44415. /**
  44416. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  44417. * @param name defines the name to search for
  44418. * @return the found morph target or null if not found at all.
  44419. */
  44420. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  44421. /**
  44422. * Gets a post process using a given name (if many are found, this function will pick the first one)
  44423. * @param name defines the name to search for
  44424. * @return the found post process or null if not found at all.
  44425. */
  44426. getPostProcessByName(name: string): Nullable<PostProcess>;
  44427. /**
  44428. * Gets a boolean indicating if the given mesh is active
  44429. * @param mesh defines the mesh to look for
  44430. * @returns true if the mesh is in the active list
  44431. */
  44432. isActiveMesh(mesh: AbstractMesh): boolean;
  44433. /**
  44434. * Return a unique id as a string which can serve as an identifier for the scene
  44435. */
  44436. get uid(): string;
  44437. /**
  44438. * Add an externaly attached data from its key.
  44439. * This method call will fail and return false, if such key already exists.
  44440. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  44441. * @param key the unique key that identifies the data
  44442. * @param data the data object to associate to the key for this Engine instance
  44443. * @return true if no such key were already present and the data was added successfully, false otherwise
  44444. */
  44445. addExternalData<T>(key: string, data: T): boolean;
  44446. /**
  44447. * Get an externaly attached data from its key
  44448. * @param key the unique key that identifies the data
  44449. * @return the associated data, if present (can be null), or undefined if not present
  44450. */
  44451. getExternalData<T>(key: string): Nullable<T>;
  44452. /**
  44453. * Get an externaly attached data from its key, create it using a factory if it's not already present
  44454. * @param key the unique key that identifies the data
  44455. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  44456. * @return the associated data, can be null if the factory returned null.
  44457. */
  44458. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44459. /**
  44460. * Remove an externaly attached data from the Engine instance
  44461. * @param key the unique key that identifies the data
  44462. * @return true if the data was successfully removed, false if it doesn't exist
  44463. */
  44464. removeExternalData(key: string): boolean;
  44465. private _evaluateSubMesh;
  44466. /**
  44467. * Clear the processed materials smart array preventing retention point in material dispose.
  44468. */
  44469. freeProcessedMaterials(): void;
  44470. private _preventFreeActiveMeshesAndRenderingGroups;
  44471. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44472. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44473. * when disposing several meshes in a row or a hierarchy of meshes.
  44474. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44475. */
  44476. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44477. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44478. /**
  44479. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44480. */
  44481. freeActiveMeshes(): void;
  44482. /**
  44483. * Clear the info related to rendering groups preventing retention points during dispose.
  44484. */
  44485. freeRenderingGroups(): void;
  44486. /** @hidden */
  44487. _isInIntermediateRendering(): boolean;
  44488. /**
  44489. * Lambda returning the list of potentially active meshes.
  44490. */
  44491. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44492. /**
  44493. * Lambda returning the list of potentially active sub meshes.
  44494. */
  44495. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44496. /**
  44497. * Lambda returning the list of potentially intersecting sub meshes.
  44498. */
  44499. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44500. /**
  44501. * Lambda returning the list of potentially colliding sub meshes.
  44502. */
  44503. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44504. /** @hidden */
  44505. _activeMeshesFrozen: boolean;
  44506. private _skipEvaluateActiveMeshesCompletely;
  44507. /**
  44508. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44509. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44510. * @param onSuccess optional success callback
  44511. * @param onError optional error callback
  44512. * @returns the current scene
  44513. */
  44514. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44515. /**
  44516. * Use this function to restart evaluating active meshes on every frame
  44517. * @returns the current scene
  44518. */
  44519. unfreezeActiveMeshes(): Scene;
  44520. private _evaluateActiveMeshes;
  44521. private _activeMesh;
  44522. /**
  44523. * Update the transform matrix to update from the current active camera
  44524. * @param force defines a boolean used to force the update even if cache is up to date
  44525. */
  44526. updateTransformMatrix(force?: boolean): void;
  44527. private _bindFrameBuffer;
  44528. /** @hidden */
  44529. _allowPostProcessClearColor: boolean;
  44530. /** @hidden */
  44531. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44532. private _processSubCameras;
  44533. private _checkIntersections;
  44534. /** @hidden */
  44535. _advancePhysicsEngineStep(step: number): void;
  44536. /**
  44537. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44538. */
  44539. getDeterministicFrameTime: () => number;
  44540. /** @hidden */
  44541. _animate(): void;
  44542. /** Execute all animations (for a frame) */
  44543. animate(): void;
  44544. /**
  44545. * Render the scene
  44546. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44547. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44548. */
  44549. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44550. /**
  44551. * Freeze all materials
  44552. * A frozen material will not be updatable but should be faster to render
  44553. */
  44554. freezeMaterials(): void;
  44555. /**
  44556. * Unfreeze all materials
  44557. * A frozen material will not be updatable but should be faster to render
  44558. */
  44559. unfreezeMaterials(): void;
  44560. /**
  44561. * Releases all held ressources
  44562. */
  44563. dispose(): void;
  44564. /**
  44565. * Gets if the scene is already disposed
  44566. */
  44567. get isDisposed(): boolean;
  44568. /**
  44569. * Call this function to reduce memory footprint of the scene.
  44570. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44571. */
  44572. clearCachedVertexData(): void;
  44573. /**
  44574. * This function will remove the local cached buffer data from texture.
  44575. * It will save memory but will prevent the texture from being rebuilt
  44576. */
  44577. cleanCachedTextureBuffer(): void;
  44578. /**
  44579. * Get the world extend vectors with an optional filter
  44580. *
  44581. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44582. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44583. */
  44584. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44585. min: Vector3;
  44586. max: Vector3;
  44587. };
  44588. /**
  44589. * Creates a ray that can be used to pick in the scene
  44590. * @param x defines the x coordinate of the origin (on-screen)
  44591. * @param y defines the y coordinate of the origin (on-screen)
  44592. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44593. * @param camera defines the camera to use for the picking
  44594. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44595. * @returns a Ray
  44596. */
  44597. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44598. /**
  44599. * Creates a ray that can be used to pick in the scene
  44600. * @param x defines the x coordinate of the origin (on-screen)
  44601. * @param y defines the y coordinate of the origin (on-screen)
  44602. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44603. * @param result defines the ray where to store the picking ray
  44604. * @param camera defines the camera to use for the picking
  44605. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44606. * @returns the current scene
  44607. */
  44608. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44609. /**
  44610. * Creates a ray that can be used to pick in the scene
  44611. * @param x defines the x coordinate of the origin (on-screen)
  44612. * @param y defines the y coordinate of the origin (on-screen)
  44613. * @param camera defines the camera to use for the picking
  44614. * @returns a Ray
  44615. */
  44616. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44617. /**
  44618. * Creates a ray that can be used to pick in the scene
  44619. * @param x defines the x coordinate of the origin (on-screen)
  44620. * @param y defines the y coordinate of the origin (on-screen)
  44621. * @param result defines the ray where to store the picking ray
  44622. * @param camera defines the camera to use for the picking
  44623. * @returns the current scene
  44624. */
  44625. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44626. /** Launch a ray to try to pick a mesh in the scene
  44627. * @param x position on screen
  44628. * @param y position on screen
  44629. * @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
  44630. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44631. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44632. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44633. * @returns a PickingInfo
  44634. */
  44635. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44636. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44637. * @param x position on screen
  44638. * @param y position on screen
  44639. * @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
  44640. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44641. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44642. * @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)
  44643. */
  44644. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44645. /** Use the given ray to pick a mesh in the scene
  44646. * @param ray The ray to use to pick meshes
  44647. * @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
  44648. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44649. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44650. * @returns a PickingInfo
  44651. */
  44652. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44653. /**
  44654. * Launch a ray to try to pick a mesh in the scene
  44655. * @param x X position on screen
  44656. * @param y Y position on screen
  44657. * @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
  44658. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44659. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44660. * @returns an array of PickingInfo
  44661. */
  44662. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44663. /**
  44664. * Launch a ray to try to pick a mesh in the scene
  44665. * @param ray Ray to use
  44666. * @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
  44667. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44668. * @returns an array of PickingInfo
  44669. */
  44670. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44671. /**
  44672. * Force the value of meshUnderPointer
  44673. * @param mesh defines the mesh to use
  44674. * @param pointerId optional pointer id when using more than one pointer
  44675. */
  44676. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44677. /**
  44678. * Gets the mesh under the pointer
  44679. * @returns a Mesh or null if no mesh is under the pointer
  44680. */
  44681. getPointerOverMesh(): Nullable<AbstractMesh>;
  44682. /** @hidden */
  44683. _rebuildGeometries(): void;
  44684. /** @hidden */
  44685. _rebuildTextures(): void;
  44686. private _getByTags;
  44687. /**
  44688. * Get a list of meshes by tags
  44689. * @param tagsQuery defines the tags query to use
  44690. * @param forEach defines a predicate used to filter results
  44691. * @returns an array of Mesh
  44692. */
  44693. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44694. /**
  44695. * Get a list of cameras by tags
  44696. * @param tagsQuery defines the tags query to use
  44697. * @param forEach defines a predicate used to filter results
  44698. * @returns an array of Camera
  44699. */
  44700. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44701. /**
  44702. * Get a list of lights by tags
  44703. * @param tagsQuery defines the tags query to use
  44704. * @param forEach defines a predicate used to filter results
  44705. * @returns an array of Light
  44706. */
  44707. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44708. /**
  44709. * Get a list of materials by tags
  44710. * @param tagsQuery defines the tags query to use
  44711. * @param forEach defines a predicate used to filter results
  44712. * @returns an array of Material
  44713. */
  44714. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44715. /**
  44716. * Get a list of transform nodes by tags
  44717. * @param tagsQuery defines the tags query to use
  44718. * @param forEach defines a predicate used to filter results
  44719. * @returns an array of TransformNode
  44720. */
  44721. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44722. /**
  44723. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44724. * This allowed control for front to back rendering or reversly depending of the special needs.
  44725. *
  44726. * @param renderingGroupId The rendering group id corresponding to its index
  44727. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44728. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44729. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44730. */
  44731. 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;
  44732. /**
  44733. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44734. *
  44735. * @param renderingGroupId The rendering group id corresponding to its index
  44736. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44737. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44738. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44739. */
  44740. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44741. /**
  44742. * Gets the current auto clear configuration for one rendering group of the rendering
  44743. * manager.
  44744. * @param index the rendering group index to get the information for
  44745. * @returns The auto clear setup for the requested rendering group
  44746. */
  44747. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44748. private _blockMaterialDirtyMechanism;
  44749. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44750. get blockMaterialDirtyMechanism(): boolean;
  44751. set blockMaterialDirtyMechanism(value: boolean);
  44752. /**
  44753. * Will flag all materials as dirty to trigger new shader compilation
  44754. * @param flag defines the flag used to specify which material part must be marked as dirty
  44755. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44756. */
  44757. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44758. /** @hidden */
  44759. _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;
  44760. /** @hidden */
  44761. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44762. /** @hidden */
  44763. _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;
  44764. /** @hidden */
  44765. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44766. /** @hidden */
  44767. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44768. /** @hidden */
  44769. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44770. }
  44771. }
  44772. declare module BABYLON {
  44773. /**
  44774. * Set of assets to keep when moving a scene into an asset container.
  44775. */
  44776. export class KeepAssets extends AbstractScene {
  44777. }
  44778. /**
  44779. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44780. */
  44781. export class InstantiatedEntries {
  44782. /**
  44783. * List of new root nodes (eg. nodes with no parent)
  44784. */
  44785. rootNodes: TransformNode[];
  44786. /**
  44787. * List of new skeletons
  44788. */
  44789. skeletons: Skeleton[];
  44790. /**
  44791. * List of new animation groups
  44792. */
  44793. animationGroups: AnimationGroup[];
  44794. }
  44795. /**
  44796. * Container with a set of assets that can be added or removed from a scene.
  44797. */
  44798. export class AssetContainer extends AbstractScene {
  44799. private _wasAddedToScene;
  44800. /**
  44801. * The scene the AssetContainer belongs to.
  44802. */
  44803. scene: Scene;
  44804. /**
  44805. * Instantiates an AssetContainer.
  44806. * @param scene The scene the AssetContainer belongs to.
  44807. */
  44808. constructor(scene: Scene);
  44809. /**
  44810. * Instantiate or clone all meshes and add the new ones to the scene.
  44811. * Skeletons and animation groups will all be cloned
  44812. * @param nameFunction defines an optional function used to get new names for clones
  44813. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44814. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44815. */
  44816. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44817. /**
  44818. * Adds all the assets from the container to the scene.
  44819. */
  44820. addAllToScene(): void;
  44821. /**
  44822. * Removes all the assets in the container from the scene
  44823. */
  44824. removeAllFromScene(): void;
  44825. /**
  44826. * Disposes all the assets in the container
  44827. */
  44828. dispose(): void;
  44829. private _moveAssets;
  44830. /**
  44831. * Removes all the assets contained in the scene and adds them to the container.
  44832. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44833. */
  44834. moveAllFromScene(keepAssets?: KeepAssets): void;
  44835. /**
  44836. * 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.
  44837. * @returns the root mesh
  44838. */
  44839. createRootMesh(): Mesh;
  44840. /**
  44841. * Merge animations (direct and animation groups) from this asset container into a scene
  44842. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44843. * @param animatables set of animatables to retarget to a node from the scene
  44844. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44845. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44846. */
  44847. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44848. }
  44849. }
  44850. declare module BABYLON {
  44851. /**
  44852. * Defines how the parser contract is defined.
  44853. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44854. */
  44855. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44856. /**
  44857. * Defines how the individual parser contract is defined.
  44858. * These parser can parse an individual asset
  44859. */
  44860. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44861. /**
  44862. * Base class of the scene acting as a container for the different elements composing a scene.
  44863. * This class is dynamically extended by the different components of the scene increasing
  44864. * flexibility and reducing coupling
  44865. */
  44866. export abstract class AbstractScene {
  44867. /**
  44868. * Stores the list of available parsers in the application.
  44869. */
  44870. private static _BabylonFileParsers;
  44871. /**
  44872. * Stores the list of available individual parsers in the application.
  44873. */
  44874. private static _IndividualBabylonFileParsers;
  44875. /**
  44876. * Adds a parser in the list of available ones
  44877. * @param name Defines the name of the parser
  44878. * @param parser Defines the parser to add
  44879. */
  44880. static AddParser(name: string, parser: BabylonFileParser): void;
  44881. /**
  44882. * Gets a general parser from the list of avaialble ones
  44883. * @param name Defines the name of the parser
  44884. * @returns the requested parser or null
  44885. */
  44886. static GetParser(name: string): Nullable<BabylonFileParser>;
  44887. /**
  44888. * Adds n individual parser in the list of available ones
  44889. * @param name Defines the name of the parser
  44890. * @param parser Defines the parser to add
  44891. */
  44892. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44893. /**
  44894. * Gets an individual parser from the list of avaialble ones
  44895. * @param name Defines the name of the parser
  44896. * @returns the requested parser or null
  44897. */
  44898. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44899. /**
  44900. * Parser json data and populate both a scene and its associated container object
  44901. * @param jsonData Defines the data to parse
  44902. * @param scene Defines the scene to parse the data for
  44903. * @param container Defines the container attached to the parsing sequence
  44904. * @param rootUrl Defines the root url of the data
  44905. */
  44906. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44907. /**
  44908. * Gets the list of root nodes (ie. nodes with no parent)
  44909. */
  44910. rootNodes: Node[];
  44911. /** All of the cameras added to this scene
  44912. * @see https://doc.babylonjs.com/babylon101/cameras
  44913. */
  44914. cameras: Camera[];
  44915. /**
  44916. * All of the lights added to this scene
  44917. * @see https://doc.babylonjs.com/babylon101/lights
  44918. */
  44919. lights: Light[];
  44920. /**
  44921. * All of the (abstract) meshes added to this scene
  44922. */
  44923. meshes: AbstractMesh[];
  44924. /**
  44925. * The list of skeletons added to the scene
  44926. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44927. */
  44928. skeletons: Skeleton[];
  44929. /**
  44930. * All of the particle systems added to this scene
  44931. * @see https://doc.babylonjs.com/babylon101/particles
  44932. */
  44933. particleSystems: IParticleSystem[];
  44934. /**
  44935. * Gets a list of Animations associated with the scene
  44936. */
  44937. animations: Animation[];
  44938. /**
  44939. * All of the animation groups added to this scene
  44940. * @see https://doc.babylonjs.com/how_to/group
  44941. */
  44942. animationGroups: AnimationGroup[];
  44943. /**
  44944. * All of the multi-materials added to this scene
  44945. * @see https://doc.babylonjs.com/how_to/multi_materials
  44946. */
  44947. multiMaterials: MultiMaterial[];
  44948. /**
  44949. * All of the materials added to this scene
  44950. * In the context of a Scene, it is not supposed to be modified manually.
  44951. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44952. * Note also that the order of the Material within the array is not significant and might change.
  44953. * @see https://doc.babylonjs.com/babylon101/materials
  44954. */
  44955. materials: Material[];
  44956. /**
  44957. * The list of morph target managers added to the scene
  44958. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44959. */
  44960. morphTargetManagers: MorphTargetManager[];
  44961. /**
  44962. * The list of geometries used in the scene.
  44963. */
  44964. geometries: Geometry[];
  44965. /**
  44966. * All of the tranform nodes added to this scene
  44967. * In the context of a Scene, it is not supposed to be modified manually.
  44968. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44969. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44970. * @see https://doc.babylonjs.com/how_to/transformnode
  44971. */
  44972. transformNodes: TransformNode[];
  44973. /**
  44974. * ActionManagers available on the scene.
  44975. */
  44976. actionManagers: AbstractActionManager[];
  44977. /**
  44978. * Textures to keep.
  44979. */
  44980. textures: BaseTexture[];
  44981. /** @hidden */
  44982. protected _environmentTexture: Nullable<BaseTexture>;
  44983. /**
  44984. * Texture used in all pbr material as the reflection texture.
  44985. * As in the majority of the scene they are the same (exception for multi room and so on),
  44986. * this is easier to reference from here than from all the materials.
  44987. */
  44988. get environmentTexture(): Nullable<BaseTexture>;
  44989. set environmentTexture(value: Nullable<BaseTexture>);
  44990. /**
  44991. * The list of postprocesses added to the scene
  44992. */
  44993. postProcesses: PostProcess[];
  44994. /**
  44995. * @returns all meshes, lights, cameras, transformNodes and bones
  44996. */
  44997. getNodes(): Array<Node>;
  44998. }
  44999. }
  45000. declare module BABYLON {
  45001. /**
  45002. * Interface used to define options for Sound class
  45003. */
  45004. export interface ISoundOptions {
  45005. /**
  45006. * Does the sound autoplay once loaded.
  45007. */
  45008. autoplay?: boolean;
  45009. /**
  45010. * Does the sound loop after it finishes playing once.
  45011. */
  45012. loop?: boolean;
  45013. /**
  45014. * Sound's volume
  45015. */
  45016. volume?: number;
  45017. /**
  45018. * Is it a spatial sound?
  45019. */
  45020. spatialSound?: boolean;
  45021. /**
  45022. * Maximum distance to hear that sound
  45023. */
  45024. maxDistance?: number;
  45025. /**
  45026. * Uses user defined attenuation function
  45027. */
  45028. useCustomAttenuation?: boolean;
  45029. /**
  45030. * Define the roll off factor of spatial sounds.
  45031. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45032. */
  45033. rolloffFactor?: number;
  45034. /**
  45035. * Define the reference distance the sound should be heard perfectly.
  45036. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45037. */
  45038. refDistance?: number;
  45039. /**
  45040. * Define the distance attenuation model the sound will follow.
  45041. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45042. */
  45043. distanceModel?: string;
  45044. /**
  45045. * Defines the playback speed (1 by default)
  45046. */
  45047. playbackRate?: number;
  45048. /**
  45049. * Defines if the sound is from a streaming source
  45050. */
  45051. streaming?: boolean;
  45052. /**
  45053. * Defines an optional length (in seconds) inside the sound file
  45054. */
  45055. length?: number;
  45056. /**
  45057. * Defines an optional offset (in seconds) inside the sound file
  45058. */
  45059. offset?: number;
  45060. /**
  45061. * If true, URLs will not be required to state the audio file codec to use.
  45062. */
  45063. skipCodecCheck?: boolean;
  45064. }
  45065. }
  45066. declare module BABYLON {
  45067. /**
  45068. * Defines a sound that can be played in the application.
  45069. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  45070. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45071. */
  45072. export class Sound {
  45073. /**
  45074. * The name of the sound in the scene.
  45075. */
  45076. name: string;
  45077. /**
  45078. * Does the sound autoplay once loaded.
  45079. */
  45080. autoplay: boolean;
  45081. /**
  45082. * Does the sound loop after it finishes playing once.
  45083. */
  45084. loop: boolean;
  45085. /**
  45086. * Does the sound use a custom attenuation curve to simulate the falloff
  45087. * happening when the source gets further away from the camera.
  45088. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45089. */
  45090. useCustomAttenuation: boolean;
  45091. /**
  45092. * The sound track id this sound belongs to.
  45093. */
  45094. soundTrackId: number;
  45095. /**
  45096. * Is this sound currently played.
  45097. */
  45098. isPlaying: boolean;
  45099. /**
  45100. * Is this sound currently paused.
  45101. */
  45102. isPaused: boolean;
  45103. /**
  45104. * Does this sound enables spatial sound.
  45105. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45106. */
  45107. spatialSound: boolean;
  45108. /**
  45109. * Define the reference distance the sound should be heard perfectly.
  45110. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45111. */
  45112. refDistance: number;
  45113. /**
  45114. * Define the roll off factor of spatial sounds.
  45115. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45116. */
  45117. rolloffFactor: number;
  45118. /**
  45119. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  45120. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45121. */
  45122. maxDistance: number;
  45123. /**
  45124. * Define the distance attenuation model the sound will follow.
  45125. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45126. */
  45127. distanceModel: string;
  45128. /**
  45129. * @hidden
  45130. * Back Compat
  45131. **/
  45132. onended: () => any;
  45133. /**
  45134. * Gets or sets an object used to store user defined information for the sound.
  45135. */
  45136. metadata: any;
  45137. /**
  45138. * Observable event when the current playing sound finishes.
  45139. */
  45140. onEndedObservable: Observable<Sound>;
  45141. /**
  45142. * Gets the current time for the sound.
  45143. */
  45144. get currentTime(): number;
  45145. private _panningModel;
  45146. private _playbackRate;
  45147. private _streaming;
  45148. private _startTime;
  45149. private _startOffset;
  45150. private _position;
  45151. /** @hidden */
  45152. _positionInEmitterSpace: boolean;
  45153. private _localDirection;
  45154. private _volume;
  45155. private _isReadyToPlay;
  45156. private _isDirectional;
  45157. private _readyToPlayCallback;
  45158. private _audioBuffer;
  45159. private _soundSource;
  45160. private _streamingSource;
  45161. private _soundPanner;
  45162. private _soundGain;
  45163. private _inputAudioNode;
  45164. private _outputAudioNode;
  45165. private _coneInnerAngle;
  45166. private _coneOuterAngle;
  45167. private _coneOuterGain;
  45168. private _scene;
  45169. private _connectedTransformNode;
  45170. private _customAttenuationFunction;
  45171. private _registerFunc;
  45172. private _isOutputConnected;
  45173. private _htmlAudioElement;
  45174. private _urlType;
  45175. private _length?;
  45176. private _offset?;
  45177. /** @hidden */
  45178. static _SceneComponentInitialization: (scene: Scene) => void;
  45179. /**
  45180. * Create a sound and attach it to a scene
  45181. * @param name Name of your sound
  45182. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  45183. * @param scene defines the scene the sound belongs to
  45184. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  45185. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  45186. */
  45187. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  45188. /**
  45189. * Release the sound and its associated resources
  45190. */
  45191. dispose(): void;
  45192. /**
  45193. * Gets if the sounds is ready to be played or not.
  45194. * @returns true if ready, otherwise false
  45195. */
  45196. isReady(): boolean;
  45197. private _soundLoaded;
  45198. /**
  45199. * Sets the data of the sound from an audiobuffer
  45200. * @param audioBuffer The audioBuffer containing the data
  45201. */
  45202. setAudioBuffer(audioBuffer: AudioBuffer): void;
  45203. /**
  45204. * Updates the current sounds options such as maxdistance, loop...
  45205. * @param options A JSON object containing values named as the object properties
  45206. */
  45207. updateOptions(options: ISoundOptions): void;
  45208. private _createSpatialParameters;
  45209. private _updateSpatialParameters;
  45210. /**
  45211. * Switch the panning model to HRTF:
  45212. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45213. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45214. */
  45215. switchPanningModelToHRTF(): void;
  45216. /**
  45217. * Switch the panning model to Equal Power:
  45218. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45219. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45220. */
  45221. switchPanningModelToEqualPower(): void;
  45222. private _switchPanningModel;
  45223. /**
  45224. * Connect this sound to a sound track audio node like gain...
  45225. * @param soundTrackAudioNode the sound track audio node to connect to
  45226. */
  45227. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  45228. /**
  45229. * Transform this sound into a directional source
  45230. * @param coneInnerAngle Size of the inner cone in degree
  45231. * @param coneOuterAngle Size of the outer cone in degree
  45232. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  45233. */
  45234. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  45235. /**
  45236. * Gets or sets the inner angle for the directional cone.
  45237. */
  45238. get directionalConeInnerAngle(): number;
  45239. /**
  45240. * Gets or sets the inner angle for the directional cone.
  45241. */
  45242. set directionalConeInnerAngle(value: number);
  45243. /**
  45244. * Gets or sets the outer angle for the directional cone.
  45245. */
  45246. get directionalConeOuterAngle(): number;
  45247. /**
  45248. * Gets or sets the outer angle for the directional cone.
  45249. */
  45250. set directionalConeOuterAngle(value: number);
  45251. /**
  45252. * Sets the position of the emitter if spatial sound is enabled
  45253. * @param newPosition Defines the new posisiton
  45254. */
  45255. setPosition(newPosition: Vector3): void;
  45256. /**
  45257. * Sets the local direction of the emitter if spatial sound is enabled
  45258. * @param newLocalDirection Defines the new local direction
  45259. */
  45260. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  45261. private _updateDirection;
  45262. /** @hidden */
  45263. updateDistanceFromListener(): void;
  45264. /**
  45265. * Sets a new custom attenuation function for the sound.
  45266. * @param callback Defines the function used for the attenuation
  45267. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45268. */
  45269. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  45270. /**
  45271. * Play the sound
  45272. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  45273. * @param offset (optional) Start the sound at a specific time in seconds
  45274. * @param length (optional) Sound duration (in seconds)
  45275. */
  45276. play(time?: number, offset?: number, length?: number): void;
  45277. private _onended;
  45278. /**
  45279. * Stop the sound
  45280. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  45281. */
  45282. stop(time?: number): void;
  45283. /**
  45284. * Put the sound in pause
  45285. */
  45286. pause(): void;
  45287. /**
  45288. * Sets a dedicated volume for this sounds
  45289. * @param newVolume Define the new volume of the sound
  45290. * @param time Define time for gradual change to new volume
  45291. */
  45292. setVolume(newVolume: number, time?: number): void;
  45293. /**
  45294. * Set the sound play back rate
  45295. * @param newPlaybackRate Define the playback rate the sound should be played at
  45296. */
  45297. setPlaybackRate(newPlaybackRate: number): void;
  45298. /**
  45299. * Gets the volume of the sound.
  45300. * @returns the volume of the sound
  45301. */
  45302. getVolume(): number;
  45303. /**
  45304. * Attach the sound to a dedicated mesh
  45305. * @param transformNode The transform node to connect the sound with
  45306. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45307. */
  45308. attachToMesh(transformNode: TransformNode): void;
  45309. /**
  45310. * Detach the sound from the previously attached mesh
  45311. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45312. */
  45313. detachFromMesh(): void;
  45314. private _onRegisterAfterWorldMatrixUpdate;
  45315. /**
  45316. * Clone the current sound in the scene.
  45317. * @returns the new sound clone
  45318. */
  45319. clone(): Nullable<Sound>;
  45320. /**
  45321. * Gets the current underlying audio buffer containing the data
  45322. * @returns the audio buffer
  45323. */
  45324. getAudioBuffer(): Nullable<AudioBuffer>;
  45325. /**
  45326. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  45327. * @returns the source node
  45328. */
  45329. getSoundSource(): Nullable<AudioBufferSourceNode>;
  45330. /**
  45331. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  45332. * @returns the gain node
  45333. */
  45334. getSoundGain(): Nullable<GainNode>;
  45335. /**
  45336. * Serializes the Sound in a JSON representation
  45337. * @returns the JSON representation of the sound
  45338. */
  45339. serialize(): any;
  45340. /**
  45341. * Parse a JSON representation of a sound to innstantiate in a given scene
  45342. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  45343. * @param scene Define the scene the new parsed sound should be created in
  45344. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  45345. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  45346. * @returns the newly parsed sound
  45347. */
  45348. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  45349. }
  45350. }
  45351. declare module BABYLON {
  45352. /**
  45353. * This defines an action helpful to play a defined sound on a triggered action.
  45354. */
  45355. export class PlaySoundAction extends Action {
  45356. private _sound;
  45357. /**
  45358. * Instantiate the action
  45359. * @param triggerOptions defines the trigger options
  45360. * @param sound defines the sound to play
  45361. * @param condition defines the trigger related conditions
  45362. */
  45363. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45364. /** @hidden */
  45365. _prepare(): void;
  45366. /**
  45367. * Execute the action and play the sound.
  45368. */
  45369. execute(): void;
  45370. /**
  45371. * Serializes the actions and its related information.
  45372. * @param parent defines the object to serialize in
  45373. * @returns the serialized object
  45374. */
  45375. serialize(parent: any): any;
  45376. }
  45377. /**
  45378. * This defines an action helpful to stop a defined sound on a triggered action.
  45379. */
  45380. export class StopSoundAction extends Action {
  45381. private _sound;
  45382. /**
  45383. * Instantiate the action
  45384. * @param triggerOptions defines the trigger options
  45385. * @param sound defines the sound to stop
  45386. * @param condition defines the trigger related conditions
  45387. */
  45388. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45389. /** @hidden */
  45390. _prepare(): void;
  45391. /**
  45392. * Execute the action and stop the sound.
  45393. */
  45394. execute(): void;
  45395. /**
  45396. * Serializes the actions and its related information.
  45397. * @param parent defines the object to serialize in
  45398. * @returns the serialized object
  45399. */
  45400. serialize(parent: any): any;
  45401. }
  45402. }
  45403. declare module BABYLON {
  45404. /**
  45405. * This defines an action responsible to change the value of a property
  45406. * by interpolating between its current value and the newly set one once triggered.
  45407. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45408. */
  45409. export class InterpolateValueAction extends Action {
  45410. /**
  45411. * Defines the path of the property where the value should be interpolated
  45412. */
  45413. propertyPath: string;
  45414. /**
  45415. * Defines the target value at the end of the interpolation.
  45416. */
  45417. value: any;
  45418. /**
  45419. * Defines the time it will take for the property to interpolate to the value.
  45420. */
  45421. duration: number;
  45422. /**
  45423. * Defines if the other scene animations should be stopped when the action has been triggered
  45424. */
  45425. stopOtherAnimations?: boolean;
  45426. /**
  45427. * Defines a callback raised once the interpolation animation has been done.
  45428. */
  45429. onInterpolationDone?: () => void;
  45430. /**
  45431. * Observable triggered once the interpolation animation has been done.
  45432. */
  45433. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  45434. private _target;
  45435. private _effectiveTarget;
  45436. private _property;
  45437. /**
  45438. * Instantiate the action
  45439. * @param triggerOptions defines the trigger options
  45440. * @param target defines the object containing the value to interpolate
  45441. * @param propertyPath defines the path to the property in the target object
  45442. * @param value defines the target value at the end of the interpolation
  45443. * @param duration deines the time it will take for the property to interpolate to the value.
  45444. * @param condition defines the trigger related conditions
  45445. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  45446. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  45447. */
  45448. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  45449. /** @hidden */
  45450. _prepare(): void;
  45451. /**
  45452. * Execute the action starts the value interpolation.
  45453. */
  45454. execute(): void;
  45455. /**
  45456. * Serializes the actions and its related information.
  45457. * @param parent defines the object to serialize in
  45458. * @returns the serialized object
  45459. */
  45460. serialize(parent: any): any;
  45461. }
  45462. }
  45463. declare module BABYLON {
  45464. /**
  45465. * This represents the default audio engine used in babylon.
  45466. * It is responsible to play, synchronize and analyse sounds throughout the application.
  45467. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45468. */
  45469. export class AudioEngine implements IAudioEngine {
  45470. private _audioContext;
  45471. private _audioContextInitialized;
  45472. private _muteButton;
  45473. private _hostElement;
  45474. /**
  45475. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  45476. */
  45477. canUseWebAudio: boolean;
  45478. /**
  45479. * The master gain node defines the global audio volume of your audio engine.
  45480. */
  45481. masterGain: GainNode;
  45482. /**
  45483. * Defines if Babylon should emit a warning if WebAudio is not supported.
  45484. * @ignoreNaming
  45485. */
  45486. WarnedWebAudioUnsupported: boolean;
  45487. /**
  45488. * Gets whether or not mp3 are supported by your browser.
  45489. */
  45490. isMP3supported: boolean;
  45491. /**
  45492. * Gets whether or not ogg are supported by your browser.
  45493. */
  45494. isOGGsupported: boolean;
  45495. /**
  45496. * Gets whether audio has been unlocked on the device.
  45497. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  45498. * a user interaction has happened.
  45499. */
  45500. unlocked: boolean;
  45501. /**
  45502. * Defines if the audio engine relies on a custom unlocked button.
  45503. * In this case, the embedded button will not be displayed.
  45504. */
  45505. useCustomUnlockedButton: boolean;
  45506. /**
  45507. * Event raised when audio has been unlocked on the browser.
  45508. */
  45509. onAudioUnlockedObservable: Observable<IAudioEngine>;
  45510. /**
  45511. * Event raised when audio has been locked on the browser.
  45512. */
  45513. onAudioLockedObservable: Observable<IAudioEngine>;
  45514. /**
  45515. * Gets the current AudioContext if available.
  45516. */
  45517. get audioContext(): Nullable<AudioContext>;
  45518. private _connectedAnalyser;
  45519. /**
  45520. * Instantiates a new audio engine.
  45521. *
  45522. * There should be only one per page as some browsers restrict the number
  45523. * of audio contexts you can create.
  45524. * @param hostElement defines the host element where to display the mute icon if necessary
  45525. */
  45526. constructor(hostElement?: Nullable<HTMLElement>);
  45527. /**
  45528. * Flags the audio engine in Locked state.
  45529. * This happens due to new browser policies preventing audio to autoplay.
  45530. */
  45531. lock(): void;
  45532. /**
  45533. * Unlocks the audio engine once a user action has been done on the dom.
  45534. * This is helpful to resume play once browser policies have been satisfied.
  45535. */
  45536. unlock(): void;
  45537. private _resumeAudioContext;
  45538. private _initializeAudioContext;
  45539. private _tryToRun;
  45540. private _triggerRunningState;
  45541. private _triggerSuspendedState;
  45542. private _displayMuteButton;
  45543. private _moveButtonToTopLeft;
  45544. private _onResize;
  45545. private _hideMuteButton;
  45546. /**
  45547. * Destroy and release the resources associated with the audio ccontext.
  45548. */
  45549. dispose(): void;
  45550. /**
  45551. * Gets the global volume sets on the master gain.
  45552. * @returns the global volume if set or -1 otherwise
  45553. */
  45554. getGlobalVolume(): number;
  45555. /**
  45556. * Sets the global volume of your experience (sets on the master gain).
  45557. * @param newVolume Defines the new global volume of the application
  45558. */
  45559. setGlobalVolume(newVolume: number): void;
  45560. /**
  45561. * Connect the audio engine to an audio analyser allowing some amazing
  45562. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45563. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45564. * @param analyser The analyser to connect to the engine
  45565. */
  45566. connectToAnalyser(analyser: Analyser): void;
  45567. }
  45568. }
  45569. declare module BABYLON {
  45570. /**
  45571. * Options allowed during the creation of a sound track.
  45572. */
  45573. export interface ISoundTrackOptions {
  45574. /**
  45575. * The volume the sound track should take during creation
  45576. */
  45577. volume?: number;
  45578. /**
  45579. * Define if the sound track is the main sound track of the scene
  45580. */
  45581. mainTrack?: boolean;
  45582. }
  45583. /**
  45584. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45585. * It will be also used in a future release to apply effects on a specific track.
  45586. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45587. */
  45588. export class SoundTrack {
  45589. /**
  45590. * The unique identifier of the sound track in the scene.
  45591. */
  45592. id: number;
  45593. /**
  45594. * The list of sounds included in the sound track.
  45595. */
  45596. soundCollection: Array<Sound>;
  45597. private _outputAudioNode;
  45598. private _scene;
  45599. private _connectedAnalyser;
  45600. private _options;
  45601. private _isInitialized;
  45602. /**
  45603. * Creates a new sound track.
  45604. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45605. * @param scene Define the scene the sound track belongs to
  45606. * @param options
  45607. */
  45608. constructor(scene: Scene, options?: ISoundTrackOptions);
  45609. private _initializeSoundTrackAudioGraph;
  45610. /**
  45611. * Release the sound track and its associated resources
  45612. */
  45613. dispose(): void;
  45614. /**
  45615. * Adds a sound to this sound track
  45616. * @param sound define the cound to add
  45617. * @ignoreNaming
  45618. */
  45619. addSound(sound: Sound): void;
  45620. /**
  45621. * Removes a sound to this sound track
  45622. * @param sound define the cound to remove
  45623. * @ignoreNaming
  45624. */
  45625. removeSound(sound: Sound): void;
  45626. /**
  45627. * Set a global volume for the full sound track.
  45628. * @param newVolume Define the new volume of the sound track
  45629. */
  45630. setVolume(newVolume: number): void;
  45631. /**
  45632. * Switch the panning model to HRTF:
  45633. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45634. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45635. */
  45636. switchPanningModelToHRTF(): void;
  45637. /**
  45638. * Switch the panning model to Equal Power:
  45639. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45640. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45641. */
  45642. switchPanningModelToEqualPower(): void;
  45643. /**
  45644. * Connect the sound track to an audio analyser allowing some amazing
  45645. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45646. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45647. * @param analyser The analyser to connect to the engine
  45648. */
  45649. connectToAnalyser(analyser: Analyser): void;
  45650. }
  45651. }
  45652. declare module BABYLON {
  45653. interface AbstractScene {
  45654. /**
  45655. * The list of sounds used in the scene.
  45656. */
  45657. sounds: Nullable<Array<Sound>>;
  45658. }
  45659. interface Scene {
  45660. /**
  45661. * @hidden
  45662. * Backing field
  45663. */
  45664. _mainSoundTrack: SoundTrack;
  45665. /**
  45666. * The main sound track played by the scene.
  45667. * It cotains your primary collection of sounds.
  45668. */
  45669. mainSoundTrack: SoundTrack;
  45670. /**
  45671. * The list of sound tracks added to the scene
  45672. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45673. */
  45674. soundTracks: Nullable<Array<SoundTrack>>;
  45675. /**
  45676. * Gets a sound using a given name
  45677. * @param name defines the name to search for
  45678. * @return the found sound or null if not found at all.
  45679. */
  45680. getSoundByName(name: string): Nullable<Sound>;
  45681. /**
  45682. * Gets or sets if audio support is enabled
  45683. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45684. */
  45685. audioEnabled: boolean;
  45686. /**
  45687. * Gets or sets if audio will be output to headphones
  45688. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45689. */
  45690. headphone: boolean;
  45691. /**
  45692. * Gets or sets custom audio listener position provider
  45693. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45694. */
  45695. audioListenerPositionProvider: Nullable<() => Vector3>;
  45696. /**
  45697. * Gets or sets a refresh rate when using 3D audio positioning
  45698. */
  45699. audioPositioningRefreshRate: number;
  45700. }
  45701. /**
  45702. * Defines the sound scene component responsible to manage any sounds
  45703. * in a given scene.
  45704. */
  45705. export class AudioSceneComponent implements ISceneSerializableComponent {
  45706. private static _CameraDirectionLH;
  45707. private static _CameraDirectionRH;
  45708. /**
  45709. * The component name helpfull to identify the component in the list of scene components.
  45710. */
  45711. readonly name: string;
  45712. /**
  45713. * The scene the component belongs to.
  45714. */
  45715. scene: Scene;
  45716. private _audioEnabled;
  45717. /**
  45718. * Gets whether audio is enabled or not.
  45719. * Please use related enable/disable method to switch state.
  45720. */
  45721. get audioEnabled(): boolean;
  45722. private _headphone;
  45723. /**
  45724. * Gets whether audio is outputing to headphone or not.
  45725. * Please use the according Switch methods to change output.
  45726. */
  45727. get headphone(): boolean;
  45728. /**
  45729. * Gets or sets a refresh rate when using 3D audio positioning
  45730. */
  45731. audioPositioningRefreshRate: number;
  45732. private _audioListenerPositionProvider;
  45733. /**
  45734. * Gets the current audio listener position provider
  45735. */
  45736. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45737. /**
  45738. * Sets a custom listener position for all sounds in the scene
  45739. * By default, this is the position of the first active camera
  45740. */
  45741. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45742. /**
  45743. * Creates a new instance of the component for the given scene
  45744. * @param scene Defines the scene to register the component in
  45745. */
  45746. constructor(scene: Scene);
  45747. /**
  45748. * Registers the component in a given scene
  45749. */
  45750. register(): void;
  45751. /**
  45752. * Rebuilds the elements related to this component in case of
  45753. * context lost for instance.
  45754. */
  45755. rebuild(): void;
  45756. /**
  45757. * Serializes the component data to the specified json object
  45758. * @param serializationObject The object to serialize to
  45759. */
  45760. serialize(serializationObject: any): void;
  45761. /**
  45762. * Adds all the elements from the container to the scene
  45763. * @param container the container holding the elements
  45764. */
  45765. addFromContainer(container: AbstractScene): void;
  45766. /**
  45767. * Removes all the elements in the container from the scene
  45768. * @param container contains the elements to remove
  45769. * @param dispose if the removed element should be disposed (default: false)
  45770. */
  45771. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45772. /**
  45773. * Disposes the component and the associated ressources.
  45774. */
  45775. dispose(): void;
  45776. /**
  45777. * Disables audio in the associated scene.
  45778. */
  45779. disableAudio(): void;
  45780. /**
  45781. * Enables audio in the associated scene.
  45782. */
  45783. enableAudio(): void;
  45784. /**
  45785. * Switch audio to headphone output.
  45786. */
  45787. switchAudioModeForHeadphones(): void;
  45788. /**
  45789. * Switch audio to normal speakers.
  45790. */
  45791. switchAudioModeForNormalSpeakers(): void;
  45792. private _cachedCameraDirection;
  45793. private _cachedCameraPosition;
  45794. private _lastCheck;
  45795. private _afterRender;
  45796. }
  45797. }
  45798. declare module BABYLON {
  45799. /**
  45800. * Wraps one or more Sound objects and selects one with random weight for playback.
  45801. */
  45802. export class WeightedSound {
  45803. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45804. loop: boolean;
  45805. private _coneInnerAngle;
  45806. private _coneOuterAngle;
  45807. private _volume;
  45808. /** A Sound is currently playing. */
  45809. isPlaying: boolean;
  45810. /** A Sound is currently paused. */
  45811. isPaused: boolean;
  45812. private _sounds;
  45813. private _weights;
  45814. private _currentIndex?;
  45815. /**
  45816. * Creates a new WeightedSound from the list of sounds given.
  45817. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45818. * @param sounds Array of Sounds that will be selected from.
  45819. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45820. */
  45821. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45822. /**
  45823. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45824. */
  45825. get directionalConeInnerAngle(): number;
  45826. /**
  45827. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45828. */
  45829. set directionalConeInnerAngle(value: number);
  45830. /**
  45831. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45832. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45833. */
  45834. get directionalConeOuterAngle(): number;
  45835. /**
  45836. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45837. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45838. */
  45839. set directionalConeOuterAngle(value: number);
  45840. /**
  45841. * Playback volume.
  45842. */
  45843. get volume(): number;
  45844. /**
  45845. * Playback volume.
  45846. */
  45847. set volume(value: number);
  45848. private _onended;
  45849. /**
  45850. * Suspend playback
  45851. */
  45852. pause(): void;
  45853. /**
  45854. * Stop playback
  45855. */
  45856. stop(): void;
  45857. /**
  45858. * Start playback.
  45859. * @param startOffset Position the clip head at a specific time in seconds.
  45860. */
  45861. play(startOffset?: number): void;
  45862. }
  45863. }
  45864. declare module BABYLON {
  45865. /**
  45866. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45867. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45868. */
  45869. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45870. /**
  45871. * Gets the name of the behavior.
  45872. */
  45873. get name(): string;
  45874. /**
  45875. * The easing function used by animations
  45876. */
  45877. static EasingFunction: BackEase;
  45878. /**
  45879. * The easing mode used by animations
  45880. */
  45881. static EasingMode: number;
  45882. /**
  45883. * The duration of the animation, in milliseconds
  45884. */
  45885. transitionDuration: number;
  45886. /**
  45887. * Length of the distance animated by the transition when lower radius is reached
  45888. */
  45889. lowerRadiusTransitionRange: number;
  45890. /**
  45891. * Length of the distance animated by the transition when upper radius is reached
  45892. */
  45893. upperRadiusTransitionRange: number;
  45894. private _autoTransitionRange;
  45895. /**
  45896. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45897. */
  45898. get autoTransitionRange(): boolean;
  45899. /**
  45900. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45901. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45902. */
  45903. set autoTransitionRange(value: boolean);
  45904. private _attachedCamera;
  45905. private _onAfterCheckInputsObserver;
  45906. private _onMeshTargetChangedObserver;
  45907. /**
  45908. * Initializes the behavior.
  45909. */
  45910. init(): void;
  45911. /**
  45912. * Attaches the behavior to its arc rotate camera.
  45913. * @param camera Defines the camera to attach the behavior to
  45914. */
  45915. attach(camera: ArcRotateCamera): void;
  45916. /**
  45917. * Detaches the behavior from its current arc rotate camera.
  45918. */
  45919. detach(): void;
  45920. private _radiusIsAnimating;
  45921. private _radiusBounceTransition;
  45922. private _animatables;
  45923. private _cachedWheelPrecision;
  45924. /**
  45925. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45926. * @param radiusLimit The limit to check against.
  45927. * @return Bool to indicate if at limit.
  45928. */
  45929. private _isRadiusAtLimit;
  45930. /**
  45931. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45932. * @param radiusDelta The delta by which to animate to. Can be negative.
  45933. */
  45934. private _applyBoundRadiusAnimation;
  45935. /**
  45936. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45937. */
  45938. protected _clearAnimationLocks(): void;
  45939. /**
  45940. * Stops and removes all animations that have been applied to the camera
  45941. */
  45942. stopAllAnimations(): void;
  45943. }
  45944. }
  45945. declare module BABYLON {
  45946. /**
  45947. * 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.
  45948. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45949. */
  45950. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45951. /**
  45952. * Gets the name of the behavior.
  45953. */
  45954. get name(): string;
  45955. private _mode;
  45956. private _radiusScale;
  45957. private _positionScale;
  45958. private _defaultElevation;
  45959. private _elevationReturnTime;
  45960. private _elevationReturnWaitTime;
  45961. private _zoomStopsAnimation;
  45962. private _framingTime;
  45963. /**
  45964. * The easing function used by animations
  45965. */
  45966. static EasingFunction: ExponentialEase;
  45967. /**
  45968. * The easing mode used by animations
  45969. */
  45970. static EasingMode: number;
  45971. /**
  45972. * Sets the current mode used by the behavior
  45973. */
  45974. set mode(mode: number);
  45975. /**
  45976. * Gets current mode used by the behavior.
  45977. */
  45978. get mode(): number;
  45979. /**
  45980. * Sets the scale applied to the radius (1 by default)
  45981. */
  45982. set radiusScale(radius: number);
  45983. /**
  45984. * Gets the scale applied to the radius
  45985. */
  45986. get radiusScale(): number;
  45987. /**
  45988. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45989. */
  45990. set positionScale(scale: number);
  45991. /**
  45992. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45993. */
  45994. get positionScale(): number;
  45995. /**
  45996. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45997. * behaviour is triggered, in radians.
  45998. */
  45999. set defaultElevation(elevation: number);
  46000. /**
  46001. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46002. * behaviour is triggered, in radians.
  46003. */
  46004. get defaultElevation(): number;
  46005. /**
  46006. * Sets the time (in milliseconds) taken to return to the default beta position.
  46007. * Negative value indicates camera should not return to default.
  46008. */
  46009. set elevationReturnTime(speed: number);
  46010. /**
  46011. * Gets the time (in milliseconds) taken to return to the default beta position.
  46012. * Negative value indicates camera should not return to default.
  46013. */
  46014. get elevationReturnTime(): number;
  46015. /**
  46016. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46017. */
  46018. set elevationReturnWaitTime(time: number);
  46019. /**
  46020. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46021. */
  46022. get elevationReturnWaitTime(): number;
  46023. /**
  46024. * Sets the flag that indicates if user zooming should stop animation.
  46025. */
  46026. set zoomStopsAnimation(flag: boolean);
  46027. /**
  46028. * Gets the flag that indicates if user zooming should stop animation.
  46029. */
  46030. get zoomStopsAnimation(): boolean;
  46031. /**
  46032. * Sets the transition time when framing the mesh, in milliseconds
  46033. */
  46034. set framingTime(time: number);
  46035. /**
  46036. * Gets the transition time when framing the mesh, in milliseconds
  46037. */
  46038. get framingTime(): number;
  46039. /**
  46040. * Define if the behavior should automatically change the configured
  46041. * camera limits and sensibilities.
  46042. */
  46043. autoCorrectCameraLimitsAndSensibility: boolean;
  46044. private _onPrePointerObservableObserver;
  46045. private _onAfterCheckInputsObserver;
  46046. private _onMeshTargetChangedObserver;
  46047. private _attachedCamera;
  46048. private _isPointerDown;
  46049. private _lastInteractionTime;
  46050. /**
  46051. * Initializes the behavior.
  46052. */
  46053. init(): void;
  46054. /**
  46055. * Attaches the behavior to its arc rotate camera.
  46056. * @param camera Defines the camera to attach the behavior to
  46057. */
  46058. attach(camera: ArcRotateCamera): void;
  46059. /**
  46060. * Detaches the behavior from its current arc rotate camera.
  46061. */
  46062. detach(): void;
  46063. private _animatables;
  46064. private _betaIsAnimating;
  46065. private _betaTransition;
  46066. private _radiusTransition;
  46067. private _vectorTransition;
  46068. /**
  46069. * Targets the given mesh and updates zoom level accordingly.
  46070. * @param mesh The mesh to target.
  46071. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46072. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46073. */
  46074. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46075. /**
  46076. * Targets the given mesh with its children and updates zoom level accordingly.
  46077. * @param mesh The mesh to target.
  46078. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46079. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46080. */
  46081. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46082. /**
  46083. * Targets the given meshes with their children and updates zoom level accordingly.
  46084. * @param meshes The mesh to target.
  46085. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46086. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46087. */
  46088. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46089. /**
  46090. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  46091. * @param minimumWorld Determines the smaller position of the bounding box extend
  46092. * @param maximumWorld Determines the bigger position of the bounding box extend
  46093. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46094. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46095. */
  46096. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46097. /**
  46098. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  46099. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  46100. * frustum width.
  46101. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  46102. * to fully enclose the mesh in the viewing frustum.
  46103. */
  46104. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  46105. /**
  46106. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  46107. * is automatically returned to its default position (expected to be above ground plane).
  46108. */
  46109. private _maintainCameraAboveGround;
  46110. /**
  46111. * Returns the frustum slope based on the canvas ratio and camera FOV
  46112. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  46113. */
  46114. private _getFrustumSlope;
  46115. /**
  46116. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  46117. */
  46118. private _clearAnimationLocks;
  46119. /**
  46120. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46121. */
  46122. private _applyUserInteraction;
  46123. /**
  46124. * Stops and removes all animations that have been applied to the camera
  46125. */
  46126. stopAllAnimations(): void;
  46127. /**
  46128. * Gets a value indicating if the user is moving the camera
  46129. */
  46130. get isUserIsMoving(): boolean;
  46131. /**
  46132. * The camera can move all the way towards the mesh.
  46133. */
  46134. static IgnoreBoundsSizeMode: number;
  46135. /**
  46136. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  46137. */
  46138. static FitFrustumSidesMode: number;
  46139. }
  46140. }
  46141. declare module BABYLON {
  46142. /**
  46143. * Base class for Camera Pointer Inputs.
  46144. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  46145. * for example usage.
  46146. */
  46147. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  46148. /**
  46149. * Defines the camera the input is attached to.
  46150. */
  46151. abstract camera: Camera;
  46152. /**
  46153. * Whether keyboard modifier keys are pressed at time of last mouse event.
  46154. */
  46155. protected _altKey: boolean;
  46156. protected _ctrlKey: boolean;
  46157. protected _metaKey: boolean;
  46158. protected _shiftKey: boolean;
  46159. /**
  46160. * Which mouse buttons were pressed at time of last mouse event.
  46161. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  46162. */
  46163. protected _buttonsPressed: number;
  46164. /**
  46165. * Defines the buttons associated with the input to handle camera move.
  46166. */
  46167. buttons: number[];
  46168. /**
  46169. * Attach the input controls to a specific dom element to get the input from.
  46170. * @param element Defines the element the controls should be listened from
  46171. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46172. */
  46173. attachControl(noPreventDefault?: boolean): void;
  46174. /**
  46175. * Detach the current controls from the specified dom element.
  46176. */
  46177. detachControl(): void;
  46178. /**
  46179. * Gets the class name of the current input.
  46180. * @returns the class name
  46181. */
  46182. getClassName(): string;
  46183. /**
  46184. * Get the friendly name associated with the input class.
  46185. * @returns the input friendly name
  46186. */
  46187. getSimpleName(): string;
  46188. /**
  46189. * Called on pointer POINTERDOUBLETAP event.
  46190. * Override this method to provide functionality on POINTERDOUBLETAP event.
  46191. */
  46192. protected onDoubleTap(type: string): void;
  46193. /**
  46194. * Called on pointer POINTERMOVE event if only a single touch is active.
  46195. * Override this method to provide functionality.
  46196. */
  46197. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46198. /**
  46199. * Called on pointer POINTERMOVE event if multiple touches are active.
  46200. * Override this method to provide functionality.
  46201. */
  46202. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46203. /**
  46204. * Called on JS contextmenu event.
  46205. * Override this method to provide functionality.
  46206. */
  46207. protected onContextMenu(evt: PointerEvent): void;
  46208. /**
  46209. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46210. * press.
  46211. * Override this method to provide functionality.
  46212. */
  46213. protected onButtonDown(evt: PointerEvent): void;
  46214. /**
  46215. * Called each time a new POINTERUP event occurs. Ie, for each button
  46216. * release.
  46217. * Override this method to provide functionality.
  46218. */
  46219. protected onButtonUp(evt: PointerEvent): void;
  46220. /**
  46221. * Called when window becomes inactive.
  46222. * Override this method to provide functionality.
  46223. */
  46224. protected onLostFocus(): void;
  46225. private _pointerInput;
  46226. private _observer;
  46227. private _onLostFocus;
  46228. private pointA;
  46229. private pointB;
  46230. }
  46231. }
  46232. declare module BABYLON {
  46233. /**
  46234. * Manage the pointers inputs to control an arc rotate camera.
  46235. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46236. */
  46237. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  46238. /**
  46239. * Defines the camera the input is attached to.
  46240. */
  46241. camera: ArcRotateCamera;
  46242. /**
  46243. * Gets the class name of the current input.
  46244. * @returns the class name
  46245. */
  46246. getClassName(): string;
  46247. /**
  46248. * Defines the buttons associated with the input to handle camera move.
  46249. */
  46250. buttons: number[];
  46251. /**
  46252. * Defines the pointer angular sensibility along the X axis or how fast is
  46253. * the camera rotating.
  46254. */
  46255. angularSensibilityX: number;
  46256. /**
  46257. * Defines the pointer angular sensibility along the Y axis or how fast is
  46258. * the camera rotating.
  46259. */
  46260. angularSensibilityY: number;
  46261. /**
  46262. * Defines the pointer pinch precision or how fast is the camera zooming.
  46263. */
  46264. pinchPrecision: number;
  46265. /**
  46266. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46267. * from 0.
  46268. * It defines the percentage of current camera.radius to use as delta when
  46269. * pinch zoom is used.
  46270. */
  46271. pinchDeltaPercentage: number;
  46272. /**
  46273. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46274. * that any object in the plane at the camera's target point will scale
  46275. * perfectly with finger motion.
  46276. * Overrides pinchDeltaPercentage and pinchPrecision.
  46277. */
  46278. useNaturalPinchZoom: boolean;
  46279. /**
  46280. * Defines the pointer panning sensibility or how fast is the camera moving.
  46281. */
  46282. panningSensibility: number;
  46283. /**
  46284. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  46285. */
  46286. multiTouchPanning: boolean;
  46287. /**
  46288. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  46289. * zoom (pinch) through multitouch.
  46290. */
  46291. multiTouchPanAndZoom: boolean;
  46292. /**
  46293. * Revers pinch action direction.
  46294. */
  46295. pinchInwards: boolean;
  46296. private _isPanClick;
  46297. private _twoFingerActivityCount;
  46298. private _isPinching;
  46299. /**
  46300. * Called on pointer POINTERMOVE event if only a single touch is active.
  46301. */
  46302. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46303. /**
  46304. * Called on pointer POINTERDOUBLETAP event.
  46305. */
  46306. protected onDoubleTap(type: string): void;
  46307. /**
  46308. * Called on pointer POINTERMOVE event if multiple touches are active.
  46309. */
  46310. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46311. /**
  46312. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46313. * press.
  46314. */
  46315. protected onButtonDown(evt: PointerEvent): void;
  46316. /**
  46317. * Called each time a new POINTERUP event occurs. Ie, for each button
  46318. * release.
  46319. */
  46320. protected onButtonUp(evt: PointerEvent): void;
  46321. /**
  46322. * Called when window becomes inactive.
  46323. */
  46324. protected onLostFocus(): void;
  46325. }
  46326. }
  46327. declare module BABYLON {
  46328. /**
  46329. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  46330. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46331. */
  46332. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  46333. /**
  46334. * Defines the camera the input is attached to.
  46335. */
  46336. camera: ArcRotateCamera;
  46337. /**
  46338. * Defines the list of key codes associated with the up action (increase alpha)
  46339. */
  46340. keysUp: number[];
  46341. /**
  46342. * Defines the list of key codes associated with the down action (decrease alpha)
  46343. */
  46344. keysDown: number[];
  46345. /**
  46346. * Defines the list of key codes associated with the left action (increase beta)
  46347. */
  46348. keysLeft: number[];
  46349. /**
  46350. * Defines the list of key codes associated with the right action (decrease beta)
  46351. */
  46352. keysRight: number[];
  46353. /**
  46354. * Defines the list of key codes associated with the reset action.
  46355. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  46356. */
  46357. keysReset: number[];
  46358. /**
  46359. * Defines the panning sensibility of the inputs.
  46360. * (How fast is the camera panning)
  46361. */
  46362. panningSensibility: number;
  46363. /**
  46364. * Defines the zooming sensibility of the inputs.
  46365. * (How fast is the camera zooming)
  46366. */
  46367. zoomingSensibility: number;
  46368. /**
  46369. * Defines whether maintaining the alt key down switch the movement mode from
  46370. * orientation to zoom.
  46371. */
  46372. useAltToZoom: boolean;
  46373. /**
  46374. * Rotation speed of the camera
  46375. */
  46376. angularSpeed: number;
  46377. private _keys;
  46378. private _ctrlPressed;
  46379. private _altPressed;
  46380. private _onCanvasBlurObserver;
  46381. private _onKeyboardObserver;
  46382. private _engine;
  46383. private _scene;
  46384. /**
  46385. * Attach the input controls to a specific dom element to get the input from.
  46386. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46387. */
  46388. attachControl(noPreventDefault?: boolean): void;
  46389. /**
  46390. * Detach the current controls from the specified dom element.
  46391. */
  46392. detachControl(): void;
  46393. /**
  46394. * Update the current camera state depending on the inputs that have been used this frame.
  46395. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46396. */
  46397. checkInputs(): void;
  46398. /**
  46399. * Gets the class name of the current intput.
  46400. * @returns the class name
  46401. */
  46402. getClassName(): string;
  46403. /**
  46404. * Get the friendly name associated with the input class.
  46405. * @returns the input friendly name
  46406. */
  46407. getSimpleName(): string;
  46408. }
  46409. }
  46410. declare module BABYLON {
  46411. /**
  46412. * Manage the mouse wheel inputs to control an arc rotate camera.
  46413. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46414. */
  46415. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  46416. /**
  46417. * Defines the camera the input is attached to.
  46418. */
  46419. camera: ArcRotateCamera;
  46420. /**
  46421. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46422. */
  46423. wheelPrecision: number;
  46424. /**
  46425. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46426. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46427. */
  46428. wheelDeltaPercentage: number;
  46429. private _wheel;
  46430. private _observer;
  46431. private computeDeltaFromMouseWheelLegacyEvent;
  46432. /**
  46433. * Attach the input controls to a specific dom element to get the input from.
  46434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46435. */
  46436. attachControl(noPreventDefault?: boolean): void;
  46437. /**
  46438. * Detach the current controls from the specified dom element.
  46439. */
  46440. detachControl(): void;
  46441. /**
  46442. * Gets the class name of the current intput.
  46443. * @returns the class name
  46444. */
  46445. getClassName(): string;
  46446. /**
  46447. * Get the friendly name associated with the input class.
  46448. * @returns the input friendly name
  46449. */
  46450. getSimpleName(): string;
  46451. }
  46452. }
  46453. declare module BABYLON {
  46454. /**
  46455. * Default Inputs manager for the ArcRotateCamera.
  46456. * It groups all the default supported inputs for ease of use.
  46457. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46458. */
  46459. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  46460. /**
  46461. * Instantiates a new ArcRotateCameraInputsManager.
  46462. * @param camera Defines the camera the inputs belong to
  46463. */
  46464. constructor(camera: ArcRotateCamera);
  46465. /**
  46466. * Add mouse wheel input support to the input manager.
  46467. * @returns the current input manager
  46468. */
  46469. addMouseWheel(): ArcRotateCameraInputsManager;
  46470. /**
  46471. * Add pointers input support to the input manager.
  46472. * @returns the current input manager
  46473. */
  46474. addPointers(): ArcRotateCameraInputsManager;
  46475. /**
  46476. * Add keyboard input support to the input manager.
  46477. * @returns the current input manager
  46478. */
  46479. addKeyboard(): ArcRotateCameraInputsManager;
  46480. }
  46481. }
  46482. declare module BABYLON {
  46483. /**
  46484. * This represents an orbital type of camera.
  46485. *
  46486. * 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.
  46487. * 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.
  46488. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  46489. */
  46490. export class ArcRotateCamera extends TargetCamera {
  46491. /**
  46492. * Defines the rotation angle of the camera along the longitudinal axis.
  46493. */
  46494. alpha: number;
  46495. /**
  46496. * Defines the rotation angle of the camera along the latitudinal axis.
  46497. */
  46498. beta: number;
  46499. /**
  46500. * Defines the radius of the camera from it s target point.
  46501. */
  46502. radius: number;
  46503. protected _target: Vector3;
  46504. protected _targetHost: Nullable<AbstractMesh>;
  46505. /**
  46506. * Defines the target point of the camera.
  46507. * The camera looks towards it form the radius distance.
  46508. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  46509. */
  46510. get target(): Vector3;
  46511. set target(value: Vector3);
  46512. /**
  46513. * Define the current local position of the camera in the scene
  46514. */
  46515. get position(): Vector3;
  46516. set position(newPosition: Vector3);
  46517. protected _upToYMatrix: Matrix;
  46518. protected _YToUpMatrix: Matrix;
  46519. /**
  46520. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  46521. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  46522. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  46523. */
  46524. set upVector(vec: Vector3);
  46525. get upVector(): Vector3;
  46526. /**
  46527. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  46528. */
  46529. setMatUp(): void;
  46530. /**
  46531. * Current inertia value on the longitudinal axis.
  46532. * The bigger this number the longer it will take for the camera to stop.
  46533. */
  46534. inertialAlphaOffset: number;
  46535. /**
  46536. * Current inertia value on the latitudinal axis.
  46537. * The bigger this number the longer it will take for the camera to stop.
  46538. */
  46539. inertialBetaOffset: number;
  46540. /**
  46541. * Current inertia value on the radius axis.
  46542. * The bigger this number the longer it will take for the camera to stop.
  46543. */
  46544. inertialRadiusOffset: number;
  46545. /**
  46546. * Minimum allowed angle on the longitudinal axis.
  46547. * This can help limiting how the Camera is able to move in the scene.
  46548. */
  46549. lowerAlphaLimit: Nullable<number>;
  46550. /**
  46551. * Maximum allowed angle on the longitudinal axis.
  46552. * This can help limiting how the Camera is able to move in the scene.
  46553. */
  46554. upperAlphaLimit: Nullable<number>;
  46555. /**
  46556. * Minimum allowed angle on the latitudinal axis.
  46557. * This can help limiting how the Camera is able to move in the scene.
  46558. */
  46559. lowerBetaLimit: number;
  46560. /**
  46561. * Maximum allowed angle on the latitudinal axis.
  46562. * This can help limiting how the Camera is able to move in the scene.
  46563. */
  46564. upperBetaLimit: number;
  46565. /**
  46566. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46567. * This can help limiting how the Camera is able to move in the scene.
  46568. */
  46569. lowerRadiusLimit: Nullable<number>;
  46570. /**
  46571. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46572. * This can help limiting how the Camera is able to move in the scene.
  46573. */
  46574. upperRadiusLimit: Nullable<number>;
  46575. /**
  46576. * Defines the current inertia value used during panning of the camera along the X axis.
  46577. */
  46578. inertialPanningX: number;
  46579. /**
  46580. * Defines the current inertia value used during panning of the camera along the Y axis.
  46581. */
  46582. inertialPanningY: number;
  46583. /**
  46584. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46585. * Basically if your fingers moves away from more than this distance you will be considered
  46586. * in pinch mode.
  46587. */
  46588. pinchToPanMaxDistance: number;
  46589. /**
  46590. * Defines the maximum distance the camera can pan.
  46591. * This could help keeping the cammera always in your scene.
  46592. */
  46593. panningDistanceLimit: Nullable<number>;
  46594. /**
  46595. * Defines the target of the camera before paning.
  46596. */
  46597. panningOriginTarget: Vector3;
  46598. /**
  46599. * Defines the value of the inertia used during panning.
  46600. * 0 would mean stop inertia and one would mean no decelleration at all.
  46601. */
  46602. panningInertia: number;
  46603. /**
  46604. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46605. */
  46606. get angularSensibilityX(): number;
  46607. set angularSensibilityX(value: number);
  46608. /**
  46609. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46610. */
  46611. get angularSensibilityY(): number;
  46612. set angularSensibilityY(value: number);
  46613. /**
  46614. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46615. */
  46616. get pinchPrecision(): number;
  46617. set pinchPrecision(value: number);
  46618. /**
  46619. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46620. * It will be used instead of pinchDeltaPrecision if different from 0.
  46621. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46622. */
  46623. get pinchDeltaPercentage(): number;
  46624. set pinchDeltaPercentage(value: number);
  46625. /**
  46626. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46627. * and pinch delta percentage.
  46628. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46629. * that any object in the plane at the camera's target point will scale
  46630. * perfectly with finger motion.
  46631. */
  46632. get useNaturalPinchZoom(): boolean;
  46633. set useNaturalPinchZoom(value: boolean);
  46634. /**
  46635. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46636. */
  46637. get panningSensibility(): number;
  46638. set panningSensibility(value: number);
  46639. /**
  46640. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46641. */
  46642. get keysUp(): number[];
  46643. set keysUp(value: number[]);
  46644. /**
  46645. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46646. */
  46647. get keysDown(): number[];
  46648. set keysDown(value: number[]);
  46649. /**
  46650. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46651. */
  46652. get keysLeft(): number[];
  46653. set keysLeft(value: number[]);
  46654. /**
  46655. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46656. */
  46657. get keysRight(): number[];
  46658. set keysRight(value: number[]);
  46659. /**
  46660. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46661. */
  46662. get wheelPrecision(): number;
  46663. set wheelPrecision(value: number);
  46664. /**
  46665. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46666. * It will be used instead of pinchDeltaPrecision if different from 0.
  46667. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46668. */
  46669. get wheelDeltaPercentage(): number;
  46670. set wheelDeltaPercentage(value: number);
  46671. /**
  46672. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46673. */
  46674. zoomOnFactor: number;
  46675. /**
  46676. * Defines a screen offset for the camera position.
  46677. */
  46678. targetScreenOffset: Vector2;
  46679. /**
  46680. * Allows the camera to be completely reversed.
  46681. * If false the camera can not arrive upside down.
  46682. */
  46683. allowUpsideDown: boolean;
  46684. /**
  46685. * Define if double tap/click is used to restore the previously saved state of the camera.
  46686. */
  46687. useInputToRestoreState: boolean;
  46688. /** @hidden */
  46689. _viewMatrix: Matrix;
  46690. /** @hidden */
  46691. _useCtrlForPanning: boolean;
  46692. /** @hidden */
  46693. _panningMouseButton: number;
  46694. /**
  46695. * Defines the input associated to the camera.
  46696. */
  46697. inputs: ArcRotateCameraInputsManager;
  46698. /** @hidden */
  46699. _reset: () => void;
  46700. /**
  46701. * Defines the allowed panning axis.
  46702. */
  46703. panningAxis: Vector3;
  46704. protected _localDirection: Vector3;
  46705. protected _transformedDirection: Vector3;
  46706. private _bouncingBehavior;
  46707. /**
  46708. * Gets the bouncing behavior of the camera if it has been enabled.
  46709. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46710. */
  46711. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46712. /**
  46713. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46714. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46715. */
  46716. get useBouncingBehavior(): boolean;
  46717. set useBouncingBehavior(value: boolean);
  46718. private _framingBehavior;
  46719. /**
  46720. * Gets the framing behavior of the camera if it has been enabled.
  46721. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46722. */
  46723. get framingBehavior(): Nullable<FramingBehavior>;
  46724. /**
  46725. * Defines if the framing behavior of the camera is enabled on the camera.
  46726. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46727. */
  46728. get useFramingBehavior(): boolean;
  46729. set useFramingBehavior(value: boolean);
  46730. private _autoRotationBehavior;
  46731. /**
  46732. * Gets the auto rotation behavior of the camera if it has been enabled.
  46733. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46734. */
  46735. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46736. /**
  46737. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46738. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46739. */
  46740. get useAutoRotationBehavior(): boolean;
  46741. set useAutoRotationBehavior(value: boolean);
  46742. /**
  46743. * Observable triggered when the mesh target has been changed on the camera.
  46744. */
  46745. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46746. /**
  46747. * Event raised when the camera is colliding with a mesh.
  46748. */
  46749. onCollide: (collidedMesh: AbstractMesh) => void;
  46750. /**
  46751. * Defines whether the camera should check collision with the objects oh the scene.
  46752. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46753. */
  46754. checkCollisions: boolean;
  46755. /**
  46756. * Defines the collision radius of the camera.
  46757. * This simulates a sphere around the camera.
  46758. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46759. */
  46760. collisionRadius: Vector3;
  46761. protected _collider: Collider;
  46762. protected _previousPosition: Vector3;
  46763. protected _collisionVelocity: Vector3;
  46764. protected _newPosition: Vector3;
  46765. protected _previousAlpha: number;
  46766. protected _previousBeta: number;
  46767. protected _previousRadius: number;
  46768. protected _collisionTriggered: boolean;
  46769. protected _targetBoundingCenter: Nullable<Vector3>;
  46770. private _computationVector;
  46771. /**
  46772. * Instantiates a new ArcRotateCamera in a given scene
  46773. * @param name Defines the name of the camera
  46774. * @param alpha Defines the camera rotation along the logitudinal axis
  46775. * @param beta Defines the camera rotation along the latitudinal axis
  46776. * @param radius Defines the camera distance from its target
  46777. * @param target Defines the camera target
  46778. * @param scene Defines the scene the camera belongs to
  46779. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46780. */
  46781. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46782. /** @hidden */
  46783. _initCache(): void;
  46784. /** @hidden */
  46785. _updateCache(ignoreParentClass?: boolean): void;
  46786. protected _getTargetPosition(): Vector3;
  46787. private _storedAlpha;
  46788. private _storedBeta;
  46789. private _storedRadius;
  46790. private _storedTarget;
  46791. private _storedTargetScreenOffset;
  46792. /**
  46793. * Stores the current state of the camera (alpha, beta, radius and target)
  46794. * @returns the camera itself
  46795. */
  46796. storeState(): Camera;
  46797. /**
  46798. * @hidden
  46799. * Restored camera state. You must call storeState() first
  46800. */
  46801. _restoreStateValues(): boolean;
  46802. /** @hidden */
  46803. _isSynchronizedViewMatrix(): boolean;
  46804. /**
  46805. * Attach the input controls to a specific dom element to get the input from.
  46806. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46807. */
  46808. attachControl(noPreventDefault?: boolean): void;
  46809. /**
  46810. * Attach the input controls to a specific dom element to get the input from.
  46811. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46812. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46813. */
  46814. attachControl(ignored: any, noPreventDefault?: boolean): void;
  46815. /**
  46816. * Attached controls to the current camera.
  46817. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46818. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46819. */
  46820. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46821. /**
  46822. * Attached controls to the current camera.
  46823. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46825. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46826. */
  46827. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46828. /**
  46829. * Attached controls to the current camera.
  46830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46831. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46832. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46833. */
  46834. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  46835. /**
  46836. * Detach the current controls from the specified dom element.
  46837. */
  46838. detachControl(): void;
  46839. /**
  46840. * Detach the current controls from the specified dom element.
  46841. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  46842. */
  46843. detachControl(ignored: any): void;
  46844. /** @hidden */
  46845. _checkInputs(): void;
  46846. protected _checkLimits(): void;
  46847. /**
  46848. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46849. */
  46850. rebuildAnglesAndRadius(): void;
  46851. /**
  46852. * Use a position to define the current camera related information like alpha, beta and radius
  46853. * @param position Defines the position to set the camera at
  46854. */
  46855. setPosition(position: Vector3): void;
  46856. /**
  46857. * Defines the target the camera should look at.
  46858. * This will automatically adapt alpha beta and radius to fit within the new target.
  46859. * @param target Defines the new target as a Vector or a mesh
  46860. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46861. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46862. */
  46863. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46864. /** @hidden */
  46865. _getViewMatrix(): Matrix;
  46866. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46867. /**
  46868. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46869. * @param meshes Defines the mesh to zoom on
  46870. * @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)
  46871. */
  46872. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46873. /**
  46874. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46875. * The target will be changed but the radius
  46876. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46877. * @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)
  46878. */
  46879. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46880. min: Vector3;
  46881. max: Vector3;
  46882. distance: number;
  46883. }, doNotUpdateMaxZ?: boolean): void;
  46884. /**
  46885. * @override
  46886. * Override Camera.createRigCamera
  46887. */
  46888. createRigCamera(name: string, cameraIndex: number): Camera;
  46889. /**
  46890. * @hidden
  46891. * @override
  46892. * Override Camera._updateRigCameras
  46893. */
  46894. _updateRigCameras(): void;
  46895. /**
  46896. * Destroy the camera and release the current resources hold by it.
  46897. */
  46898. dispose(): void;
  46899. /**
  46900. * Gets the current object class name.
  46901. * @return the class name
  46902. */
  46903. getClassName(): string;
  46904. }
  46905. }
  46906. declare module BABYLON {
  46907. /**
  46908. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46909. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46910. */
  46911. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46912. /**
  46913. * Gets the name of the behavior.
  46914. */
  46915. get name(): string;
  46916. private _zoomStopsAnimation;
  46917. private _idleRotationSpeed;
  46918. private _idleRotationWaitTime;
  46919. private _idleRotationSpinupTime;
  46920. /**
  46921. * Sets the flag that indicates if user zooming should stop animation.
  46922. */
  46923. set zoomStopsAnimation(flag: boolean);
  46924. /**
  46925. * Gets the flag that indicates if user zooming should stop animation.
  46926. */
  46927. get zoomStopsAnimation(): boolean;
  46928. /**
  46929. * Sets the default speed at which the camera rotates around the model.
  46930. */
  46931. set idleRotationSpeed(speed: number);
  46932. /**
  46933. * Gets the default speed at which the camera rotates around the model.
  46934. */
  46935. get idleRotationSpeed(): number;
  46936. /**
  46937. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46938. */
  46939. set idleRotationWaitTime(time: number);
  46940. /**
  46941. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46942. */
  46943. get idleRotationWaitTime(): number;
  46944. /**
  46945. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46946. */
  46947. set idleRotationSpinupTime(time: number);
  46948. /**
  46949. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46950. */
  46951. get idleRotationSpinupTime(): number;
  46952. /**
  46953. * Gets a value indicating if the camera is currently rotating because of this behavior
  46954. */
  46955. get rotationInProgress(): boolean;
  46956. private _onPrePointerObservableObserver;
  46957. private _onAfterCheckInputsObserver;
  46958. private _attachedCamera;
  46959. private _isPointerDown;
  46960. private _lastFrameTime;
  46961. private _lastInteractionTime;
  46962. private _cameraRotationSpeed;
  46963. /**
  46964. * Initializes the behavior.
  46965. */
  46966. init(): void;
  46967. /**
  46968. * Attaches the behavior to its arc rotate camera.
  46969. * @param camera Defines the camera to attach the behavior to
  46970. */
  46971. attach(camera: ArcRotateCamera): void;
  46972. /**
  46973. * Detaches the behavior from its current arc rotate camera.
  46974. */
  46975. detach(): void;
  46976. /**
  46977. * Returns true if user is scrolling.
  46978. * @return true if user is scrolling.
  46979. */
  46980. private _userIsZooming;
  46981. private _lastFrameRadius;
  46982. private _shouldAnimationStopForInteraction;
  46983. /**
  46984. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46985. */
  46986. private _applyUserInteraction;
  46987. private _userIsMoving;
  46988. }
  46989. }
  46990. declare module BABYLON {
  46991. /**
  46992. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46993. */
  46994. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46995. private ui;
  46996. /**
  46997. * The name of the behavior
  46998. */
  46999. name: string;
  47000. /**
  47001. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  47002. */
  47003. distanceAwayFromFace: number;
  47004. /**
  47005. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  47006. */
  47007. distanceAwayFromBottomOfFace: number;
  47008. private _faceVectors;
  47009. private _target;
  47010. private _scene;
  47011. private _onRenderObserver;
  47012. private _tmpMatrix;
  47013. private _tmpVector;
  47014. /**
  47015. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  47016. * @param ui The transform node that should be attched to the mesh
  47017. */
  47018. constructor(ui: TransformNode);
  47019. /**
  47020. * Initializes the behavior
  47021. */
  47022. init(): void;
  47023. private _closestFace;
  47024. private _zeroVector;
  47025. private _lookAtTmpMatrix;
  47026. private _lookAtToRef;
  47027. /**
  47028. * Attaches the AttachToBoxBehavior to the passed in mesh
  47029. * @param target The mesh that the specified node will be attached to
  47030. */
  47031. attach(target: Mesh): void;
  47032. /**
  47033. * Detaches the behavior from the mesh
  47034. */
  47035. detach(): void;
  47036. }
  47037. }
  47038. declare module BABYLON {
  47039. /**
  47040. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  47041. */
  47042. export class FadeInOutBehavior implements Behavior<Mesh> {
  47043. /**
  47044. * Time in milliseconds to delay before fading in (Default: 0)
  47045. */
  47046. delay: number;
  47047. /**
  47048. * Time in milliseconds for the mesh to fade in (Default: 300)
  47049. */
  47050. fadeInTime: number;
  47051. private _millisecondsPerFrame;
  47052. private _hovered;
  47053. private _hoverValue;
  47054. private _ownerNode;
  47055. /**
  47056. * Instatiates the FadeInOutBehavior
  47057. */
  47058. constructor();
  47059. /**
  47060. * The name of the behavior
  47061. */
  47062. get name(): string;
  47063. /**
  47064. * Initializes the behavior
  47065. */
  47066. init(): void;
  47067. /**
  47068. * Attaches the fade behavior on the passed in mesh
  47069. * @param ownerNode The mesh that will be faded in/out once attached
  47070. */
  47071. attach(ownerNode: Mesh): void;
  47072. /**
  47073. * Detaches the behavior from the mesh
  47074. */
  47075. detach(): void;
  47076. /**
  47077. * Triggers the mesh to begin fading in or out
  47078. * @param value if the object should fade in or out (true to fade in)
  47079. */
  47080. fadeIn(value: boolean): void;
  47081. private _update;
  47082. private _setAllVisibility;
  47083. }
  47084. }
  47085. declare module BABYLON {
  47086. /**
  47087. * Class containing a set of static utilities functions for managing Pivots
  47088. * @hidden
  47089. */
  47090. export class PivotTools {
  47091. private static _PivotCached;
  47092. private static _OldPivotPoint;
  47093. private static _PivotTranslation;
  47094. private static _PivotTmpVector;
  47095. private static _PivotPostMultiplyPivotMatrix;
  47096. /** @hidden */
  47097. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  47098. /** @hidden */
  47099. static _RestorePivotPoint(mesh: AbstractMesh): void;
  47100. }
  47101. }
  47102. declare module BABYLON {
  47103. /**
  47104. * Class containing static functions to help procedurally build meshes
  47105. */
  47106. export class PlaneBuilder {
  47107. /**
  47108. * Creates a plane mesh
  47109. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  47110. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  47111. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  47112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47113. * * 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
  47114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47115. * @param name defines the name of the mesh
  47116. * @param options defines the options used to create the mesh
  47117. * @param scene defines the hosting scene
  47118. * @returns the plane mesh
  47119. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  47120. */
  47121. static CreatePlane(name: string, options: {
  47122. size?: number;
  47123. width?: number;
  47124. height?: number;
  47125. sideOrientation?: number;
  47126. frontUVs?: Vector4;
  47127. backUVs?: Vector4;
  47128. updatable?: boolean;
  47129. sourcePlane?: Plane;
  47130. }, scene?: Nullable<Scene>): Mesh;
  47131. }
  47132. }
  47133. declare module BABYLON {
  47134. /**
  47135. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  47136. */
  47137. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  47138. private static _AnyMouseID;
  47139. /**
  47140. * Abstract mesh the behavior is set on
  47141. */
  47142. attachedNode: AbstractMesh;
  47143. private _dragPlane;
  47144. private _scene;
  47145. private _pointerObserver;
  47146. private _beforeRenderObserver;
  47147. private static _planeScene;
  47148. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  47149. /**
  47150. * 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)
  47151. */
  47152. maxDragAngle: number;
  47153. /**
  47154. * @hidden
  47155. */
  47156. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  47157. /**
  47158. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47159. */
  47160. currentDraggingPointerID: number;
  47161. /**
  47162. * The last position where the pointer hit the drag plane in world space
  47163. */
  47164. lastDragPosition: Vector3;
  47165. /**
  47166. * If the behavior is currently in a dragging state
  47167. */
  47168. dragging: boolean;
  47169. /**
  47170. * 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)
  47171. */
  47172. dragDeltaRatio: number;
  47173. /**
  47174. * If the drag plane orientation should be updated during the dragging (Default: true)
  47175. */
  47176. updateDragPlane: boolean;
  47177. private _debugMode;
  47178. private _moving;
  47179. /**
  47180. * Fires each time the attached mesh is dragged with the pointer
  47181. * * delta between last drag position and current drag position in world space
  47182. * * dragDistance along the drag axis
  47183. * * dragPlaneNormal normal of the current drag plane used during the drag
  47184. * * dragPlanePoint in world space where the drag intersects the drag plane
  47185. */
  47186. onDragObservable: Observable<{
  47187. delta: Vector3;
  47188. dragPlanePoint: Vector3;
  47189. dragPlaneNormal: Vector3;
  47190. dragDistance: number;
  47191. pointerId: number;
  47192. }>;
  47193. /**
  47194. * Fires each time a drag begins (eg. mouse down on mesh)
  47195. */
  47196. onDragStartObservable: Observable<{
  47197. dragPlanePoint: Vector3;
  47198. pointerId: number;
  47199. }>;
  47200. /**
  47201. * Fires each time a drag ends (eg. mouse release after drag)
  47202. */
  47203. onDragEndObservable: Observable<{
  47204. dragPlanePoint: Vector3;
  47205. pointerId: number;
  47206. }>;
  47207. /**
  47208. * If the attached mesh should be moved when dragged
  47209. */
  47210. moveAttached: boolean;
  47211. /**
  47212. * If the drag behavior will react to drag events (Default: true)
  47213. */
  47214. enabled: boolean;
  47215. /**
  47216. * If pointer events should start and release the drag (Default: true)
  47217. */
  47218. startAndReleaseDragOnPointerEvents: boolean;
  47219. /**
  47220. * If camera controls should be detached during the drag
  47221. */
  47222. detachCameraControls: boolean;
  47223. /**
  47224. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  47225. */
  47226. useObjectOrientationForDragging: boolean;
  47227. private _options;
  47228. /**
  47229. * Gets the options used by the behavior
  47230. */
  47231. get options(): {
  47232. dragAxis?: Vector3;
  47233. dragPlaneNormal?: Vector3;
  47234. };
  47235. /**
  47236. * Sets the options used by the behavior
  47237. */
  47238. set options(options: {
  47239. dragAxis?: Vector3;
  47240. dragPlaneNormal?: Vector3;
  47241. });
  47242. /**
  47243. * Creates a pointer drag behavior that can be attached to a mesh
  47244. * @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)
  47245. */
  47246. constructor(options?: {
  47247. dragAxis?: Vector3;
  47248. dragPlaneNormal?: Vector3;
  47249. });
  47250. /**
  47251. * Predicate to determine if it is valid to move the object to a new position when it is moved
  47252. */
  47253. validateDrag: (targetPosition: Vector3) => boolean;
  47254. /**
  47255. * The name of the behavior
  47256. */
  47257. get name(): string;
  47258. /**
  47259. * Initializes the behavior
  47260. */
  47261. init(): void;
  47262. private _tmpVector;
  47263. private _alternatePickedPoint;
  47264. private _worldDragAxis;
  47265. private _targetPosition;
  47266. private _attachedToElement;
  47267. /**
  47268. * Attaches the drag behavior the passed in mesh
  47269. * @param ownerNode The mesh that will be dragged around once attached
  47270. * @param predicate Predicate to use for pick filtering
  47271. */
  47272. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  47273. /**
  47274. * Force relase the drag action by code.
  47275. */
  47276. releaseDrag(): void;
  47277. private _startDragRay;
  47278. private _lastPointerRay;
  47279. /**
  47280. * Simulates the start of a pointer drag event on the behavior
  47281. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  47282. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  47283. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  47284. */
  47285. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47286. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47287. private _dragDelta;
  47288. protected _moveDrag(ray: Ray): void;
  47289. private _pickWithRayOnDragPlane;
  47290. private _pointA;
  47291. private _pointC;
  47292. private _localAxis;
  47293. private _lookAt;
  47294. private _updateDragPlanePosition;
  47295. /**
  47296. * Detaches the behavior from the mesh
  47297. */
  47298. detach(): void;
  47299. }
  47300. }
  47301. declare module BABYLON {
  47302. /**
  47303. * A behavior that when attached to a mesh will allow the mesh to be scaled
  47304. */
  47305. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  47306. private _dragBehaviorA;
  47307. private _dragBehaviorB;
  47308. private _startDistance;
  47309. private _initialScale;
  47310. private _targetScale;
  47311. private _ownerNode;
  47312. private _sceneRenderObserver;
  47313. /**
  47314. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  47315. */
  47316. constructor();
  47317. /**
  47318. * The name of the behavior
  47319. */
  47320. get name(): string;
  47321. /**
  47322. * Initializes the behavior
  47323. */
  47324. init(): void;
  47325. private _getCurrentDistance;
  47326. /**
  47327. * Attaches the scale behavior the passed in mesh
  47328. * @param ownerNode The mesh that will be scaled around once attached
  47329. */
  47330. attach(ownerNode: Mesh): void;
  47331. /**
  47332. * Detaches the behavior from the mesh
  47333. */
  47334. detach(): void;
  47335. }
  47336. }
  47337. declare module BABYLON {
  47338. /**
  47339. * 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
  47340. */
  47341. export class SixDofDragBehavior implements Behavior<Mesh> {
  47342. private static _virtualScene;
  47343. private _ownerNode;
  47344. private _sceneRenderObserver;
  47345. private _scene;
  47346. private _targetPosition;
  47347. private _virtualOriginMesh;
  47348. private _virtualDragMesh;
  47349. private _pointerObserver;
  47350. private _moving;
  47351. private _startingOrientation;
  47352. private _attachedToElement;
  47353. /**
  47354. * 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)
  47355. */
  47356. private zDragFactor;
  47357. /**
  47358. * If the object should rotate to face the drag origin
  47359. */
  47360. rotateDraggedObject: boolean;
  47361. /**
  47362. * If the behavior is currently in a dragging state
  47363. */
  47364. dragging: boolean;
  47365. /**
  47366. * 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)
  47367. */
  47368. dragDeltaRatio: number;
  47369. /**
  47370. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47371. */
  47372. currentDraggingPointerID: number;
  47373. /**
  47374. * If camera controls should be detached during the drag
  47375. */
  47376. detachCameraControls: boolean;
  47377. /**
  47378. * Fires each time a drag starts
  47379. */
  47380. onDragStartObservable: Observable<{}>;
  47381. /**
  47382. * Fires each time a drag happens
  47383. */
  47384. onDragObservable: Observable<void>;
  47385. /**
  47386. * Fires each time a drag ends (eg. mouse release after drag)
  47387. */
  47388. onDragEndObservable: Observable<{}>;
  47389. /**
  47390. * 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
  47391. */
  47392. constructor();
  47393. /**
  47394. * The name of the behavior
  47395. */
  47396. get name(): string;
  47397. /**
  47398. * Initializes the behavior
  47399. */
  47400. init(): void;
  47401. /**
  47402. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  47403. */
  47404. private get _pointerCamera();
  47405. /**
  47406. * Attaches the scale behavior the passed in mesh
  47407. * @param ownerNode The mesh that will be scaled around once attached
  47408. */
  47409. attach(ownerNode: Mesh): void;
  47410. /**
  47411. * Detaches the behavior from the mesh
  47412. */
  47413. detach(): void;
  47414. }
  47415. }
  47416. declare module BABYLON {
  47417. /**
  47418. * Class used to apply inverse kinematics to bones
  47419. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  47420. */
  47421. export class BoneIKController {
  47422. private static _tmpVecs;
  47423. private static _tmpQuat;
  47424. private static _tmpMats;
  47425. /**
  47426. * Gets or sets the target mesh
  47427. */
  47428. targetMesh: AbstractMesh;
  47429. /** Gets or sets the mesh used as pole */
  47430. poleTargetMesh: AbstractMesh;
  47431. /**
  47432. * Gets or sets the bone used as pole
  47433. */
  47434. poleTargetBone: Nullable<Bone>;
  47435. /**
  47436. * Gets or sets the target position
  47437. */
  47438. targetPosition: Vector3;
  47439. /**
  47440. * Gets or sets the pole target position
  47441. */
  47442. poleTargetPosition: Vector3;
  47443. /**
  47444. * Gets or sets the pole target local offset
  47445. */
  47446. poleTargetLocalOffset: Vector3;
  47447. /**
  47448. * Gets or sets the pole angle
  47449. */
  47450. poleAngle: number;
  47451. /**
  47452. * Gets or sets the mesh associated with the controller
  47453. */
  47454. mesh: AbstractMesh;
  47455. /**
  47456. * 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)
  47457. */
  47458. slerpAmount: number;
  47459. private _bone1Quat;
  47460. private _bone1Mat;
  47461. private _bone2Ang;
  47462. private _bone1;
  47463. private _bone2;
  47464. private _bone1Length;
  47465. private _bone2Length;
  47466. private _maxAngle;
  47467. private _maxReach;
  47468. private _rightHandedSystem;
  47469. private _bendAxis;
  47470. private _slerping;
  47471. private _adjustRoll;
  47472. /**
  47473. * Gets or sets maximum allowed angle
  47474. */
  47475. get maxAngle(): number;
  47476. set maxAngle(value: number);
  47477. /**
  47478. * Creates a new BoneIKController
  47479. * @param mesh defines the mesh to control
  47480. * @param bone defines the bone to control
  47481. * @param options defines options to set up the controller
  47482. */
  47483. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  47484. targetMesh?: AbstractMesh;
  47485. poleTargetMesh?: AbstractMesh;
  47486. poleTargetBone?: Bone;
  47487. poleTargetLocalOffset?: Vector3;
  47488. poleAngle?: number;
  47489. bendAxis?: Vector3;
  47490. maxAngle?: number;
  47491. slerpAmount?: number;
  47492. });
  47493. private _setMaxAngle;
  47494. /**
  47495. * Force the controller to update the bones
  47496. */
  47497. update(): void;
  47498. }
  47499. }
  47500. declare module BABYLON {
  47501. /**
  47502. * Class used to make a bone look toward a point in space
  47503. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  47504. */
  47505. export class BoneLookController {
  47506. private static _tmpVecs;
  47507. private static _tmpQuat;
  47508. private static _tmpMats;
  47509. /**
  47510. * The target Vector3 that the bone will look at
  47511. */
  47512. target: Vector3;
  47513. /**
  47514. * The mesh that the bone is attached to
  47515. */
  47516. mesh: AbstractMesh;
  47517. /**
  47518. * The bone that will be looking to the target
  47519. */
  47520. bone: Bone;
  47521. /**
  47522. * The up axis of the coordinate system that is used when the bone is rotated
  47523. */
  47524. upAxis: Vector3;
  47525. /**
  47526. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  47527. */
  47528. upAxisSpace: Space;
  47529. /**
  47530. * Used to make an adjustment to the yaw of the bone
  47531. */
  47532. adjustYaw: number;
  47533. /**
  47534. * Used to make an adjustment to the pitch of the bone
  47535. */
  47536. adjustPitch: number;
  47537. /**
  47538. * Used to make an adjustment to the roll of the bone
  47539. */
  47540. adjustRoll: number;
  47541. /**
  47542. * 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)
  47543. */
  47544. slerpAmount: number;
  47545. private _minYaw;
  47546. private _maxYaw;
  47547. private _minPitch;
  47548. private _maxPitch;
  47549. private _minYawSin;
  47550. private _minYawCos;
  47551. private _maxYawSin;
  47552. private _maxYawCos;
  47553. private _midYawConstraint;
  47554. private _minPitchTan;
  47555. private _maxPitchTan;
  47556. private _boneQuat;
  47557. private _slerping;
  47558. private _transformYawPitch;
  47559. private _transformYawPitchInv;
  47560. private _firstFrameSkipped;
  47561. private _yawRange;
  47562. private _fowardAxis;
  47563. /**
  47564. * Gets or sets the minimum yaw angle that the bone can look to
  47565. */
  47566. get minYaw(): number;
  47567. set minYaw(value: number);
  47568. /**
  47569. * Gets or sets the maximum yaw angle that the bone can look to
  47570. */
  47571. get maxYaw(): number;
  47572. set maxYaw(value: number);
  47573. /**
  47574. * Gets or sets the minimum pitch angle that the bone can look to
  47575. */
  47576. get minPitch(): number;
  47577. set minPitch(value: number);
  47578. /**
  47579. * Gets or sets the maximum pitch angle that the bone can look to
  47580. */
  47581. get maxPitch(): number;
  47582. set maxPitch(value: number);
  47583. /**
  47584. * Create a BoneLookController
  47585. * @param mesh the mesh that the bone belongs to
  47586. * @param bone the bone that will be looking to the target
  47587. * @param target the target Vector3 to look at
  47588. * @param options optional settings:
  47589. * * maxYaw: the maximum angle the bone will yaw to
  47590. * * minYaw: the minimum angle the bone will yaw to
  47591. * * maxPitch: the maximum angle the bone will pitch to
  47592. * * minPitch: the minimum angle the bone will yaw to
  47593. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  47594. * * upAxis: the up axis of the coordinate system
  47595. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  47596. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47597. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47598. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47599. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47600. * * adjustRoll: used to make an adjustment to the roll of the bone
  47601. **/
  47602. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47603. maxYaw?: number;
  47604. minYaw?: number;
  47605. maxPitch?: number;
  47606. minPitch?: number;
  47607. slerpAmount?: number;
  47608. upAxis?: Vector3;
  47609. upAxisSpace?: Space;
  47610. yawAxis?: Vector3;
  47611. pitchAxis?: Vector3;
  47612. adjustYaw?: number;
  47613. adjustPitch?: number;
  47614. adjustRoll?: number;
  47615. });
  47616. /**
  47617. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47618. */
  47619. update(): void;
  47620. private _getAngleDiff;
  47621. private _getAngleBetween;
  47622. private _isAngleBetween;
  47623. }
  47624. }
  47625. declare module BABYLON {
  47626. /**
  47627. * Manage the gamepad inputs to control an arc rotate camera.
  47628. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47629. */
  47630. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47631. /**
  47632. * Defines the camera the input is attached to.
  47633. */
  47634. camera: ArcRotateCamera;
  47635. /**
  47636. * Defines the gamepad the input is gathering event from.
  47637. */
  47638. gamepad: Nullable<Gamepad>;
  47639. /**
  47640. * Defines the gamepad rotation sensiblity.
  47641. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47642. */
  47643. gamepadRotationSensibility: number;
  47644. /**
  47645. * Defines the gamepad move sensiblity.
  47646. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47647. */
  47648. gamepadMoveSensibility: number;
  47649. private _yAxisScale;
  47650. /**
  47651. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47652. */
  47653. get invertYAxis(): boolean;
  47654. set invertYAxis(value: boolean);
  47655. private _onGamepadConnectedObserver;
  47656. private _onGamepadDisconnectedObserver;
  47657. /**
  47658. * Attach the input controls to a specific dom element to get the input from.
  47659. */
  47660. attachControl(): void;
  47661. /**
  47662. * Detach the current controls from the specified dom element.
  47663. */
  47664. detachControl(): void;
  47665. /**
  47666. * Update the current camera state depending on the inputs that have been used this frame.
  47667. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47668. */
  47669. checkInputs(): void;
  47670. /**
  47671. * Gets the class name of the current intput.
  47672. * @returns the class name
  47673. */
  47674. getClassName(): string;
  47675. /**
  47676. * Get the friendly name associated with the input class.
  47677. * @returns the input friendly name
  47678. */
  47679. getSimpleName(): string;
  47680. }
  47681. }
  47682. declare module BABYLON {
  47683. interface ArcRotateCameraInputsManager {
  47684. /**
  47685. * Add orientation input support to the input manager.
  47686. * @returns the current input manager
  47687. */
  47688. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47689. }
  47690. /**
  47691. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47692. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47693. */
  47694. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47695. /**
  47696. * Defines the camera the input is attached to.
  47697. */
  47698. camera: ArcRotateCamera;
  47699. /**
  47700. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47701. */
  47702. alphaCorrection: number;
  47703. /**
  47704. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47705. */
  47706. gammaCorrection: number;
  47707. private _alpha;
  47708. private _gamma;
  47709. private _dirty;
  47710. private _deviceOrientationHandler;
  47711. /**
  47712. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47713. */
  47714. constructor();
  47715. /**
  47716. * Attach the input controls to a specific dom element to get the input from.
  47717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47718. */
  47719. attachControl(noPreventDefault?: boolean): void;
  47720. /** @hidden */
  47721. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47722. /**
  47723. * Update the current camera state depending on the inputs that have been used this frame.
  47724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47725. */
  47726. checkInputs(): void;
  47727. /**
  47728. * Detach the current controls from the specified dom element.
  47729. */
  47730. detachControl(): void;
  47731. /**
  47732. * Gets the class name of the current intput.
  47733. * @returns the class name
  47734. */
  47735. getClassName(): string;
  47736. /**
  47737. * Get the friendly name associated with the input class.
  47738. * @returns the input friendly name
  47739. */
  47740. getSimpleName(): string;
  47741. }
  47742. }
  47743. declare module BABYLON {
  47744. /**
  47745. * Listen to mouse events to control the camera.
  47746. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47747. */
  47748. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47749. /**
  47750. * Defines the camera the input is attached to.
  47751. */
  47752. camera: FlyCamera;
  47753. /**
  47754. * Defines if touch is enabled. (Default is true.)
  47755. */
  47756. touchEnabled: boolean;
  47757. /**
  47758. * Defines the buttons associated with the input to handle camera rotation.
  47759. */
  47760. buttons: number[];
  47761. /**
  47762. * Assign buttons for Yaw control.
  47763. */
  47764. buttonsYaw: number[];
  47765. /**
  47766. * Assign buttons for Pitch control.
  47767. */
  47768. buttonsPitch: number[];
  47769. /**
  47770. * Assign buttons for Roll control.
  47771. */
  47772. buttonsRoll: number[];
  47773. /**
  47774. * Detect if any button is being pressed while mouse is moved.
  47775. * -1 = Mouse locked.
  47776. * 0 = Left button.
  47777. * 1 = Middle Button.
  47778. * 2 = Right Button.
  47779. */
  47780. activeButton: number;
  47781. /**
  47782. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47783. * Higher values reduce its sensitivity.
  47784. */
  47785. angularSensibility: number;
  47786. private _observer;
  47787. private _rollObserver;
  47788. private previousPosition;
  47789. private noPreventDefault;
  47790. private element;
  47791. /**
  47792. * Listen to mouse events to control the camera.
  47793. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47794. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47795. */
  47796. constructor(touchEnabled?: boolean);
  47797. /**
  47798. * Attach the mouse control to the HTML DOM element.
  47799. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47800. */
  47801. attachControl(noPreventDefault?: boolean): void;
  47802. /**
  47803. * Detach the current controls from the specified dom element.
  47804. */
  47805. detachControl(): void;
  47806. /**
  47807. * Gets the class name of the current input.
  47808. * @returns the class name.
  47809. */
  47810. getClassName(): string;
  47811. /**
  47812. * Get the friendly name associated with the input class.
  47813. * @returns the input's friendly name.
  47814. */
  47815. getSimpleName(): string;
  47816. private _pointerInput;
  47817. private _onMouseMove;
  47818. /**
  47819. * Rotate camera by mouse offset.
  47820. */
  47821. private rotateCamera;
  47822. }
  47823. }
  47824. declare module BABYLON {
  47825. /**
  47826. * Default Inputs manager for the FlyCamera.
  47827. * It groups all the default supported inputs for ease of use.
  47828. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47829. */
  47830. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47831. /**
  47832. * Instantiates a new FlyCameraInputsManager.
  47833. * @param camera Defines the camera the inputs belong to.
  47834. */
  47835. constructor(camera: FlyCamera);
  47836. /**
  47837. * Add keyboard input support to the input manager.
  47838. * @returns the new FlyCameraKeyboardMoveInput().
  47839. */
  47840. addKeyboard(): FlyCameraInputsManager;
  47841. /**
  47842. * Add mouse input support to the input manager.
  47843. * @param touchEnabled Enable touch screen support.
  47844. * @returns the new FlyCameraMouseInput().
  47845. */
  47846. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47847. }
  47848. }
  47849. declare module BABYLON {
  47850. /**
  47851. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47852. * such as in a 3D Space Shooter or a Flight Simulator.
  47853. */
  47854. export class FlyCamera extends TargetCamera {
  47855. /**
  47856. * Define the collision ellipsoid of the camera.
  47857. * This is helpful for simulating a camera body, like a player's body.
  47858. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47859. */
  47860. ellipsoid: Vector3;
  47861. /**
  47862. * Define an offset for the position of the ellipsoid around the camera.
  47863. * This can be helpful if the camera is attached away from the player's body center,
  47864. * such as at its head.
  47865. */
  47866. ellipsoidOffset: Vector3;
  47867. /**
  47868. * Enable or disable collisions of the camera with the rest of the scene objects.
  47869. */
  47870. checkCollisions: boolean;
  47871. /**
  47872. * Enable or disable gravity on the camera.
  47873. */
  47874. applyGravity: boolean;
  47875. /**
  47876. * Define the current direction the camera is moving to.
  47877. */
  47878. cameraDirection: Vector3;
  47879. /**
  47880. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47881. * This overrides and empties cameraRotation.
  47882. */
  47883. rotationQuaternion: Quaternion;
  47884. /**
  47885. * Track Roll to maintain the wanted Rolling when looking around.
  47886. */
  47887. _trackRoll: number;
  47888. /**
  47889. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47890. */
  47891. rollCorrect: number;
  47892. /**
  47893. * Mimic a banked turn, Rolling the camera when Yawing.
  47894. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47895. */
  47896. bankedTurn: boolean;
  47897. /**
  47898. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47899. */
  47900. bankedTurnLimit: number;
  47901. /**
  47902. * Value of 0 disables the banked Roll.
  47903. * Value of 1 is equal to the Yaw angle in radians.
  47904. */
  47905. bankedTurnMultiplier: number;
  47906. /**
  47907. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47908. */
  47909. inputs: FlyCameraInputsManager;
  47910. /**
  47911. * Gets the input sensibility for mouse input.
  47912. * Higher values reduce sensitivity.
  47913. */
  47914. get angularSensibility(): number;
  47915. /**
  47916. * Sets the input sensibility for a mouse input.
  47917. * Higher values reduce sensitivity.
  47918. */
  47919. set angularSensibility(value: number);
  47920. /**
  47921. * Get the keys for camera movement forward.
  47922. */
  47923. get keysForward(): number[];
  47924. /**
  47925. * Set the keys for camera movement forward.
  47926. */
  47927. set keysForward(value: number[]);
  47928. /**
  47929. * Get the keys for camera movement backward.
  47930. */
  47931. get keysBackward(): number[];
  47932. set keysBackward(value: number[]);
  47933. /**
  47934. * Get the keys for camera movement up.
  47935. */
  47936. get keysUp(): number[];
  47937. /**
  47938. * Set the keys for camera movement up.
  47939. */
  47940. set keysUp(value: number[]);
  47941. /**
  47942. * Get the keys for camera movement down.
  47943. */
  47944. get keysDown(): number[];
  47945. /**
  47946. * Set the keys for camera movement down.
  47947. */
  47948. set keysDown(value: number[]);
  47949. /**
  47950. * Get the keys for camera movement left.
  47951. */
  47952. get keysLeft(): number[];
  47953. /**
  47954. * Set the keys for camera movement left.
  47955. */
  47956. set keysLeft(value: number[]);
  47957. /**
  47958. * Set the keys for camera movement right.
  47959. */
  47960. get keysRight(): number[];
  47961. /**
  47962. * Set the keys for camera movement right.
  47963. */
  47964. set keysRight(value: number[]);
  47965. /**
  47966. * Event raised when the camera collides with a mesh in the scene.
  47967. */
  47968. onCollide: (collidedMesh: AbstractMesh) => void;
  47969. private _collider;
  47970. private _needMoveForGravity;
  47971. private _oldPosition;
  47972. private _diffPosition;
  47973. private _newPosition;
  47974. /** @hidden */
  47975. _localDirection: Vector3;
  47976. /** @hidden */
  47977. _transformedDirection: Vector3;
  47978. /**
  47979. * Instantiates a FlyCamera.
  47980. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47981. * such as in a 3D Space Shooter or a Flight Simulator.
  47982. * @param name Define the name of the camera in the scene.
  47983. * @param position Define the starting position of the camera in the scene.
  47984. * @param scene Define the scene the camera belongs to.
  47985. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47986. */
  47987. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47988. /**
  47989. * Attach the input controls to a specific dom element to get the input from.
  47990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47991. */
  47992. attachControl(noPreventDefault?: boolean): void;
  47993. /**
  47994. * Detach a control from the HTML DOM element.
  47995. * The camera will stop reacting to that input.
  47996. */
  47997. detachControl(): void;
  47998. private _collisionMask;
  47999. /**
  48000. * Get the mask that the camera ignores in collision events.
  48001. */
  48002. get collisionMask(): number;
  48003. /**
  48004. * Set the mask that the camera ignores in collision events.
  48005. */
  48006. set collisionMask(mask: number);
  48007. /** @hidden */
  48008. _collideWithWorld(displacement: Vector3): void;
  48009. /** @hidden */
  48010. private _onCollisionPositionChange;
  48011. /** @hidden */
  48012. _checkInputs(): void;
  48013. /** @hidden */
  48014. _decideIfNeedsToMove(): boolean;
  48015. /** @hidden */
  48016. _updatePosition(): void;
  48017. /**
  48018. * Restore the Roll to its target value at the rate specified.
  48019. * @param rate - Higher means slower restoring.
  48020. * @hidden
  48021. */
  48022. restoreRoll(rate: number): void;
  48023. /**
  48024. * Destroy the camera and release the current resources held by it.
  48025. */
  48026. dispose(): void;
  48027. /**
  48028. * Get the current object class name.
  48029. * @returns the class name.
  48030. */
  48031. getClassName(): string;
  48032. }
  48033. }
  48034. declare module BABYLON {
  48035. /**
  48036. * Listen to keyboard events to control the camera.
  48037. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48038. */
  48039. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  48040. /**
  48041. * Defines the camera the input is attached to.
  48042. */
  48043. camera: FlyCamera;
  48044. /**
  48045. * The list of keyboard keys used to control the forward move of the camera.
  48046. */
  48047. keysForward: number[];
  48048. /**
  48049. * The list of keyboard keys used to control the backward move of the camera.
  48050. */
  48051. keysBackward: number[];
  48052. /**
  48053. * The list of keyboard keys used to control the forward move of the camera.
  48054. */
  48055. keysUp: number[];
  48056. /**
  48057. * The list of keyboard keys used to control the backward move of the camera.
  48058. */
  48059. keysDown: number[];
  48060. /**
  48061. * The list of keyboard keys used to control the right strafe move of the camera.
  48062. */
  48063. keysRight: number[];
  48064. /**
  48065. * The list of keyboard keys used to control the left strafe move of the camera.
  48066. */
  48067. keysLeft: number[];
  48068. private _keys;
  48069. private _onCanvasBlurObserver;
  48070. private _onKeyboardObserver;
  48071. private _engine;
  48072. private _scene;
  48073. /**
  48074. * Attach the input controls to a specific dom element to get the input from.
  48075. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48076. */
  48077. attachControl(noPreventDefault?: boolean): void;
  48078. /**
  48079. * Detach the current controls from the specified dom element.
  48080. */
  48081. detachControl(): void;
  48082. /**
  48083. * Gets the class name of the current intput.
  48084. * @returns the class name
  48085. */
  48086. getClassName(): string;
  48087. /** @hidden */
  48088. _onLostFocus(e: FocusEvent): void;
  48089. /**
  48090. * Get the friendly name associated with the input class.
  48091. * @returns the input friendly name
  48092. */
  48093. getSimpleName(): string;
  48094. /**
  48095. * Update the current camera state depending on the inputs that have been used this frame.
  48096. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48097. */
  48098. checkInputs(): void;
  48099. }
  48100. }
  48101. declare module BABYLON {
  48102. /**
  48103. * Manage the mouse wheel inputs to control a follow camera.
  48104. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48105. */
  48106. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  48107. /**
  48108. * Defines the camera the input is attached to.
  48109. */
  48110. camera: FollowCamera;
  48111. /**
  48112. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  48113. */
  48114. axisControlRadius: boolean;
  48115. /**
  48116. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  48117. */
  48118. axisControlHeight: boolean;
  48119. /**
  48120. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  48121. */
  48122. axisControlRotation: boolean;
  48123. /**
  48124. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  48125. * relation to mouseWheel events.
  48126. */
  48127. wheelPrecision: number;
  48128. /**
  48129. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  48130. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  48131. */
  48132. wheelDeltaPercentage: number;
  48133. private _wheel;
  48134. private _observer;
  48135. /**
  48136. * Attach the input controls to a specific dom element to get the input from.
  48137. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48138. */
  48139. attachControl(noPreventDefault?: boolean): void;
  48140. /**
  48141. * Detach the current controls from the specified dom element.
  48142. */
  48143. detachControl(): void;
  48144. /**
  48145. * Gets the class name of the current intput.
  48146. * @returns the class name
  48147. */
  48148. getClassName(): string;
  48149. /**
  48150. * Get the friendly name associated with the input class.
  48151. * @returns the input friendly name
  48152. */
  48153. getSimpleName(): string;
  48154. }
  48155. }
  48156. declare module BABYLON {
  48157. /**
  48158. * Manage the pointers inputs to control an follow camera.
  48159. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48160. */
  48161. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  48162. /**
  48163. * Defines the camera the input is attached to.
  48164. */
  48165. camera: FollowCamera;
  48166. /**
  48167. * Gets the class name of the current input.
  48168. * @returns the class name
  48169. */
  48170. getClassName(): string;
  48171. /**
  48172. * Defines the pointer angular sensibility along the X axis or how fast is
  48173. * the camera rotating.
  48174. * A negative number will reverse the axis direction.
  48175. */
  48176. angularSensibilityX: number;
  48177. /**
  48178. * Defines the pointer angular sensibility along the Y axis or how fast is
  48179. * the camera rotating.
  48180. * A negative number will reverse the axis direction.
  48181. */
  48182. angularSensibilityY: number;
  48183. /**
  48184. * Defines the pointer pinch precision or how fast is the camera zooming.
  48185. * A negative number will reverse the axis direction.
  48186. */
  48187. pinchPrecision: number;
  48188. /**
  48189. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  48190. * from 0.
  48191. * It defines the percentage of current camera.radius to use as delta when
  48192. * pinch zoom is used.
  48193. */
  48194. pinchDeltaPercentage: number;
  48195. /**
  48196. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  48197. */
  48198. axisXControlRadius: boolean;
  48199. /**
  48200. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  48201. */
  48202. axisXControlHeight: boolean;
  48203. /**
  48204. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  48205. */
  48206. axisXControlRotation: boolean;
  48207. /**
  48208. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  48209. */
  48210. axisYControlRadius: boolean;
  48211. /**
  48212. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  48213. */
  48214. axisYControlHeight: boolean;
  48215. /**
  48216. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  48217. */
  48218. axisYControlRotation: boolean;
  48219. /**
  48220. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  48221. */
  48222. axisPinchControlRadius: boolean;
  48223. /**
  48224. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  48225. */
  48226. axisPinchControlHeight: boolean;
  48227. /**
  48228. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  48229. */
  48230. axisPinchControlRotation: boolean;
  48231. /**
  48232. * Log error messages if basic misconfiguration has occurred.
  48233. */
  48234. warningEnable: boolean;
  48235. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48236. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48237. private _warningCounter;
  48238. private _warning;
  48239. }
  48240. }
  48241. declare module BABYLON {
  48242. /**
  48243. * Default Inputs manager for the FollowCamera.
  48244. * It groups all the default supported inputs for ease of use.
  48245. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48246. */
  48247. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  48248. /**
  48249. * Instantiates a new FollowCameraInputsManager.
  48250. * @param camera Defines the camera the inputs belong to
  48251. */
  48252. constructor(camera: FollowCamera);
  48253. /**
  48254. * Add keyboard input support to the input manager.
  48255. * @returns the current input manager
  48256. */
  48257. addKeyboard(): FollowCameraInputsManager;
  48258. /**
  48259. * Add mouse wheel input support to the input manager.
  48260. * @returns the current input manager
  48261. */
  48262. addMouseWheel(): FollowCameraInputsManager;
  48263. /**
  48264. * Add pointers input support to the input manager.
  48265. * @returns the current input manager
  48266. */
  48267. addPointers(): FollowCameraInputsManager;
  48268. /**
  48269. * Add orientation input support to the input manager.
  48270. * @returns the current input manager
  48271. */
  48272. addVRDeviceOrientation(): FollowCameraInputsManager;
  48273. }
  48274. }
  48275. declare module BABYLON {
  48276. /**
  48277. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  48278. * an arc rotate version arcFollowCamera are available.
  48279. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48280. */
  48281. export class FollowCamera extends TargetCamera {
  48282. /**
  48283. * Distance the follow camera should follow an object at
  48284. */
  48285. radius: number;
  48286. /**
  48287. * Minimum allowed distance of the camera to the axis of rotation
  48288. * (The camera can not get closer).
  48289. * This can help limiting how the Camera is able to move in the scene.
  48290. */
  48291. lowerRadiusLimit: Nullable<number>;
  48292. /**
  48293. * Maximum allowed distance of the camera to the axis of rotation
  48294. * (The camera can not get further).
  48295. * This can help limiting how the Camera is able to move in the scene.
  48296. */
  48297. upperRadiusLimit: Nullable<number>;
  48298. /**
  48299. * Define a rotation offset between the camera and the object it follows
  48300. */
  48301. rotationOffset: number;
  48302. /**
  48303. * Minimum allowed angle to camera position relative to target object.
  48304. * This can help limiting how the Camera is able to move in the scene.
  48305. */
  48306. lowerRotationOffsetLimit: Nullable<number>;
  48307. /**
  48308. * Maximum allowed angle to camera position relative to target object.
  48309. * This can help limiting how the Camera is able to move in the scene.
  48310. */
  48311. upperRotationOffsetLimit: Nullable<number>;
  48312. /**
  48313. * Define a height offset between the camera and the object it follows.
  48314. * It can help following an object from the top (like a car chaing a plane)
  48315. */
  48316. heightOffset: number;
  48317. /**
  48318. * Minimum allowed height of camera position relative to target object.
  48319. * This can help limiting how the Camera is able to move in the scene.
  48320. */
  48321. lowerHeightOffsetLimit: Nullable<number>;
  48322. /**
  48323. * Maximum allowed height of camera position relative to target object.
  48324. * This can help limiting how the Camera is able to move in the scene.
  48325. */
  48326. upperHeightOffsetLimit: Nullable<number>;
  48327. /**
  48328. * Define how fast the camera can accelerate to follow it s target.
  48329. */
  48330. cameraAcceleration: number;
  48331. /**
  48332. * Define the speed limit of the camera following an object.
  48333. */
  48334. maxCameraSpeed: number;
  48335. /**
  48336. * Define the target of the camera.
  48337. */
  48338. lockedTarget: Nullable<AbstractMesh>;
  48339. /**
  48340. * Defines the input associated with the camera.
  48341. */
  48342. inputs: FollowCameraInputsManager;
  48343. /**
  48344. * Instantiates the follow camera.
  48345. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48346. * @param name Define the name of the camera in the scene
  48347. * @param position Define the position of the camera
  48348. * @param scene Define the scene the camera belong to
  48349. * @param lockedTarget Define the target of the camera
  48350. */
  48351. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  48352. private _follow;
  48353. /**
  48354. * Attach the input controls to a specific dom element to get the input from.
  48355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48356. */
  48357. attachControl(noPreventDefault?: boolean): void;
  48358. /**
  48359. * Detach the current controls from the specified dom element.
  48360. */
  48361. detachControl(): void;
  48362. /** @hidden */
  48363. _checkInputs(): void;
  48364. private _checkLimits;
  48365. /**
  48366. * Gets the camera class name.
  48367. * @returns the class name
  48368. */
  48369. getClassName(): string;
  48370. }
  48371. /**
  48372. * Arc Rotate version of the follow camera.
  48373. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  48374. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48375. */
  48376. export class ArcFollowCamera extends TargetCamera {
  48377. /** The longitudinal angle of the camera */
  48378. alpha: number;
  48379. /** The latitudinal angle of the camera */
  48380. beta: number;
  48381. /** The radius of the camera from its target */
  48382. radius: number;
  48383. private _cartesianCoordinates;
  48384. /** Define the camera target (the mesh it should follow) */
  48385. private _meshTarget;
  48386. /**
  48387. * Instantiates a new ArcFollowCamera
  48388. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48389. * @param name Define the name of the camera
  48390. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  48391. * @param beta Define the rotation angle of the camera around the elevation axis
  48392. * @param radius Define the radius of the camera from its target point
  48393. * @param target Define the target of the camera
  48394. * @param scene Define the scene the camera belongs to
  48395. */
  48396. constructor(name: string,
  48397. /** The longitudinal angle of the camera */
  48398. alpha: number,
  48399. /** The latitudinal angle of the camera */
  48400. beta: number,
  48401. /** The radius of the camera from its target */
  48402. radius: number,
  48403. /** Define the camera target (the mesh it should follow) */
  48404. target: Nullable<AbstractMesh>, scene: Scene);
  48405. private _follow;
  48406. /** @hidden */
  48407. _checkInputs(): void;
  48408. /**
  48409. * Returns the class name of the object.
  48410. * It is mostly used internally for serialization purposes.
  48411. */
  48412. getClassName(): string;
  48413. }
  48414. }
  48415. declare module BABYLON {
  48416. /**
  48417. * Manage the keyboard inputs to control the movement of a follow camera.
  48418. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48419. */
  48420. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  48421. /**
  48422. * Defines the camera the input is attached to.
  48423. */
  48424. camera: FollowCamera;
  48425. /**
  48426. * Defines the list of key codes associated with the up action (increase heightOffset)
  48427. */
  48428. keysHeightOffsetIncr: number[];
  48429. /**
  48430. * Defines the list of key codes associated with the down action (decrease heightOffset)
  48431. */
  48432. keysHeightOffsetDecr: number[];
  48433. /**
  48434. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  48435. */
  48436. keysHeightOffsetModifierAlt: boolean;
  48437. /**
  48438. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  48439. */
  48440. keysHeightOffsetModifierCtrl: boolean;
  48441. /**
  48442. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  48443. */
  48444. keysHeightOffsetModifierShift: boolean;
  48445. /**
  48446. * Defines the list of key codes associated with the left action (increase rotationOffset)
  48447. */
  48448. keysRotationOffsetIncr: number[];
  48449. /**
  48450. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  48451. */
  48452. keysRotationOffsetDecr: number[];
  48453. /**
  48454. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  48455. */
  48456. keysRotationOffsetModifierAlt: boolean;
  48457. /**
  48458. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  48459. */
  48460. keysRotationOffsetModifierCtrl: boolean;
  48461. /**
  48462. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  48463. */
  48464. keysRotationOffsetModifierShift: boolean;
  48465. /**
  48466. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  48467. */
  48468. keysRadiusIncr: number[];
  48469. /**
  48470. * Defines the list of key codes associated with the zoom-out action (increase radius)
  48471. */
  48472. keysRadiusDecr: number[];
  48473. /**
  48474. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  48475. */
  48476. keysRadiusModifierAlt: boolean;
  48477. /**
  48478. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  48479. */
  48480. keysRadiusModifierCtrl: boolean;
  48481. /**
  48482. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  48483. */
  48484. keysRadiusModifierShift: boolean;
  48485. /**
  48486. * Defines the rate of change of heightOffset.
  48487. */
  48488. heightSensibility: number;
  48489. /**
  48490. * Defines the rate of change of rotationOffset.
  48491. */
  48492. rotationSensibility: number;
  48493. /**
  48494. * Defines the rate of change of radius.
  48495. */
  48496. radiusSensibility: number;
  48497. private _keys;
  48498. private _ctrlPressed;
  48499. private _altPressed;
  48500. private _shiftPressed;
  48501. private _onCanvasBlurObserver;
  48502. private _onKeyboardObserver;
  48503. private _engine;
  48504. private _scene;
  48505. /**
  48506. * Attach the input controls to a specific dom element to get the input from.
  48507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48508. */
  48509. attachControl(noPreventDefault?: boolean): void;
  48510. /**
  48511. * Detach the current controls from the specified dom element.
  48512. */
  48513. detachControl(): void;
  48514. /**
  48515. * Update the current camera state depending on the inputs that have been used this frame.
  48516. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48517. */
  48518. checkInputs(): void;
  48519. /**
  48520. * Gets the class name of the current input.
  48521. * @returns the class name
  48522. */
  48523. getClassName(): string;
  48524. /**
  48525. * Get the friendly name associated with the input class.
  48526. * @returns the input friendly name
  48527. */
  48528. getSimpleName(): string;
  48529. /**
  48530. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48531. * allow modification of the heightOffset value.
  48532. */
  48533. private _modifierHeightOffset;
  48534. /**
  48535. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48536. * allow modification of the rotationOffset value.
  48537. */
  48538. private _modifierRotationOffset;
  48539. /**
  48540. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48541. * allow modification of the radius value.
  48542. */
  48543. private _modifierRadius;
  48544. }
  48545. }
  48546. declare module BABYLON {
  48547. interface FreeCameraInputsManager {
  48548. /**
  48549. * @hidden
  48550. */
  48551. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  48552. /**
  48553. * Add orientation input support to the input manager.
  48554. * @returns the current input manager
  48555. */
  48556. addDeviceOrientation(): FreeCameraInputsManager;
  48557. }
  48558. /**
  48559. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  48560. * Screen rotation is taken into account.
  48561. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48562. */
  48563. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  48564. private _camera;
  48565. private _screenOrientationAngle;
  48566. private _constantTranform;
  48567. private _screenQuaternion;
  48568. private _alpha;
  48569. private _beta;
  48570. private _gamma;
  48571. /**
  48572. * Can be used to detect if a device orientation sensor is available on a device
  48573. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  48574. * @returns a promise that will resolve on orientation change
  48575. */
  48576. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  48577. /**
  48578. * @hidden
  48579. */
  48580. _onDeviceOrientationChangedObservable: Observable<void>;
  48581. /**
  48582. * Instantiates a new input
  48583. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48584. */
  48585. constructor();
  48586. /**
  48587. * Define the camera controlled by the input.
  48588. */
  48589. get camera(): FreeCamera;
  48590. set camera(camera: FreeCamera);
  48591. /**
  48592. * Attach the input controls to a specific dom element to get the input from.
  48593. */
  48594. attachControl(): void;
  48595. private _orientationChanged;
  48596. private _deviceOrientation;
  48597. /**
  48598. * Detach the current controls from the specified dom element.
  48599. */
  48600. detachControl(): void;
  48601. /**
  48602. * Update the current camera state depending on the inputs that have been used this frame.
  48603. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48604. */
  48605. checkInputs(): void;
  48606. /**
  48607. * Gets the class name of the current intput.
  48608. * @returns the class name
  48609. */
  48610. getClassName(): string;
  48611. /**
  48612. * Get the friendly name associated with the input class.
  48613. * @returns the input friendly name
  48614. */
  48615. getSimpleName(): string;
  48616. }
  48617. }
  48618. declare module BABYLON {
  48619. /**
  48620. * Manage the gamepad inputs to control a free camera.
  48621. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48622. */
  48623. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48624. /**
  48625. * Define the camera the input is attached to.
  48626. */
  48627. camera: FreeCamera;
  48628. /**
  48629. * Define the Gamepad controlling the input
  48630. */
  48631. gamepad: Nullable<Gamepad>;
  48632. /**
  48633. * Defines the gamepad rotation sensiblity.
  48634. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48635. */
  48636. gamepadAngularSensibility: number;
  48637. /**
  48638. * Defines the gamepad move sensiblity.
  48639. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48640. */
  48641. gamepadMoveSensibility: number;
  48642. private _yAxisScale;
  48643. /**
  48644. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48645. */
  48646. get invertYAxis(): boolean;
  48647. set invertYAxis(value: boolean);
  48648. private _onGamepadConnectedObserver;
  48649. private _onGamepadDisconnectedObserver;
  48650. private _cameraTransform;
  48651. private _deltaTransform;
  48652. private _vector3;
  48653. private _vector2;
  48654. /**
  48655. * Attach the input controls to a specific dom element to get the input from.
  48656. */
  48657. attachControl(): void;
  48658. /**
  48659. * Detach the current controls from the specified dom element.
  48660. */
  48661. detachControl(): void;
  48662. /**
  48663. * Update the current camera state depending on the inputs that have been used this frame.
  48664. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48665. */
  48666. checkInputs(): void;
  48667. /**
  48668. * Gets the class name of the current intput.
  48669. * @returns the class name
  48670. */
  48671. getClassName(): string;
  48672. /**
  48673. * Get the friendly name associated with the input class.
  48674. * @returns the input friendly name
  48675. */
  48676. getSimpleName(): string;
  48677. }
  48678. }
  48679. declare module BABYLON {
  48680. /**
  48681. * Defines the potential axis of a Joystick
  48682. */
  48683. export enum JoystickAxis {
  48684. /** X axis */
  48685. X = 0,
  48686. /** Y axis */
  48687. Y = 1,
  48688. /** Z axis */
  48689. Z = 2
  48690. }
  48691. /**
  48692. * Represents the different customization options available
  48693. * for VirtualJoystick
  48694. */
  48695. interface VirtualJoystickCustomizations {
  48696. /**
  48697. * Size of the joystick's puck
  48698. */
  48699. puckSize: number;
  48700. /**
  48701. * Size of the joystick's container
  48702. */
  48703. containerSize: number;
  48704. /**
  48705. * Color of the joystick && puck
  48706. */
  48707. color: string;
  48708. /**
  48709. * Image URL for the joystick's puck
  48710. */
  48711. puckImage?: string;
  48712. /**
  48713. * Image URL for the joystick's container
  48714. */
  48715. containerImage?: string;
  48716. /**
  48717. * Defines the unmoving position of the joystick container
  48718. */
  48719. position?: {
  48720. x: number;
  48721. y: number;
  48722. };
  48723. /**
  48724. * Defines whether or not the joystick container is always visible
  48725. */
  48726. alwaysVisible: boolean;
  48727. /**
  48728. * Defines whether or not to limit the movement of the puck to the joystick's container
  48729. */
  48730. limitToContainer: boolean;
  48731. }
  48732. /**
  48733. * Class used to define virtual joystick (used in touch mode)
  48734. */
  48735. export class VirtualJoystick {
  48736. /**
  48737. * Gets or sets a boolean indicating that left and right values must be inverted
  48738. */
  48739. reverseLeftRight: boolean;
  48740. /**
  48741. * Gets or sets a boolean indicating that up and down values must be inverted
  48742. */
  48743. reverseUpDown: boolean;
  48744. /**
  48745. * Gets the offset value for the position (ie. the change of the position value)
  48746. */
  48747. deltaPosition: Vector3;
  48748. /**
  48749. * Gets a boolean indicating if the virtual joystick was pressed
  48750. */
  48751. pressed: boolean;
  48752. /**
  48753. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48754. */
  48755. static Canvas: Nullable<HTMLCanvasElement>;
  48756. /**
  48757. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48758. */
  48759. limitToContainer: boolean;
  48760. private static _globalJoystickIndex;
  48761. private static _alwaysVisibleSticks;
  48762. private static vjCanvasContext;
  48763. private static vjCanvasWidth;
  48764. private static vjCanvasHeight;
  48765. private static halfWidth;
  48766. private static _GetDefaultOptions;
  48767. private _action;
  48768. private _axisTargetedByLeftAndRight;
  48769. private _axisTargetedByUpAndDown;
  48770. private _joystickSensibility;
  48771. private _inversedSensibility;
  48772. private _joystickPointerID;
  48773. private _joystickColor;
  48774. private _joystickPointerPos;
  48775. private _joystickPreviousPointerPos;
  48776. private _joystickPointerStartPos;
  48777. private _deltaJoystickVector;
  48778. private _leftJoystick;
  48779. private _touches;
  48780. private _joystickPosition;
  48781. private _alwaysVisible;
  48782. private _puckImage;
  48783. private _containerImage;
  48784. private _joystickPuckSize;
  48785. private _joystickContainerSize;
  48786. private _clearPuckSize;
  48787. private _clearContainerSize;
  48788. private _clearPuckSizeOffset;
  48789. private _clearContainerSizeOffset;
  48790. private _onPointerDownHandlerRef;
  48791. private _onPointerMoveHandlerRef;
  48792. private _onPointerUpHandlerRef;
  48793. private _onResize;
  48794. /**
  48795. * Creates a new virtual joystick
  48796. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48797. * @param customizations Defines the options we want to customize the VirtualJoystick
  48798. */
  48799. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48800. /**
  48801. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48802. * @param newJoystickSensibility defines the new sensibility
  48803. */
  48804. setJoystickSensibility(newJoystickSensibility: number): void;
  48805. private _onPointerDown;
  48806. private _onPointerMove;
  48807. private _onPointerUp;
  48808. /**
  48809. * Change the color of the virtual joystick
  48810. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48811. */
  48812. setJoystickColor(newColor: string): void;
  48813. /**
  48814. * Size of the joystick's container
  48815. */
  48816. set containerSize(newSize: number);
  48817. get containerSize(): number;
  48818. /**
  48819. * Size of the joystick's puck
  48820. */
  48821. set puckSize(newSize: number);
  48822. get puckSize(): number;
  48823. /**
  48824. * Clears the set position of the joystick
  48825. */
  48826. clearPosition(): void;
  48827. /**
  48828. * Defines whether or not the joystick container is always visible
  48829. */
  48830. set alwaysVisible(value: boolean);
  48831. get alwaysVisible(): boolean;
  48832. /**
  48833. * Sets the constant position of the Joystick container
  48834. * @param x X axis coordinate
  48835. * @param y Y axis coordinate
  48836. */
  48837. setPosition(x: number, y: number): void;
  48838. /**
  48839. * Defines a callback to call when the joystick is touched
  48840. * @param action defines the callback
  48841. */
  48842. setActionOnTouch(action: () => any): void;
  48843. /**
  48844. * Defines which axis you'd like to control for left & right
  48845. * @param axis defines the axis to use
  48846. */
  48847. setAxisForLeftRight(axis: JoystickAxis): void;
  48848. /**
  48849. * Defines which axis you'd like to control for up & down
  48850. * @param axis defines the axis to use
  48851. */
  48852. setAxisForUpDown(axis: JoystickAxis): void;
  48853. /**
  48854. * Clears the canvas from the previous puck / container draw
  48855. */
  48856. private _clearPreviousDraw;
  48857. /**
  48858. * Loads `urlPath` to be used for the container's image
  48859. * @param urlPath defines the urlPath of an image to use
  48860. */
  48861. setContainerImage(urlPath: string): void;
  48862. /**
  48863. * Loads `urlPath` to be used for the puck's image
  48864. * @param urlPath defines the urlPath of an image to use
  48865. */
  48866. setPuckImage(urlPath: string): void;
  48867. /**
  48868. * Draws the Virtual Joystick's container
  48869. */
  48870. private _drawContainer;
  48871. /**
  48872. * Draws the Virtual Joystick's puck
  48873. */
  48874. private _drawPuck;
  48875. private _drawVirtualJoystick;
  48876. /**
  48877. * Release internal HTML canvas
  48878. */
  48879. releaseCanvas(): void;
  48880. }
  48881. }
  48882. declare module BABYLON {
  48883. interface FreeCameraInputsManager {
  48884. /**
  48885. * Add virtual joystick input support to the input manager.
  48886. * @returns the current input manager
  48887. */
  48888. addVirtualJoystick(): FreeCameraInputsManager;
  48889. }
  48890. /**
  48891. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48892. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48893. */
  48894. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48895. /**
  48896. * Defines the camera the input is attached to.
  48897. */
  48898. camera: FreeCamera;
  48899. private _leftjoystick;
  48900. private _rightjoystick;
  48901. /**
  48902. * Gets the left stick of the virtual joystick.
  48903. * @returns The virtual Joystick
  48904. */
  48905. getLeftJoystick(): VirtualJoystick;
  48906. /**
  48907. * Gets the right stick of the virtual joystick.
  48908. * @returns The virtual Joystick
  48909. */
  48910. getRightJoystick(): VirtualJoystick;
  48911. /**
  48912. * Update the current camera state depending on the inputs that have been used this frame.
  48913. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48914. */
  48915. checkInputs(): void;
  48916. /**
  48917. * Attach the input controls to a specific dom element to get the input from.
  48918. */
  48919. attachControl(): void;
  48920. /**
  48921. * Detach the current controls from the specified dom element.
  48922. */
  48923. detachControl(): void;
  48924. /**
  48925. * Gets the class name of the current intput.
  48926. * @returns the class name
  48927. */
  48928. getClassName(): string;
  48929. /**
  48930. * Get the friendly name associated with the input class.
  48931. * @returns the input friendly name
  48932. */
  48933. getSimpleName(): string;
  48934. }
  48935. }
  48936. declare module BABYLON {
  48937. /**
  48938. * This represents a FPS type of camera controlled by touch.
  48939. * This is like a universal camera minus the Gamepad controls.
  48940. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48941. */
  48942. export class TouchCamera extends FreeCamera {
  48943. /**
  48944. * Defines the touch sensibility for rotation.
  48945. * The higher the faster.
  48946. */
  48947. get touchAngularSensibility(): number;
  48948. set touchAngularSensibility(value: number);
  48949. /**
  48950. * Defines the touch sensibility for move.
  48951. * The higher the faster.
  48952. */
  48953. get touchMoveSensibility(): number;
  48954. set touchMoveSensibility(value: number);
  48955. /**
  48956. * Instantiates a new touch camera.
  48957. * This represents a FPS type of camera controlled by touch.
  48958. * This is like a universal camera minus the Gamepad controls.
  48959. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48960. * @param name Define the name of the camera in the scene
  48961. * @param position Define the start position of the camera in the scene
  48962. * @param scene Define the scene the camera belongs to
  48963. */
  48964. constructor(name: string, position: Vector3, scene: Scene);
  48965. /**
  48966. * Gets the current object class name.
  48967. * @return the class name
  48968. */
  48969. getClassName(): string;
  48970. /** @hidden */
  48971. _setupInputs(): void;
  48972. }
  48973. }
  48974. declare module BABYLON {
  48975. /**
  48976. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48977. * being tilted forward or back and left or right.
  48978. */
  48979. export class DeviceOrientationCamera extends FreeCamera {
  48980. private _initialQuaternion;
  48981. private _quaternionCache;
  48982. private _tmpDragQuaternion;
  48983. private _disablePointerInputWhenUsingDeviceOrientation;
  48984. /**
  48985. * Creates a new device orientation camera
  48986. * @param name The name of the camera
  48987. * @param position The start position camera
  48988. * @param scene The scene the camera belongs to
  48989. */
  48990. constructor(name: string, position: Vector3, scene: Scene);
  48991. /**
  48992. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48993. */
  48994. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48995. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48996. private _dragFactor;
  48997. /**
  48998. * Enabled turning on the y axis when the orientation sensor is active
  48999. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  49000. */
  49001. enableHorizontalDragging(dragFactor?: number): void;
  49002. /**
  49003. * Gets the current instance class name ("DeviceOrientationCamera").
  49004. * This helps avoiding instanceof at run time.
  49005. * @returns the class name
  49006. */
  49007. getClassName(): string;
  49008. /**
  49009. * @hidden
  49010. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  49011. */
  49012. _checkInputs(): void;
  49013. /**
  49014. * Reset the camera to its default orientation on the specified axis only.
  49015. * @param axis The axis to reset
  49016. */
  49017. resetToCurrentRotation(axis?: Axis): void;
  49018. }
  49019. }
  49020. declare module BABYLON {
  49021. /**
  49022. * Defines supported buttons for XBox360 compatible gamepads
  49023. */
  49024. export enum Xbox360Button {
  49025. /** A */
  49026. A = 0,
  49027. /** B */
  49028. B = 1,
  49029. /** X */
  49030. X = 2,
  49031. /** Y */
  49032. Y = 3,
  49033. /** Left button */
  49034. LB = 4,
  49035. /** Right button */
  49036. RB = 5,
  49037. /** Back */
  49038. Back = 8,
  49039. /** Start */
  49040. Start = 9,
  49041. /** Left stick */
  49042. LeftStick = 10,
  49043. /** Right stick */
  49044. RightStick = 11
  49045. }
  49046. /** Defines values for XBox360 DPad */
  49047. export enum Xbox360Dpad {
  49048. /** Up */
  49049. Up = 12,
  49050. /** Down */
  49051. Down = 13,
  49052. /** Left */
  49053. Left = 14,
  49054. /** Right */
  49055. Right = 15
  49056. }
  49057. /**
  49058. * Defines a XBox360 gamepad
  49059. */
  49060. export class Xbox360Pad extends Gamepad {
  49061. private _leftTrigger;
  49062. private _rightTrigger;
  49063. private _onlefttriggerchanged;
  49064. private _onrighttriggerchanged;
  49065. private _onbuttondown;
  49066. private _onbuttonup;
  49067. private _ondpaddown;
  49068. private _ondpadup;
  49069. /** Observable raised when a button is pressed */
  49070. onButtonDownObservable: Observable<Xbox360Button>;
  49071. /** Observable raised when a button is released */
  49072. onButtonUpObservable: Observable<Xbox360Button>;
  49073. /** Observable raised when a pad is pressed */
  49074. onPadDownObservable: Observable<Xbox360Dpad>;
  49075. /** Observable raised when a pad is released */
  49076. onPadUpObservable: Observable<Xbox360Dpad>;
  49077. private _buttonA;
  49078. private _buttonB;
  49079. private _buttonX;
  49080. private _buttonY;
  49081. private _buttonBack;
  49082. private _buttonStart;
  49083. private _buttonLB;
  49084. private _buttonRB;
  49085. private _buttonLeftStick;
  49086. private _buttonRightStick;
  49087. private _dPadUp;
  49088. private _dPadDown;
  49089. private _dPadLeft;
  49090. private _dPadRight;
  49091. private _isXboxOnePad;
  49092. /**
  49093. * Creates a new XBox360 gamepad object
  49094. * @param id defines the id of this gamepad
  49095. * @param index defines its index
  49096. * @param gamepad defines the internal HTML gamepad object
  49097. * @param xboxOne defines if it is a XBox One gamepad
  49098. */
  49099. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  49100. /**
  49101. * Defines the callback to call when left trigger is pressed
  49102. * @param callback defines the callback to use
  49103. */
  49104. onlefttriggerchanged(callback: (value: number) => void): void;
  49105. /**
  49106. * Defines the callback to call when right trigger is pressed
  49107. * @param callback defines the callback to use
  49108. */
  49109. onrighttriggerchanged(callback: (value: number) => void): void;
  49110. /**
  49111. * Gets the left trigger value
  49112. */
  49113. get leftTrigger(): number;
  49114. /**
  49115. * Sets the left trigger value
  49116. */
  49117. set leftTrigger(newValue: number);
  49118. /**
  49119. * Gets the right trigger value
  49120. */
  49121. get rightTrigger(): number;
  49122. /**
  49123. * Sets the right trigger value
  49124. */
  49125. set rightTrigger(newValue: number);
  49126. /**
  49127. * Defines the callback to call when a button is pressed
  49128. * @param callback defines the callback to use
  49129. */
  49130. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  49131. /**
  49132. * Defines the callback to call when a button is released
  49133. * @param callback defines the callback to use
  49134. */
  49135. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  49136. /**
  49137. * Defines the callback to call when a pad is pressed
  49138. * @param callback defines the callback to use
  49139. */
  49140. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  49141. /**
  49142. * Defines the callback to call when a pad is released
  49143. * @param callback defines the callback to use
  49144. */
  49145. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  49146. private _setButtonValue;
  49147. private _setDPadValue;
  49148. /**
  49149. * Gets the value of the `A` button
  49150. */
  49151. get buttonA(): number;
  49152. /**
  49153. * Sets the value of the `A` button
  49154. */
  49155. set buttonA(value: number);
  49156. /**
  49157. * Gets the value of the `B` button
  49158. */
  49159. get buttonB(): number;
  49160. /**
  49161. * Sets the value of the `B` button
  49162. */
  49163. set buttonB(value: number);
  49164. /**
  49165. * Gets the value of the `X` button
  49166. */
  49167. get buttonX(): number;
  49168. /**
  49169. * Sets the value of the `X` button
  49170. */
  49171. set buttonX(value: number);
  49172. /**
  49173. * Gets the value of the `Y` button
  49174. */
  49175. get buttonY(): number;
  49176. /**
  49177. * Sets the value of the `Y` button
  49178. */
  49179. set buttonY(value: number);
  49180. /**
  49181. * Gets the value of the `Start` button
  49182. */
  49183. get buttonStart(): number;
  49184. /**
  49185. * Sets the value of the `Start` button
  49186. */
  49187. set buttonStart(value: number);
  49188. /**
  49189. * Gets the value of the `Back` button
  49190. */
  49191. get buttonBack(): number;
  49192. /**
  49193. * Sets the value of the `Back` button
  49194. */
  49195. set buttonBack(value: number);
  49196. /**
  49197. * Gets the value of the `Left` button
  49198. */
  49199. get buttonLB(): number;
  49200. /**
  49201. * Sets the value of the `Left` button
  49202. */
  49203. set buttonLB(value: number);
  49204. /**
  49205. * Gets the value of the `Right` button
  49206. */
  49207. get buttonRB(): number;
  49208. /**
  49209. * Sets the value of the `Right` button
  49210. */
  49211. set buttonRB(value: number);
  49212. /**
  49213. * Gets the value of the Left joystick
  49214. */
  49215. get buttonLeftStick(): number;
  49216. /**
  49217. * Sets the value of the Left joystick
  49218. */
  49219. set buttonLeftStick(value: number);
  49220. /**
  49221. * Gets the value of the Right joystick
  49222. */
  49223. get buttonRightStick(): number;
  49224. /**
  49225. * Sets the value of the Right joystick
  49226. */
  49227. set buttonRightStick(value: number);
  49228. /**
  49229. * Gets the value of D-pad up
  49230. */
  49231. get dPadUp(): number;
  49232. /**
  49233. * Sets the value of D-pad up
  49234. */
  49235. set dPadUp(value: number);
  49236. /**
  49237. * Gets the value of D-pad down
  49238. */
  49239. get dPadDown(): number;
  49240. /**
  49241. * Sets the value of D-pad down
  49242. */
  49243. set dPadDown(value: number);
  49244. /**
  49245. * Gets the value of D-pad left
  49246. */
  49247. get dPadLeft(): number;
  49248. /**
  49249. * Sets the value of D-pad left
  49250. */
  49251. set dPadLeft(value: number);
  49252. /**
  49253. * Gets the value of D-pad right
  49254. */
  49255. get dPadRight(): number;
  49256. /**
  49257. * Sets the value of D-pad right
  49258. */
  49259. set dPadRight(value: number);
  49260. /**
  49261. * Force the gamepad to synchronize with device values
  49262. */
  49263. update(): void;
  49264. /**
  49265. * Disposes the gamepad
  49266. */
  49267. dispose(): void;
  49268. }
  49269. }
  49270. declare module BABYLON {
  49271. /**
  49272. * Defines supported buttons for DualShock compatible gamepads
  49273. */
  49274. export enum DualShockButton {
  49275. /** Cross */
  49276. Cross = 0,
  49277. /** Circle */
  49278. Circle = 1,
  49279. /** Square */
  49280. Square = 2,
  49281. /** Triangle */
  49282. Triangle = 3,
  49283. /** L1 */
  49284. L1 = 4,
  49285. /** R1 */
  49286. R1 = 5,
  49287. /** Share */
  49288. Share = 8,
  49289. /** Options */
  49290. Options = 9,
  49291. /** Left stick */
  49292. LeftStick = 10,
  49293. /** Right stick */
  49294. RightStick = 11
  49295. }
  49296. /** Defines values for DualShock DPad */
  49297. export enum DualShockDpad {
  49298. /** Up */
  49299. Up = 12,
  49300. /** Down */
  49301. Down = 13,
  49302. /** Left */
  49303. Left = 14,
  49304. /** Right */
  49305. Right = 15
  49306. }
  49307. /**
  49308. * Defines a DualShock gamepad
  49309. */
  49310. export class DualShockPad extends Gamepad {
  49311. private _leftTrigger;
  49312. private _rightTrigger;
  49313. private _onlefttriggerchanged;
  49314. private _onrighttriggerchanged;
  49315. private _onbuttondown;
  49316. private _onbuttonup;
  49317. private _ondpaddown;
  49318. private _ondpadup;
  49319. /** Observable raised when a button is pressed */
  49320. onButtonDownObservable: Observable<DualShockButton>;
  49321. /** Observable raised when a button is released */
  49322. onButtonUpObservable: Observable<DualShockButton>;
  49323. /** Observable raised when a pad is pressed */
  49324. onPadDownObservable: Observable<DualShockDpad>;
  49325. /** Observable raised when a pad is released */
  49326. onPadUpObservable: Observable<DualShockDpad>;
  49327. private _buttonCross;
  49328. private _buttonCircle;
  49329. private _buttonSquare;
  49330. private _buttonTriangle;
  49331. private _buttonShare;
  49332. private _buttonOptions;
  49333. private _buttonL1;
  49334. private _buttonR1;
  49335. private _buttonLeftStick;
  49336. private _buttonRightStick;
  49337. private _dPadUp;
  49338. private _dPadDown;
  49339. private _dPadLeft;
  49340. private _dPadRight;
  49341. /**
  49342. * Creates a new DualShock gamepad object
  49343. * @param id defines the id of this gamepad
  49344. * @param index defines its index
  49345. * @param gamepad defines the internal HTML gamepad object
  49346. */
  49347. constructor(id: string, index: number, gamepad: any);
  49348. /**
  49349. * Defines the callback to call when left trigger is pressed
  49350. * @param callback defines the callback to use
  49351. */
  49352. onlefttriggerchanged(callback: (value: number) => void): void;
  49353. /**
  49354. * Defines the callback to call when right trigger is pressed
  49355. * @param callback defines the callback to use
  49356. */
  49357. onrighttriggerchanged(callback: (value: number) => void): void;
  49358. /**
  49359. * Gets the left trigger value
  49360. */
  49361. get leftTrigger(): number;
  49362. /**
  49363. * Sets the left trigger value
  49364. */
  49365. set leftTrigger(newValue: number);
  49366. /**
  49367. * Gets the right trigger value
  49368. */
  49369. get rightTrigger(): number;
  49370. /**
  49371. * Sets the right trigger value
  49372. */
  49373. set rightTrigger(newValue: number);
  49374. /**
  49375. * Defines the callback to call when a button is pressed
  49376. * @param callback defines the callback to use
  49377. */
  49378. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  49379. /**
  49380. * Defines the callback to call when a button is released
  49381. * @param callback defines the callback to use
  49382. */
  49383. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  49384. /**
  49385. * Defines the callback to call when a pad is pressed
  49386. * @param callback defines the callback to use
  49387. */
  49388. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  49389. /**
  49390. * Defines the callback to call when a pad is released
  49391. * @param callback defines the callback to use
  49392. */
  49393. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  49394. private _setButtonValue;
  49395. private _setDPadValue;
  49396. /**
  49397. * Gets the value of the `Cross` button
  49398. */
  49399. get buttonCross(): number;
  49400. /**
  49401. * Sets the value of the `Cross` button
  49402. */
  49403. set buttonCross(value: number);
  49404. /**
  49405. * Gets the value of the `Circle` button
  49406. */
  49407. get buttonCircle(): number;
  49408. /**
  49409. * Sets the value of the `Circle` button
  49410. */
  49411. set buttonCircle(value: number);
  49412. /**
  49413. * Gets the value of the `Square` button
  49414. */
  49415. get buttonSquare(): number;
  49416. /**
  49417. * Sets the value of the `Square` button
  49418. */
  49419. set buttonSquare(value: number);
  49420. /**
  49421. * Gets the value of the `Triangle` button
  49422. */
  49423. get buttonTriangle(): number;
  49424. /**
  49425. * Sets the value of the `Triangle` button
  49426. */
  49427. set buttonTriangle(value: number);
  49428. /**
  49429. * Gets the value of the `Options` button
  49430. */
  49431. get buttonOptions(): number;
  49432. /**
  49433. * Sets the value of the `Options` button
  49434. */
  49435. set buttonOptions(value: number);
  49436. /**
  49437. * Gets the value of the `Share` button
  49438. */
  49439. get buttonShare(): number;
  49440. /**
  49441. * Sets the value of the `Share` button
  49442. */
  49443. set buttonShare(value: number);
  49444. /**
  49445. * Gets the value of the `L1` button
  49446. */
  49447. get buttonL1(): number;
  49448. /**
  49449. * Sets the value of the `L1` button
  49450. */
  49451. set buttonL1(value: number);
  49452. /**
  49453. * Gets the value of the `R1` button
  49454. */
  49455. get buttonR1(): number;
  49456. /**
  49457. * Sets the value of the `R1` button
  49458. */
  49459. set buttonR1(value: number);
  49460. /**
  49461. * Gets the value of the Left joystick
  49462. */
  49463. get buttonLeftStick(): number;
  49464. /**
  49465. * Sets the value of the Left joystick
  49466. */
  49467. set buttonLeftStick(value: number);
  49468. /**
  49469. * Gets the value of the Right joystick
  49470. */
  49471. get buttonRightStick(): number;
  49472. /**
  49473. * Sets the value of the Right joystick
  49474. */
  49475. set buttonRightStick(value: number);
  49476. /**
  49477. * Gets the value of D-pad up
  49478. */
  49479. get dPadUp(): number;
  49480. /**
  49481. * Sets the value of D-pad up
  49482. */
  49483. set dPadUp(value: number);
  49484. /**
  49485. * Gets the value of D-pad down
  49486. */
  49487. get dPadDown(): number;
  49488. /**
  49489. * Sets the value of D-pad down
  49490. */
  49491. set dPadDown(value: number);
  49492. /**
  49493. * Gets the value of D-pad left
  49494. */
  49495. get dPadLeft(): number;
  49496. /**
  49497. * Sets the value of D-pad left
  49498. */
  49499. set dPadLeft(value: number);
  49500. /**
  49501. * Gets the value of D-pad right
  49502. */
  49503. get dPadRight(): number;
  49504. /**
  49505. * Sets the value of D-pad right
  49506. */
  49507. set dPadRight(value: number);
  49508. /**
  49509. * Force the gamepad to synchronize with device values
  49510. */
  49511. update(): void;
  49512. /**
  49513. * Disposes the gamepad
  49514. */
  49515. dispose(): void;
  49516. }
  49517. }
  49518. declare module BABYLON {
  49519. /**
  49520. * Manager for handling gamepads
  49521. */
  49522. export class GamepadManager {
  49523. private _scene?;
  49524. private _babylonGamepads;
  49525. private _oneGamepadConnected;
  49526. /** @hidden */
  49527. _isMonitoring: boolean;
  49528. private _gamepadEventSupported;
  49529. private _gamepadSupport?;
  49530. /**
  49531. * observable to be triggered when the gamepad controller has been connected
  49532. */
  49533. onGamepadConnectedObservable: Observable<Gamepad>;
  49534. /**
  49535. * observable to be triggered when the gamepad controller has been disconnected
  49536. */
  49537. onGamepadDisconnectedObservable: Observable<Gamepad>;
  49538. private _onGamepadConnectedEvent;
  49539. private _onGamepadDisconnectedEvent;
  49540. /**
  49541. * Initializes the gamepad manager
  49542. * @param _scene BabylonJS scene
  49543. */
  49544. constructor(_scene?: Scene | undefined);
  49545. /**
  49546. * The gamepads in the game pad manager
  49547. */
  49548. get gamepads(): Gamepad[];
  49549. /**
  49550. * Get the gamepad controllers based on type
  49551. * @param type The type of gamepad controller
  49552. * @returns Nullable gamepad
  49553. */
  49554. getGamepadByType(type?: number): Nullable<Gamepad>;
  49555. /**
  49556. * Disposes the gamepad manager
  49557. */
  49558. dispose(): void;
  49559. private _addNewGamepad;
  49560. private _startMonitoringGamepads;
  49561. private _stopMonitoringGamepads;
  49562. /** @hidden */
  49563. _checkGamepadsStatus(): void;
  49564. private _updateGamepadObjects;
  49565. }
  49566. }
  49567. declare module BABYLON {
  49568. interface Scene {
  49569. /** @hidden */
  49570. _gamepadManager: Nullable<GamepadManager>;
  49571. /**
  49572. * Gets the gamepad manager associated with the scene
  49573. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49574. */
  49575. gamepadManager: GamepadManager;
  49576. }
  49577. /**
  49578. * Interface representing a free camera inputs manager
  49579. */
  49580. interface FreeCameraInputsManager {
  49581. /**
  49582. * Adds gamepad input support to the FreeCameraInputsManager.
  49583. * @returns the FreeCameraInputsManager
  49584. */
  49585. addGamepad(): FreeCameraInputsManager;
  49586. }
  49587. /**
  49588. * Interface representing an arc rotate camera inputs manager
  49589. */
  49590. interface ArcRotateCameraInputsManager {
  49591. /**
  49592. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49593. * @returns the camera inputs manager
  49594. */
  49595. addGamepad(): ArcRotateCameraInputsManager;
  49596. }
  49597. /**
  49598. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49599. */
  49600. export class GamepadSystemSceneComponent implements ISceneComponent {
  49601. /**
  49602. * The component name helpfull to identify the component in the list of scene components.
  49603. */
  49604. readonly name: string;
  49605. /**
  49606. * The scene the component belongs to.
  49607. */
  49608. scene: Scene;
  49609. /**
  49610. * Creates a new instance of the component for the given scene
  49611. * @param scene Defines the scene to register the component in
  49612. */
  49613. constructor(scene: Scene);
  49614. /**
  49615. * Registers the component in a given scene
  49616. */
  49617. register(): void;
  49618. /**
  49619. * Rebuilds the elements related to this component in case of
  49620. * context lost for instance.
  49621. */
  49622. rebuild(): void;
  49623. /**
  49624. * Disposes the component and the associated ressources
  49625. */
  49626. dispose(): void;
  49627. private _beforeCameraUpdate;
  49628. }
  49629. }
  49630. declare module BABYLON {
  49631. /**
  49632. * 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,
  49633. * which still works and will still be found in many Playgrounds.
  49634. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49635. */
  49636. export class UniversalCamera extends TouchCamera {
  49637. /**
  49638. * Defines the gamepad rotation sensiblity.
  49639. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49640. */
  49641. get gamepadAngularSensibility(): number;
  49642. set gamepadAngularSensibility(value: number);
  49643. /**
  49644. * Defines the gamepad move sensiblity.
  49645. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49646. */
  49647. get gamepadMoveSensibility(): number;
  49648. set gamepadMoveSensibility(value: number);
  49649. /**
  49650. * 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,
  49651. * which still works and will still be found in many Playgrounds.
  49652. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49653. * @param name Define the name of the camera in the scene
  49654. * @param position Define the start position of the camera in the scene
  49655. * @param scene Define the scene the camera belongs to
  49656. */
  49657. constructor(name: string, position: Vector3, scene: Scene);
  49658. /**
  49659. * Gets the current object class name.
  49660. * @return the class name
  49661. */
  49662. getClassName(): string;
  49663. }
  49664. }
  49665. declare module BABYLON {
  49666. /**
  49667. * This represents a FPS type of camera. This is only here for back compat purpose.
  49668. * Please use the UniversalCamera instead as both are identical.
  49669. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49670. */
  49671. export class GamepadCamera extends UniversalCamera {
  49672. /**
  49673. * Instantiates a new Gamepad Camera
  49674. * This represents a FPS type of camera. This is only here for back compat purpose.
  49675. * Please use the UniversalCamera instead as both are identical.
  49676. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49677. * @param name Define the name of the camera in the scene
  49678. * @param position Define the start position of the camera in the scene
  49679. * @param scene Define the scene the camera belongs to
  49680. */
  49681. constructor(name: string, position: Vector3, scene: Scene);
  49682. /**
  49683. * Gets the current object class name.
  49684. * @return the class name
  49685. */
  49686. getClassName(): string;
  49687. }
  49688. }
  49689. declare module BABYLON {
  49690. /** @hidden */
  49691. export var passPixelShader: {
  49692. name: string;
  49693. shader: string;
  49694. };
  49695. }
  49696. declare module BABYLON {
  49697. /** @hidden */
  49698. export var passCubePixelShader: {
  49699. name: string;
  49700. shader: string;
  49701. };
  49702. }
  49703. declare module BABYLON {
  49704. /**
  49705. * PassPostProcess which produces an output the same as it's input
  49706. */
  49707. export class PassPostProcess extends PostProcess {
  49708. /**
  49709. * Gets a string identifying the name of the class
  49710. * @returns "PassPostProcess" string
  49711. */
  49712. getClassName(): string;
  49713. /**
  49714. * Creates the PassPostProcess
  49715. * @param name The name of the effect.
  49716. * @param options The required width/height ratio to downsize to before computing the render pass.
  49717. * @param camera The camera to apply the render pass to.
  49718. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49719. * @param engine The engine which the post process will be applied. (default: current engine)
  49720. * @param reusable If the post process can be reused on the same frame. (default: false)
  49721. * @param textureType The type of texture to be used when performing the post processing.
  49722. * @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)
  49723. */
  49724. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49725. /** @hidden */
  49726. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49727. }
  49728. /**
  49729. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49730. */
  49731. export class PassCubePostProcess extends PostProcess {
  49732. private _face;
  49733. /**
  49734. * Gets or sets the cube face to display.
  49735. * * 0 is +X
  49736. * * 1 is -X
  49737. * * 2 is +Y
  49738. * * 3 is -Y
  49739. * * 4 is +Z
  49740. * * 5 is -Z
  49741. */
  49742. get face(): number;
  49743. set face(value: number);
  49744. /**
  49745. * Gets a string identifying the name of the class
  49746. * @returns "PassCubePostProcess" string
  49747. */
  49748. getClassName(): string;
  49749. /**
  49750. * Creates the PassCubePostProcess
  49751. * @param name The name of the effect.
  49752. * @param options The required width/height ratio to downsize to before computing the render pass.
  49753. * @param camera The camera to apply the render pass to.
  49754. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49755. * @param engine The engine which the post process will be applied. (default: current engine)
  49756. * @param reusable If the post process can be reused on the same frame. (default: false)
  49757. * @param textureType The type of texture to be used when performing the post processing.
  49758. * @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)
  49759. */
  49760. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49761. /** @hidden */
  49762. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49763. }
  49764. }
  49765. declare module BABYLON {
  49766. /** @hidden */
  49767. export var anaglyphPixelShader: {
  49768. name: string;
  49769. shader: string;
  49770. };
  49771. }
  49772. declare module BABYLON {
  49773. /**
  49774. * Postprocess used to generate anaglyphic rendering
  49775. */
  49776. export class AnaglyphPostProcess extends PostProcess {
  49777. private _passedProcess;
  49778. /**
  49779. * Gets a string identifying the name of the class
  49780. * @returns "AnaglyphPostProcess" string
  49781. */
  49782. getClassName(): string;
  49783. /**
  49784. * Creates a new AnaglyphPostProcess
  49785. * @param name defines postprocess name
  49786. * @param options defines creation options or target ratio scale
  49787. * @param rigCameras defines cameras using this postprocess
  49788. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49789. * @param engine defines hosting engine
  49790. * @param reusable defines if the postprocess will be reused multiple times per frame
  49791. */
  49792. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49793. }
  49794. }
  49795. declare module BABYLON {
  49796. /**
  49797. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49798. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49799. */
  49800. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49801. /**
  49802. * Creates a new AnaglyphArcRotateCamera
  49803. * @param name defines camera name
  49804. * @param alpha defines alpha angle (in radians)
  49805. * @param beta defines beta angle (in radians)
  49806. * @param radius defines radius
  49807. * @param target defines camera target
  49808. * @param interaxialDistance defines distance between each color axis
  49809. * @param scene defines the hosting scene
  49810. */
  49811. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49812. /**
  49813. * Gets camera class name
  49814. * @returns AnaglyphArcRotateCamera
  49815. */
  49816. getClassName(): string;
  49817. }
  49818. }
  49819. declare module BABYLON {
  49820. /**
  49821. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49822. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49823. */
  49824. export class AnaglyphFreeCamera extends FreeCamera {
  49825. /**
  49826. * Creates a new AnaglyphFreeCamera
  49827. * @param name defines camera name
  49828. * @param position defines initial position
  49829. * @param interaxialDistance defines distance between each color axis
  49830. * @param scene defines the hosting scene
  49831. */
  49832. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49833. /**
  49834. * Gets camera class name
  49835. * @returns AnaglyphFreeCamera
  49836. */
  49837. getClassName(): string;
  49838. }
  49839. }
  49840. declare module BABYLON {
  49841. /**
  49842. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49843. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49844. */
  49845. export class AnaglyphGamepadCamera extends GamepadCamera {
  49846. /**
  49847. * Creates a new AnaglyphGamepadCamera
  49848. * @param name defines camera name
  49849. * @param position defines initial position
  49850. * @param interaxialDistance defines distance between each color axis
  49851. * @param scene defines the hosting scene
  49852. */
  49853. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49854. /**
  49855. * Gets camera class name
  49856. * @returns AnaglyphGamepadCamera
  49857. */
  49858. getClassName(): string;
  49859. }
  49860. }
  49861. declare module BABYLON {
  49862. /**
  49863. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49864. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49865. */
  49866. export class AnaglyphUniversalCamera extends UniversalCamera {
  49867. /**
  49868. * Creates a new AnaglyphUniversalCamera
  49869. * @param name defines camera name
  49870. * @param position defines initial position
  49871. * @param interaxialDistance defines distance between each color axis
  49872. * @param scene defines the hosting scene
  49873. */
  49874. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49875. /**
  49876. * Gets camera class name
  49877. * @returns AnaglyphUniversalCamera
  49878. */
  49879. getClassName(): string;
  49880. }
  49881. }
  49882. declare module BABYLON {
  49883. /**
  49884. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49885. * @see https://doc.babylonjs.com/features/cameras
  49886. */
  49887. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49888. /**
  49889. * Creates a new StereoscopicArcRotateCamera
  49890. * @param name defines camera name
  49891. * @param alpha defines alpha angle (in radians)
  49892. * @param beta defines beta angle (in radians)
  49893. * @param radius defines radius
  49894. * @param target defines camera target
  49895. * @param interaxialDistance defines distance between each color axis
  49896. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49897. * @param scene defines the hosting scene
  49898. */
  49899. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49900. /**
  49901. * Gets camera class name
  49902. * @returns StereoscopicArcRotateCamera
  49903. */
  49904. getClassName(): string;
  49905. }
  49906. }
  49907. declare module BABYLON {
  49908. /**
  49909. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49910. * @see https://doc.babylonjs.com/features/cameras
  49911. */
  49912. export class StereoscopicFreeCamera extends FreeCamera {
  49913. /**
  49914. * Creates a new StereoscopicFreeCamera
  49915. * @param name defines camera name
  49916. * @param position defines initial position
  49917. * @param interaxialDistance defines distance between each color axis
  49918. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49919. * @param scene defines the hosting scene
  49920. */
  49921. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49922. /**
  49923. * Gets camera class name
  49924. * @returns StereoscopicFreeCamera
  49925. */
  49926. getClassName(): string;
  49927. }
  49928. }
  49929. declare module BABYLON {
  49930. /**
  49931. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49932. * @see https://doc.babylonjs.com/features/cameras
  49933. */
  49934. export class StereoscopicGamepadCamera extends GamepadCamera {
  49935. /**
  49936. * Creates a new StereoscopicGamepadCamera
  49937. * @param name defines camera name
  49938. * @param position defines initial position
  49939. * @param interaxialDistance defines distance between each color axis
  49940. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49941. * @param scene defines the hosting scene
  49942. */
  49943. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49944. /**
  49945. * Gets camera class name
  49946. * @returns StereoscopicGamepadCamera
  49947. */
  49948. getClassName(): string;
  49949. }
  49950. }
  49951. declare module BABYLON {
  49952. /**
  49953. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49954. * @see https://doc.babylonjs.com/features/cameras
  49955. */
  49956. export class StereoscopicUniversalCamera extends UniversalCamera {
  49957. /**
  49958. * Creates a new StereoscopicUniversalCamera
  49959. * @param name defines camera name
  49960. * @param position defines initial position
  49961. * @param interaxialDistance defines distance between each color axis
  49962. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49963. * @param scene defines the hosting scene
  49964. */
  49965. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49966. /**
  49967. * Gets camera class name
  49968. * @returns StereoscopicUniversalCamera
  49969. */
  49970. getClassName(): string;
  49971. }
  49972. }
  49973. declare module BABYLON {
  49974. /**
  49975. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49976. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49977. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49978. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49979. */
  49980. export class VirtualJoysticksCamera extends FreeCamera {
  49981. /**
  49982. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49983. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49984. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49985. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49986. * @param name Define the name of the camera in the scene
  49987. * @param position Define the start position of the camera in the scene
  49988. * @param scene Define the scene the camera belongs to
  49989. */
  49990. constructor(name: string, position: Vector3, scene: Scene);
  49991. /**
  49992. * Gets the current object class name.
  49993. * @return the class name
  49994. */
  49995. getClassName(): string;
  49996. }
  49997. }
  49998. declare module BABYLON {
  49999. /**
  50000. * This represents all the required metrics to create a VR camera.
  50001. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  50002. */
  50003. export class VRCameraMetrics {
  50004. /**
  50005. * Define the horizontal resolution off the screen.
  50006. */
  50007. hResolution: number;
  50008. /**
  50009. * Define the vertical resolution off the screen.
  50010. */
  50011. vResolution: number;
  50012. /**
  50013. * Define the horizontal screen size.
  50014. */
  50015. hScreenSize: number;
  50016. /**
  50017. * Define the vertical screen size.
  50018. */
  50019. vScreenSize: number;
  50020. /**
  50021. * Define the vertical screen center position.
  50022. */
  50023. vScreenCenter: number;
  50024. /**
  50025. * Define the distance of the eyes to the screen.
  50026. */
  50027. eyeToScreenDistance: number;
  50028. /**
  50029. * Define the distance between both lenses
  50030. */
  50031. lensSeparationDistance: number;
  50032. /**
  50033. * Define the distance between both viewer's eyes.
  50034. */
  50035. interpupillaryDistance: number;
  50036. /**
  50037. * Define the distortion factor of the VR postprocess.
  50038. * Please, touch with care.
  50039. */
  50040. distortionK: number[];
  50041. /**
  50042. * Define the chromatic aberration correction factors for the VR post process.
  50043. */
  50044. chromaAbCorrection: number[];
  50045. /**
  50046. * Define the scale factor of the post process.
  50047. * The smaller the better but the slower.
  50048. */
  50049. postProcessScaleFactor: number;
  50050. /**
  50051. * Define an offset for the lens center.
  50052. */
  50053. lensCenterOffset: number;
  50054. /**
  50055. * Define if the current vr camera should compensate the distortion of the lense or not.
  50056. */
  50057. compensateDistortion: boolean;
  50058. /**
  50059. * Defines if multiview should be enabled when rendering (Default: false)
  50060. */
  50061. multiviewEnabled: boolean;
  50062. /**
  50063. * Gets the rendering aspect ratio based on the provided resolutions.
  50064. */
  50065. get aspectRatio(): number;
  50066. /**
  50067. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  50068. */
  50069. get aspectRatioFov(): number;
  50070. /**
  50071. * @hidden
  50072. */
  50073. get leftHMatrix(): Matrix;
  50074. /**
  50075. * @hidden
  50076. */
  50077. get rightHMatrix(): Matrix;
  50078. /**
  50079. * @hidden
  50080. */
  50081. get leftPreViewMatrix(): Matrix;
  50082. /**
  50083. * @hidden
  50084. */
  50085. get rightPreViewMatrix(): Matrix;
  50086. /**
  50087. * Get the default VRMetrics based on the most generic setup.
  50088. * @returns the default vr metrics
  50089. */
  50090. static GetDefault(): VRCameraMetrics;
  50091. }
  50092. }
  50093. declare module BABYLON {
  50094. /** @hidden */
  50095. export var vrDistortionCorrectionPixelShader: {
  50096. name: string;
  50097. shader: string;
  50098. };
  50099. }
  50100. declare module BABYLON {
  50101. /**
  50102. * VRDistortionCorrectionPostProcess used for mobile VR
  50103. */
  50104. export class VRDistortionCorrectionPostProcess extends PostProcess {
  50105. private _isRightEye;
  50106. private _distortionFactors;
  50107. private _postProcessScaleFactor;
  50108. private _lensCenterOffset;
  50109. private _scaleIn;
  50110. private _scaleFactor;
  50111. private _lensCenter;
  50112. /**
  50113. * Gets a string identifying the name of the class
  50114. * @returns "VRDistortionCorrectionPostProcess" string
  50115. */
  50116. getClassName(): string;
  50117. /**
  50118. * Initializes the VRDistortionCorrectionPostProcess
  50119. * @param name The name of the effect.
  50120. * @param camera The camera to apply the render pass to.
  50121. * @param isRightEye If this is for the right eye distortion
  50122. * @param vrMetrics All the required metrics for the VR camera
  50123. */
  50124. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  50125. }
  50126. }
  50127. declare module BABYLON {
  50128. /**
  50129. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  50130. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50131. */
  50132. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  50133. /**
  50134. * Creates a new VRDeviceOrientationArcRotateCamera
  50135. * @param name defines camera name
  50136. * @param alpha defines the camera rotation along the logitudinal axis
  50137. * @param beta defines the camera rotation along the latitudinal axis
  50138. * @param radius defines the camera distance from its target
  50139. * @param target defines the camera target
  50140. * @param scene defines the scene the camera belongs to
  50141. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50142. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50143. */
  50144. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50145. /**
  50146. * Gets camera class name
  50147. * @returns VRDeviceOrientationArcRotateCamera
  50148. */
  50149. getClassName(): string;
  50150. }
  50151. }
  50152. declare module BABYLON {
  50153. /**
  50154. * Camera used to simulate VR rendering (based on FreeCamera)
  50155. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50156. */
  50157. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  50158. /**
  50159. * Creates a new VRDeviceOrientationFreeCamera
  50160. * @param name defines camera name
  50161. * @param position defines the start position of the camera
  50162. * @param scene defines the scene the camera belongs to
  50163. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50164. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50165. */
  50166. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50167. /**
  50168. * Gets camera class name
  50169. * @returns VRDeviceOrientationFreeCamera
  50170. */
  50171. getClassName(): string;
  50172. }
  50173. }
  50174. declare module BABYLON {
  50175. /**
  50176. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  50177. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50178. */
  50179. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  50180. /**
  50181. * Creates a new VRDeviceOrientationGamepadCamera
  50182. * @param name defines camera name
  50183. * @param position defines the start position of the camera
  50184. * @param scene defines the scene the camera belongs to
  50185. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50186. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50187. */
  50188. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50189. /**
  50190. * Gets camera class name
  50191. * @returns VRDeviceOrientationGamepadCamera
  50192. */
  50193. getClassName(): string;
  50194. }
  50195. }
  50196. declare module BABYLON {
  50197. /**
  50198. * A class extending Texture allowing drawing on a texture
  50199. * @see https://doc.babylonjs.com/how_to/dynamictexture
  50200. */
  50201. export class DynamicTexture extends Texture {
  50202. private _generateMipMaps;
  50203. private _canvas;
  50204. private _context;
  50205. /**
  50206. * Creates a DynamicTexture
  50207. * @param name defines the name of the texture
  50208. * @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
  50209. * @param scene defines the scene where you want the texture
  50210. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  50211. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  50212. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  50213. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  50214. */
  50215. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  50216. /**
  50217. * Get the current class name of the texture useful for serialization or dynamic coding.
  50218. * @returns "DynamicTexture"
  50219. */
  50220. getClassName(): string;
  50221. /**
  50222. * Gets the current state of canRescale
  50223. */
  50224. get canRescale(): boolean;
  50225. private _recreate;
  50226. /**
  50227. * Scales the texture
  50228. * @param ratio the scale factor to apply to both width and height
  50229. */
  50230. scale(ratio: number): void;
  50231. /**
  50232. * Resizes the texture
  50233. * @param width the new width
  50234. * @param height the new height
  50235. */
  50236. scaleTo(width: number, height: number): void;
  50237. /**
  50238. * Gets the context of the canvas used by the texture
  50239. * @returns the canvas context of the dynamic texture
  50240. */
  50241. getContext(): CanvasRenderingContext2D;
  50242. /**
  50243. * Clears the texture
  50244. */
  50245. clear(): void;
  50246. /**
  50247. * Updates the texture
  50248. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50249. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  50250. */
  50251. update(invertY?: boolean, premulAlpha?: boolean): void;
  50252. /**
  50253. * Draws text onto the texture
  50254. * @param text defines the text to be drawn
  50255. * @param x defines the placement of the text from the left
  50256. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  50257. * @param font defines the font to be used with font-style, font-size, font-name
  50258. * @param color defines the color used for the text
  50259. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  50260. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50261. * @param update defines whether texture is immediately update (default is true)
  50262. */
  50263. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  50264. /**
  50265. * Clones the texture
  50266. * @returns the clone of the texture.
  50267. */
  50268. clone(): DynamicTexture;
  50269. /**
  50270. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  50271. * @returns a serialized dynamic texture object
  50272. */
  50273. serialize(): any;
  50274. private _IsCanvasElement;
  50275. /** @hidden */
  50276. _rebuild(): void;
  50277. }
  50278. }
  50279. declare module BABYLON {
  50280. /**
  50281. * Class containing static functions to help procedurally build meshes
  50282. */
  50283. export class GroundBuilder {
  50284. /**
  50285. * Creates a ground mesh
  50286. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50287. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50289. * @param name defines the name of the mesh
  50290. * @param options defines the options used to create the mesh
  50291. * @param scene defines the hosting scene
  50292. * @returns the ground mesh
  50293. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50294. */
  50295. static CreateGround(name: string, options: {
  50296. width?: number;
  50297. height?: number;
  50298. subdivisions?: number;
  50299. subdivisionsX?: number;
  50300. subdivisionsY?: number;
  50301. updatable?: boolean;
  50302. }, scene: any): Mesh;
  50303. /**
  50304. * Creates a tiled ground mesh
  50305. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50306. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50307. * * 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
  50308. * * 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
  50309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50310. * @param name defines the name of the mesh
  50311. * @param options defines the options used to create the mesh
  50312. * @param scene defines the hosting scene
  50313. * @returns the tiled ground mesh
  50314. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50315. */
  50316. static CreateTiledGround(name: string, options: {
  50317. xmin: number;
  50318. zmin: number;
  50319. xmax: number;
  50320. zmax: number;
  50321. subdivisions?: {
  50322. w: number;
  50323. h: number;
  50324. };
  50325. precision?: {
  50326. w: number;
  50327. h: number;
  50328. };
  50329. updatable?: boolean;
  50330. }, scene?: Nullable<Scene>): Mesh;
  50331. /**
  50332. * Creates a ground mesh from a height map
  50333. * * The parameter `url` sets the URL of the height map image resource.
  50334. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50335. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50336. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50337. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50338. * * 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.
  50339. * * 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).
  50340. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50342. * @param name defines the name of the mesh
  50343. * @param url defines the url to the height map
  50344. * @param options defines the options used to create the mesh
  50345. * @param scene defines the hosting scene
  50346. * @returns the ground mesh
  50347. * @see https://doc.babylonjs.com/babylon101/height_map
  50348. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50349. */
  50350. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50351. width?: number;
  50352. height?: number;
  50353. subdivisions?: number;
  50354. minHeight?: number;
  50355. maxHeight?: number;
  50356. colorFilter?: Color3;
  50357. alphaFilter?: number;
  50358. updatable?: boolean;
  50359. onReady?: (mesh: GroundMesh) => void;
  50360. }, scene?: Nullable<Scene>): GroundMesh;
  50361. }
  50362. }
  50363. declare module BABYLON {
  50364. /**
  50365. * Class containing static functions to help procedurally build meshes
  50366. */
  50367. export class TorusBuilder {
  50368. /**
  50369. * Creates a torus mesh
  50370. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50371. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50372. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50374. * * 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
  50375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50376. * @param name defines the name of the mesh
  50377. * @param options defines the options used to create the mesh
  50378. * @param scene defines the hosting scene
  50379. * @returns the torus mesh
  50380. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50381. */
  50382. static CreateTorus(name: string, options: {
  50383. diameter?: number;
  50384. thickness?: number;
  50385. tessellation?: number;
  50386. updatable?: boolean;
  50387. sideOrientation?: number;
  50388. frontUVs?: Vector4;
  50389. backUVs?: Vector4;
  50390. }, scene: any): Mesh;
  50391. }
  50392. }
  50393. declare module BABYLON {
  50394. /**
  50395. * Class containing static functions to help procedurally build meshes
  50396. */
  50397. export class CylinderBuilder {
  50398. /**
  50399. * Creates a cylinder or a cone mesh
  50400. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50401. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50402. * * 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.
  50403. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50404. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50405. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50406. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50407. * * 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).
  50408. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50409. * * 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).
  50410. * * 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
  50411. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50412. * * 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
  50413. * * 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.
  50414. * * If `enclose` is false, a ring surface is one element.
  50415. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50416. * * 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
  50417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50418. * * 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
  50419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50420. * @param name defines the name of the mesh
  50421. * @param options defines the options used to create the mesh
  50422. * @param scene defines the hosting scene
  50423. * @returns the cylinder mesh
  50424. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50425. */
  50426. static CreateCylinder(name: string, options: {
  50427. height?: number;
  50428. diameterTop?: number;
  50429. diameterBottom?: number;
  50430. diameter?: number;
  50431. tessellation?: number;
  50432. subdivisions?: number;
  50433. arc?: number;
  50434. faceColors?: Color4[];
  50435. faceUV?: Vector4[];
  50436. updatable?: boolean;
  50437. hasRings?: boolean;
  50438. enclose?: boolean;
  50439. cap?: number;
  50440. sideOrientation?: number;
  50441. frontUVs?: Vector4;
  50442. backUVs?: Vector4;
  50443. }, scene: any): Mesh;
  50444. }
  50445. }
  50446. declare module BABYLON {
  50447. /**
  50448. * States of the webXR experience
  50449. */
  50450. export enum WebXRState {
  50451. /**
  50452. * Transitioning to being in XR mode
  50453. */
  50454. ENTERING_XR = 0,
  50455. /**
  50456. * Transitioning to non XR mode
  50457. */
  50458. EXITING_XR = 1,
  50459. /**
  50460. * In XR mode and presenting
  50461. */
  50462. IN_XR = 2,
  50463. /**
  50464. * Not entered XR mode
  50465. */
  50466. NOT_IN_XR = 3
  50467. }
  50468. /**
  50469. * The state of the XR camera's tracking
  50470. */
  50471. export enum WebXRTrackingState {
  50472. /**
  50473. * No transformation received, device is not being tracked
  50474. */
  50475. NOT_TRACKING = 0,
  50476. /**
  50477. * Tracking lost - using emulated position
  50478. */
  50479. TRACKING_LOST = 1,
  50480. /**
  50481. * Transformation tracking works normally
  50482. */
  50483. TRACKING = 2
  50484. }
  50485. /**
  50486. * Abstraction of the XR render target
  50487. */
  50488. export interface WebXRRenderTarget extends IDisposable {
  50489. /**
  50490. * xrpresent context of the canvas which can be used to display/mirror xr content
  50491. */
  50492. canvasContext: WebGLRenderingContext;
  50493. /**
  50494. * xr layer for the canvas
  50495. */
  50496. xrLayer: Nullable<XRWebGLLayer>;
  50497. /**
  50498. * Initializes the xr layer for the session
  50499. * @param xrSession xr session
  50500. * @returns a promise that will resolve once the XR Layer has been created
  50501. */
  50502. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50503. }
  50504. }
  50505. declare module BABYLON {
  50506. /**
  50507. * COnfiguration object for WebXR output canvas
  50508. */
  50509. export class WebXRManagedOutputCanvasOptions {
  50510. /**
  50511. * An optional canvas in case you wish to create it yourself and provide it here.
  50512. * If not provided, a new canvas will be created
  50513. */
  50514. canvasElement?: HTMLCanvasElement;
  50515. /**
  50516. * Options for this XR Layer output
  50517. */
  50518. canvasOptions?: XRWebGLLayerInit;
  50519. /**
  50520. * CSS styling for a newly created canvas (if not provided)
  50521. */
  50522. newCanvasCssStyle?: string;
  50523. /**
  50524. * Get the default values of the configuration object
  50525. * @param engine defines the engine to use (can be null)
  50526. * @returns default values of this configuration object
  50527. */
  50528. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  50529. }
  50530. /**
  50531. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  50532. */
  50533. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  50534. private _options;
  50535. private _canvas;
  50536. private _engine;
  50537. private _originalCanvasSize;
  50538. /**
  50539. * Rendering context of the canvas which can be used to display/mirror xr content
  50540. */
  50541. canvasContext: WebGLRenderingContext;
  50542. /**
  50543. * xr layer for the canvas
  50544. */
  50545. xrLayer: Nullable<XRWebGLLayer>;
  50546. /**
  50547. * Obseervers registered here will be triggered when the xr layer was initialized
  50548. */
  50549. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  50550. /**
  50551. * Initializes the canvas to be added/removed upon entering/exiting xr
  50552. * @param _xrSessionManager The XR Session manager
  50553. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  50554. */
  50555. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  50556. /**
  50557. * Disposes of the object
  50558. */
  50559. dispose(): void;
  50560. /**
  50561. * Initializes the xr layer for the session
  50562. * @param xrSession xr session
  50563. * @returns a promise that will resolve once the XR Layer has been created
  50564. */
  50565. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50566. private _addCanvas;
  50567. private _removeCanvas;
  50568. private _setCanvasSize;
  50569. private _setManagedOutputCanvas;
  50570. }
  50571. }
  50572. declare module BABYLON {
  50573. /**
  50574. * Manages an XRSession to work with Babylon's engine
  50575. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50576. */
  50577. export class WebXRSessionManager implements IDisposable {
  50578. /** The scene which the session should be created for */
  50579. scene: Scene;
  50580. private _referenceSpace;
  50581. private _rttProvider;
  50582. private _sessionEnded;
  50583. private _xrNavigator;
  50584. private baseLayer;
  50585. /**
  50586. * The base reference space from which the session started. good if you want to reset your
  50587. * reference space
  50588. */
  50589. baseReferenceSpace: XRReferenceSpace;
  50590. /**
  50591. * Current XR frame
  50592. */
  50593. currentFrame: Nullable<XRFrame>;
  50594. /** WebXR timestamp updated every frame */
  50595. currentTimestamp: number;
  50596. /**
  50597. * Used just in case of a failure to initialize an immersive session.
  50598. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50599. */
  50600. defaultHeightCompensation: number;
  50601. /**
  50602. * Fires every time a new xrFrame arrives which can be used to update the camera
  50603. */
  50604. onXRFrameObservable: Observable<XRFrame>;
  50605. /**
  50606. * Fires when the reference space changed
  50607. */
  50608. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50609. /**
  50610. * Fires when the xr session is ended either by the device or manually done
  50611. */
  50612. onXRSessionEnded: Observable<any>;
  50613. /**
  50614. * Fires when the xr session is ended either by the device or manually done
  50615. */
  50616. onXRSessionInit: Observable<XRSession>;
  50617. /**
  50618. * Underlying xr session
  50619. */
  50620. session: XRSession;
  50621. /**
  50622. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50623. * or get the offset the player is currently at.
  50624. */
  50625. viewerReferenceSpace: XRReferenceSpace;
  50626. /**
  50627. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50628. * @param scene The scene which the session should be created for
  50629. */
  50630. constructor(
  50631. /** The scene which the session should be created for */
  50632. scene: Scene);
  50633. /**
  50634. * The current reference space used in this session. This reference space can constantly change!
  50635. * It is mainly used to offset the camera's position.
  50636. */
  50637. get referenceSpace(): XRReferenceSpace;
  50638. /**
  50639. * Set a new reference space and triggers the observable
  50640. */
  50641. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50642. /**
  50643. * Disposes of the session manager
  50644. */
  50645. dispose(): void;
  50646. /**
  50647. * Stops the xrSession and restores the render loop
  50648. * @returns Promise which resolves after it exits XR
  50649. */
  50650. exitXRAsync(): Promise<void>;
  50651. /**
  50652. * Gets the correct render target texture to be rendered this frame for this eye
  50653. * @param eye the eye for which to get the render target
  50654. * @returns the render target for the specified eye
  50655. */
  50656. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50657. /**
  50658. * Creates a WebXRRenderTarget object for the XR session
  50659. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50660. * @param options optional options to provide when creating a new render target
  50661. * @returns a WebXR render target to which the session can render
  50662. */
  50663. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50664. /**
  50665. * Initializes the manager
  50666. * After initialization enterXR can be called to start an XR session
  50667. * @returns Promise which resolves after it is initialized
  50668. */
  50669. initializeAsync(): Promise<void>;
  50670. /**
  50671. * Initializes an xr session
  50672. * @param xrSessionMode mode to initialize
  50673. * @param xrSessionInit defines optional and required values to pass to the session builder
  50674. * @returns a promise which will resolve once the session has been initialized
  50675. */
  50676. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50677. /**
  50678. * Checks if a session would be supported for the creation options specified
  50679. * @param sessionMode session mode to check if supported eg. immersive-vr
  50680. * @returns A Promise that resolves to true if supported and false if not
  50681. */
  50682. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50683. /**
  50684. * Resets the reference space to the one started the session
  50685. */
  50686. resetReferenceSpace(): void;
  50687. /**
  50688. * Starts rendering to the xr layer
  50689. */
  50690. runXRRenderLoop(): void;
  50691. /**
  50692. * Sets the reference space on the xr session
  50693. * @param referenceSpaceType space to set
  50694. * @returns a promise that will resolve once the reference space has been set
  50695. */
  50696. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50697. /**
  50698. * Updates the render state of the session
  50699. * @param state state to set
  50700. * @returns a promise that resolves once the render state has been updated
  50701. */
  50702. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50703. /**
  50704. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50705. * @param sessionMode defines the session to test
  50706. * @returns a promise with boolean as final value
  50707. */
  50708. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50709. private _createRenderTargetTexture;
  50710. }
  50711. }
  50712. declare module BABYLON {
  50713. /**
  50714. * WebXR Camera which holds the views for the xrSession
  50715. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50716. */
  50717. export class WebXRCamera extends FreeCamera {
  50718. private _xrSessionManager;
  50719. private _firstFrame;
  50720. private _referenceQuaternion;
  50721. private _referencedPosition;
  50722. private _xrInvPositionCache;
  50723. private _xrInvQuaternionCache;
  50724. private _trackingState;
  50725. /**
  50726. * Observable raised before camera teleportation
  50727. */
  50728. onBeforeCameraTeleport: Observable<Vector3>;
  50729. /**
  50730. * Observable raised after camera teleportation
  50731. */
  50732. onAfterCameraTeleport: Observable<Vector3>;
  50733. /**
  50734. * Notifies when the camera's tracking state has changed.
  50735. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50736. */
  50737. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50738. /**
  50739. * Should position compensation execute on first frame.
  50740. * This is used when copying the position from a native (non XR) camera
  50741. */
  50742. compensateOnFirstFrame: boolean;
  50743. /**
  50744. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50745. * @param name the name of the camera
  50746. * @param scene the scene to add the camera to
  50747. * @param _xrSessionManager a constructed xr session manager
  50748. */
  50749. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50750. /**
  50751. * Get the current XR tracking state of the camera
  50752. */
  50753. get trackingState(): WebXRTrackingState;
  50754. private _setTrackingState;
  50755. /**
  50756. * Return the user's height, unrelated to the current ground.
  50757. * This will be the y position of this camera, when ground level is 0.
  50758. */
  50759. get realWorldHeight(): number;
  50760. /** @hidden */
  50761. _updateForDualEyeDebugging(): void;
  50762. /**
  50763. * Sets this camera's transformation based on a non-vr camera
  50764. * @param otherCamera the non-vr camera to copy the transformation from
  50765. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50766. */
  50767. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50768. /**
  50769. * Gets the current instance class name ("WebXRCamera").
  50770. * @returns the class name
  50771. */
  50772. getClassName(): string;
  50773. private _rotate180;
  50774. private _updateFromXRSession;
  50775. private _updateNumberOfRigCameras;
  50776. private _updateReferenceSpace;
  50777. private _updateReferenceSpaceOffset;
  50778. }
  50779. }
  50780. declare module BABYLON {
  50781. /**
  50782. * Defining the interface required for a (webxr) feature
  50783. */
  50784. export interface IWebXRFeature extends IDisposable {
  50785. /**
  50786. * Is this feature attached
  50787. */
  50788. attached: boolean;
  50789. /**
  50790. * Should auto-attach be disabled?
  50791. */
  50792. disableAutoAttach: boolean;
  50793. /**
  50794. * Attach the feature to the session
  50795. * Will usually be called by the features manager
  50796. *
  50797. * @param force should attachment be forced (even when already attached)
  50798. * @returns true if successful.
  50799. */
  50800. attach(force?: boolean): boolean;
  50801. /**
  50802. * Detach the feature from the session
  50803. * Will usually be called by the features manager
  50804. *
  50805. * @returns true if successful.
  50806. */
  50807. detach(): boolean;
  50808. /**
  50809. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50810. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50811. *
  50812. * @returns whether or not the feature is compatible in this environment
  50813. */
  50814. isCompatible(): boolean;
  50815. /**
  50816. * Was this feature disposed;
  50817. */
  50818. isDisposed: boolean;
  50819. /**
  50820. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50821. */
  50822. xrNativeFeatureName?: string;
  50823. /**
  50824. * A list of (Babylon WebXR) features this feature depends on
  50825. */
  50826. dependsOn?: string[];
  50827. }
  50828. /**
  50829. * A list of the currently available features without referencing them
  50830. */
  50831. export class WebXRFeatureName {
  50832. /**
  50833. * The name of the anchor system feature
  50834. */
  50835. static readonly ANCHOR_SYSTEM: string;
  50836. /**
  50837. * The name of the background remover feature
  50838. */
  50839. static readonly BACKGROUND_REMOVER: string;
  50840. /**
  50841. * The name of the hit test feature
  50842. */
  50843. static readonly HIT_TEST: string;
  50844. /**
  50845. * physics impostors for xr controllers feature
  50846. */
  50847. static readonly PHYSICS_CONTROLLERS: string;
  50848. /**
  50849. * The name of the plane detection feature
  50850. */
  50851. static readonly PLANE_DETECTION: string;
  50852. /**
  50853. * The name of the pointer selection feature
  50854. */
  50855. static readonly POINTER_SELECTION: string;
  50856. /**
  50857. * The name of the teleportation feature
  50858. */
  50859. static readonly TELEPORTATION: string;
  50860. /**
  50861. * The name of the feature points feature.
  50862. */
  50863. static readonly FEATURE_POINTS: string;
  50864. /**
  50865. * The name of the hand tracking feature.
  50866. */
  50867. static readonly HAND_TRACKING: string;
  50868. }
  50869. /**
  50870. * Defining the constructor of a feature. Used to register the modules.
  50871. */
  50872. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50873. /**
  50874. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50875. * It is mainly used in AR sessions.
  50876. *
  50877. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50878. */
  50879. export class WebXRFeaturesManager implements IDisposable {
  50880. private _xrSessionManager;
  50881. private static readonly _AvailableFeatures;
  50882. private _features;
  50883. /**
  50884. * constructs a new features manages.
  50885. *
  50886. * @param _xrSessionManager an instance of WebXRSessionManager
  50887. */
  50888. constructor(_xrSessionManager: WebXRSessionManager);
  50889. /**
  50890. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50891. * Mainly used internally.
  50892. *
  50893. * @param featureName the name of the feature to register
  50894. * @param constructorFunction the function used to construct the module
  50895. * @param version the (babylon) version of the module
  50896. * @param stable is that a stable version of this module
  50897. */
  50898. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50899. /**
  50900. * Returns a constructor of a specific feature.
  50901. *
  50902. * @param featureName the name of the feature to construct
  50903. * @param version the version of the feature to load
  50904. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50905. * @param options optional options provided to the module.
  50906. * @returns a function that, when called, will return a new instance of this feature
  50907. */
  50908. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50909. /**
  50910. * Can be used to return the list of features currently registered
  50911. *
  50912. * @returns an Array of available features
  50913. */
  50914. static GetAvailableFeatures(): string[];
  50915. /**
  50916. * Gets the versions available for a specific feature
  50917. * @param featureName the name of the feature
  50918. * @returns an array with the available versions
  50919. */
  50920. static GetAvailableVersions(featureName: string): string[];
  50921. /**
  50922. * Return the latest unstable version of this feature
  50923. * @param featureName the name of the feature to search
  50924. * @returns the version number. if not found will return -1
  50925. */
  50926. static GetLatestVersionOfFeature(featureName: string): number;
  50927. /**
  50928. * Return the latest stable version of this feature
  50929. * @param featureName the name of the feature to search
  50930. * @returns the version number. if not found will return -1
  50931. */
  50932. static GetStableVersionOfFeature(featureName: string): number;
  50933. /**
  50934. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50935. * Can be used during a session to start a feature
  50936. * @param featureName the name of feature to attach
  50937. */
  50938. attachFeature(featureName: string): void;
  50939. /**
  50940. * Can be used inside a session or when the session ends to detach a specific feature
  50941. * @param featureName the name of the feature to detach
  50942. */
  50943. detachFeature(featureName: string): void;
  50944. /**
  50945. * Used to disable an already-enabled feature
  50946. * The feature will be disposed and will be recreated once enabled.
  50947. * @param featureName the feature to disable
  50948. * @returns true if disable was successful
  50949. */
  50950. disableFeature(featureName: string | {
  50951. Name: string;
  50952. }): boolean;
  50953. /**
  50954. * dispose this features manager
  50955. */
  50956. dispose(): void;
  50957. /**
  50958. * 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.
  50959. * 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.
  50960. *
  50961. * @param featureName the name of the feature to load or the class of the feature
  50962. * @param version optional version to load. if not provided the latest version will be enabled
  50963. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50964. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50965. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50966. * @returns a new constructed feature or throws an error if feature not found.
  50967. */
  50968. enableFeature(featureName: string | {
  50969. Name: string;
  50970. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50971. /**
  50972. * get the implementation of an enabled feature.
  50973. * @param featureName the name of the feature to load
  50974. * @returns the feature class, if found
  50975. */
  50976. getEnabledFeature(featureName: string): IWebXRFeature;
  50977. /**
  50978. * Get the list of enabled features
  50979. * @returns an array of enabled features
  50980. */
  50981. getEnabledFeatures(): string[];
  50982. /**
  50983. * This function will exten the session creation configuration object with enabled features.
  50984. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50985. * according to the defined "required" variable, provided during enableFeature call
  50986. * @param xrSessionInit the xr Session init object to extend
  50987. *
  50988. * @returns an extended XRSessionInit object
  50989. */
  50990. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50991. }
  50992. }
  50993. declare module BABYLON {
  50994. /**
  50995. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50996. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50997. */
  50998. export class WebXRExperienceHelper implements IDisposable {
  50999. private scene;
  51000. private _nonVRCamera;
  51001. private _originalSceneAutoClear;
  51002. private _supported;
  51003. /**
  51004. * Camera used to render xr content
  51005. */
  51006. camera: WebXRCamera;
  51007. /** A features manager for this xr session */
  51008. featuresManager: WebXRFeaturesManager;
  51009. /**
  51010. * Observers registered here will be triggered after the camera's initial transformation is set
  51011. * This can be used to set a different ground level or an extra rotation.
  51012. *
  51013. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  51014. * to the position set after this observable is done executing.
  51015. */
  51016. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  51017. /**
  51018. * Fires when the state of the experience helper has changed
  51019. */
  51020. onStateChangedObservable: Observable<WebXRState>;
  51021. /** Session manager used to keep track of xr session */
  51022. sessionManager: WebXRSessionManager;
  51023. /**
  51024. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  51025. */
  51026. state: WebXRState;
  51027. /**
  51028. * Creates a WebXRExperienceHelper
  51029. * @param scene The scene the helper should be created in
  51030. */
  51031. private constructor();
  51032. /**
  51033. * Creates the experience helper
  51034. * @param scene the scene to attach the experience helper to
  51035. * @returns a promise for the experience helper
  51036. */
  51037. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  51038. /**
  51039. * Disposes of the experience helper
  51040. */
  51041. dispose(): void;
  51042. /**
  51043. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  51044. * @param sessionMode options for the XR session
  51045. * @param referenceSpaceType frame of reference of the XR session
  51046. * @param renderTarget the output canvas that will be used to enter XR mode
  51047. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  51048. * @returns promise that resolves after xr mode has entered
  51049. */
  51050. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  51051. /**
  51052. * Exits XR mode and returns the scene to its original state
  51053. * @returns promise that resolves after xr mode has exited
  51054. */
  51055. exitXRAsync(): Promise<void>;
  51056. private _nonXRToXRCamera;
  51057. private _setState;
  51058. }
  51059. }
  51060. declare module BABYLON {
  51061. /**
  51062. * X-Y values for axes in WebXR
  51063. */
  51064. export interface IWebXRMotionControllerAxesValue {
  51065. /**
  51066. * The value of the x axis
  51067. */
  51068. x: number;
  51069. /**
  51070. * The value of the y-axis
  51071. */
  51072. y: number;
  51073. }
  51074. /**
  51075. * changed / previous values for the values of this component
  51076. */
  51077. export interface IWebXRMotionControllerComponentChangesValues<T> {
  51078. /**
  51079. * current (this frame) value
  51080. */
  51081. current: T;
  51082. /**
  51083. * previous (last change) value
  51084. */
  51085. previous: T;
  51086. }
  51087. /**
  51088. * Represents changes in the component between current frame and last values recorded
  51089. */
  51090. export interface IWebXRMotionControllerComponentChanges {
  51091. /**
  51092. * will be populated with previous and current values if axes changed
  51093. */
  51094. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  51095. /**
  51096. * will be populated with previous and current values if pressed changed
  51097. */
  51098. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51099. /**
  51100. * will be populated with previous and current values if touched changed
  51101. */
  51102. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51103. /**
  51104. * will be populated with previous and current values if value changed
  51105. */
  51106. value?: IWebXRMotionControllerComponentChangesValues<number>;
  51107. }
  51108. /**
  51109. * This class represents a single component (for example button or thumbstick) of a motion controller
  51110. */
  51111. export class WebXRControllerComponent implements IDisposable {
  51112. /**
  51113. * the id of this component
  51114. */
  51115. id: string;
  51116. /**
  51117. * the type of the component
  51118. */
  51119. type: MotionControllerComponentType;
  51120. private _buttonIndex;
  51121. private _axesIndices;
  51122. private _axes;
  51123. private _changes;
  51124. private _currentValue;
  51125. private _hasChanges;
  51126. private _pressed;
  51127. private _touched;
  51128. /**
  51129. * button component type
  51130. */
  51131. static BUTTON_TYPE: MotionControllerComponentType;
  51132. /**
  51133. * squeeze component type
  51134. */
  51135. static SQUEEZE_TYPE: MotionControllerComponentType;
  51136. /**
  51137. * Thumbstick component type
  51138. */
  51139. static THUMBSTICK_TYPE: MotionControllerComponentType;
  51140. /**
  51141. * Touchpad component type
  51142. */
  51143. static TOUCHPAD_TYPE: MotionControllerComponentType;
  51144. /**
  51145. * trigger component type
  51146. */
  51147. static TRIGGER_TYPE: MotionControllerComponentType;
  51148. /**
  51149. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  51150. * the axes data changes
  51151. */
  51152. onAxisValueChangedObservable: Observable<{
  51153. x: number;
  51154. y: number;
  51155. }>;
  51156. /**
  51157. * Observers registered here will be triggered when the state of a button changes
  51158. * State change is either pressed / touched / value
  51159. */
  51160. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  51161. /**
  51162. * Creates a new component for a motion controller.
  51163. * It is created by the motion controller itself
  51164. *
  51165. * @param id the id of this component
  51166. * @param type the type of the component
  51167. * @param _buttonIndex index in the buttons array of the gamepad
  51168. * @param _axesIndices indices of the values in the axes array of the gamepad
  51169. */
  51170. constructor(
  51171. /**
  51172. * the id of this component
  51173. */
  51174. id: string,
  51175. /**
  51176. * the type of the component
  51177. */
  51178. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  51179. /**
  51180. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  51181. */
  51182. get axes(): IWebXRMotionControllerAxesValue;
  51183. /**
  51184. * Get the changes. Elements will be populated only if they changed with their previous and current value
  51185. */
  51186. get changes(): IWebXRMotionControllerComponentChanges;
  51187. /**
  51188. * Return whether or not the component changed the last frame
  51189. */
  51190. get hasChanges(): boolean;
  51191. /**
  51192. * is the button currently pressed
  51193. */
  51194. get pressed(): boolean;
  51195. /**
  51196. * is the button currently touched
  51197. */
  51198. get touched(): boolean;
  51199. /**
  51200. * Get the current value of this component
  51201. */
  51202. get value(): number;
  51203. /**
  51204. * Dispose this component
  51205. */
  51206. dispose(): void;
  51207. /**
  51208. * Are there axes correlating to this component
  51209. * @return true is axes data is available
  51210. */
  51211. isAxes(): boolean;
  51212. /**
  51213. * Is this component a button (hence - pressable)
  51214. * @returns true if can be pressed
  51215. */
  51216. isButton(): boolean;
  51217. /**
  51218. * update this component using the gamepad object it is in. Called on every frame
  51219. * @param nativeController the native gamepad controller object
  51220. */
  51221. update(nativeController: IMinimalMotionControllerObject): void;
  51222. }
  51223. }
  51224. declare module BABYLON {
  51225. /**
  51226. * Type used for the success callback of ImportMesh
  51227. */
  51228. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  51229. /**
  51230. * Interface used for the result of ImportMeshAsync
  51231. */
  51232. export interface ISceneLoaderAsyncResult {
  51233. /**
  51234. * The array of loaded meshes
  51235. */
  51236. readonly meshes: AbstractMesh[];
  51237. /**
  51238. * The array of loaded particle systems
  51239. */
  51240. readonly particleSystems: IParticleSystem[];
  51241. /**
  51242. * The array of loaded skeletons
  51243. */
  51244. readonly skeletons: Skeleton[];
  51245. /**
  51246. * The array of loaded animation groups
  51247. */
  51248. readonly animationGroups: AnimationGroup[];
  51249. /**
  51250. * The array of loaded transform nodes
  51251. */
  51252. readonly transformNodes: TransformNode[];
  51253. /**
  51254. * The array of loaded geometries
  51255. */
  51256. readonly geometries: Geometry[];
  51257. /**
  51258. * The array of loaded lights
  51259. */
  51260. readonly lights: Light[];
  51261. }
  51262. /**
  51263. * Interface used to represent data loading progression
  51264. */
  51265. export interface ISceneLoaderProgressEvent {
  51266. /**
  51267. * Defines if data length to load can be evaluated
  51268. */
  51269. readonly lengthComputable: boolean;
  51270. /**
  51271. * Defines the loaded data length
  51272. */
  51273. readonly loaded: number;
  51274. /**
  51275. * Defines the data length to load
  51276. */
  51277. readonly total: number;
  51278. }
  51279. /**
  51280. * Interface used by SceneLoader plugins to define supported file extensions
  51281. */
  51282. export interface ISceneLoaderPluginExtensions {
  51283. /**
  51284. * Defines the list of supported extensions
  51285. */
  51286. [extension: string]: {
  51287. isBinary: boolean;
  51288. };
  51289. }
  51290. /**
  51291. * Interface used by SceneLoader plugin factory
  51292. */
  51293. export interface ISceneLoaderPluginFactory {
  51294. /**
  51295. * Defines the name of the factory
  51296. */
  51297. name: string;
  51298. /**
  51299. * Function called to create a new plugin
  51300. * @return the new plugin
  51301. */
  51302. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  51303. /**
  51304. * The callback that returns true if the data can be directly loaded.
  51305. * @param data string containing the file data
  51306. * @returns if the data can be loaded directly
  51307. */
  51308. canDirectLoad?(data: string): boolean;
  51309. }
  51310. /**
  51311. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  51312. */
  51313. export interface ISceneLoaderPluginBase {
  51314. /**
  51315. * The friendly name of this plugin.
  51316. */
  51317. name: string;
  51318. /**
  51319. * The file extensions supported by this plugin.
  51320. */
  51321. extensions: string | ISceneLoaderPluginExtensions;
  51322. /**
  51323. * The callback called when loading from a url.
  51324. * @param scene scene loading this url
  51325. * @param url url to load
  51326. * @param onSuccess callback called when the file successfully loads
  51327. * @param onProgress callback called while file is loading (if the server supports this mode)
  51328. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  51329. * @param onError callback called when the file fails to load
  51330. * @returns a file request object
  51331. */
  51332. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51333. /**
  51334. * The callback called when loading from a file object.
  51335. * @param scene scene loading this file
  51336. * @param file defines the file to load
  51337. * @param onSuccess defines the callback to call when data is loaded
  51338. * @param onProgress defines the callback to call during loading process
  51339. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  51340. * @param onError defines the callback to call when an error occurs
  51341. * @returns a file request object
  51342. */
  51343. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51344. /**
  51345. * The callback that returns true if the data can be directly loaded.
  51346. * @param data string containing the file data
  51347. * @returns if the data can be loaded directly
  51348. */
  51349. canDirectLoad?(data: string): boolean;
  51350. /**
  51351. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  51352. * @param scene scene loading this data
  51353. * @param data string containing the data
  51354. * @returns data to pass to the plugin
  51355. */
  51356. directLoad?(scene: Scene, data: string): any;
  51357. /**
  51358. * The callback that allows custom handling of the root url based on the response url.
  51359. * @param rootUrl the original root url
  51360. * @param responseURL the response url if available
  51361. * @returns the new root url
  51362. */
  51363. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  51364. }
  51365. /**
  51366. * Interface used to define a SceneLoader plugin
  51367. */
  51368. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  51369. /**
  51370. * Import meshes into a scene.
  51371. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51372. * @param scene The scene to import into
  51373. * @param data The data to import
  51374. * @param rootUrl The root url for scene and resources
  51375. * @param meshes The meshes array to import into
  51376. * @param particleSystems The particle systems array to import into
  51377. * @param skeletons The skeletons array to import into
  51378. * @param onError The callback when import fails
  51379. * @returns True if successful or false otherwise
  51380. */
  51381. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  51382. /**
  51383. * Load into a scene.
  51384. * @param scene The scene to load into
  51385. * @param data The data to import
  51386. * @param rootUrl The root url for scene and resources
  51387. * @param onError The callback when import fails
  51388. * @returns True if successful or false otherwise
  51389. */
  51390. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  51391. /**
  51392. * Load into an asset container.
  51393. * @param scene The scene to load into
  51394. * @param data The data to import
  51395. * @param rootUrl The root url for scene and resources
  51396. * @param onError The callback when import fails
  51397. * @returns The loaded asset container
  51398. */
  51399. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  51400. }
  51401. /**
  51402. * Interface used to define an async SceneLoader plugin
  51403. */
  51404. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  51405. /**
  51406. * Import meshes into a scene.
  51407. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51408. * @param scene The scene to import into
  51409. * @param data The data to import
  51410. * @param rootUrl The root url for scene and resources
  51411. * @param onProgress The callback when the load progresses
  51412. * @param fileName Defines the name of the file to load
  51413. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  51414. */
  51415. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  51416. /**
  51417. * Load into a scene.
  51418. * @param scene The scene to load into
  51419. * @param data The data to import
  51420. * @param rootUrl The root url for scene and resources
  51421. * @param onProgress The callback when the load progresses
  51422. * @param fileName Defines the name of the file to load
  51423. * @returns Nothing
  51424. */
  51425. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51426. /**
  51427. * Load into an asset container.
  51428. * @param scene The scene to load into
  51429. * @param data The data to import
  51430. * @param rootUrl The root url for scene and resources
  51431. * @param onProgress The callback when the load progresses
  51432. * @param fileName Defines the name of the file to load
  51433. * @returns The loaded asset container
  51434. */
  51435. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51436. }
  51437. /**
  51438. * Mode that determines how to handle old animation groups before loading new ones.
  51439. */
  51440. export enum SceneLoaderAnimationGroupLoadingMode {
  51441. /**
  51442. * Reset all old animations to initial state then dispose them.
  51443. */
  51444. Clean = 0,
  51445. /**
  51446. * Stop all old animations.
  51447. */
  51448. Stop = 1,
  51449. /**
  51450. * Restart old animations from first frame.
  51451. */
  51452. Sync = 2,
  51453. /**
  51454. * Old animations remains untouched.
  51455. */
  51456. NoSync = 3
  51457. }
  51458. /**
  51459. * Defines a plugin registered by the SceneLoader
  51460. */
  51461. interface IRegisteredPlugin {
  51462. /**
  51463. * Defines the plugin to use
  51464. */
  51465. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51466. /**
  51467. * Defines if the plugin supports binary data
  51468. */
  51469. isBinary: boolean;
  51470. }
  51471. /**
  51472. * Class used to load scene from various file formats using registered plugins
  51473. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  51474. */
  51475. export class SceneLoader {
  51476. /**
  51477. * No logging while loading
  51478. */
  51479. static readonly NO_LOGGING: number;
  51480. /**
  51481. * Minimal logging while loading
  51482. */
  51483. static readonly MINIMAL_LOGGING: number;
  51484. /**
  51485. * Summary logging while loading
  51486. */
  51487. static readonly SUMMARY_LOGGING: number;
  51488. /**
  51489. * Detailled logging while loading
  51490. */
  51491. static readonly DETAILED_LOGGING: number;
  51492. /**
  51493. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51494. */
  51495. static get ForceFullSceneLoadingForIncremental(): boolean;
  51496. static set ForceFullSceneLoadingForIncremental(value: boolean);
  51497. /**
  51498. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51499. */
  51500. static get ShowLoadingScreen(): boolean;
  51501. static set ShowLoadingScreen(value: boolean);
  51502. /**
  51503. * Defines the current logging level (while loading the scene)
  51504. * @ignorenaming
  51505. */
  51506. static get loggingLevel(): number;
  51507. static set loggingLevel(value: number);
  51508. /**
  51509. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51510. */
  51511. static get CleanBoneMatrixWeights(): boolean;
  51512. static set CleanBoneMatrixWeights(value: boolean);
  51513. /**
  51514. * Event raised when a plugin is used to load a scene
  51515. */
  51516. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51517. private static _registeredPlugins;
  51518. private static _showingLoadingScreen;
  51519. /**
  51520. * Gets the default plugin (used to load Babylon files)
  51521. * @returns the .babylon plugin
  51522. */
  51523. static GetDefaultPlugin(): IRegisteredPlugin;
  51524. private static _GetPluginForExtension;
  51525. private static _GetPluginForDirectLoad;
  51526. private static _GetPluginForFilename;
  51527. private static _GetDirectLoad;
  51528. private static _LoadData;
  51529. private static _GetFileInfo;
  51530. /**
  51531. * Gets a plugin that can load the given extension
  51532. * @param extension defines the extension to load
  51533. * @returns a plugin or null if none works
  51534. */
  51535. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51536. /**
  51537. * Gets a boolean indicating that the given extension can be loaded
  51538. * @param extension defines the extension to load
  51539. * @returns true if the extension is supported
  51540. */
  51541. static IsPluginForExtensionAvailable(extension: string): boolean;
  51542. /**
  51543. * Adds a new plugin to the list of registered plugins
  51544. * @param plugin defines the plugin to add
  51545. */
  51546. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  51547. /**
  51548. * Import meshes into a scene
  51549. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51550. * @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)
  51551. * @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)
  51552. * @param scene the instance of BABYLON.Scene to append to
  51553. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  51554. * @param onProgress a callback with a progress event for each file being loaded
  51555. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51556. * @param pluginExtension the extension used to determine the plugin
  51557. * @returns The loaded plugin
  51558. */
  51559. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51560. /**
  51561. * Import meshes into a scene
  51562. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51563. * @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)
  51564. * @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)
  51565. * @param scene the instance of BABYLON.Scene to append to
  51566. * @param onProgress a callback with a progress event for each file being loaded
  51567. * @param pluginExtension the extension used to determine the plugin
  51568. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51569. */
  51570. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  51571. /**
  51572. * Load a scene
  51573. * @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)
  51574. * @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)
  51575. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51576. * @param onSuccess a callback with the scene when import succeeds
  51577. * @param onProgress a callback with a progress event for each file being loaded
  51578. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51579. * @param pluginExtension the extension used to determine the plugin
  51580. * @returns The loaded plugin
  51581. */
  51582. 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>;
  51583. /**
  51584. * Load a scene
  51585. * @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)
  51586. * @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)
  51587. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51588. * @param onProgress a callback with a progress event for each file being loaded
  51589. * @param pluginExtension the extension used to determine the plugin
  51590. * @returns The loaded scene
  51591. */
  51592. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51593. /**
  51594. * Append a scene
  51595. * @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)
  51596. * @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)
  51597. * @param scene is the instance of BABYLON.Scene to append to
  51598. * @param onSuccess a callback with the scene when import succeeds
  51599. * @param onProgress a callback with a progress event for each file being loaded
  51600. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51601. * @param pluginExtension the extension used to determine the plugin
  51602. * @returns The loaded plugin
  51603. */
  51604. 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>;
  51605. /**
  51606. * Append a scene
  51607. * @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)
  51608. * @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)
  51609. * @param scene is the instance of BABYLON.Scene to append to
  51610. * @param onProgress a callback with a progress event for each file being loaded
  51611. * @param pluginExtension the extension used to determine the plugin
  51612. * @returns The given scene
  51613. */
  51614. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51615. /**
  51616. * Load a scene into an asset container
  51617. * @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)
  51618. * @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)
  51619. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51620. * @param onSuccess a callback with the scene when import succeeds
  51621. * @param onProgress a callback with a progress event for each file being loaded
  51622. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51623. * @param pluginExtension the extension used to determine the plugin
  51624. * @returns The loaded plugin
  51625. */
  51626. 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>;
  51627. /**
  51628. * Load a scene into an asset container
  51629. * @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)
  51630. * @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)
  51631. * @param scene is the instance of Scene to append to
  51632. * @param onProgress a callback with a progress event for each file being loaded
  51633. * @param pluginExtension the extension used to determine the plugin
  51634. * @returns The loaded asset container
  51635. */
  51636. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51637. /**
  51638. * Import animations from a file into a scene
  51639. * @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)
  51640. * @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)
  51641. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51642. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51643. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51644. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51645. * @param onSuccess a callback with the scene when import succeeds
  51646. * @param onProgress a callback with a progress event for each file being loaded
  51647. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51648. * @param pluginExtension the extension used to determine the plugin
  51649. */
  51650. 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;
  51651. /**
  51652. * Import animations from a file into a scene
  51653. * @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)
  51654. * @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)
  51655. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51656. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51657. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51658. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51659. * @param onSuccess a callback with the scene when import succeeds
  51660. * @param onProgress a callback with a progress event for each file being loaded
  51661. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51662. * @param pluginExtension the extension used to determine the plugin
  51663. * @returns the updated scene with imported animations
  51664. */
  51665. 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>;
  51666. }
  51667. }
  51668. declare module BABYLON {
  51669. /**
  51670. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51671. */
  51672. export type MotionControllerHandedness = "none" | "left" | "right";
  51673. /**
  51674. * The type of components available in motion controllers.
  51675. * This is not the name of the component.
  51676. */
  51677. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51678. /**
  51679. * The state of a controller component
  51680. */
  51681. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51682. /**
  51683. * The schema of motion controller layout.
  51684. * No object will be initialized using this interface
  51685. * This is used just to define the profile.
  51686. */
  51687. export interface IMotionControllerLayout {
  51688. /**
  51689. * Path to load the assets. Usually relative to the base path
  51690. */
  51691. assetPath: string;
  51692. /**
  51693. * Available components (unsorted)
  51694. */
  51695. components: {
  51696. /**
  51697. * A map of component Ids
  51698. */
  51699. [componentId: string]: {
  51700. /**
  51701. * The type of input the component outputs
  51702. */
  51703. type: MotionControllerComponentType;
  51704. /**
  51705. * The indices of this component in the gamepad object
  51706. */
  51707. gamepadIndices: {
  51708. /**
  51709. * Index of button
  51710. */
  51711. button?: number;
  51712. /**
  51713. * If available, index of x-axis
  51714. */
  51715. xAxis?: number;
  51716. /**
  51717. * If available, index of y-axis
  51718. */
  51719. yAxis?: number;
  51720. };
  51721. /**
  51722. * The mesh's root node name
  51723. */
  51724. rootNodeName: string;
  51725. /**
  51726. * Animation definitions for this model
  51727. */
  51728. visualResponses: {
  51729. [stateKey: string]: {
  51730. /**
  51731. * What property will be animated
  51732. */
  51733. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51734. /**
  51735. * What states influence this visual response
  51736. */
  51737. states: MotionControllerComponentStateType[];
  51738. /**
  51739. * Type of animation - movement or visibility
  51740. */
  51741. valueNodeProperty: "transform" | "visibility";
  51742. /**
  51743. * Base node name to move. Its position will be calculated according to the min and max nodes
  51744. */
  51745. valueNodeName?: string;
  51746. /**
  51747. * Minimum movement node
  51748. */
  51749. minNodeName?: string;
  51750. /**
  51751. * Max movement node
  51752. */
  51753. maxNodeName?: string;
  51754. };
  51755. };
  51756. /**
  51757. * If touch enabled, what is the name of node to display user feedback
  51758. */
  51759. touchPointNodeName?: string;
  51760. };
  51761. };
  51762. /**
  51763. * Is it xr standard mapping or not
  51764. */
  51765. gamepadMapping: "" | "xr-standard";
  51766. /**
  51767. * Base root node of this entire model
  51768. */
  51769. rootNodeName: string;
  51770. /**
  51771. * Defines the main button component id
  51772. */
  51773. selectComponentId: string;
  51774. }
  51775. /**
  51776. * A definition for the layout map in the input profile
  51777. */
  51778. export interface IMotionControllerLayoutMap {
  51779. /**
  51780. * Layouts with handedness type as a key
  51781. */
  51782. [handedness: string]: IMotionControllerLayout;
  51783. }
  51784. /**
  51785. * The XR Input profile schema
  51786. * Profiles can be found here:
  51787. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51788. */
  51789. export interface IMotionControllerProfile {
  51790. /**
  51791. * fallback profiles for this profileId
  51792. */
  51793. fallbackProfileIds: string[];
  51794. /**
  51795. * The layout map, with handedness as key
  51796. */
  51797. layouts: IMotionControllerLayoutMap;
  51798. /**
  51799. * The id of this profile
  51800. * correlates to the profile(s) in the xrInput.profiles array
  51801. */
  51802. profileId: string;
  51803. }
  51804. /**
  51805. * A helper-interface for the 3 meshes needed for controller button animation
  51806. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51807. */
  51808. export interface IMotionControllerButtonMeshMap {
  51809. /**
  51810. * the mesh that defines the pressed value mesh position.
  51811. * This is used to find the max-position of this button
  51812. */
  51813. pressedMesh: AbstractMesh;
  51814. /**
  51815. * the mesh that defines the unpressed value mesh position.
  51816. * This is used to find the min (or initial) position of this button
  51817. */
  51818. unpressedMesh: AbstractMesh;
  51819. /**
  51820. * The mesh that will be changed when value changes
  51821. */
  51822. valueMesh: AbstractMesh;
  51823. }
  51824. /**
  51825. * A helper-interface for the 3 meshes needed for controller axis animation.
  51826. * This will be expanded when touchpad animations are fully supported
  51827. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51828. */
  51829. export interface IMotionControllerMeshMap {
  51830. /**
  51831. * the mesh that defines the maximum value mesh position.
  51832. */
  51833. maxMesh?: AbstractMesh;
  51834. /**
  51835. * the mesh that defines the minimum value mesh position.
  51836. */
  51837. minMesh?: AbstractMesh;
  51838. /**
  51839. * The mesh that will be changed when axis value changes
  51840. */
  51841. valueMesh?: AbstractMesh;
  51842. }
  51843. /**
  51844. * The elements needed for change-detection of the gamepad objects in motion controllers
  51845. */
  51846. export interface IMinimalMotionControllerObject {
  51847. /**
  51848. * Available axes of this controller
  51849. */
  51850. axes: number[];
  51851. /**
  51852. * An array of available buttons
  51853. */
  51854. buttons: Array<{
  51855. /**
  51856. * Value of the button/trigger
  51857. */
  51858. value: number;
  51859. /**
  51860. * If the button/trigger is currently touched
  51861. */
  51862. touched: boolean;
  51863. /**
  51864. * If the button/trigger is currently pressed
  51865. */
  51866. pressed: boolean;
  51867. }>;
  51868. /**
  51869. * EXPERIMENTAL haptic support.
  51870. */
  51871. hapticActuators?: Array<{
  51872. pulse: (value: number, duration: number) => Promise<boolean>;
  51873. }>;
  51874. }
  51875. /**
  51876. * An Abstract Motion controller
  51877. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51878. * Each component has an observable to check for changes in value and state
  51879. */
  51880. export abstract class WebXRAbstractMotionController implements IDisposable {
  51881. protected scene: Scene;
  51882. protected layout: IMotionControllerLayout;
  51883. /**
  51884. * The gamepad object correlating to this controller
  51885. */
  51886. gamepadObject: IMinimalMotionControllerObject;
  51887. /**
  51888. * handedness (left/right/none) of this controller
  51889. */
  51890. handedness: MotionControllerHandedness;
  51891. private _initComponent;
  51892. private _modelReady;
  51893. /**
  51894. * A map of components (WebXRControllerComponent) in this motion controller
  51895. * Components have a ComponentType and can also have both button and axis definitions
  51896. */
  51897. readonly components: {
  51898. [id: string]: WebXRControllerComponent;
  51899. };
  51900. /**
  51901. * Disable the model's animation. Can be set at any time.
  51902. */
  51903. disableAnimation: boolean;
  51904. /**
  51905. * Observers registered here will be triggered when the model of this controller is done loading
  51906. */
  51907. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51908. /**
  51909. * The profile id of this motion controller
  51910. */
  51911. abstract profileId: string;
  51912. /**
  51913. * The root mesh of the model. It is null if the model was not yet initialized
  51914. */
  51915. rootMesh: Nullable<AbstractMesh>;
  51916. /**
  51917. * constructs a new abstract motion controller
  51918. * @param scene the scene to which the model of the controller will be added
  51919. * @param layout The profile layout to load
  51920. * @param gamepadObject The gamepad object correlating to this controller
  51921. * @param handedness handedness (left/right/none) of this controller
  51922. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51923. */
  51924. constructor(scene: Scene, layout: IMotionControllerLayout,
  51925. /**
  51926. * The gamepad object correlating to this controller
  51927. */
  51928. gamepadObject: IMinimalMotionControllerObject,
  51929. /**
  51930. * handedness (left/right/none) of this controller
  51931. */
  51932. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51933. /**
  51934. * Dispose this controller, the model mesh and all its components
  51935. */
  51936. dispose(): void;
  51937. /**
  51938. * Returns all components of specific type
  51939. * @param type the type to search for
  51940. * @return an array of components with this type
  51941. */
  51942. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51943. /**
  51944. * get a component based an its component id as defined in layout.components
  51945. * @param id the id of the component
  51946. * @returns the component correlates to the id or undefined if not found
  51947. */
  51948. getComponent(id: string): WebXRControllerComponent;
  51949. /**
  51950. * Get the list of components available in this motion controller
  51951. * @returns an array of strings correlating to available components
  51952. */
  51953. getComponentIds(): string[];
  51954. /**
  51955. * Get the first component of specific type
  51956. * @param type type of component to find
  51957. * @return a controller component or null if not found
  51958. */
  51959. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51960. /**
  51961. * Get the main (Select) component of this controller as defined in the layout
  51962. * @returns the main component of this controller
  51963. */
  51964. getMainComponent(): WebXRControllerComponent;
  51965. /**
  51966. * Loads the model correlating to this controller
  51967. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51968. * @returns A promise fulfilled with the result of the model loading
  51969. */
  51970. loadModel(): Promise<boolean>;
  51971. /**
  51972. * Update this model using the current XRFrame
  51973. * @param xrFrame the current xr frame to use and update the model
  51974. */
  51975. updateFromXRFrame(xrFrame: XRFrame): void;
  51976. /**
  51977. * Backwards compatibility due to a deeply-integrated typo
  51978. */
  51979. get handness(): XREye;
  51980. /**
  51981. * Pulse (vibrate) this controller
  51982. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51983. * Consecutive calls to this function will cancel the last pulse call
  51984. *
  51985. * @param value the strength of the pulse in 0.0...1.0 range
  51986. * @param duration Duration of the pulse in milliseconds
  51987. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51988. * @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
  51989. */
  51990. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51991. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51992. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51993. /**
  51994. * Moves the axis on the controller mesh based on its current state
  51995. * @param axis the index of the axis
  51996. * @param axisValue the value of the axis which determines the meshes new position
  51997. * @hidden
  51998. */
  51999. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  52000. /**
  52001. * Update the model itself with the current frame data
  52002. * @param xrFrame the frame to use for updating the model mesh
  52003. */
  52004. protected updateModel(xrFrame: XRFrame): void;
  52005. /**
  52006. * Get the filename and path for this controller's model
  52007. * @returns a map of filename and path
  52008. */
  52009. protected abstract _getFilenameAndPath(): {
  52010. filename: string;
  52011. path: string;
  52012. };
  52013. /**
  52014. * This function is called before the mesh is loaded. It checks for loading constraints.
  52015. * For example, this function can check if the GLB loader is available
  52016. * If this function returns false, the generic controller will be loaded instead
  52017. * @returns Is the client ready to load the mesh
  52018. */
  52019. protected abstract _getModelLoadingConstraints(): boolean;
  52020. /**
  52021. * This function will be called after the model was successfully loaded and can be used
  52022. * for mesh transformations before it is available for the user
  52023. * @param meshes the loaded meshes
  52024. */
  52025. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  52026. /**
  52027. * Set the root mesh for this controller. Important for the WebXR controller class
  52028. * @param meshes the loaded meshes
  52029. */
  52030. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  52031. /**
  52032. * A function executed each frame that updates the mesh (if needed)
  52033. * @param xrFrame the current xrFrame
  52034. */
  52035. protected abstract _updateModel(xrFrame: XRFrame): void;
  52036. private _getGenericFilenameAndPath;
  52037. private _getGenericParentMesh;
  52038. }
  52039. }
  52040. declare module BABYLON {
  52041. /**
  52042. * A generic trigger-only motion controller for WebXR
  52043. */
  52044. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  52045. /**
  52046. * Static version of the profile id of this controller
  52047. */
  52048. static ProfileId: string;
  52049. profileId: string;
  52050. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  52051. protected _getFilenameAndPath(): {
  52052. filename: string;
  52053. path: string;
  52054. };
  52055. protected _getModelLoadingConstraints(): boolean;
  52056. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  52057. protected _setRootMesh(meshes: AbstractMesh[]): void;
  52058. protected _updateModel(): void;
  52059. }
  52060. }
  52061. declare module BABYLON {
  52062. /**
  52063. * Class containing static functions to help procedurally build meshes
  52064. */
  52065. export class SphereBuilder {
  52066. /**
  52067. * Creates a sphere mesh
  52068. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52069. * * 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`)
  52070. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52071. * * 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
  52072. * * 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)
  52073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52074. * * 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
  52075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52076. * @param name defines the name of the mesh
  52077. * @param options defines the options used to create the mesh
  52078. * @param scene defines the hosting scene
  52079. * @returns the sphere mesh
  52080. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52081. */
  52082. static CreateSphere(name: string, options: {
  52083. segments?: number;
  52084. diameter?: number;
  52085. diameterX?: number;
  52086. diameterY?: number;
  52087. diameterZ?: number;
  52088. arc?: number;
  52089. slice?: number;
  52090. sideOrientation?: number;
  52091. frontUVs?: Vector4;
  52092. backUVs?: Vector4;
  52093. updatable?: boolean;
  52094. }, scene?: Nullable<Scene>): Mesh;
  52095. }
  52096. }
  52097. declare module BABYLON {
  52098. /**
  52099. * A profiled motion controller has its profile loaded from an online repository.
  52100. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  52101. */
  52102. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  52103. private _repositoryUrl;
  52104. private _buttonMeshMapping;
  52105. private _touchDots;
  52106. /**
  52107. * The profile ID of this controller. Will be populated when the controller initializes.
  52108. */
  52109. profileId: string;
  52110. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  52111. dispose(): void;
  52112. protected _getFilenameAndPath(): {
  52113. filename: string;
  52114. path: string;
  52115. };
  52116. protected _getModelLoadingConstraints(): boolean;
  52117. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  52118. protected _setRootMesh(meshes: AbstractMesh[]): void;
  52119. protected _updateModel(_xrFrame: XRFrame): void;
  52120. }
  52121. }
  52122. declare module BABYLON {
  52123. /**
  52124. * A construction function type to create a new controller based on an xrInput object
  52125. */
  52126. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  52127. /**
  52128. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  52129. *
  52130. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  52131. * it should be replaced with auto-loaded controllers.
  52132. *
  52133. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  52134. */
  52135. export class WebXRMotionControllerManager {
  52136. private static _AvailableControllers;
  52137. private static _Fallbacks;
  52138. private static _ProfileLoadingPromises;
  52139. private static _ProfilesList;
  52140. /**
  52141. * The base URL of the online controller repository. Can be changed at any time.
  52142. */
  52143. static BaseRepositoryUrl: string;
  52144. /**
  52145. * Which repository gets priority - local or online
  52146. */
  52147. static PrioritizeOnlineRepository: boolean;
  52148. /**
  52149. * Use the online repository, or use only locally-defined controllers
  52150. */
  52151. static UseOnlineRepository: boolean;
  52152. /**
  52153. * Clear the cache used for profile loading and reload when requested again
  52154. */
  52155. static ClearProfilesCache(): void;
  52156. /**
  52157. * Register the default fallbacks.
  52158. * This function is called automatically when this file is imported.
  52159. */
  52160. static DefaultFallbacks(): void;
  52161. /**
  52162. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  52163. * @param profileId the profile to which a fallback needs to be found
  52164. * @return an array with corresponding fallback profiles
  52165. */
  52166. static FindFallbackWithProfileId(profileId: string): string[];
  52167. /**
  52168. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  52169. * The order of search:
  52170. *
  52171. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  52172. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  52173. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  52174. * 4) return the generic trigger controller if none were found
  52175. *
  52176. * @param xrInput the xrInput to which a new controller is initialized
  52177. * @param scene the scene to which the model will be added
  52178. * @param forceProfile force a certain profile for this controller
  52179. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  52180. */
  52181. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  52182. /**
  52183. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  52184. *
  52185. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  52186. *
  52187. * @param type the profile type to register
  52188. * @param constructFunction the function to be called when loading this profile
  52189. */
  52190. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  52191. /**
  52192. * Register a fallback to a specific profile.
  52193. * @param profileId the profileId that will receive the fallbacks
  52194. * @param fallbacks A list of fallback profiles
  52195. */
  52196. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  52197. /**
  52198. * Will update the list of profiles available in the repository
  52199. * @return a promise that resolves to a map of profiles available online
  52200. */
  52201. static UpdateProfilesList(): Promise<{
  52202. [profile: string]: string;
  52203. }>;
  52204. private static _LoadProfileFromRepository;
  52205. private static _LoadProfilesFromAvailableControllers;
  52206. }
  52207. }
  52208. declare module BABYLON {
  52209. /**
  52210. * Configuration options for the WebXR controller creation
  52211. */
  52212. export interface IWebXRControllerOptions {
  52213. /**
  52214. * Should the controller mesh be animated when a user interacts with it
  52215. * The pressed buttons / thumbstick and touchpad animations will be disabled
  52216. */
  52217. disableMotionControllerAnimation?: boolean;
  52218. /**
  52219. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  52220. */
  52221. doNotLoadControllerMesh?: boolean;
  52222. /**
  52223. * Force a specific controller type for this controller.
  52224. * This can be used when creating your own profile or when testing different controllers
  52225. */
  52226. forceControllerProfile?: string;
  52227. /**
  52228. * Defines a rendering group ID for meshes that will be loaded.
  52229. * This is for the default controllers only.
  52230. */
  52231. renderingGroupId?: number;
  52232. }
  52233. /**
  52234. * Represents an XR controller
  52235. */
  52236. export class WebXRInputSource {
  52237. private _scene;
  52238. /** The underlying input source for the controller */
  52239. inputSource: XRInputSource;
  52240. private _options;
  52241. private _tmpVector;
  52242. private _uniqueId;
  52243. private _disposed;
  52244. /**
  52245. * 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
  52246. */
  52247. grip?: AbstractMesh;
  52248. /**
  52249. * If available, this is the gamepad object related to this controller.
  52250. * Using this object it is possible to get click events and trackpad changes of the
  52251. * webxr controller that is currently being used.
  52252. */
  52253. motionController?: WebXRAbstractMotionController;
  52254. /**
  52255. * Event that fires when the controller is removed/disposed.
  52256. * The object provided as event data is this controller, after associated assets were disposed.
  52257. * uniqueId is still available.
  52258. */
  52259. onDisposeObservable: Observable<WebXRInputSource>;
  52260. /**
  52261. * Will be triggered when the mesh associated with the motion controller is done loading.
  52262. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  52263. * A shortened version of controller -> motion controller -> on mesh loaded.
  52264. */
  52265. onMeshLoadedObservable: Observable<AbstractMesh>;
  52266. /**
  52267. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  52268. */
  52269. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  52270. /**
  52271. * Pointer which can be used to select objects or attach a visible laser to
  52272. */
  52273. pointer: AbstractMesh;
  52274. /**
  52275. * Creates the input source object
  52276. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  52277. * @param _scene the scene which the controller should be associated to
  52278. * @param inputSource the underlying input source for the controller
  52279. * @param _options options for this controller creation
  52280. */
  52281. constructor(_scene: Scene,
  52282. /** The underlying input source for the controller */
  52283. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  52284. /**
  52285. * Get this controllers unique id
  52286. */
  52287. get uniqueId(): string;
  52288. /**
  52289. * Disposes of the object
  52290. */
  52291. dispose(): void;
  52292. /**
  52293. * Gets a world space ray coming from the pointer or grip
  52294. * @param result the resulting ray
  52295. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  52296. */
  52297. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  52298. /**
  52299. * Updates the controller pose based on the given XRFrame
  52300. * @param xrFrame xr frame to update the pose with
  52301. * @param referenceSpace reference space to use
  52302. */
  52303. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  52304. }
  52305. }
  52306. declare module BABYLON {
  52307. /**
  52308. * The schema for initialization options of the XR Input class
  52309. */
  52310. export interface IWebXRInputOptions {
  52311. /**
  52312. * If set to true no model will be automatically loaded
  52313. */
  52314. doNotLoadControllerMeshes?: boolean;
  52315. /**
  52316. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  52317. * If not found, the xr input profile data will be used.
  52318. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  52319. */
  52320. forceInputProfile?: string;
  52321. /**
  52322. * Do not send a request to the controller repository to load the profile.
  52323. *
  52324. * Instead, use the controllers available in babylon itself.
  52325. */
  52326. disableOnlineControllerRepository?: boolean;
  52327. /**
  52328. * A custom URL for the controllers repository
  52329. */
  52330. customControllersRepositoryURL?: string;
  52331. /**
  52332. * Should the controller model's components not move according to the user input
  52333. */
  52334. disableControllerAnimation?: boolean;
  52335. /**
  52336. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  52337. */
  52338. controllerOptions?: IWebXRControllerOptions;
  52339. }
  52340. /**
  52341. * XR input used to track XR inputs such as controllers/rays
  52342. */
  52343. export class WebXRInput implements IDisposable {
  52344. /**
  52345. * the xr session manager for this session
  52346. */
  52347. xrSessionManager: WebXRSessionManager;
  52348. /**
  52349. * the WebXR camera for this session. Mainly used for teleportation
  52350. */
  52351. xrCamera: WebXRCamera;
  52352. private readonly options;
  52353. /**
  52354. * XR controllers being tracked
  52355. */
  52356. controllers: Array<WebXRInputSource>;
  52357. private _frameObserver;
  52358. private _sessionEndedObserver;
  52359. private _sessionInitObserver;
  52360. /**
  52361. * Event when a controller has been connected/added
  52362. */
  52363. onControllerAddedObservable: Observable<WebXRInputSource>;
  52364. /**
  52365. * Event when a controller has been removed/disconnected
  52366. */
  52367. onControllerRemovedObservable: Observable<WebXRInputSource>;
  52368. /**
  52369. * Initializes the WebXRInput
  52370. * @param xrSessionManager the xr session manager for this session
  52371. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  52372. * @param options = initialization options for this xr input
  52373. */
  52374. constructor(
  52375. /**
  52376. * the xr session manager for this session
  52377. */
  52378. xrSessionManager: WebXRSessionManager,
  52379. /**
  52380. * the WebXR camera for this session. Mainly used for teleportation
  52381. */
  52382. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  52383. private _onInputSourcesChange;
  52384. private _addAndRemoveControllers;
  52385. /**
  52386. * Disposes of the object
  52387. */
  52388. dispose(): void;
  52389. }
  52390. }
  52391. declare module BABYLON {
  52392. /**
  52393. * This is the base class for all WebXR features.
  52394. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  52395. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  52396. */
  52397. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  52398. protected _xrSessionManager: WebXRSessionManager;
  52399. private _attached;
  52400. private _removeOnDetach;
  52401. /**
  52402. * Is this feature disposed?
  52403. */
  52404. isDisposed: boolean;
  52405. /**
  52406. * Should auto-attach be disabled?
  52407. */
  52408. disableAutoAttach: boolean;
  52409. /**
  52410. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  52411. */
  52412. xrNativeFeatureName: string;
  52413. /**
  52414. * Construct a new (abstract) WebXR feature
  52415. * @param _xrSessionManager the xr session manager for this feature
  52416. */
  52417. constructor(_xrSessionManager: WebXRSessionManager);
  52418. /**
  52419. * Is this feature attached
  52420. */
  52421. get attached(): boolean;
  52422. /**
  52423. * attach this feature
  52424. *
  52425. * @param force should attachment be forced (even when already attached)
  52426. * @returns true if successful, false is failed or already attached
  52427. */
  52428. attach(force?: boolean): boolean;
  52429. /**
  52430. * detach this feature.
  52431. *
  52432. * @returns true if successful, false if failed or already detached
  52433. */
  52434. detach(): boolean;
  52435. /**
  52436. * Dispose this feature and all of the resources attached
  52437. */
  52438. dispose(): void;
  52439. /**
  52440. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52441. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52442. *
  52443. * @returns whether or not the feature is compatible in this environment
  52444. */
  52445. isCompatible(): boolean;
  52446. /**
  52447. * This is used to register callbacks that will automatically be removed when detach is called.
  52448. * @param observable the observable to which the observer will be attached
  52449. * @param callback the callback to register
  52450. */
  52451. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  52452. /**
  52453. * Code in this function will be executed on each xrFrame received from the browser.
  52454. * This function will not execute after the feature is detached.
  52455. * @param _xrFrame the current frame
  52456. */
  52457. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  52458. }
  52459. }
  52460. declare module BABYLON {
  52461. /**
  52462. * Renders a layer on top of an existing scene
  52463. */
  52464. export class UtilityLayerRenderer implements IDisposable {
  52465. /** the original scene that will be rendered on top of */
  52466. originalScene: Scene;
  52467. private _pointerCaptures;
  52468. private _lastPointerEvents;
  52469. private static _DefaultUtilityLayer;
  52470. private static _DefaultKeepDepthUtilityLayer;
  52471. private _sharedGizmoLight;
  52472. private _renderCamera;
  52473. /**
  52474. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  52475. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  52476. * @returns the camera that is used when rendering the utility layer
  52477. */
  52478. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  52479. /**
  52480. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  52481. * @param cam the camera that should be used when rendering the utility layer
  52482. */
  52483. setRenderCamera(cam: Nullable<Camera>): void;
  52484. /**
  52485. * @hidden
  52486. * Light which used by gizmos to get light shading
  52487. */
  52488. _getSharedGizmoLight(): HemisphericLight;
  52489. /**
  52490. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  52491. */
  52492. pickUtilitySceneFirst: boolean;
  52493. /**
  52494. * 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)
  52495. */
  52496. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  52497. /**
  52498. * 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)
  52499. */
  52500. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  52501. /**
  52502. * The scene that is rendered on top of the original scene
  52503. */
  52504. utilityLayerScene: Scene;
  52505. /**
  52506. * If the utility layer should automatically be rendered on top of existing scene
  52507. */
  52508. shouldRender: boolean;
  52509. /**
  52510. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  52511. */
  52512. onlyCheckPointerDownEvents: boolean;
  52513. /**
  52514. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  52515. */
  52516. processAllEvents: boolean;
  52517. /**
  52518. * Observable raised when the pointer move from the utility layer scene to the main scene
  52519. */
  52520. onPointerOutObservable: Observable<number>;
  52521. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  52522. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  52523. private _afterRenderObserver;
  52524. private _sceneDisposeObserver;
  52525. private _originalPointerObserver;
  52526. /**
  52527. * Instantiates a UtilityLayerRenderer
  52528. * @param originalScene the original scene that will be rendered on top of
  52529. * @param handleEvents boolean indicating if the utility layer should handle events
  52530. */
  52531. constructor(
  52532. /** the original scene that will be rendered on top of */
  52533. originalScene: Scene, handleEvents?: boolean);
  52534. private _notifyObservers;
  52535. /**
  52536. * Renders the utility layers scene on top of the original scene
  52537. */
  52538. render(): void;
  52539. /**
  52540. * Disposes of the renderer
  52541. */
  52542. dispose(): void;
  52543. private _updateCamera;
  52544. }
  52545. }
  52546. declare module BABYLON {
  52547. /**
  52548. * Options interface for the pointer selection module
  52549. */
  52550. export interface IWebXRControllerPointerSelectionOptions {
  52551. /**
  52552. * if provided, this scene will be used to render meshes.
  52553. */
  52554. customUtilityLayerScene?: Scene;
  52555. /**
  52556. * 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)
  52557. * If not disabled, the last picked point will be used to execute a pointer up event
  52558. * If disabled, pointer up event will be triggered right after the pointer down event.
  52559. * Used in screen and gaze target ray mode only
  52560. */
  52561. disablePointerUpOnTouchOut: boolean;
  52562. /**
  52563. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  52564. */
  52565. forceGazeMode: boolean;
  52566. /**
  52567. * 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
  52568. * to start a new countdown to the pointer down event.
  52569. * Defaults to 1.
  52570. */
  52571. gazeModePointerMovedFactor?: number;
  52572. /**
  52573. * Different button type to use instead of the main component
  52574. */
  52575. overrideButtonId?: string;
  52576. /**
  52577. * use this rendering group id for the meshes (optional)
  52578. */
  52579. renderingGroupId?: number;
  52580. /**
  52581. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  52582. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  52583. * 3000 means 3 seconds between pointing at something and selecting it
  52584. */
  52585. timeToSelect?: number;
  52586. /**
  52587. * Should meshes created here be added to a utility layer or the main scene
  52588. */
  52589. useUtilityLayer?: boolean;
  52590. /**
  52591. * Optional WebXR camera to be used for gaze selection
  52592. */
  52593. gazeCamera?: WebXRCamera;
  52594. /**
  52595. * the xr input to use with this pointer selection
  52596. */
  52597. xrInput: WebXRInput;
  52598. /**
  52599. * Should the scene pointerX and pointerY update be disabled
  52600. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52601. * Disable in VR, if not needed.
  52602. * The first rig camera (left eye) will be used to calculate the projection
  52603. */
  52604. disableScenePointerVectorUpdate: boolean;
  52605. /**
  52606. * Enable pointer selection on all controllers instead of switching between them
  52607. */
  52608. enablePointerSelectionOnAllControllers?: boolean;
  52609. /**
  52610. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52611. * If switch is enabled, it will still allow the user to switch between the different controllers
  52612. */
  52613. preferredHandedness?: XRHandedness;
  52614. /**
  52615. * Disable switching the pointer selection from one controller to the other.
  52616. * 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
  52617. */
  52618. disableSwitchOnClick?: boolean;
  52619. /**
  52620. * The maximum distance of the pointer selection feature. Defaults to 100.
  52621. */
  52622. maxPointerDistance?: number;
  52623. }
  52624. /**
  52625. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52626. */
  52627. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52628. private readonly _options;
  52629. private static _idCounter;
  52630. private _attachController;
  52631. private _controllers;
  52632. private _scene;
  52633. private _tmpVectorForPickCompare;
  52634. private _attachedController;
  52635. /**
  52636. * The module's name
  52637. */
  52638. static readonly Name: string;
  52639. /**
  52640. * The (Babylon) version of this module.
  52641. * This is an integer representing the implementation version.
  52642. * This number does not correspond to the WebXR specs version
  52643. */
  52644. static readonly Version: number;
  52645. /**
  52646. * Disable lighting on the laser pointer (so it will always be visible)
  52647. */
  52648. disablePointerLighting: boolean;
  52649. /**
  52650. * Disable lighting on the selection mesh (so it will always be visible)
  52651. */
  52652. disableSelectionMeshLighting: boolean;
  52653. /**
  52654. * Should the laser pointer be displayed
  52655. */
  52656. displayLaserPointer: boolean;
  52657. /**
  52658. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52659. */
  52660. displaySelectionMesh: boolean;
  52661. /**
  52662. * This color will be set to the laser pointer when selection is triggered
  52663. */
  52664. laserPointerPickedColor: Color3;
  52665. /**
  52666. * Default color of the laser pointer
  52667. */
  52668. laserPointerDefaultColor: Color3;
  52669. /**
  52670. * default color of the selection ring
  52671. */
  52672. selectionMeshDefaultColor: Color3;
  52673. /**
  52674. * This color will be applied to the selection ring when selection is triggered
  52675. */
  52676. selectionMeshPickedColor: Color3;
  52677. /**
  52678. * Optional filter to be used for ray selection. This predicate shares behavior with
  52679. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52680. */
  52681. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52682. /**
  52683. * constructs a new background remover module
  52684. * @param _xrSessionManager the session manager for this module
  52685. * @param _options read-only options to be used in this module
  52686. */
  52687. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52688. /**
  52689. * attach this feature
  52690. * Will usually be called by the features manager
  52691. *
  52692. * @returns true if successful.
  52693. */
  52694. attach(): boolean;
  52695. /**
  52696. * detach this feature.
  52697. * Will usually be called by the features manager
  52698. *
  52699. * @returns true if successful.
  52700. */
  52701. detach(): boolean;
  52702. /**
  52703. * Will get the mesh under a specific pointer.
  52704. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52705. * @param controllerId the controllerId to check
  52706. * @returns The mesh under pointer or null if no mesh is under the pointer
  52707. */
  52708. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52709. /**
  52710. * Get the xr controller that correlates to the pointer id in the pointer event
  52711. *
  52712. * @param id the pointer id to search for
  52713. * @returns the controller that correlates to this id or null if not found
  52714. */
  52715. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52716. private _identityMatrix;
  52717. private _screenCoordinatesRef;
  52718. private _viewportRef;
  52719. protected _onXRFrame(_xrFrame: XRFrame): void;
  52720. private _attachGazeMode;
  52721. private _attachScreenRayMode;
  52722. private _attachTrackedPointerRayMode;
  52723. private _convertNormalToDirectionOfRay;
  52724. private _detachController;
  52725. private _generateNewMeshPair;
  52726. private _pickingMoved;
  52727. private _updatePointerDistance;
  52728. /** @hidden */
  52729. get lasterPointerDefaultColor(): Color3;
  52730. }
  52731. }
  52732. declare module BABYLON {
  52733. /**
  52734. * Button which can be used to enter a different mode of XR
  52735. */
  52736. export class WebXREnterExitUIButton {
  52737. /** button element */
  52738. element: HTMLElement;
  52739. /** XR initialization options for the button */
  52740. sessionMode: XRSessionMode;
  52741. /** Reference space type */
  52742. referenceSpaceType: XRReferenceSpaceType;
  52743. /**
  52744. * Creates a WebXREnterExitUIButton
  52745. * @param element button element
  52746. * @param sessionMode XR initialization session mode
  52747. * @param referenceSpaceType the type of reference space to be used
  52748. */
  52749. constructor(
  52750. /** button element */
  52751. element: HTMLElement,
  52752. /** XR initialization options for the button */
  52753. sessionMode: XRSessionMode,
  52754. /** Reference space type */
  52755. referenceSpaceType: XRReferenceSpaceType);
  52756. /**
  52757. * Extendable function which can be used to update the button's visuals when the state changes
  52758. * @param activeButton the current active button in the UI
  52759. */
  52760. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52761. }
  52762. /**
  52763. * Options to create the webXR UI
  52764. */
  52765. export class WebXREnterExitUIOptions {
  52766. /**
  52767. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52768. */
  52769. customButtons?: Array<WebXREnterExitUIButton>;
  52770. /**
  52771. * A reference space type to use when creating the default button.
  52772. * Default is local-floor
  52773. */
  52774. referenceSpaceType?: XRReferenceSpaceType;
  52775. /**
  52776. * Context to enter xr with
  52777. */
  52778. renderTarget?: Nullable<WebXRRenderTarget>;
  52779. /**
  52780. * A session mode to use when creating the default button.
  52781. * Default is immersive-vr
  52782. */
  52783. sessionMode?: XRSessionMode;
  52784. /**
  52785. * A list of optional features to init the session with
  52786. */
  52787. optionalFeatures?: string[];
  52788. /**
  52789. * A list of optional features to init the session with
  52790. */
  52791. requiredFeatures?: string[];
  52792. /**
  52793. * If defined, this function will be executed if the UI encounters an error when entering XR
  52794. */
  52795. onError?: (error: any) => void;
  52796. }
  52797. /**
  52798. * UI to allow the user to enter/exit XR mode
  52799. */
  52800. export class WebXREnterExitUI implements IDisposable {
  52801. private scene;
  52802. /** version of the options passed to this UI */
  52803. options: WebXREnterExitUIOptions;
  52804. private _activeButton;
  52805. private _buttons;
  52806. /**
  52807. * The HTML Div Element to which buttons are added.
  52808. */
  52809. readonly overlay: HTMLDivElement;
  52810. /**
  52811. * Fired every time the active button is changed.
  52812. *
  52813. * When xr is entered via a button that launches xr that button will be the callback parameter
  52814. *
  52815. * When exiting xr the callback parameter will be null)
  52816. */
  52817. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52818. /**
  52819. *
  52820. * @param scene babylon scene object to use
  52821. * @param options (read-only) version of the options passed to this UI
  52822. */
  52823. private constructor();
  52824. /**
  52825. * Creates UI to allow the user to enter/exit XR mode
  52826. * @param scene the scene to add the ui to
  52827. * @param helper the xr experience helper to enter/exit xr with
  52828. * @param options options to configure the UI
  52829. * @returns the created ui
  52830. */
  52831. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52832. /**
  52833. * Disposes of the XR UI component
  52834. */
  52835. dispose(): void;
  52836. private _updateButtons;
  52837. }
  52838. }
  52839. declare module BABYLON {
  52840. /**
  52841. * Class containing static functions to help procedurally build meshes
  52842. */
  52843. export class LinesBuilder {
  52844. /**
  52845. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52846. * * 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
  52847. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52848. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52849. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52850. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52851. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52852. * * 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
  52853. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52855. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52856. * @param name defines the name of the new line system
  52857. * @param options defines the options used to create the line system
  52858. * @param scene defines the hosting scene
  52859. * @returns a new line system mesh
  52860. */
  52861. static CreateLineSystem(name: string, options: {
  52862. lines: Vector3[][];
  52863. updatable?: boolean;
  52864. instance?: Nullable<LinesMesh>;
  52865. colors?: Nullable<Color4[][]>;
  52866. useVertexAlpha?: boolean;
  52867. }, scene: Nullable<Scene>): LinesMesh;
  52868. /**
  52869. * Creates a line mesh
  52870. * 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
  52871. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52872. * * The parameter `points` is an array successive Vector3
  52873. * * 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
  52874. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52875. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52876. * * When updating an instance, remember that only point positions can change, not the number of points
  52877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52878. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52879. * @param name defines the name of the new line system
  52880. * @param options defines the options used to create the line system
  52881. * @param scene defines the hosting scene
  52882. * @returns a new line mesh
  52883. */
  52884. static CreateLines(name: string, options: {
  52885. points: Vector3[];
  52886. updatable?: boolean;
  52887. instance?: Nullable<LinesMesh>;
  52888. colors?: Color4[];
  52889. useVertexAlpha?: boolean;
  52890. }, scene?: Nullable<Scene>): LinesMesh;
  52891. /**
  52892. * Creates a dashed line mesh
  52893. * * 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
  52894. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52895. * * The parameter `points` is an array successive Vector3
  52896. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52897. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52898. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52899. * * 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
  52900. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52901. * * When updating an instance, remember that only point positions can change, not the number of points
  52902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52903. * @param name defines the name of the mesh
  52904. * @param options defines the options used to create the mesh
  52905. * @param scene defines the hosting scene
  52906. * @returns the dashed line mesh
  52907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52908. */
  52909. static CreateDashedLines(name: string, options: {
  52910. points: Vector3[];
  52911. dashSize?: number;
  52912. gapSize?: number;
  52913. dashNb?: number;
  52914. updatable?: boolean;
  52915. instance?: LinesMesh;
  52916. useVertexAlpha?: boolean;
  52917. }, scene?: Nullable<Scene>): LinesMesh;
  52918. }
  52919. }
  52920. declare module BABYLON {
  52921. /**
  52922. * Construction options for a timer
  52923. */
  52924. export interface ITimerOptions<T> {
  52925. /**
  52926. * Time-to-end
  52927. */
  52928. timeout: number;
  52929. /**
  52930. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52931. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52932. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52933. */
  52934. contextObservable: Observable<T>;
  52935. /**
  52936. * Optional parameters when adding an observer to the observable
  52937. */
  52938. observableParameters?: {
  52939. mask?: number;
  52940. insertFirst?: boolean;
  52941. scope?: any;
  52942. };
  52943. /**
  52944. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52945. */
  52946. breakCondition?: (data?: ITimerData<T>) => boolean;
  52947. /**
  52948. * Will be triggered when the time condition has met
  52949. */
  52950. onEnded?: (data: ITimerData<any>) => void;
  52951. /**
  52952. * Will be triggered when the break condition has met (prematurely ended)
  52953. */
  52954. onAborted?: (data: ITimerData<any>) => void;
  52955. /**
  52956. * Optional function to execute on each tick (or count)
  52957. */
  52958. onTick?: (data: ITimerData<any>) => void;
  52959. }
  52960. /**
  52961. * An interface defining the data sent by the timer
  52962. */
  52963. export interface ITimerData<T> {
  52964. /**
  52965. * When did it start
  52966. */
  52967. startTime: number;
  52968. /**
  52969. * Time now
  52970. */
  52971. currentTime: number;
  52972. /**
  52973. * Time passed since started
  52974. */
  52975. deltaTime: number;
  52976. /**
  52977. * How much is completed, in [0.0...1.0].
  52978. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52979. */
  52980. completeRate: number;
  52981. /**
  52982. * What the registered observable sent in the last count
  52983. */
  52984. payload: T;
  52985. }
  52986. /**
  52987. * The current state of the timer
  52988. */
  52989. export enum TimerState {
  52990. /**
  52991. * Timer initialized, not yet started
  52992. */
  52993. INIT = 0,
  52994. /**
  52995. * Timer started and counting
  52996. */
  52997. STARTED = 1,
  52998. /**
  52999. * Timer ended (whether aborted or time reached)
  53000. */
  53001. ENDED = 2
  53002. }
  53003. /**
  53004. * A simple version of the timer. Will take options and start the timer immediately after calling it
  53005. *
  53006. * @param options options with which to initialize this timer
  53007. */
  53008. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  53009. /**
  53010. * An advanced implementation of a timer class
  53011. */
  53012. export class AdvancedTimer<T = any> implements IDisposable {
  53013. /**
  53014. * Will notify each time the timer calculates the remaining time
  53015. */
  53016. onEachCountObservable: Observable<ITimerData<T>>;
  53017. /**
  53018. * Will trigger when the timer was aborted due to the break condition
  53019. */
  53020. onTimerAbortedObservable: Observable<ITimerData<T>>;
  53021. /**
  53022. * Will trigger when the timer ended successfully
  53023. */
  53024. onTimerEndedObservable: Observable<ITimerData<T>>;
  53025. /**
  53026. * Will trigger when the timer state has changed
  53027. */
  53028. onStateChangedObservable: Observable<TimerState>;
  53029. private _observer;
  53030. private _contextObservable;
  53031. private _observableParameters;
  53032. private _startTime;
  53033. private _timer;
  53034. private _state;
  53035. private _breakCondition;
  53036. private _timeToEnd;
  53037. private _breakOnNextTick;
  53038. /**
  53039. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  53040. * @param options construction options for this advanced timer
  53041. */
  53042. constructor(options: ITimerOptions<T>);
  53043. /**
  53044. * set a breaking condition for this timer. Default is to never break during count
  53045. * @param predicate the new break condition. Returns true to break, false otherwise
  53046. */
  53047. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  53048. /**
  53049. * Reset ALL associated observables in this advanced timer
  53050. */
  53051. clearObservables(): void;
  53052. /**
  53053. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  53054. *
  53055. * @param timeToEnd how much time to measure until timer ended
  53056. */
  53057. start(timeToEnd?: number): void;
  53058. /**
  53059. * Will force a stop on the next tick.
  53060. */
  53061. stop(): void;
  53062. /**
  53063. * Dispose this timer, clearing all resources
  53064. */
  53065. dispose(): void;
  53066. private _setState;
  53067. private _tick;
  53068. private _stop;
  53069. }
  53070. }
  53071. declare module BABYLON {
  53072. /**
  53073. * The options container for the teleportation module
  53074. */
  53075. export interface IWebXRTeleportationOptions {
  53076. /**
  53077. * if provided, this scene will be used to render meshes.
  53078. */
  53079. customUtilityLayerScene?: Scene;
  53080. /**
  53081. * Values to configure the default target mesh
  53082. */
  53083. defaultTargetMeshOptions?: {
  53084. /**
  53085. * Fill color of the teleportation area
  53086. */
  53087. teleportationFillColor?: string;
  53088. /**
  53089. * Border color for the teleportation area
  53090. */
  53091. teleportationBorderColor?: string;
  53092. /**
  53093. * Disable the mesh's animation sequence
  53094. */
  53095. disableAnimation?: boolean;
  53096. /**
  53097. * Disable lighting on the material or the ring and arrow
  53098. */
  53099. disableLighting?: boolean;
  53100. /**
  53101. * Override the default material of the torus and arrow
  53102. */
  53103. torusArrowMaterial?: Material;
  53104. };
  53105. /**
  53106. * A list of meshes to use as floor meshes.
  53107. * Meshes can be added and removed after initializing the feature using the
  53108. * addFloorMesh and removeFloorMesh functions
  53109. * If empty, rotation will still work
  53110. */
  53111. floorMeshes?: AbstractMesh[];
  53112. /**
  53113. * use this rendering group id for the meshes (optional)
  53114. */
  53115. renderingGroupId?: number;
  53116. /**
  53117. * Should teleportation move only to snap points
  53118. */
  53119. snapPointsOnly?: boolean;
  53120. /**
  53121. * An array of points to which the teleportation will snap to.
  53122. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  53123. */
  53124. snapPositions?: Vector3[];
  53125. /**
  53126. * How close should the teleportation ray be in order to snap to position.
  53127. * Default to 0.8 units (meters)
  53128. */
  53129. snapToPositionRadius?: number;
  53130. /**
  53131. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  53132. * If you want to support rotation, make sure your mesh has a direction indicator.
  53133. *
  53134. * When left untouched, the default mesh will be initialized.
  53135. */
  53136. teleportationTargetMesh?: AbstractMesh;
  53137. /**
  53138. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  53139. */
  53140. timeToTeleport?: number;
  53141. /**
  53142. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  53143. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  53144. */
  53145. useMainComponentOnly?: boolean;
  53146. /**
  53147. * Should meshes created here be added to a utility layer or the main scene
  53148. */
  53149. useUtilityLayer?: boolean;
  53150. /**
  53151. * Babylon XR Input class for controller
  53152. */
  53153. xrInput: WebXRInput;
  53154. /**
  53155. * Meshes that the teleportation ray cannot go through
  53156. */
  53157. pickBlockerMeshes?: AbstractMesh[];
  53158. /**
  53159. * Should teleport work only on a specific hand?
  53160. */
  53161. forceHandedness?: XRHandedness;
  53162. /**
  53163. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  53164. */
  53165. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  53166. }
  53167. /**
  53168. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  53169. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  53170. * the input of the attached controllers.
  53171. */
  53172. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  53173. private _options;
  53174. private _controllers;
  53175. private _currentTeleportationControllerId;
  53176. private _floorMeshes;
  53177. private _quadraticBezierCurve;
  53178. private _selectionFeature;
  53179. private _snapToPositions;
  53180. private _snappedToPoint;
  53181. private _teleportationRingMaterial?;
  53182. private _tmpRay;
  53183. private _tmpVector;
  53184. private _tmpQuaternion;
  53185. /**
  53186. * The module's name
  53187. */
  53188. static readonly Name: string;
  53189. /**
  53190. * The (Babylon) version of this module.
  53191. * This is an integer representing the implementation version.
  53192. * This number does not correspond to the webxr specs version
  53193. */
  53194. static readonly Version: number;
  53195. /**
  53196. * Is movement backwards enabled
  53197. */
  53198. backwardsMovementEnabled: boolean;
  53199. /**
  53200. * Distance to travel when moving backwards
  53201. */
  53202. backwardsTeleportationDistance: number;
  53203. /**
  53204. * The distance from the user to the inspection point in the direction of the controller
  53205. * A higher number will allow the user to move further
  53206. * defaults to 5 (meters, in xr units)
  53207. */
  53208. parabolicCheckRadius: number;
  53209. /**
  53210. * Should the module support parabolic ray on top of direct ray
  53211. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  53212. * Very helpful when moving between floors / different heights
  53213. */
  53214. parabolicRayEnabled: boolean;
  53215. /**
  53216. * The second type of ray - straight line.
  53217. * Should it be enabled or should the parabolic line be the only one.
  53218. */
  53219. straightRayEnabled: boolean;
  53220. /**
  53221. * How much rotation should be applied when rotating right and left
  53222. */
  53223. rotationAngle: number;
  53224. private _rotationEnabled;
  53225. /**
  53226. * Is rotation enabled when moving forward?
  53227. * Disabling this feature will prevent the user from deciding the direction when teleporting
  53228. */
  53229. get rotationEnabled(): boolean;
  53230. /**
  53231. * Sets wether rotation is enabled or not
  53232. * @param enabled is rotation enabled when teleportation is shown
  53233. */
  53234. set rotationEnabled(enabled: boolean);
  53235. /**
  53236. * Exposes the currently set teleportation target mesh.
  53237. */
  53238. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  53239. /**
  53240. * constructs a new anchor system
  53241. * @param _xrSessionManager an instance of WebXRSessionManager
  53242. * @param _options configuration object for this feature
  53243. */
  53244. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  53245. /**
  53246. * Get the snapPointsOnly flag
  53247. */
  53248. get snapPointsOnly(): boolean;
  53249. /**
  53250. * Sets the snapPointsOnly flag
  53251. * @param snapToPoints should teleportation be exclusively to snap points
  53252. */
  53253. set snapPointsOnly(snapToPoints: boolean);
  53254. /**
  53255. * Add a new mesh to the floor meshes array
  53256. * @param mesh the mesh to use as floor mesh
  53257. */
  53258. addFloorMesh(mesh: AbstractMesh): void;
  53259. /**
  53260. * Add a new snap-to point to fix teleportation to this position
  53261. * @param newSnapPoint The new Snap-To point
  53262. */
  53263. addSnapPoint(newSnapPoint: Vector3): void;
  53264. attach(): boolean;
  53265. detach(): boolean;
  53266. dispose(): void;
  53267. /**
  53268. * Remove a mesh from the floor meshes array
  53269. * @param mesh the mesh to remove
  53270. */
  53271. removeFloorMesh(mesh: AbstractMesh): void;
  53272. /**
  53273. * Remove a mesh from the floor meshes array using its name
  53274. * @param name the mesh name to remove
  53275. */
  53276. removeFloorMeshByName(name: string): void;
  53277. /**
  53278. * 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
  53279. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  53280. * @returns was the point found and removed or not
  53281. */
  53282. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  53283. /**
  53284. * This function sets a selection feature that will be disabled when
  53285. * the forward ray is shown and will be reattached when hidden.
  53286. * This is used to remove the selection rays when moving.
  53287. * @param selectionFeature the feature to disable when forward movement is enabled
  53288. */
  53289. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  53290. protected _onXRFrame(_xrFrame: XRFrame): void;
  53291. private _attachController;
  53292. private _createDefaultTargetMesh;
  53293. private _detachController;
  53294. private _findClosestSnapPointWithRadius;
  53295. private _setTargetMeshPosition;
  53296. private _setTargetMeshVisibility;
  53297. private _showParabolicPath;
  53298. private _teleportForward;
  53299. }
  53300. }
  53301. declare module BABYLON {
  53302. /**
  53303. * Options for the default xr helper
  53304. */
  53305. export class WebXRDefaultExperienceOptions {
  53306. /**
  53307. * Enable or disable default UI to enter XR
  53308. */
  53309. disableDefaultUI?: boolean;
  53310. /**
  53311. * Should teleportation not initialize. defaults to false.
  53312. */
  53313. disableTeleportation?: boolean;
  53314. /**
  53315. * Floor meshes that will be used for teleport
  53316. */
  53317. floorMeshes?: Array<AbstractMesh>;
  53318. /**
  53319. * If set to true, the first frame will not be used to reset position
  53320. * The first frame is mainly used when copying transformation from the old camera
  53321. * Mainly used in AR
  53322. */
  53323. ignoreNativeCameraTransformation?: boolean;
  53324. /**
  53325. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  53326. */
  53327. inputOptions?: IWebXRInputOptions;
  53328. /**
  53329. * optional configuration for the output canvas
  53330. */
  53331. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  53332. /**
  53333. * optional UI options. This can be used among other to change session mode and reference space type
  53334. */
  53335. uiOptions?: WebXREnterExitUIOptions;
  53336. /**
  53337. * When loading teleportation and pointer select, use stable versions instead of latest.
  53338. */
  53339. useStablePlugins?: boolean;
  53340. /**
  53341. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  53342. */
  53343. renderingGroupId?: number;
  53344. /**
  53345. * A list of optional features to init the session with
  53346. * If set to true, all features we support will be added
  53347. */
  53348. optionalFeatures?: boolean | string[];
  53349. }
  53350. /**
  53351. * Default experience which provides a similar setup to the previous webVRExperience
  53352. */
  53353. export class WebXRDefaultExperience {
  53354. /**
  53355. * Base experience
  53356. */
  53357. baseExperience: WebXRExperienceHelper;
  53358. /**
  53359. * Enables ui for entering/exiting xr
  53360. */
  53361. enterExitUI: WebXREnterExitUI;
  53362. /**
  53363. * Input experience extension
  53364. */
  53365. input: WebXRInput;
  53366. /**
  53367. * Enables laser pointer and selection
  53368. */
  53369. pointerSelection: WebXRControllerPointerSelection;
  53370. /**
  53371. * Default target xr should render to
  53372. */
  53373. renderTarget: WebXRRenderTarget;
  53374. /**
  53375. * Enables teleportation
  53376. */
  53377. teleportation: WebXRMotionControllerTeleportation;
  53378. private constructor();
  53379. /**
  53380. * Creates the default xr experience
  53381. * @param scene scene
  53382. * @param options options for basic configuration
  53383. * @returns resulting WebXRDefaultExperience
  53384. */
  53385. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53386. /**
  53387. * DIsposes of the experience helper
  53388. */
  53389. dispose(): void;
  53390. }
  53391. }
  53392. declare module BABYLON {
  53393. /**
  53394. * Options to modify the vr teleportation behavior.
  53395. */
  53396. export interface VRTeleportationOptions {
  53397. /**
  53398. * The name of the mesh which should be used as the teleportation floor. (default: null)
  53399. */
  53400. floorMeshName?: string;
  53401. /**
  53402. * A list of meshes to be used as the teleportation floor. (default: empty)
  53403. */
  53404. floorMeshes?: Mesh[];
  53405. /**
  53406. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  53407. */
  53408. teleportationMode?: number;
  53409. /**
  53410. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  53411. */
  53412. teleportationTime?: number;
  53413. /**
  53414. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  53415. */
  53416. teleportationSpeed?: number;
  53417. /**
  53418. * The easing function used in the animation or null for Linear. (default CircleEase)
  53419. */
  53420. easingFunction?: EasingFunction;
  53421. }
  53422. /**
  53423. * Options to modify the vr experience helper's behavior.
  53424. */
  53425. export interface VRExperienceHelperOptions extends WebVROptions {
  53426. /**
  53427. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  53428. */
  53429. createDeviceOrientationCamera?: boolean;
  53430. /**
  53431. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  53432. */
  53433. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  53434. /**
  53435. * Uses the main button on the controller to toggle the laser casted. (default: true)
  53436. */
  53437. laserToggle?: boolean;
  53438. /**
  53439. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  53440. */
  53441. floorMeshes?: Mesh[];
  53442. /**
  53443. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  53444. */
  53445. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  53446. /**
  53447. * Defines if WebXR should be used instead of WebVR (if available)
  53448. */
  53449. useXR?: boolean;
  53450. }
  53451. /**
  53452. * Event containing information after VR has been entered
  53453. */
  53454. export class OnAfterEnteringVRObservableEvent {
  53455. /**
  53456. * If entering vr was successful
  53457. */
  53458. success: boolean;
  53459. }
  53460. /**
  53461. * Helps to quickly add VR support to an existing scene.
  53462. * See https://doc.babylonjs.com/how_to/webvr_helper
  53463. */
  53464. export class VRExperienceHelper {
  53465. /** Options to modify the vr experience helper's behavior. */
  53466. webVROptions: VRExperienceHelperOptions;
  53467. private _scene;
  53468. private _position;
  53469. private _btnVR;
  53470. private _btnVRDisplayed;
  53471. private _webVRsupported;
  53472. private _webVRready;
  53473. private _webVRrequesting;
  53474. private _webVRpresenting;
  53475. private _hasEnteredVR;
  53476. private _fullscreenVRpresenting;
  53477. private _inputElement;
  53478. private _webVRCamera;
  53479. private _vrDeviceOrientationCamera;
  53480. private _deviceOrientationCamera;
  53481. private _existingCamera;
  53482. private _onKeyDown;
  53483. private _onVrDisplayPresentChange;
  53484. private _onVRDisplayChanged;
  53485. private _onVRRequestPresentStart;
  53486. private _onVRRequestPresentComplete;
  53487. /**
  53488. * 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)
  53489. */
  53490. enableGazeEvenWhenNoPointerLock: boolean;
  53491. /**
  53492. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  53493. */
  53494. exitVROnDoubleTap: boolean;
  53495. /**
  53496. * Observable raised right before entering VR.
  53497. */
  53498. onEnteringVRObservable: Observable<VRExperienceHelper>;
  53499. /**
  53500. * Observable raised when entering VR has completed.
  53501. */
  53502. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  53503. /**
  53504. * Observable raised when exiting VR.
  53505. */
  53506. onExitingVRObservable: Observable<VRExperienceHelper>;
  53507. /**
  53508. * Observable raised when controller mesh is loaded.
  53509. */
  53510. onControllerMeshLoadedObservable: Observable<WebVRController>;
  53511. /** Return this.onEnteringVRObservable
  53512. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  53513. */
  53514. get onEnteringVR(): Observable<VRExperienceHelper>;
  53515. /** Return this.onExitingVRObservable
  53516. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  53517. */
  53518. get onExitingVR(): Observable<VRExperienceHelper>;
  53519. /** Return this.onControllerMeshLoadedObservable
  53520. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  53521. */
  53522. get onControllerMeshLoaded(): Observable<WebVRController>;
  53523. private _rayLength;
  53524. private _useCustomVRButton;
  53525. private _teleportationRequested;
  53526. private _teleportActive;
  53527. private _floorMeshName;
  53528. private _floorMeshesCollection;
  53529. private _teleportationMode;
  53530. private _teleportationTime;
  53531. private _teleportationSpeed;
  53532. private _teleportationEasing;
  53533. private _rotationAllowed;
  53534. private _teleportBackwardsVector;
  53535. private _teleportationTarget;
  53536. private _isDefaultTeleportationTarget;
  53537. private _postProcessMove;
  53538. private _teleportationFillColor;
  53539. private _teleportationBorderColor;
  53540. private _rotationAngle;
  53541. private _haloCenter;
  53542. private _cameraGazer;
  53543. private _padSensibilityUp;
  53544. private _padSensibilityDown;
  53545. private _leftController;
  53546. private _rightController;
  53547. private _gazeColor;
  53548. private _laserColor;
  53549. private _pickedLaserColor;
  53550. private _pickedGazeColor;
  53551. /**
  53552. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  53553. */
  53554. onNewMeshSelected: Observable<AbstractMesh>;
  53555. /**
  53556. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  53557. * This observable will provide the mesh and the controller used to select the mesh
  53558. */
  53559. onMeshSelectedWithController: Observable<{
  53560. mesh: AbstractMesh;
  53561. controller: WebVRController;
  53562. }>;
  53563. /**
  53564. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  53565. */
  53566. onNewMeshPicked: Observable<PickingInfo>;
  53567. private _circleEase;
  53568. /**
  53569. * Observable raised before camera teleportation
  53570. */
  53571. onBeforeCameraTeleport: Observable<Vector3>;
  53572. /**
  53573. * Observable raised after camera teleportation
  53574. */
  53575. onAfterCameraTeleport: Observable<Vector3>;
  53576. /**
  53577. * Observable raised when current selected mesh gets unselected
  53578. */
  53579. onSelectedMeshUnselected: Observable<AbstractMesh>;
  53580. private _raySelectionPredicate;
  53581. /**
  53582. * To be optionaly changed by user to define custom ray selection
  53583. */
  53584. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53585. /**
  53586. * To be optionaly changed by user to define custom selection logic (after ray selection)
  53587. */
  53588. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53589. /**
  53590. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  53591. */
  53592. teleportationEnabled: boolean;
  53593. private _defaultHeight;
  53594. private _teleportationInitialized;
  53595. private _interactionsEnabled;
  53596. private _interactionsRequested;
  53597. private _displayGaze;
  53598. private _displayLaserPointer;
  53599. /**
  53600. * The mesh used to display where the user is going to teleport.
  53601. */
  53602. get teleportationTarget(): Mesh;
  53603. /**
  53604. * Sets the mesh to be used to display where the user is going to teleport.
  53605. */
  53606. set teleportationTarget(value: Mesh);
  53607. /**
  53608. * 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
  53609. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  53610. * See https://doc.babylonjs.com/resources/baking_transformations
  53611. */
  53612. get gazeTrackerMesh(): Mesh;
  53613. set gazeTrackerMesh(value: Mesh);
  53614. /**
  53615. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  53616. */
  53617. updateGazeTrackerScale: boolean;
  53618. /**
  53619. * If the gaze trackers color should be updated when selecting meshes
  53620. */
  53621. updateGazeTrackerColor: boolean;
  53622. /**
  53623. * If the controller laser color should be updated when selecting meshes
  53624. */
  53625. updateControllerLaserColor: boolean;
  53626. /**
  53627. * The gaze tracking mesh corresponding to the left controller
  53628. */
  53629. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53630. /**
  53631. * The gaze tracking mesh corresponding to the right controller
  53632. */
  53633. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53634. /**
  53635. * If the ray of the gaze should be displayed.
  53636. */
  53637. get displayGaze(): boolean;
  53638. /**
  53639. * Sets if the ray of the gaze should be displayed.
  53640. */
  53641. set displayGaze(value: boolean);
  53642. /**
  53643. * If the ray of the LaserPointer should be displayed.
  53644. */
  53645. get displayLaserPointer(): boolean;
  53646. /**
  53647. * Sets if the ray of the LaserPointer should be displayed.
  53648. */
  53649. set displayLaserPointer(value: boolean);
  53650. /**
  53651. * The deviceOrientationCamera used as the camera when not in VR.
  53652. */
  53653. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53654. /**
  53655. * Based on the current WebVR support, returns the current VR camera used.
  53656. */
  53657. get currentVRCamera(): Nullable<Camera>;
  53658. /**
  53659. * The webVRCamera which is used when in VR.
  53660. */
  53661. get webVRCamera(): WebVRFreeCamera;
  53662. /**
  53663. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53664. */
  53665. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53666. /**
  53667. * The html button that is used to trigger entering into VR.
  53668. */
  53669. get vrButton(): Nullable<HTMLButtonElement>;
  53670. private get _teleportationRequestInitiated();
  53671. /**
  53672. * Defines whether or not Pointer lock should be requested when switching to
  53673. * full screen.
  53674. */
  53675. requestPointerLockOnFullScreen: boolean;
  53676. /**
  53677. * If asking to force XR, this will be populated with the default xr experience
  53678. */
  53679. xr: WebXRDefaultExperience;
  53680. /**
  53681. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53682. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53683. */
  53684. xrTestDone: boolean;
  53685. /**
  53686. * Instantiates a VRExperienceHelper.
  53687. * Helps to quickly add VR support to an existing scene.
  53688. * @param scene The scene the VRExperienceHelper belongs to.
  53689. * @param webVROptions Options to modify the vr experience helper's behavior.
  53690. */
  53691. constructor(scene: Scene,
  53692. /** Options to modify the vr experience helper's behavior. */
  53693. webVROptions?: VRExperienceHelperOptions);
  53694. private completeVRInit;
  53695. private _onDefaultMeshLoaded;
  53696. private _onResize;
  53697. private _onFullscreenChange;
  53698. /**
  53699. * Gets a value indicating if we are currently in VR mode.
  53700. */
  53701. get isInVRMode(): boolean;
  53702. private onVrDisplayPresentChange;
  53703. private onVRDisplayChanged;
  53704. private moveButtonToBottomRight;
  53705. private displayVRButton;
  53706. private updateButtonVisibility;
  53707. private _cachedAngularSensibility;
  53708. /**
  53709. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53710. * Otherwise, will use the fullscreen API.
  53711. */
  53712. enterVR(): void;
  53713. /**
  53714. * Attempt to exit VR, or fullscreen.
  53715. */
  53716. exitVR(): void;
  53717. /**
  53718. * The position of the vr experience helper.
  53719. */
  53720. get position(): Vector3;
  53721. /**
  53722. * Sets the position of the vr experience helper.
  53723. */
  53724. set position(value: Vector3);
  53725. /**
  53726. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53727. */
  53728. enableInteractions(): void;
  53729. private get _noControllerIsActive();
  53730. private beforeRender;
  53731. private _isTeleportationFloor;
  53732. /**
  53733. * Adds a floor mesh to be used for teleportation.
  53734. * @param floorMesh the mesh to be used for teleportation.
  53735. */
  53736. addFloorMesh(floorMesh: Mesh): void;
  53737. /**
  53738. * Removes a floor mesh from being used for teleportation.
  53739. * @param floorMesh the mesh to be removed.
  53740. */
  53741. removeFloorMesh(floorMesh: Mesh): void;
  53742. /**
  53743. * Enables interactions and teleportation using the VR controllers and gaze.
  53744. * @param vrTeleportationOptions options to modify teleportation behavior.
  53745. */
  53746. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53747. private _onNewGamepadConnected;
  53748. private _tryEnableInteractionOnController;
  53749. private _onNewGamepadDisconnected;
  53750. private _enableInteractionOnController;
  53751. private _checkTeleportWithRay;
  53752. private _checkRotate;
  53753. private _checkTeleportBackwards;
  53754. private _enableTeleportationOnController;
  53755. private _createTeleportationCircles;
  53756. private _displayTeleportationTarget;
  53757. private _hideTeleportationTarget;
  53758. private _rotateCamera;
  53759. private _moveTeleportationSelectorTo;
  53760. private _workingVector;
  53761. private _workingQuaternion;
  53762. private _workingMatrix;
  53763. /**
  53764. * Time Constant Teleportation Mode
  53765. */
  53766. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53767. /**
  53768. * Speed Constant Teleportation Mode
  53769. */
  53770. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53771. /**
  53772. * Teleports the users feet to the desired location
  53773. * @param location The location where the user's feet should be placed
  53774. */
  53775. teleportCamera(location: Vector3): void;
  53776. private _convertNormalToDirectionOfRay;
  53777. private _castRayAndSelectObject;
  53778. private _notifySelectedMeshUnselected;
  53779. /**
  53780. * Permanently set new colors for the laser pointer
  53781. * @param color the new laser color
  53782. * @param pickedColor the new laser color when picked mesh detected
  53783. */
  53784. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53785. /**
  53786. * Set lighting enabled / disabled on the laser pointer of both controllers
  53787. * @param enabled should the lighting be enabled on the laser pointer
  53788. */
  53789. setLaserLightingState(enabled?: boolean): void;
  53790. /**
  53791. * Permanently set new colors for the gaze pointer
  53792. * @param color the new gaze color
  53793. * @param pickedColor the new gaze color when picked mesh detected
  53794. */
  53795. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53796. /**
  53797. * Sets the color of the laser ray from the vr controllers.
  53798. * @param color new color for the ray.
  53799. */
  53800. changeLaserColor(color: Color3): void;
  53801. /**
  53802. * Sets the color of the ray from the vr headsets gaze.
  53803. * @param color new color for the ray.
  53804. */
  53805. changeGazeColor(color: Color3): void;
  53806. /**
  53807. * Exits VR and disposes of the vr experience helper
  53808. */
  53809. dispose(): void;
  53810. /**
  53811. * Gets the name of the VRExperienceHelper class
  53812. * @returns "VRExperienceHelper"
  53813. */
  53814. getClassName(): string;
  53815. }
  53816. }
  53817. declare module BABYLON {
  53818. /**
  53819. * Contains an array of blocks representing the octree
  53820. */
  53821. export interface IOctreeContainer<T> {
  53822. /**
  53823. * Blocks within the octree
  53824. */
  53825. blocks: Array<OctreeBlock<T>>;
  53826. }
  53827. /**
  53828. * Class used to store a cell in an octree
  53829. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53830. */
  53831. export class OctreeBlock<T> {
  53832. /**
  53833. * Gets the content of the current block
  53834. */
  53835. entries: T[];
  53836. /**
  53837. * Gets the list of block children
  53838. */
  53839. blocks: Array<OctreeBlock<T>>;
  53840. private _depth;
  53841. private _maxDepth;
  53842. private _capacity;
  53843. private _minPoint;
  53844. private _maxPoint;
  53845. private _boundingVectors;
  53846. private _creationFunc;
  53847. /**
  53848. * Creates a new block
  53849. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53850. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53851. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53852. * @param depth defines the current depth of this block in the octree
  53853. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53854. * @param creationFunc defines a callback to call when an element is added to the block
  53855. */
  53856. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53857. /**
  53858. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53859. */
  53860. get capacity(): number;
  53861. /**
  53862. * Gets the minimum vector (in world space) of the block's bounding box
  53863. */
  53864. get minPoint(): Vector3;
  53865. /**
  53866. * Gets the maximum vector (in world space) of the block's bounding box
  53867. */
  53868. get maxPoint(): Vector3;
  53869. /**
  53870. * Add a new element to this block
  53871. * @param entry defines the element to add
  53872. */
  53873. addEntry(entry: T): void;
  53874. /**
  53875. * Remove an element from this block
  53876. * @param entry defines the element to remove
  53877. */
  53878. removeEntry(entry: T): void;
  53879. /**
  53880. * Add an array of elements to this block
  53881. * @param entries defines the array of elements to add
  53882. */
  53883. addEntries(entries: T[]): void;
  53884. /**
  53885. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53886. * @param frustumPlanes defines the frustum planes to test
  53887. * @param selection defines the array to store current content if selection is positive
  53888. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53889. */
  53890. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53891. /**
  53892. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53893. * @param sphereCenter defines the bounding sphere center
  53894. * @param sphereRadius defines the bounding sphere radius
  53895. * @param selection defines the array to store current content if selection is positive
  53896. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53897. */
  53898. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53899. /**
  53900. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53901. * @param ray defines the ray to test with
  53902. * @param selection defines the array to store current content if selection is positive
  53903. */
  53904. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53905. /**
  53906. * Subdivide the content into child blocks (this block will then be empty)
  53907. */
  53908. createInnerBlocks(): void;
  53909. /**
  53910. * @hidden
  53911. */
  53912. 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;
  53913. }
  53914. }
  53915. declare module BABYLON {
  53916. /**
  53917. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53918. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53919. */
  53920. export class Octree<T> {
  53921. /** 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.) */
  53922. maxDepth: number;
  53923. /**
  53924. * Blocks within the octree containing objects
  53925. */
  53926. blocks: Array<OctreeBlock<T>>;
  53927. /**
  53928. * Content stored in the octree
  53929. */
  53930. dynamicContent: T[];
  53931. private _maxBlockCapacity;
  53932. private _selectionContent;
  53933. private _creationFunc;
  53934. /**
  53935. * Creates a octree
  53936. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53937. * @param creationFunc function to be used to instatiate the octree
  53938. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53939. * @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.)
  53940. */
  53941. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53942. /** 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.) */
  53943. maxDepth?: number);
  53944. /**
  53945. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53946. * @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);
  53947. * @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);
  53948. * @param entries meshes to be added to the octree blocks
  53949. */
  53950. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53951. /**
  53952. * Adds a mesh to the octree
  53953. * @param entry Mesh to add to the octree
  53954. */
  53955. addMesh(entry: T): void;
  53956. /**
  53957. * Remove an element from the octree
  53958. * @param entry defines the element to remove
  53959. */
  53960. removeMesh(entry: T): void;
  53961. /**
  53962. * Selects an array of meshes within the frustum
  53963. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53964. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53965. * @returns array of meshes within the frustum
  53966. */
  53967. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53968. /**
  53969. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53970. * @param sphereCenter defines the bounding sphere center
  53971. * @param sphereRadius defines the bounding sphere radius
  53972. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53973. * @returns an array of objects that intersect the sphere
  53974. */
  53975. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53976. /**
  53977. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53978. * @param ray defines the ray to test with
  53979. * @returns array of intersected objects
  53980. */
  53981. intersectsRay(ray: Ray): SmartArray<T>;
  53982. /**
  53983. * Adds a mesh into the octree block if it intersects the block
  53984. */
  53985. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53986. /**
  53987. * Adds a submesh into the octree block if it intersects the block
  53988. */
  53989. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53990. }
  53991. }
  53992. declare module BABYLON {
  53993. interface Scene {
  53994. /**
  53995. * @hidden
  53996. * Backing Filed
  53997. */
  53998. _selectionOctree: Octree<AbstractMesh>;
  53999. /**
  54000. * Gets the octree used to boost mesh selection (picking)
  54001. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54002. */
  54003. selectionOctree: Octree<AbstractMesh>;
  54004. /**
  54005. * Creates or updates the octree used to boost selection (picking)
  54006. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54007. * @param maxCapacity defines the maximum capacity per leaf
  54008. * @param maxDepth defines the maximum depth of the octree
  54009. * @returns an octree of AbstractMesh
  54010. */
  54011. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  54012. }
  54013. interface AbstractMesh {
  54014. /**
  54015. * @hidden
  54016. * Backing Field
  54017. */
  54018. _submeshesOctree: Octree<SubMesh>;
  54019. /**
  54020. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  54021. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  54022. * @param maxCapacity defines the maximum size of each block (64 by default)
  54023. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  54024. * @returns the new octree
  54025. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  54026. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54027. */
  54028. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  54029. }
  54030. /**
  54031. * Defines the octree scene component responsible to manage any octrees
  54032. * in a given scene.
  54033. */
  54034. export class OctreeSceneComponent {
  54035. /**
  54036. * The component name help to identify the component in the list of scene components.
  54037. */
  54038. readonly name: string;
  54039. /**
  54040. * The scene the component belongs to.
  54041. */
  54042. scene: Scene;
  54043. /**
  54044. * Indicates if the meshes have been checked to make sure they are isEnabled()
  54045. */
  54046. readonly checksIsEnabled: boolean;
  54047. /**
  54048. * Creates a new instance of the component for the given scene
  54049. * @param scene Defines the scene to register the component in
  54050. */
  54051. constructor(scene: Scene);
  54052. /**
  54053. * Registers the component in a given scene
  54054. */
  54055. register(): void;
  54056. /**
  54057. * Return the list of active meshes
  54058. * @returns the list of active meshes
  54059. */
  54060. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  54061. /**
  54062. * Return the list of active sub meshes
  54063. * @param mesh The mesh to get the candidates sub meshes from
  54064. * @returns the list of active sub meshes
  54065. */
  54066. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  54067. private _tempRay;
  54068. /**
  54069. * Return the list of sub meshes intersecting with a given local ray
  54070. * @param mesh defines the mesh to find the submesh for
  54071. * @param localRay defines the ray in local space
  54072. * @returns the list of intersecting sub meshes
  54073. */
  54074. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  54075. /**
  54076. * Return the list of sub meshes colliding with a collider
  54077. * @param mesh defines the mesh to find the submesh for
  54078. * @param collider defines the collider to evaluate the collision against
  54079. * @returns the list of colliding sub meshes
  54080. */
  54081. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  54082. /**
  54083. * Rebuilds the elements related to this component in case of
  54084. * context lost for instance.
  54085. */
  54086. rebuild(): void;
  54087. /**
  54088. * Disposes the component and the associated ressources.
  54089. */
  54090. dispose(): void;
  54091. }
  54092. }
  54093. declare module BABYLON {
  54094. /**
  54095. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  54096. */
  54097. export interface GizmoAxisCache {
  54098. /** Mesh used to runder the Gizmo */
  54099. gizmoMeshes: Mesh[];
  54100. /** Mesh used to detect user interaction with Gizmo */
  54101. colliderMeshes: Mesh[];
  54102. /** Material used to inicate color of gizmo mesh */
  54103. material: StandardMaterial;
  54104. /** Material used to inicate hover state of the Gizmo */
  54105. hoverMaterial: StandardMaterial;
  54106. /** Material used to inicate disabled state of the Gizmo */
  54107. disableMaterial: StandardMaterial;
  54108. /** Used to indicate Active state of the Gizmo */
  54109. active: boolean;
  54110. }
  54111. /**
  54112. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  54113. */
  54114. export class Gizmo implements IDisposable {
  54115. /** The utility layer the gizmo will be added to */
  54116. gizmoLayer: UtilityLayerRenderer;
  54117. /**
  54118. * The root mesh of the gizmo
  54119. */
  54120. _rootMesh: Mesh;
  54121. private _attachedMesh;
  54122. private _attachedNode;
  54123. /**
  54124. * Ratio for the scale of the gizmo (Default: 1)
  54125. */
  54126. protected _scaleRatio: number;
  54127. /**
  54128. * boolean updated by pointermove when a gizmo mesh is hovered
  54129. */
  54130. protected _isHovered: boolean;
  54131. /**
  54132. * Ratio for the scale of the gizmo (Default: 1)
  54133. */
  54134. set scaleRatio(value: number);
  54135. get scaleRatio(): number;
  54136. /**
  54137. * True when the mouse pointer is hovered a gizmo mesh
  54138. */
  54139. get isHovered(): boolean;
  54140. /**
  54141. * If a custom mesh has been set (Default: false)
  54142. */
  54143. protected _customMeshSet: boolean;
  54144. /**
  54145. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  54146. * * When set, interactions will be enabled
  54147. */
  54148. get attachedMesh(): Nullable<AbstractMesh>;
  54149. set attachedMesh(value: Nullable<AbstractMesh>);
  54150. /**
  54151. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  54152. * * When set, interactions will be enabled
  54153. */
  54154. get attachedNode(): Nullable<Node>;
  54155. set attachedNode(value: Nullable<Node>);
  54156. /**
  54157. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54158. * @param mesh The mesh to replace the default mesh of the gizmo
  54159. */
  54160. setCustomMesh(mesh: Mesh): void;
  54161. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  54162. /**
  54163. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  54164. */
  54165. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54166. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54167. /**
  54168. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  54169. */
  54170. updateGizmoPositionToMatchAttachedMesh: boolean;
  54171. /**
  54172. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  54173. */
  54174. updateScale: boolean;
  54175. protected _interactionsEnabled: boolean;
  54176. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54177. private _beforeRenderObserver;
  54178. private _tempQuaternion;
  54179. private _tempVector;
  54180. private _tempVector2;
  54181. private _tempMatrix1;
  54182. private _tempMatrix2;
  54183. private _rightHandtoLeftHandMatrix;
  54184. /**
  54185. * Creates a gizmo
  54186. * @param gizmoLayer The utility layer the gizmo will be added to
  54187. */
  54188. constructor(
  54189. /** The utility layer the gizmo will be added to */
  54190. gizmoLayer?: UtilityLayerRenderer);
  54191. /**
  54192. * Updates the gizmo to match the attached mesh's position/rotation
  54193. */
  54194. protected _update(): void;
  54195. /**
  54196. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  54197. * @param value Node, TransformNode or mesh
  54198. */
  54199. protected _matrixChanged(): void;
  54200. /**
  54201. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  54202. * @param gizmoLayer The utility layer the gizmo will be added to
  54203. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54204. * @returns {Observer<PointerInfo>} pointerObserver
  54205. */
  54206. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  54207. /**
  54208. * Disposes of the gizmo
  54209. */
  54210. dispose(): void;
  54211. }
  54212. }
  54213. declare module BABYLON {
  54214. /**
  54215. * Single plane drag gizmo
  54216. */
  54217. export class PlaneDragGizmo extends Gizmo {
  54218. /**
  54219. * Drag behavior responsible for the gizmos dragging interactions
  54220. */
  54221. dragBehavior: PointerDragBehavior;
  54222. private _pointerObserver;
  54223. /**
  54224. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54225. */
  54226. snapDistance: number;
  54227. /**
  54228. * Event that fires each time the gizmo snaps to a new location.
  54229. * * snapDistance is the the change in distance
  54230. */
  54231. onSnapObservable: Observable<{
  54232. snapDistance: number;
  54233. }>;
  54234. private _gizmoMesh;
  54235. private _coloredMaterial;
  54236. private _hoverMaterial;
  54237. private _disableMaterial;
  54238. private _isEnabled;
  54239. private _parent;
  54240. private _dragging;
  54241. /** @hidden */
  54242. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  54243. /**
  54244. * Creates a PlaneDragGizmo
  54245. * @param gizmoLayer The utility layer the gizmo will be added to
  54246. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  54247. * @param color The color of the gizmo
  54248. */
  54249. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  54250. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54251. /**
  54252. * If the gizmo is enabled
  54253. */
  54254. set isEnabled(value: boolean);
  54255. get isEnabled(): boolean;
  54256. /**
  54257. * Disposes of the gizmo
  54258. */
  54259. dispose(): void;
  54260. }
  54261. }
  54262. declare module BABYLON {
  54263. /**
  54264. * Single plane rotation gizmo
  54265. */
  54266. export class PlaneRotationGizmo extends Gizmo {
  54267. /**
  54268. * Drag behavior responsible for the gizmos dragging interactions
  54269. */
  54270. dragBehavior: PointerDragBehavior;
  54271. private _pointerObserver;
  54272. /**
  54273. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54274. */
  54275. snapDistance: number;
  54276. /**
  54277. * Event that fires each time the gizmo snaps to a new location.
  54278. * * snapDistance is the the change in distance
  54279. */
  54280. onSnapObservable: Observable<{
  54281. snapDistance: number;
  54282. }>;
  54283. private _isEnabled;
  54284. private _parent;
  54285. private _coloredMaterial;
  54286. private _hoverMaterial;
  54287. private _disableMaterial;
  54288. private _gizmoMesh;
  54289. private _rotationCircle;
  54290. private _dragging;
  54291. private static _CircleConstants;
  54292. /**
  54293. * Creates a PlaneRotationGizmo
  54294. * @param gizmoLayer The utility layer the gizmo will be added to
  54295. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54296. * @param color The color of the gizmo
  54297. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54298. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54299. * @param thickness display gizmo axis thickness
  54300. */
  54301. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  54302. /** Create Geometry for Gizmo */
  54303. private _createGizmoMesh;
  54304. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54305. private setupRotationCircle;
  54306. private updateRotationPath;
  54307. private updateRotationCircle;
  54308. /**
  54309. * If the gizmo is enabled
  54310. */
  54311. set isEnabled(value: boolean);
  54312. get isEnabled(): boolean;
  54313. /**
  54314. * Disposes of the gizmo
  54315. */
  54316. dispose(): void;
  54317. }
  54318. }
  54319. declare module BABYLON {
  54320. /**
  54321. * Gizmo that enables rotating a mesh along 3 axis
  54322. */
  54323. export class RotationGizmo extends Gizmo {
  54324. /**
  54325. * Internal gizmo used for interactions on the x axis
  54326. */
  54327. xGizmo: PlaneRotationGizmo;
  54328. /**
  54329. * Internal gizmo used for interactions on the y axis
  54330. */
  54331. yGizmo: PlaneRotationGizmo;
  54332. /**
  54333. * Internal gizmo used for interactions on the z axis
  54334. */
  54335. zGizmo: PlaneRotationGizmo;
  54336. /** Fires an event when any of it's sub gizmos are dragged */
  54337. onDragStartObservable: Observable<unknown>;
  54338. /** Fires an event when any of it's sub gizmos are released from dragging */
  54339. onDragEndObservable: Observable<unknown>;
  54340. private _meshAttached;
  54341. private _nodeAttached;
  54342. private _observables;
  54343. /** Node Caching for quick lookup */
  54344. private _gizmoAxisCache;
  54345. get attachedMesh(): Nullable<AbstractMesh>;
  54346. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54347. get attachedNode(): Nullable<Node>;
  54348. set attachedNode(node: Nullable<Node>);
  54349. protected _checkBillboardTransform(): void;
  54350. /**
  54351. * True when the mouse pointer is hovering a gizmo mesh
  54352. */
  54353. get isHovered(): boolean;
  54354. /**
  54355. * Creates a RotationGizmo
  54356. * @param gizmoLayer The utility layer the gizmo will be added to
  54357. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54358. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54359. * @param thickness display gizmo axis thickness
  54360. */
  54361. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  54362. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54363. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54364. /**
  54365. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54366. */
  54367. set snapDistance(value: number);
  54368. get snapDistance(): number;
  54369. /**
  54370. * Ratio for the scale of the gizmo (Default: 1)
  54371. */
  54372. set scaleRatio(value: number);
  54373. get scaleRatio(): number;
  54374. /**
  54375. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54376. * @param mesh Axis gizmo mesh
  54377. * @param cache Gizmo axis definition used for reactive gizmo UI
  54378. */
  54379. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54380. /**
  54381. * Disposes of the gizmo
  54382. */
  54383. dispose(): void;
  54384. /**
  54385. * CustomMeshes are not supported by this gizmo
  54386. * @param mesh The mesh to replace the default mesh of the gizmo
  54387. */
  54388. setCustomMesh(mesh: Mesh): void;
  54389. }
  54390. }
  54391. declare module BABYLON {
  54392. /**
  54393. * Class containing static functions to help procedurally build meshes
  54394. */
  54395. export class PolyhedronBuilder {
  54396. /**
  54397. * Creates a polyhedron mesh
  54398. * * 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
  54399. * * The parameter `size` (positive float, default 1) sets the polygon size
  54400. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54401. * * 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`
  54402. * * 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
  54403. * * 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)`)
  54404. * * 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
  54405. * * 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
  54406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54407. * * 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
  54408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54409. * @param name defines the name of the mesh
  54410. * @param options defines the options used to create the mesh
  54411. * @param scene defines the hosting scene
  54412. * @returns the polyhedron mesh
  54413. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54414. */
  54415. static CreatePolyhedron(name: string, options: {
  54416. type?: number;
  54417. size?: number;
  54418. sizeX?: number;
  54419. sizeY?: number;
  54420. sizeZ?: number;
  54421. custom?: any;
  54422. faceUV?: Vector4[];
  54423. faceColors?: Color4[];
  54424. flat?: boolean;
  54425. updatable?: boolean;
  54426. sideOrientation?: number;
  54427. frontUVs?: Vector4;
  54428. backUVs?: Vector4;
  54429. }, scene?: Nullable<Scene>): Mesh;
  54430. }
  54431. }
  54432. declare module BABYLON {
  54433. /**
  54434. * Class containing static functions to help procedurally build meshes
  54435. */
  54436. export class BoxBuilder {
  54437. /**
  54438. * Creates a box mesh
  54439. * * The parameter `size` sets the size (float) of each box side (default 1)
  54440. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54441. * * 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)
  54442. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54444. * * 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
  54445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54446. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54447. * @param name defines the name of the mesh
  54448. * @param options defines the options used to create the mesh
  54449. * @param scene defines the hosting scene
  54450. * @returns the box mesh
  54451. */
  54452. static CreateBox(name: string, options: {
  54453. size?: number;
  54454. width?: number;
  54455. height?: number;
  54456. depth?: number;
  54457. faceUV?: Vector4[];
  54458. faceColors?: Color4[];
  54459. sideOrientation?: number;
  54460. frontUVs?: Vector4;
  54461. backUVs?: Vector4;
  54462. wrap?: boolean;
  54463. topBaseAt?: number;
  54464. bottomBaseAt?: number;
  54465. updatable?: boolean;
  54466. }, scene?: Nullable<Scene>): Mesh;
  54467. }
  54468. }
  54469. declare module BABYLON {
  54470. /**
  54471. * Single axis scale gizmo
  54472. */
  54473. export class AxisScaleGizmo extends Gizmo {
  54474. /**
  54475. * Drag behavior responsible for the gizmos dragging interactions
  54476. */
  54477. dragBehavior: PointerDragBehavior;
  54478. private _pointerObserver;
  54479. /**
  54480. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54481. */
  54482. snapDistance: number;
  54483. /**
  54484. * Event that fires each time the gizmo snaps to a new location.
  54485. * * snapDistance is the the change in distance
  54486. */
  54487. onSnapObservable: Observable<{
  54488. snapDistance: number;
  54489. }>;
  54490. /**
  54491. * If the scaling operation should be done on all axis (default: false)
  54492. */
  54493. uniformScaling: boolean;
  54494. /**
  54495. * Custom sensitivity value for the drag strength
  54496. */
  54497. sensitivity: number;
  54498. private _isEnabled;
  54499. private _parent;
  54500. private _gizmoMesh;
  54501. private _coloredMaterial;
  54502. private _hoverMaterial;
  54503. private _disableMaterial;
  54504. private _dragging;
  54505. private _tmpVector;
  54506. private _tmpMatrix;
  54507. private _tmpMatrix2;
  54508. /**
  54509. * Creates an AxisScaleGizmo
  54510. * @param gizmoLayer The utility layer the gizmo will be added to
  54511. * @param dragAxis The axis which the gizmo will be able to scale on
  54512. * @param color The color of the gizmo
  54513. * @param thickness display gizmo axis thickness
  54514. */
  54515. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  54516. /** Create Geometry for Gizmo */
  54517. private _createGizmoMesh;
  54518. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54519. /**
  54520. * If the gizmo is enabled
  54521. */
  54522. set isEnabled(value: boolean);
  54523. get isEnabled(): boolean;
  54524. /**
  54525. * Disposes of the gizmo
  54526. */
  54527. dispose(): void;
  54528. /**
  54529. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54530. * @param mesh The mesh to replace the default mesh of the gizmo
  54531. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54532. */
  54533. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54534. }
  54535. }
  54536. declare module BABYLON {
  54537. /**
  54538. * Gizmo that enables scaling a mesh along 3 axis
  54539. */
  54540. export class ScaleGizmo extends Gizmo {
  54541. /**
  54542. * Internal gizmo used for interactions on the x axis
  54543. */
  54544. xGizmo: AxisScaleGizmo;
  54545. /**
  54546. * Internal gizmo used for interactions on the y axis
  54547. */
  54548. yGizmo: AxisScaleGizmo;
  54549. /**
  54550. * Internal gizmo used for interactions on the z axis
  54551. */
  54552. zGizmo: AxisScaleGizmo;
  54553. /**
  54554. * Internal gizmo used to scale all axis equally
  54555. */
  54556. uniformScaleGizmo: AxisScaleGizmo;
  54557. private _meshAttached;
  54558. private _nodeAttached;
  54559. private _snapDistance;
  54560. private _uniformScalingMesh;
  54561. private _octahedron;
  54562. private _sensitivity;
  54563. private _coloredMaterial;
  54564. private _hoverMaterial;
  54565. private _disableMaterial;
  54566. private _observables;
  54567. /** Node Caching for quick lookup */
  54568. private _gizmoAxisCache;
  54569. /** Fires an event when any of it's sub gizmos are dragged */
  54570. onDragStartObservable: Observable<unknown>;
  54571. /** Fires an event when any of it's sub gizmos are released from dragging */
  54572. onDragEndObservable: Observable<unknown>;
  54573. get attachedMesh(): Nullable<AbstractMesh>;
  54574. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54575. get attachedNode(): Nullable<Node>;
  54576. set attachedNode(node: Nullable<Node>);
  54577. /**
  54578. * True when the mouse pointer is hovering a gizmo mesh
  54579. */
  54580. get isHovered(): boolean;
  54581. /**
  54582. * Creates a ScaleGizmo
  54583. * @param gizmoLayer The utility layer the gizmo will be added to
  54584. * @param thickness display gizmo axis thickness
  54585. */
  54586. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54587. /** Create Geometry for Gizmo */
  54588. private _createUniformScaleMesh;
  54589. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54590. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54591. /**
  54592. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54593. */
  54594. set snapDistance(value: number);
  54595. get snapDistance(): number;
  54596. /**
  54597. * Ratio for the scale of the gizmo (Default: 1)
  54598. */
  54599. set scaleRatio(value: number);
  54600. get scaleRatio(): number;
  54601. /**
  54602. * Sensitivity factor for dragging (Default: 1)
  54603. */
  54604. set sensitivity(value: number);
  54605. get sensitivity(): number;
  54606. /**
  54607. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54608. * @param mesh Axis gizmo mesh
  54609. * @param cache Gizmo axis definition used for reactive gizmo UI
  54610. */
  54611. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54612. /**
  54613. * Disposes of the gizmo
  54614. */
  54615. dispose(): void;
  54616. }
  54617. }
  54618. declare module BABYLON {
  54619. /**
  54620. * Bounding box gizmo
  54621. */
  54622. export class BoundingBoxGizmo extends Gizmo {
  54623. private _lineBoundingBox;
  54624. private _rotateSpheresParent;
  54625. private _scaleBoxesParent;
  54626. private _boundingDimensions;
  54627. private _renderObserver;
  54628. private _pointerObserver;
  54629. private _scaleDragSpeed;
  54630. private _tmpQuaternion;
  54631. private _tmpVector;
  54632. private _tmpRotationMatrix;
  54633. /**
  54634. * 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)
  54635. */
  54636. ignoreChildren: boolean;
  54637. /**
  54638. * 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)
  54639. */
  54640. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54641. /**
  54642. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54643. */
  54644. rotationSphereSize: number;
  54645. /**
  54646. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54647. */
  54648. scaleBoxSize: number;
  54649. /**
  54650. * 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)
  54651. */
  54652. fixedDragMeshScreenSize: boolean;
  54653. /**
  54654. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54655. */
  54656. fixedDragMeshScreenSizeDistanceFactor: number;
  54657. /**
  54658. * Fired when a rotation sphere or scale box is dragged
  54659. */
  54660. onDragStartObservable: Observable<{}>;
  54661. /**
  54662. * Fired when a scale box is dragged
  54663. */
  54664. onScaleBoxDragObservable: Observable<{}>;
  54665. /**
  54666. * Fired when a scale box drag is ended
  54667. */
  54668. onScaleBoxDragEndObservable: Observable<{}>;
  54669. /**
  54670. * Fired when a rotation sphere is dragged
  54671. */
  54672. onRotationSphereDragObservable: Observable<{}>;
  54673. /**
  54674. * Fired when a rotation sphere drag is ended
  54675. */
  54676. onRotationSphereDragEndObservable: Observable<{}>;
  54677. /**
  54678. * 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)
  54679. */
  54680. scalePivot: Nullable<Vector3>;
  54681. /**
  54682. * Mesh used as a pivot to rotate the attached node
  54683. */
  54684. private _anchorMesh;
  54685. private _existingMeshScale;
  54686. private _dragMesh;
  54687. private pointerDragBehavior;
  54688. private coloredMaterial;
  54689. private hoverColoredMaterial;
  54690. /**
  54691. * Sets the color of the bounding box gizmo
  54692. * @param color the color to set
  54693. */
  54694. setColor(color: Color3): void;
  54695. /**
  54696. * Creates an BoundingBoxGizmo
  54697. * @param gizmoLayer The utility layer the gizmo will be added to
  54698. * @param color The color of the gizmo
  54699. */
  54700. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54701. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  54702. private _selectNode;
  54703. /**
  54704. * Updates the bounding box information for the Gizmo
  54705. */
  54706. updateBoundingBox(): void;
  54707. private _updateRotationSpheres;
  54708. private _updateScaleBoxes;
  54709. /**
  54710. * Enables rotation on the specified axis and disables rotation on the others
  54711. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54712. */
  54713. setEnabledRotationAxis(axis: string): void;
  54714. /**
  54715. * Enables/disables scaling
  54716. * @param enable if scaling should be enabled
  54717. * @param homogeneousScaling defines if scaling should only be homogeneous
  54718. */
  54719. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54720. private _updateDummy;
  54721. /**
  54722. * Enables a pointer drag behavior on the bounding box of the gizmo
  54723. */
  54724. enableDragBehavior(): void;
  54725. /**
  54726. * Disposes of the gizmo
  54727. */
  54728. dispose(): void;
  54729. /**
  54730. * 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)
  54731. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54732. * @returns the bounding box mesh with the passed in mesh as a child
  54733. */
  54734. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54735. /**
  54736. * CustomMeshes are not supported by this gizmo
  54737. * @param mesh The mesh to replace the default mesh of the gizmo
  54738. */
  54739. setCustomMesh(mesh: Mesh): void;
  54740. }
  54741. }
  54742. declare module BABYLON {
  54743. /**
  54744. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  54745. */
  54746. export class GizmoManager implements IDisposable {
  54747. private scene;
  54748. /**
  54749. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54750. */
  54751. gizmos: {
  54752. positionGizmo: Nullable<PositionGizmo>;
  54753. rotationGizmo: Nullable<RotationGizmo>;
  54754. scaleGizmo: Nullable<ScaleGizmo>;
  54755. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54756. };
  54757. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54758. clearGizmoOnEmptyPointerEvent: boolean;
  54759. /** Fires an event when the manager is attached to a mesh */
  54760. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54761. /** Fires an event when the manager is attached to a node */
  54762. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54763. private _gizmosEnabled;
  54764. private _pointerObservers;
  54765. private _attachedMesh;
  54766. private _attachedNode;
  54767. private _boundingBoxColor;
  54768. private _defaultUtilityLayer;
  54769. private _defaultKeepDepthUtilityLayer;
  54770. private _thickness;
  54771. /** Node Caching for quick lookup */
  54772. private _gizmoAxisCache;
  54773. /**
  54774. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54775. */
  54776. boundingBoxDragBehavior: SixDofDragBehavior;
  54777. /**
  54778. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54779. */
  54780. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54781. /**
  54782. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54783. */
  54784. attachableNodes: Nullable<Array<Node>>;
  54785. /**
  54786. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54787. */
  54788. usePointerToAttachGizmos: boolean;
  54789. /**
  54790. * Utility layer that the bounding box gizmo belongs to
  54791. */
  54792. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54793. /**
  54794. * Utility layer that all gizmos besides bounding box belong to
  54795. */
  54796. get utilityLayer(): UtilityLayerRenderer;
  54797. /**
  54798. * True when the mouse pointer is hovering a gizmo mesh
  54799. */
  54800. get isHovered(): boolean;
  54801. /**
  54802. * Instatiates a gizmo manager
  54803. * @param scene the scene to overlay the gizmos on top of
  54804. * @param thickness display gizmo axis thickness
  54805. * @param utilityLayer the layer where gizmos are rendered
  54806. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  54807. */
  54808. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  54809. /**
  54810. * Subscribes to pointer down events, for attaching and detaching mesh
  54811. * @param scene The sceme layer the observer will be added to
  54812. */
  54813. private _attachToMeshPointerObserver;
  54814. /**
  54815. * Attaches a set of gizmos to the specified mesh
  54816. * @param mesh The mesh the gizmo's should be attached to
  54817. */
  54818. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54819. /**
  54820. * Attaches a set of gizmos to the specified node
  54821. * @param node The node the gizmo's should be attached to
  54822. */
  54823. attachToNode(node: Nullable<Node>): void;
  54824. /**
  54825. * If the position gizmo is enabled
  54826. */
  54827. set positionGizmoEnabled(value: boolean);
  54828. get positionGizmoEnabled(): boolean;
  54829. /**
  54830. * If the rotation gizmo is enabled
  54831. */
  54832. set rotationGizmoEnabled(value: boolean);
  54833. get rotationGizmoEnabled(): boolean;
  54834. /**
  54835. * If the scale gizmo is enabled
  54836. */
  54837. set scaleGizmoEnabled(value: boolean);
  54838. get scaleGizmoEnabled(): boolean;
  54839. /**
  54840. * If the boundingBox gizmo is enabled
  54841. */
  54842. set boundingBoxGizmoEnabled(value: boolean);
  54843. get boundingBoxGizmoEnabled(): boolean;
  54844. /**
  54845. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54846. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54847. */
  54848. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  54849. /**
  54850. * Disposes of the gizmo manager
  54851. */
  54852. dispose(): void;
  54853. }
  54854. }
  54855. declare module BABYLON {
  54856. /**
  54857. * Gizmo that enables dragging a mesh along 3 axis
  54858. */
  54859. export class PositionGizmo extends Gizmo {
  54860. /**
  54861. * Internal gizmo used for interactions on the x axis
  54862. */
  54863. xGizmo: AxisDragGizmo;
  54864. /**
  54865. * Internal gizmo used for interactions on the y axis
  54866. */
  54867. yGizmo: AxisDragGizmo;
  54868. /**
  54869. * Internal gizmo used for interactions on the z axis
  54870. */
  54871. zGizmo: AxisDragGizmo;
  54872. /**
  54873. * Internal gizmo used for interactions on the yz plane
  54874. */
  54875. xPlaneGizmo: PlaneDragGizmo;
  54876. /**
  54877. * Internal gizmo used for interactions on the xz plane
  54878. */
  54879. yPlaneGizmo: PlaneDragGizmo;
  54880. /**
  54881. * Internal gizmo used for interactions on the xy plane
  54882. */
  54883. zPlaneGizmo: PlaneDragGizmo;
  54884. /**
  54885. * private variables
  54886. */
  54887. private _meshAttached;
  54888. private _nodeAttached;
  54889. private _snapDistance;
  54890. private _observables;
  54891. /** Node Caching for quick lookup */
  54892. private _gizmoAxisCache;
  54893. /** Fires an event when any of it's sub gizmos are dragged */
  54894. onDragStartObservable: Observable<unknown>;
  54895. /** Fires an event when any of it's sub gizmos are released from dragging */
  54896. onDragEndObservable: Observable<unknown>;
  54897. /**
  54898. * If set to true, planar drag is enabled
  54899. */
  54900. private _planarGizmoEnabled;
  54901. get attachedMesh(): Nullable<AbstractMesh>;
  54902. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54903. get attachedNode(): Nullable<Node>;
  54904. set attachedNode(node: Nullable<Node>);
  54905. /**
  54906. * True when the mouse pointer is hovering a gizmo mesh
  54907. */
  54908. get isHovered(): boolean;
  54909. /**
  54910. * Creates a PositionGizmo
  54911. * @param gizmoLayer The utility layer the gizmo will be added to
  54912. @param thickness display gizmo axis thickness
  54913. */
  54914. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54915. /**
  54916. * If the planar drag gizmo is enabled
  54917. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  54918. */
  54919. set planarGizmoEnabled(value: boolean);
  54920. get planarGizmoEnabled(): boolean;
  54921. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54922. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54923. /**
  54924. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54925. */
  54926. set snapDistance(value: number);
  54927. get snapDistance(): number;
  54928. /**
  54929. * Ratio for the scale of the gizmo (Default: 1)
  54930. */
  54931. set scaleRatio(value: number);
  54932. get scaleRatio(): number;
  54933. /**
  54934. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54935. * @param mesh Axis gizmo mesh
  54936. * @param cache Gizmo axis definition used for reactive gizmo UI
  54937. */
  54938. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54939. /**
  54940. * Disposes of the gizmo
  54941. */
  54942. dispose(): void;
  54943. /**
  54944. * CustomMeshes are not supported by this gizmo
  54945. * @param mesh The mesh to replace the default mesh of the gizmo
  54946. */
  54947. setCustomMesh(mesh: Mesh): void;
  54948. }
  54949. }
  54950. declare module BABYLON {
  54951. /**
  54952. * Single axis drag gizmo
  54953. */
  54954. export class AxisDragGizmo extends Gizmo {
  54955. /**
  54956. * Drag behavior responsible for the gizmos dragging interactions
  54957. */
  54958. dragBehavior: PointerDragBehavior;
  54959. private _pointerObserver;
  54960. /**
  54961. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54962. */
  54963. snapDistance: number;
  54964. /**
  54965. * Event that fires each time the gizmo snaps to a new location.
  54966. * * snapDistance is the the change in distance
  54967. */
  54968. onSnapObservable: Observable<{
  54969. snapDistance: number;
  54970. }>;
  54971. private _isEnabled;
  54972. private _parent;
  54973. private _gizmoMesh;
  54974. private _coloredMaterial;
  54975. private _hoverMaterial;
  54976. private _disableMaterial;
  54977. private _dragging;
  54978. /** @hidden */
  54979. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  54980. /** @hidden */
  54981. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  54982. /**
  54983. * Creates an AxisDragGizmo
  54984. * @param gizmoLayer The utility layer the gizmo will be added to
  54985. * @param dragAxis The axis which the gizmo will be able to drag on
  54986. * @param color The color of the gizmo
  54987. * @param thickness display gizmo axis thickness
  54988. */
  54989. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  54990. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54991. /**
  54992. * If the gizmo is enabled
  54993. */
  54994. set isEnabled(value: boolean);
  54995. get isEnabled(): boolean;
  54996. /**
  54997. * Disposes of the gizmo
  54998. */
  54999. dispose(): void;
  55000. }
  55001. }
  55002. declare module BABYLON.Debug {
  55003. /**
  55004. * The Axes viewer will show 3 axes in a specific point in space
  55005. */
  55006. export class AxesViewer {
  55007. private _xAxis;
  55008. private _yAxis;
  55009. private _zAxis;
  55010. private _scaleLinesFactor;
  55011. private _instanced;
  55012. /**
  55013. * Gets the hosting scene
  55014. */
  55015. scene: Nullable<Scene>;
  55016. /**
  55017. * Gets or sets a number used to scale line length
  55018. */
  55019. scaleLines: number;
  55020. /** Gets the node hierarchy used to render x-axis */
  55021. get xAxis(): TransformNode;
  55022. /** Gets the node hierarchy used to render y-axis */
  55023. get yAxis(): TransformNode;
  55024. /** Gets the node hierarchy used to render z-axis */
  55025. get zAxis(): TransformNode;
  55026. /**
  55027. * Creates a new AxesViewer
  55028. * @param scene defines the hosting scene
  55029. * @param scaleLines defines a number used to scale line length (1 by default)
  55030. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  55031. * @param xAxis defines the node hierarchy used to render the x-axis
  55032. * @param yAxis defines the node hierarchy used to render the y-axis
  55033. * @param zAxis defines the node hierarchy used to render the z-axis
  55034. */
  55035. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  55036. /**
  55037. * Force the viewer to update
  55038. * @param position defines the position of the viewer
  55039. * @param xaxis defines the x axis of the viewer
  55040. * @param yaxis defines the y axis of the viewer
  55041. * @param zaxis defines the z axis of the viewer
  55042. */
  55043. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  55044. /**
  55045. * Creates an instance of this axes viewer.
  55046. * @returns a new axes viewer with instanced meshes
  55047. */
  55048. createInstance(): AxesViewer;
  55049. /** Releases resources */
  55050. dispose(): void;
  55051. private static _SetRenderingGroupId;
  55052. }
  55053. }
  55054. declare module BABYLON.Debug {
  55055. /**
  55056. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  55057. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  55058. */
  55059. export class BoneAxesViewer extends AxesViewer {
  55060. /**
  55061. * Gets or sets the target mesh where to display the axes viewer
  55062. */
  55063. mesh: Nullable<Mesh>;
  55064. /**
  55065. * Gets or sets the target bone where to display the axes viewer
  55066. */
  55067. bone: Nullable<Bone>;
  55068. /** Gets current position */
  55069. pos: Vector3;
  55070. /** Gets direction of X axis */
  55071. xaxis: Vector3;
  55072. /** Gets direction of Y axis */
  55073. yaxis: Vector3;
  55074. /** Gets direction of Z axis */
  55075. zaxis: Vector3;
  55076. /**
  55077. * Creates a new BoneAxesViewer
  55078. * @param scene defines the hosting scene
  55079. * @param bone defines the target bone
  55080. * @param mesh defines the target mesh
  55081. * @param scaleLines defines a scaling factor for line length (1 by default)
  55082. */
  55083. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  55084. /**
  55085. * Force the viewer to update
  55086. */
  55087. update(): void;
  55088. /** Releases resources */
  55089. dispose(): void;
  55090. }
  55091. }
  55092. declare module BABYLON {
  55093. /**
  55094. * Interface used to define scene explorer extensibility option
  55095. */
  55096. export interface IExplorerExtensibilityOption {
  55097. /**
  55098. * Define the option label
  55099. */
  55100. label: string;
  55101. /**
  55102. * Defines the action to execute on click
  55103. */
  55104. action: (entity: any) => void;
  55105. }
  55106. /**
  55107. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  55108. */
  55109. export interface IExplorerExtensibilityGroup {
  55110. /**
  55111. * Defines a predicate to test if a given type mut be extended
  55112. */
  55113. predicate: (entity: any) => boolean;
  55114. /**
  55115. * Gets the list of options added to a type
  55116. */
  55117. entries: IExplorerExtensibilityOption[];
  55118. }
  55119. /**
  55120. * Interface used to define the options to use to create the Inspector
  55121. */
  55122. export interface IInspectorOptions {
  55123. /**
  55124. * Display in overlay mode (default: false)
  55125. */
  55126. overlay?: boolean;
  55127. /**
  55128. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  55129. */
  55130. globalRoot?: HTMLElement;
  55131. /**
  55132. * Display the Scene explorer
  55133. */
  55134. showExplorer?: boolean;
  55135. /**
  55136. * Display the property inspector
  55137. */
  55138. showInspector?: boolean;
  55139. /**
  55140. * Display in embed mode (both panes on the right)
  55141. */
  55142. embedMode?: boolean;
  55143. /**
  55144. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  55145. */
  55146. handleResize?: boolean;
  55147. /**
  55148. * Allow the panes to popup (default: true)
  55149. */
  55150. enablePopup?: boolean;
  55151. /**
  55152. * Allow the panes to be closed by users (default: true)
  55153. */
  55154. enableClose?: boolean;
  55155. /**
  55156. * Optional list of extensibility entries
  55157. */
  55158. explorerExtensibility?: IExplorerExtensibilityGroup[];
  55159. /**
  55160. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  55161. */
  55162. inspectorURL?: string;
  55163. /**
  55164. * Optional initial tab (default to DebugLayerTab.Properties)
  55165. */
  55166. initialTab?: DebugLayerTab;
  55167. }
  55168. interface Scene {
  55169. /**
  55170. * @hidden
  55171. * Backing field
  55172. */
  55173. _debugLayer: DebugLayer;
  55174. /**
  55175. * Gets the debug layer (aka Inspector) associated with the scene
  55176. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55177. */
  55178. debugLayer: DebugLayer;
  55179. }
  55180. /**
  55181. * Enum of inspector action tab
  55182. */
  55183. export enum DebugLayerTab {
  55184. /**
  55185. * Properties tag (default)
  55186. */
  55187. Properties = 0,
  55188. /**
  55189. * Debug tab
  55190. */
  55191. Debug = 1,
  55192. /**
  55193. * Statistics tab
  55194. */
  55195. Statistics = 2,
  55196. /**
  55197. * Tools tab
  55198. */
  55199. Tools = 3,
  55200. /**
  55201. * Settings tab
  55202. */
  55203. Settings = 4
  55204. }
  55205. /**
  55206. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55207. * what is happening in your scene
  55208. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55209. */
  55210. export class DebugLayer {
  55211. /**
  55212. * Define the url to get the inspector script from.
  55213. * By default it uses the babylonjs CDN.
  55214. * @ignoreNaming
  55215. */
  55216. static InspectorURL: string;
  55217. private _scene;
  55218. private BJSINSPECTOR;
  55219. private _onPropertyChangedObservable?;
  55220. /**
  55221. * Observable triggered when a property is changed through the inspector.
  55222. */
  55223. get onPropertyChangedObservable(): any;
  55224. /**
  55225. * Instantiates a new debug layer.
  55226. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55227. * what is happening in your scene
  55228. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55229. * @param scene Defines the scene to inspect
  55230. */
  55231. constructor(scene: Scene);
  55232. /** Creates the inspector window. */
  55233. private _createInspector;
  55234. /**
  55235. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  55236. * @param entity defines the entity to select
  55237. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  55238. */
  55239. select(entity: any, lineContainerTitles?: string | string[]): void;
  55240. /** Get the inspector from bundle or global */
  55241. private _getGlobalInspector;
  55242. /**
  55243. * Get if the inspector is visible or not.
  55244. * @returns true if visible otherwise, false
  55245. */
  55246. isVisible(): boolean;
  55247. /**
  55248. * Hide the inspector and close its window.
  55249. */
  55250. hide(): void;
  55251. /**
  55252. * Update the scene in the inspector
  55253. */
  55254. setAsActiveScene(): void;
  55255. /**
  55256. * Launch the debugLayer.
  55257. * @param config Define the configuration of the inspector
  55258. * @return a promise fulfilled when the debug layer is visible
  55259. */
  55260. show(config?: IInspectorOptions): Promise<DebugLayer>;
  55261. }
  55262. }
  55263. declare module BABYLON.Debug {
  55264. /**
  55265. * Used to show the physics impostor around the specific mesh
  55266. */
  55267. export class PhysicsViewer {
  55268. /** @hidden */
  55269. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  55270. /** @hidden */
  55271. protected _meshes: Array<Nullable<AbstractMesh>>;
  55272. /** @hidden */
  55273. protected _scene: Nullable<Scene>;
  55274. /** @hidden */
  55275. protected _numMeshes: number;
  55276. /** @hidden */
  55277. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  55278. private _renderFunction;
  55279. private _utilityLayer;
  55280. private _debugBoxMesh;
  55281. private _debugSphereMesh;
  55282. private _debugCylinderMesh;
  55283. private _debugMaterial;
  55284. private _debugMeshMeshes;
  55285. /**
  55286. * Creates a new PhysicsViewer
  55287. * @param scene defines the hosting scene
  55288. */
  55289. constructor(scene: Scene);
  55290. /** @hidden */
  55291. protected _updateDebugMeshes(): void;
  55292. /**
  55293. * Renders a specified physic impostor
  55294. * @param impostor defines the impostor to render
  55295. * @param targetMesh defines the mesh represented by the impostor
  55296. * @returns the new debug mesh used to render the impostor
  55297. */
  55298. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  55299. /**
  55300. * Hides a specified physic impostor
  55301. * @param impostor defines the impostor to hide
  55302. */
  55303. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  55304. private _getDebugMaterial;
  55305. private _getDebugBoxMesh;
  55306. private _getDebugSphereMesh;
  55307. private _getDebugCylinderMesh;
  55308. private _getDebugMeshMesh;
  55309. private _getDebugMesh;
  55310. /** Releases all resources */
  55311. dispose(): void;
  55312. }
  55313. }
  55314. declare module BABYLON {
  55315. /**
  55316. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55317. * in order to better appreciate the issue one might have.
  55318. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55319. */
  55320. export class RayHelper {
  55321. /**
  55322. * Defines the ray we are currently tryin to visualize.
  55323. */
  55324. ray: Nullable<Ray>;
  55325. private _renderPoints;
  55326. private _renderLine;
  55327. private _renderFunction;
  55328. private _scene;
  55329. private _onAfterRenderObserver;
  55330. private _onAfterStepObserver;
  55331. private _attachedToMesh;
  55332. private _meshSpaceDirection;
  55333. private _meshSpaceOrigin;
  55334. /**
  55335. * Helper function to create a colored helper in a scene in one line.
  55336. * @param ray Defines the ray we are currently tryin to visualize
  55337. * @param scene Defines the scene the ray is used in
  55338. * @param color Defines the color we want to see the ray in
  55339. * @returns The newly created ray helper.
  55340. */
  55341. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  55342. /**
  55343. * Instantiate a new ray helper.
  55344. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55345. * in order to better appreciate the issue one might have.
  55346. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55347. * @param ray Defines the ray we are currently tryin to visualize
  55348. */
  55349. constructor(ray: Ray);
  55350. /**
  55351. * Shows the ray we are willing to debug.
  55352. * @param scene Defines the scene the ray needs to be rendered in
  55353. * @param color Defines the color the ray needs to be rendered in
  55354. */
  55355. show(scene: Scene, color?: Color3): void;
  55356. /**
  55357. * Hides the ray we are debugging.
  55358. */
  55359. hide(): void;
  55360. private _render;
  55361. /**
  55362. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  55363. * @param mesh Defines the mesh we want the helper attached to
  55364. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  55365. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  55366. * @param length Defines the length of the ray
  55367. */
  55368. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  55369. /**
  55370. * Detach the ray helper from the mesh it has previously been attached to.
  55371. */
  55372. detachFromMesh(): void;
  55373. private _updateToMesh;
  55374. /**
  55375. * Dispose the helper and release its associated resources.
  55376. */
  55377. dispose(): void;
  55378. }
  55379. }
  55380. declare module BABYLON {
  55381. /**
  55382. * Defines the options associated with the creation of a SkeletonViewer.
  55383. */
  55384. export interface ISkeletonViewerOptions {
  55385. /** Should the system pause animations before building the Viewer? */
  55386. pauseAnimations: boolean;
  55387. /** Should the system return the skeleton to rest before building? */
  55388. returnToRest: boolean;
  55389. /** public Display Mode of the Viewer */
  55390. displayMode: number;
  55391. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55392. displayOptions: ISkeletonViewerDisplayOptions;
  55393. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55394. computeBonesUsingShaders: boolean;
  55395. /** Flag ignore non weighted bones */
  55396. useAllBones: boolean;
  55397. }
  55398. /**
  55399. * Defines how to display the various bone meshes for the viewer.
  55400. */
  55401. export interface ISkeletonViewerDisplayOptions {
  55402. /** How far down to start tapering the bone spurs */
  55403. midStep?: number;
  55404. /** How big is the midStep? */
  55405. midStepFactor?: number;
  55406. /** Base for the Sphere Size */
  55407. sphereBaseSize?: number;
  55408. /** The ratio of the sphere to the longest bone in units */
  55409. sphereScaleUnit?: number;
  55410. /** Ratio for the Sphere Size */
  55411. sphereFactor?: number;
  55412. /** Whether a spur should attach its far end to the child bone position */
  55413. spurFollowsChild?: boolean;
  55414. /** Whether to show local axes or not */
  55415. showLocalAxes?: boolean;
  55416. /** Length of each local axis */
  55417. localAxesSize?: number;
  55418. }
  55419. /**
  55420. * Defines the constructor options for the BoneWeight Shader.
  55421. */
  55422. export interface IBoneWeightShaderOptions {
  55423. /** Skeleton to Map */
  55424. skeleton: Skeleton;
  55425. /** Colors for Uninfluenced bones */
  55426. colorBase?: Color3;
  55427. /** Colors for 0.0-0.25 Weight bones */
  55428. colorZero?: Color3;
  55429. /** Color for 0.25-0.5 Weight Influence */
  55430. colorQuarter?: Color3;
  55431. /** Color for 0.5-0.75 Weight Influence */
  55432. colorHalf?: Color3;
  55433. /** Color for 0.75-1 Weight Influence */
  55434. colorFull?: Color3;
  55435. /** Color for Zero Weight Influence */
  55436. targetBoneIndex?: number;
  55437. }
  55438. /**
  55439. * Simple structure of the gradient steps for the Color Map.
  55440. */
  55441. export interface ISkeletonMapShaderColorMapKnot {
  55442. /** Color of the Knot */
  55443. color: Color3;
  55444. /** Location of the Knot */
  55445. location: number;
  55446. }
  55447. /**
  55448. * Defines the constructor options for the SkeletonMap Shader.
  55449. */
  55450. export interface ISkeletonMapShaderOptions {
  55451. /** Skeleton to Map */
  55452. skeleton: Skeleton;
  55453. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  55454. colorMap?: ISkeletonMapShaderColorMapKnot[];
  55455. }
  55456. }
  55457. declare module BABYLON {
  55458. /**
  55459. * Class containing static functions to help procedurally build meshes
  55460. */
  55461. export class RibbonBuilder {
  55462. /**
  55463. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55464. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55465. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55466. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55467. * * 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
  55468. * * 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
  55469. * * 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
  55470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55471. * * 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
  55472. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55473. * * 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
  55474. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55475. * * 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
  55476. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55478. * @param name defines the name of the mesh
  55479. * @param options defines the options used to create the mesh
  55480. * @param scene defines the hosting scene
  55481. * @returns the ribbon mesh
  55482. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55483. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55484. */
  55485. static CreateRibbon(name: string, options: {
  55486. pathArray: Vector3[][];
  55487. closeArray?: boolean;
  55488. closePath?: boolean;
  55489. offset?: number;
  55490. updatable?: boolean;
  55491. sideOrientation?: number;
  55492. frontUVs?: Vector4;
  55493. backUVs?: Vector4;
  55494. instance?: Mesh;
  55495. invertUV?: boolean;
  55496. uvs?: Vector2[];
  55497. colors?: Color4[];
  55498. }, scene?: Nullable<Scene>): Mesh;
  55499. }
  55500. }
  55501. declare module BABYLON {
  55502. /**
  55503. * Class containing static functions to help procedurally build meshes
  55504. */
  55505. export class ShapeBuilder {
  55506. /**
  55507. * 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.
  55508. * * 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.
  55509. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55510. * * 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.
  55511. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55512. * * 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
  55513. * * 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
  55514. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55516. * * 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
  55517. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55519. * @param name defines the name of the mesh
  55520. * @param options defines the options used to create the mesh
  55521. * @param scene defines the hosting scene
  55522. * @returns the extruded shape mesh
  55523. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55524. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55525. */
  55526. static ExtrudeShape(name: string, options: {
  55527. shape: Vector3[];
  55528. path: Vector3[];
  55529. scale?: number;
  55530. rotation?: number;
  55531. cap?: number;
  55532. updatable?: boolean;
  55533. sideOrientation?: number;
  55534. frontUVs?: Vector4;
  55535. backUVs?: Vector4;
  55536. instance?: Mesh;
  55537. invertUV?: boolean;
  55538. }, scene?: Nullable<Scene>): Mesh;
  55539. /**
  55540. * Creates an custom extruded shape mesh.
  55541. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55542. * * 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.
  55543. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55544. * * 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
  55545. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55546. * * 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
  55547. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55548. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55549. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55550. * * 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
  55551. * * 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
  55552. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55554. * * 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
  55555. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55557. * @param name defines the name of the mesh
  55558. * @param options defines the options used to create the mesh
  55559. * @param scene defines the hosting scene
  55560. * @returns the custom extruded shape mesh
  55561. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55562. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55563. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55564. */
  55565. static ExtrudeShapeCustom(name: string, options: {
  55566. shape: Vector3[];
  55567. path: Vector3[];
  55568. scaleFunction?: any;
  55569. rotationFunction?: any;
  55570. ribbonCloseArray?: boolean;
  55571. ribbonClosePath?: boolean;
  55572. cap?: number;
  55573. updatable?: boolean;
  55574. sideOrientation?: number;
  55575. frontUVs?: Vector4;
  55576. backUVs?: Vector4;
  55577. instance?: Mesh;
  55578. invertUV?: boolean;
  55579. }, scene?: Nullable<Scene>): Mesh;
  55580. private static _ExtrudeShapeGeneric;
  55581. }
  55582. }
  55583. declare module BABYLON.Debug {
  55584. /**
  55585. * Class used to render a debug view of a given skeleton
  55586. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  55587. */
  55588. export class SkeletonViewer {
  55589. /** defines the skeleton to render */
  55590. skeleton: Skeleton;
  55591. /** defines the mesh attached to the skeleton */
  55592. mesh: AbstractMesh;
  55593. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55594. autoUpdateBonesMatrices: boolean;
  55595. /** defines the rendering group id to use with the viewer */
  55596. renderingGroupId: number;
  55597. /** is the options for the viewer */
  55598. options: Partial<ISkeletonViewerOptions>;
  55599. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  55600. static readonly DISPLAY_LINES: number;
  55601. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  55602. static readonly DISPLAY_SPHERES: number;
  55603. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  55604. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  55605. /** public static method to create a BoneWeight Shader
  55606. * @param options The constructor options
  55607. * @param scene The scene that the shader is scoped to
  55608. * @returns The created ShaderMaterial
  55609. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  55610. */
  55611. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  55612. /** public static method to create a BoneWeight Shader
  55613. * @param options The constructor options
  55614. * @param scene The scene that the shader is scoped to
  55615. * @returns The created ShaderMaterial
  55616. */
  55617. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  55618. /** private static method to create a BoneWeight Shader
  55619. * @param size The size of the buffer to create (usually the bone count)
  55620. * @param colorMap The gradient data to generate
  55621. * @param scene The scene that the shader is scoped to
  55622. * @returns an Array of floats from the color gradient values
  55623. */
  55624. private static _CreateBoneMapColorBuffer;
  55625. /** If SkeletonViewer scene scope. */
  55626. private _scene;
  55627. /** Gets or sets the color used to render the skeleton */
  55628. color: Color3;
  55629. /** Array of the points of the skeleton fo the line view. */
  55630. private _debugLines;
  55631. /** The SkeletonViewers Mesh. */
  55632. private _debugMesh;
  55633. /** The local axes Meshes. */
  55634. private _localAxes;
  55635. /** If SkeletonViewer is enabled. */
  55636. private _isEnabled;
  55637. /** If SkeletonViewer is ready. */
  55638. private _ready;
  55639. /** SkeletonViewer render observable. */
  55640. private _obs;
  55641. /** The Utility Layer to render the gizmos in. */
  55642. private _utilityLayer;
  55643. private _boneIndices;
  55644. /** Gets the Scene. */
  55645. get scene(): Scene;
  55646. /** Gets the utilityLayer. */
  55647. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  55648. /** Checks Ready Status. */
  55649. get isReady(): Boolean;
  55650. /** Sets Ready Status. */
  55651. set ready(value: boolean);
  55652. /** Gets the debugMesh */
  55653. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  55654. /** Sets the debugMesh */
  55655. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  55656. /** Gets the displayMode */
  55657. get displayMode(): number;
  55658. /** Sets the displayMode */
  55659. set displayMode(value: number);
  55660. /**
  55661. * Creates a new SkeletonViewer
  55662. * @param skeleton defines the skeleton to render
  55663. * @param mesh defines the mesh attached to the skeleton
  55664. * @param scene defines the hosting scene
  55665. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  55666. * @param renderingGroupId defines the rendering group id to use with the viewer
  55667. * @param options All of the extra constructor options for the SkeletonViewer
  55668. */
  55669. constructor(
  55670. /** defines the skeleton to render */
  55671. skeleton: Skeleton,
  55672. /** defines the mesh attached to the skeleton */
  55673. mesh: AbstractMesh,
  55674. /** The Scene scope*/
  55675. scene: Scene,
  55676. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55677. autoUpdateBonesMatrices?: boolean,
  55678. /** defines the rendering group id to use with the viewer */
  55679. renderingGroupId?: number,
  55680. /** is the options for the viewer */
  55681. options?: Partial<ISkeletonViewerOptions>);
  55682. /** The Dynamic bindings for the update functions */
  55683. private _bindObs;
  55684. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  55685. update(): void;
  55686. /** Gets or sets a boolean indicating if the viewer is enabled */
  55687. set isEnabled(value: boolean);
  55688. get isEnabled(): boolean;
  55689. private _getBonePosition;
  55690. private _getLinesForBonesWithLength;
  55691. private _getLinesForBonesNoLength;
  55692. /** function to revert the mesh and scene back to the initial state. */
  55693. private _revert;
  55694. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  55695. private _getAbsoluteBindPoseToRef;
  55696. /** function to build and bind sphere joint points and spur bone representations. */
  55697. private _buildSpheresAndSpurs;
  55698. private _buildLocalAxes;
  55699. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  55700. private _displayLinesUpdate;
  55701. /** Changes the displayMode of the skeleton viewer
  55702. * @param mode The displayMode numerical value
  55703. */
  55704. changeDisplayMode(mode: number): void;
  55705. /** Sets a display option of the skeleton viewer
  55706. *
  55707. * | Option | Type | Default | Description |
  55708. * | ---------------- | ------- | ------- | ----------- |
  55709. * | 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`. |
  55710. * | 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`. |
  55711. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55712. * | 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`. |
  55713. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  55714. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  55715. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  55716. *
  55717. * @param option String of the option name
  55718. * @param value The numerical option value
  55719. */
  55720. changeDisplayOptions(option: string, value: number): void;
  55721. /** Release associated resources */
  55722. dispose(): void;
  55723. }
  55724. }
  55725. declare module BABYLON {
  55726. /**
  55727. * Enum for Device Types
  55728. */
  55729. export enum DeviceType {
  55730. /** Generic */
  55731. Generic = 0,
  55732. /** Keyboard */
  55733. Keyboard = 1,
  55734. /** Mouse */
  55735. Mouse = 2,
  55736. /** Touch Pointers */
  55737. Touch = 3,
  55738. /** PS4 Dual Shock */
  55739. DualShock = 4,
  55740. /** Xbox */
  55741. Xbox = 5,
  55742. /** Switch Controller */
  55743. Switch = 6
  55744. }
  55745. /**
  55746. * Enum for All Pointers (Touch/Mouse)
  55747. */
  55748. export enum PointerInput {
  55749. /** Horizontal Axis */
  55750. Horizontal = 0,
  55751. /** Vertical Axis */
  55752. Vertical = 1,
  55753. /** Left Click or Touch */
  55754. LeftClick = 2,
  55755. /** Middle Click */
  55756. MiddleClick = 3,
  55757. /** Right Click */
  55758. RightClick = 4,
  55759. /** Browser Back */
  55760. BrowserBack = 5,
  55761. /** Browser Forward */
  55762. BrowserForward = 6
  55763. }
  55764. /**
  55765. * Enum for Dual Shock Gamepad
  55766. */
  55767. export enum DualShockInput {
  55768. /** Cross */
  55769. Cross = 0,
  55770. /** Circle */
  55771. Circle = 1,
  55772. /** Square */
  55773. Square = 2,
  55774. /** Triangle */
  55775. Triangle = 3,
  55776. /** L1 */
  55777. L1 = 4,
  55778. /** R1 */
  55779. R1 = 5,
  55780. /** L2 */
  55781. L2 = 6,
  55782. /** R2 */
  55783. R2 = 7,
  55784. /** Share */
  55785. Share = 8,
  55786. /** Options */
  55787. Options = 9,
  55788. /** L3 */
  55789. L3 = 10,
  55790. /** R3 */
  55791. R3 = 11,
  55792. /** DPadUp */
  55793. DPadUp = 12,
  55794. /** DPadDown */
  55795. DPadDown = 13,
  55796. /** DPadLeft */
  55797. DPadLeft = 14,
  55798. /** DRight */
  55799. DPadRight = 15,
  55800. /** Home */
  55801. Home = 16,
  55802. /** TouchPad */
  55803. TouchPad = 17,
  55804. /** LStickXAxis */
  55805. LStickXAxis = 18,
  55806. /** LStickYAxis */
  55807. LStickYAxis = 19,
  55808. /** RStickXAxis */
  55809. RStickXAxis = 20,
  55810. /** RStickYAxis */
  55811. RStickYAxis = 21
  55812. }
  55813. /**
  55814. * Enum for Xbox Gamepad
  55815. */
  55816. export enum XboxInput {
  55817. /** A */
  55818. A = 0,
  55819. /** B */
  55820. B = 1,
  55821. /** X */
  55822. X = 2,
  55823. /** Y */
  55824. Y = 3,
  55825. /** LB */
  55826. LB = 4,
  55827. /** RB */
  55828. RB = 5,
  55829. /** LT */
  55830. LT = 6,
  55831. /** RT */
  55832. RT = 7,
  55833. /** Back */
  55834. Back = 8,
  55835. /** Start */
  55836. Start = 9,
  55837. /** LS */
  55838. LS = 10,
  55839. /** RS */
  55840. RS = 11,
  55841. /** DPadUp */
  55842. DPadUp = 12,
  55843. /** DPadDown */
  55844. DPadDown = 13,
  55845. /** DPadLeft */
  55846. DPadLeft = 14,
  55847. /** DRight */
  55848. DPadRight = 15,
  55849. /** Home */
  55850. Home = 16,
  55851. /** LStickXAxis */
  55852. LStickXAxis = 17,
  55853. /** LStickYAxis */
  55854. LStickYAxis = 18,
  55855. /** RStickXAxis */
  55856. RStickXAxis = 19,
  55857. /** RStickYAxis */
  55858. RStickYAxis = 20
  55859. }
  55860. /**
  55861. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  55862. */
  55863. export enum SwitchInput {
  55864. /** B */
  55865. B = 0,
  55866. /** A */
  55867. A = 1,
  55868. /** Y */
  55869. Y = 2,
  55870. /** X */
  55871. X = 3,
  55872. /** L */
  55873. L = 4,
  55874. /** R */
  55875. R = 5,
  55876. /** ZL */
  55877. ZL = 6,
  55878. /** ZR */
  55879. ZR = 7,
  55880. /** Minus */
  55881. Minus = 8,
  55882. /** Plus */
  55883. Plus = 9,
  55884. /** LS */
  55885. LS = 10,
  55886. /** RS */
  55887. RS = 11,
  55888. /** DPadUp */
  55889. DPadUp = 12,
  55890. /** DPadDown */
  55891. DPadDown = 13,
  55892. /** DPadLeft */
  55893. DPadLeft = 14,
  55894. /** DRight */
  55895. DPadRight = 15,
  55896. /** Home */
  55897. Home = 16,
  55898. /** Capture */
  55899. Capture = 17,
  55900. /** LStickXAxis */
  55901. LStickXAxis = 18,
  55902. /** LStickYAxis */
  55903. LStickYAxis = 19,
  55904. /** RStickXAxis */
  55905. RStickXAxis = 20,
  55906. /** RStickYAxis */
  55907. RStickYAxis = 21
  55908. }
  55909. }
  55910. declare module BABYLON {
  55911. /**
  55912. * This class will take all inputs from Keyboard, Pointer, and
  55913. * any Gamepads and provide a polling system that all devices
  55914. * will use. This class assumes that there will only be one
  55915. * pointer device and one keyboard.
  55916. */
  55917. export class DeviceInputSystem implements IDisposable {
  55918. /**
  55919. * Returns onDeviceConnected callback property
  55920. * @returns Callback with function to execute when a device is connected
  55921. */
  55922. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  55923. /**
  55924. * Sets callback function when a device is connected and executes against all connected devices
  55925. * @param callback Function to execute when a device is connected
  55926. */
  55927. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  55928. /**
  55929. * Callback to be triggered when a device is disconnected
  55930. */
  55931. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  55932. /**
  55933. * Callback to be triggered when event driven input is updated
  55934. */
  55935. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  55936. private _inputs;
  55937. private _gamepads;
  55938. private _keyboardActive;
  55939. private _pointerActive;
  55940. private _elementToAttachTo;
  55941. private _keyboardDownEvent;
  55942. private _keyboardUpEvent;
  55943. private _pointerMoveEvent;
  55944. private _pointerDownEvent;
  55945. private _pointerUpEvent;
  55946. private _gamepadConnectedEvent;
  55947. private _gamepadDisconnectedEvent;
  55948. private _onDeviceConnected;
  55949. private static _MAX_KEYCODES;
  55950. private static _MAX_POINTER_INPUTS;
  55951. private constructor();
  55952. /**
  55953. * Creates a new DeviceInputSystem instance
  55954. * @param engine Engine to pull input element from
  55955. * @returns The new instance
  55956. */
  55957. static Create(engine: Engine): DeviceInputSystem;
  55958. /**
  55959. * Checks for current device input value, given an id and input index
  55960. * @param deviceName Id of connected device
  55961. * @param inputIndex Index of device input
  55962. * @returns Current value of input
  55963. */
  55964. /**
  55965. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  55966. * @param deviceType Enum specifiying device type
  55967. * @param deviceSlot "Slot" or index that device is referenced in
  55968. * @param inputIndex Id of input to be checked
  55969. * @returns Current value of input
  55970. */
  55971. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  55972. /**
  55973. * Dispose of all the eventlisteners
  55974. */
  55975. dispose(): void;
  55976. /**
  55977. * Checks for existing connections to devices and register them, if necessary
  55978. * Currently handles gamepads and mouse
  55979. */
  55980. private _checkForConnectedDevices;
  55981. /**
  55982. * Add a gamepad to the DeviceInputSystem
  55983. * @param gamepad A single DOM Gamepad object
  55984. */
  55985. private _addGamePad;
  55986. /**
  55987. * Add pointer device to DeviceInputSystem
  55988. * @param deviceType Type of Pointer to add
  55989. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  55990. * @param currentX Current X at point of adding
  55991. * @param currentY Current Y at point of adding
  55992. */
  55993. private _addPointerDevice;
  55994. /**
  55995. * Add device and inputs to device array
  55996. * @param deviceType Enum specifiying device type
  55997. * @param deviceSlot "Slot" or index that device is referenced in
  55998. * @param numberOfInputs Number of input entries to create for given device
  55999. */
  56000. private _registerDevice;
  56001. /**
  56002. * Given a specific device name, remove that device from the device map
  56003. * @param deviceType Enum specifiying device type
  56004. * @param deviceSlot "Slot" or index that device is referenced in
  56005. */
  56006. private _unregisterDevice;
  56007. /**
  56008. * Handle all actions that come from keyboard interaction
  56009. */
  56010. private _handleKeyActions;
  56011. /**
  56012. * Handle all actions that come from pointer interaction
  56013. */
  56014. private _handlePointerActions;
  56015. /**
  56016. * Handle all actions that come from gamepad interaction
  56017. */
  56018. private _handleGamepadActions;
  56019. /**
  56020. * Update all non-event based devices with each frame
  56021. * @param deviceType Enum specifiying device type
  56022. * @param deviceSlot "Slot" or index that device is referenced in
  56023. * @param inputIndex Id of input to be checked
  56024. */
  56025. private _updateDevice;
  56026. /**
  56027. * Gets DeviceType from the device name
  56028. * @param deviceName Name of Device from DeviceInputSystem
  56029. * @returns DeviceType enum value
  56030. */
  56031. private _getGamepadDeviceType;
  56032. }
  56033. }
  56034. declare module BABYLON {
  56035. /**
  56036. * Type to handle enforcement of inputs
  56037. */
  56038. 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;
  56039. }
  56040. declare module BABYLON {
  56041. /**
  56042. * Class that handles all input for a specific device
  56043. */
  56044. export class DeviceSource<T extends DeviceType> {
  56045. /** Type of device */
  56046. readonly deviceType: DeviceType;
  56047. /** "Slot" or index that device is referenced in */
  56048. readonly deviceSlot: number;
  56049. /**
  56050. * Observable to handle device input changes per device
  56051. */
  56052. readonly onInputChangedObservable: Observable<{
  56053. inputIndex: DeviceInput<T>;
  56054. previousState: Nullable<number>;
  56055. currentState: Nullable<number>;
  56056. }>;
  56057. private readonly _deviceInputSystem;
  56058. /**
  56059. * Default Constructor
  56060. * @param deviceInputSystem Reference to DeviceInputSystem
  56061. * @param deviceType Type of device
  56062. * @param deviceSlot "Slot" or index that device is referenced in
  56063. */
  56064. constructor(deviceInputSystem: DeviceInputSystem,
  56065. /** Type of device */
  56066. deviceType: DeviceType,
  56067. /** "Slot" or index that device is referenced in */
  56068. deviceSlot?: number);
  56069. /**
  56070. * Get input for specific input
  56071. * @param inputIndex index of specific input on device
  56072. * @returns Input value from DeviceInputSystem
  56073. */
  56074. getInput(inputIndex: DeviceInput<T>): number;
  56075. }
  56076. /**
  56077. * Class to keep track of devices
  56078. */
  56079. export class DeviceSourceManager implements IDisposable {
  56080. /**
  56081. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  56082. */
  56083. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  56084. /**
  56085. * Observable to be triggered when after a device is disconnected
  56086. */
  56087. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  56088. private readonly _devices;
  56089. private readonly _firstDevice;
  56090. private readonly _deviceInputSystem;
  56091. /**
  56092. * Default Constructor
  56093. * @param engine engine to pull input element from
  56094. */
  56095. constructor(engine: Engine);
  56096. /**
  56097. * Gets a DeviceSource, given a type and slot
  56098. * @param deviceType Enum specifying device type
  56099. * @param deviceSlot "Slot" or index that device is referenced in
  56100. * @returns DeviceSource object
  56101. */
  56102. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  56103. /**
  56104. * Gets an array of DeviceSource objects for a given device type
  56105. * @param deviceType Enum specifying device type
  56106. * @returns Array of DeviceSource objects
  56107. */
  56108. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  56109. /**
  56110. * Returns a read-only list of all available devices
  56111. * @returns Read-only array with active devices
  56112. */
  56113. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  56114. /**
  56115. * Dispose of DeviceInputSystem and other parts
  56116. */
  56117. dispose(): void;
  56118. /**
  56119. * Function to add device name to device list
  56120. * @param deviceType Enum specifying device type
  56121. * @param deviceSlot "Slot" or index that device is referenced in
  56122. */
  56123. private _addDevice;
  56124. /**
  56125. * Function to remove device name to device list
  56126. * @param deviceType Enum specifying device type
  56127. * @param deviceSlot "Slot" or index that device is referenced in
  56128. */
  56129. private _removeDevice;
  56130. /**
  56131. * Updates array storing first connected device of each type
  56132. * @param type Type of Device
  56133. */
  56134. private _updateFirstDevices;
  56135. }
  56136. }
  56137. declare module BABYLON {
  56138. /**
  56139. * Options to create the null engine
  56140. */
  56141. export class NullEngineOptions {
  56142. /**
  56143. * Render width (Default: 512)
  56144. */
  56145. renderWidth: number;
  56146. /**
  56147. * Render height (Default: 256)
  56148. */
  56149. renderHeight: number;
  56150. /**
  56151. * Texture size (Default: 512)
  56152. */
  56153. textureSize: number;
  56154. /**
  56155. * If delta time between frames should be constant
  56156. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56157. */
  56158. deterministicLockstep: boolean;
  56159. /**
  56160. * Maximum about of steps between frames (Default: 4)
  56161. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56162. */
  56163. lockstepMaxSteps: number;
  56164. /**
  56165. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  56166. */
  56167. useHighPrecisionMatrix?: boolean;
  56168. }
  56169. /**
  56170. * The null engine class provides support for headless version of babylon.js.
  56171. * This can be used in server side scenario or for testing purposes
  56172. */
  56173. export class NullEngine extends Engine {
  56174. private _options;
  56175. /**
  56176. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  56177. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56178. * @returns true if engine is in deterministic lock step mode
  56179. */
  56180. isDeterministicLockStep(): boolean;
  56181. /**
  56182. * Gets the max steps when engine is running in deterministic lock step
  56183. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56184. * @returns the max steps
  56185. */
  56186. getLockstepMaxSteps(): number;
  56187. /**
  56188. * Gets the current hardware scaling level.
  56189. * By default the hardware scaling level is computed from the window device ratio.
  56190. * 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.
  56191. * @returns a number indicating the current hardware scaling level
  56192. */
  56193. getHardwareScalingLevel(): number;
  56194. constructor(options?: NullEngineOptions);
  56195. /**
  56196. * Creates a vertex buffer
  56197. * @param vertices the data for the vertex buffer
  56198. * @returns the new WebGL static buffer
  56199. */
  56200. createVertexBuffer(vertices: FloatArray): DataBuffer;
  56201. /**
  56202. * Creates a new index buffer
  56203. * @param indices defines the content of the index buffer
  56204. * @param updatable defines if the index buffer must be updatable
  56205. * @returns a new webGL buffer
  56206. */
  56207. createIndexBuffer(indices: IndicesArray): DataBuffer;
  56208. /**
  56209. * Clear the current render buffer or the current render target (if any is set up)
  56210. * @param color defines the color to use
  56211. * @param backBuffer defines if the back buffer must be cleared
  56212. * @param depth defines if the depth buffer must be cleared
  56213. * @param stencil defines if the stencil buffer must be cleared
  56214. */
  56215. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56216. /**
  56217. * Gets the current render width
  56218. * @param useScreen defines if screen size must be used (or the current render target if any)
  56219. * @returns a number defining the current render width
  56220. */
  56221. getRenderWidth(useScreen?: boolean): number;
  56222. /**
  56223. * Gets the current render height
  56224. * @param useScreen defines if screen size must be used (or the current render target if any)
  56225. * @returns a number defining the current render height
  56226. */
  56227. getRenderHeight(useScreen?: boolean): number;
  56228. /**
  56229. * Set the WebGL's viewport
  56230. * @param viewport defines the viewport element to be used
  56231. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  56232. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  56233. */
  56234. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  56235. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  56236. /**
  56237. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  56238. * @param pipelineContext defines the pipeline context to use
  56239. * @param uniformsNames defines the list of uniform names
  56240. * @returns an array of webGL uniform locations
  56241. */
  56242. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  56243. /**
  56244. * Gets the lsit of active attributes for a given webGL program
  56245. * @param pipelineContext defines the pipeline context to use
  56246. * @param attributesNames defines the list of attribute names to get
  56247. * @returns an array of indices indicating the offset of each attribute
  56248. */
  56249. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56250. /**
  56251. * Binds an effect to the webGL context
  56252. * @param effect defines the effect to bind
  56253. */
  56254. bindSamplers(effect: Effect): void;
  56255. /**
  56256. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  56257. * @param effect defines the effect to activate
  56258. */
  56259. enableEffect(effect: Effect): void;
  56260. /**
  56261. * Set various states to the webGL context
  56262. * @param culling defines backface culling state
  56263. * @param zOffset defines the value to apply to zOffset (0 by default)
  56264. * @param force defines if states must be applied even if cache is up to date
  56265. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  56266. */
  56267. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56268. /**
  56269. * Set the value of an uniform to an array of int32
  56270. * @param uniform defines the webGL uniform location where to store the value
  56271. * @param array defines the array of int32 to store
  56272. * @returns true if value was set
  56273. */
  56274. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56275. /**
  56276. * Set the value of an uniform to an array of int32 (stored as vec2)
  56277. * @param uniform defines the webGL uniform location where to store the value
  56278. * @param array defines the array of int32 to store
  56279. * @returns true if value was set
  56280. */
  56281. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56282. /**
  56283. * Set the value of an uniform to an array of int32 (stored as vec3)
  56284. * @param uniform defines the webGL uniform location where to store the value
  56285. * @param array defines the array of int32 to store
  56286. * @returns true if value was set
  56287. */
  56288. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56289. /**
  56290. * Set the value of an uniform to an array of int32 (stored as vec4)
  56291. * @param uniform defines the webGL uniform location where to store the value
  56292. * @param array defines the array of int32 to store
  56293. * @returns true if value was set
  56294. */
  56295. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56296. /**
  56297. * Set the value of an uniform to an array of float32
  56298. * @param uniform defines the webGL uniform location where to store the value
  56299. * @param array defines the array of float32 to store
  56300. * @returns true if value was set
  56301. */
  56302. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56303. /**
  56304. * Set the value of an uniform to an array of float32 (stored as vec2)
  56305. * @param uniform defines the webGL uniform location where to store the value
  56306. * @param array defines the array of float32 to store
  56307. * @returns true if value was set
  56308. */
  56309. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56310. /**
  56311. * Set the value of an uniform to an array of float32 (stored as vec3)
  56312. * @param uniform defines the webGL uniform location where to store the value
  56313. * @param array defines the array of float32 to store
  56314. * @returns true if value was set
  56315. */
  56316. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56317. /**
  56318. * Set the value of an uniform to an array of float32 (stored as vec4)
  56319. * @param uniform defines the webGL uniform location where to store the value
  56320. * @param array defines the array of float32 to store
  56321. * @returns true if value was set
  56322. */
  56323. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56324. /**
  56325. * Set the value of an uniform to an array of number
  56326. * @param uniform defines the webGL uniform location where to store the value
  56327. * @param array defines the array of number to store
  56328. * @returns true if value was set
  56329. */
  56330. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56331. /**
  56332. * Set the value of an uniform to an array of number (stored as vec2)
  56333. * @param uniform defines the webGL uniform location where to store the value
  56334. * @param array defines the array of number to store
  56335. * @returns true if value was set
  56336. */
  56337. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56338. /**
  56339. * Set the value of an uniform to an array of number (stored as vec3)
  56340. * @param uniform defines the webGL uniform location where to store the value
  56341. * @param array defines the array of number to store
  56342. * @returns true if value was set
  56343. */
  56344. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56345. /**
  56346. * Set the value of an uniform to an array of number (stored as vec4)
  56347. * @param uniform defines the webGL uniform location where to store the value
  56348. * @param array defines the array of number to store
  56349. * @returns true if value was set
  56350. */
  56351. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56352. /**
  56353. * Set the value of an uniform to an array of float32 (stored as matrices)
  56354. * @param uniform defines the webGL uniform location where to store the value
  56355. * @param matrices defines the array of float32 to store
  56356. * @returns true if value was set
  56357. */
  56358. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56359. /**
  56360. * Set the value of an uniform to a matrix (3x3)
  56361. * @param uniform defines the webGL uniform location where to store the value
  56362. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  56363. * @returns true if value was set
  56364. */
  56365. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56366. /**
  56367. * Set the value of an uniform to a matrix (2x2)
  56368. * @param uniform defines the webGL uniform location where to store the value
  56369. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  56370. * @returns true if value was set
  56371. */
  56372. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56373. /**
  56374. * Set the value of an uniform to a number (float)
  56375. * @param uniform defines the webGL uniform location where to store the value
  56376. * @param value defines the float number to store
  56377. * @returns true if value was set
  56378. */
  56379. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56380. /**
  56381. * Set the value of an uniform to a vec2
  56382. * @param uniform defines the webGL uniform location where to store the value
  56383. * @param x defines the 1st component of the value
  56384. * @param y defines the 2nd component of the value
  56385. * @returns true if value was set
  56386. */
  56387. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56388. /**
  56389. * Set the value of an uniform to a vec3
  56390. * @param uniform defines the webGL uniform location where to store the value
  56391. * @param x defines the 1st component of the value
  56392. * @param y defines the 2nd component of the value
  56393. * @param z defines the 3rd component of the value
  56394. * @returns true if value was set
  56395. */
  56396. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56397. /**
  56398. * Set the value of an uniform to a boolean
  56399. * @param uniform defines the webGL uniform location where to store the value
  56400. * @param bool defines the boolean to store
  56401. * @returns true if value was set
  56402. */
  56403. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  56404. /**
  56405. * Set the value of an uniform to a vec4
  56406. * @param uniform defines the webGL uniform location where to store the value
  56407. * @param x defines the 1st component of the value
  56408. * @param y defines the 2nd component of the value
  56409. * @param z defines the 3rd component of the value
  56410. * @param w defines the 4th component of the value
  56411. * @returns true if value was set
  56412. */
  56413. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56414. /**
  56415. * Sets the current alpha mode
  56416. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  56417. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56418. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56419. */
  56420. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56421. /**
  56422. * Bind webGl buffers directly to the webGL context
  56423. * @param vertexBuffers defines the vertex buffer to bind
  56424. * @param indexBuffer defines the index buffer to bind
  56425. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  56426. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  56427. * @param effect defines the effect associated with the vertex buffer
  56428. */
  56429. bindBuffers(vertexBuffers: {
  56430. [key: string]: VertexBuffer;
  56431. }, indexBuffer: DataBuffer, effect: Effect): void;
  56432. /**
  56433. * Force the entire cache to be cleared
  56434. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  56435. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  56436. */
  56437. wipeCaches(bruteForce?: boolean): void;
  56438. /**
  56439. * Send a draw order
  56440. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  56441. * @param indexStart defines the starting index
  56442. * @param indexCount defines the number of index to draw
  56443. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56444. */
  56445. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  56446. /**
  56447. * Draw a list of indexed primitives
  56448. * @param fillMode defines the primitive to use
  56449. * @param indexStart defines the starting index
  56450. * @param indexCount defines the number of index to draw
  56451. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56452. */
  56453. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56454. /**
  56455. * Draw a list of unindexed primitives
  56456. * @param fillMode defines the primitive to use
  56457. * @param verticesStart defines the index of first vertex to draw
  56458. * @param verticesCount defines the count of vertices to draw
  56459. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56460. */
  56461. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56462. /** @hidden */
  56463. _createTexture(): WebGLTexture;
  56464. /** @hidden */
  56465. _releaseTexture(texture: InternalTexture): void;
  56466. /**
  56467. * Usually called from Texture.ts.
  56468. * Passed information to create a WebGLTexture
  56469. * @param urlArg defines a value which contains one of the following:
  56470. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  56471. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  56472. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  56473. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  56474. * @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)
  56475. * @param scene needed for loading to the correct scene
  56476. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  56477. * @param onLoad optional callback to be called upon successful completion
  56478. * @param onError optional callback to be called upon failure
  56479. * @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
  56480. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  56481. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  56482. * @param forcedExtension defines the extension to use to pick the right loader
  56483. * @param mimeType defines an optional mime type
  56484. * @returns a InternalTexture for assignment back into BABYLON.Texture
  56485. */
  56486. 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;
  56487. /**
  56488. * Creates a new render target texture
  56489. * @param size defines the size of the texture
  56490. * @param options defines the options used to create the texture
  56491. * @returns a new render target texture stored in an InternalTexture
  56492. */
  56493. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  56494. /**
  56495. * Update the sampling mode of a given texture
  56496. * @param samplingMode defines the required sampling mode
  56497. * @param texture defines the texture to update
  56498. */
  56499. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56500. /**
  56501. * Binds the frame buffer to the specified texture.
  56502. * @param texture The texture to render to or null for the default canvas
  56503. * @param faceIndex The face of the texture to render to in case of cube texture
  56504. * @param requiredWidth The width of the target to render to
  56505. * @param requiredHeight The height of the target to render to
  56506. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  56507. * @param lodLevel defines le lod level to bind to the frame buffer
  56508. */
  56509. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56510. /**
  56511. * Unbind the current render target texture from the webGL context
  56512. * @param texture defines the render target texture to unbind
  56513. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  56514. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  56515. */
  56516. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56517. /**
  56518. * Creates a dynamic vertex buffer
  56519. * @param vertices the data for the dynamic vertex buffer
  56520. * @returns the new WebGL dynamic buffer
  56521. */
  56522. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  56523. /**
  56524. * Update the content of a dynamic texture
  56525. * @param texture defines the texture to update
  56526. * @param canvas defines the canvas containing the source
  56527. * @param invertY defines if data must be stored with Y axis inverted
  56528. * @param premulAlpha defines if alpha is stored as premultiplied
  56529. * @param format defines the format of the data
  56530. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  56531. */
  56532. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  56533. /**
  56534. * Gets a boolean indicating if all created effects are ready
  56535. * @returns true if all effects are ready
  56536. */
  56537. areAllEffectsReady(): boolean;
  56538. /**
  56539. * @hidden
  56540. * Get the current error code of the webGL context
  56541. * @returns the error code
  56542. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  56543. */
  56544. getError(): number;
  56545. /** @hidden */
  56546. _getUnpackAlignement(): number;
  56547. /** @hidden */
  56548. _unpackFlipY(value: boolean): void;
  56549. /**
  56550. * Update a dynamic index buffer
  56551. * @param indexBuffer defines the target index buffer
  56552. * @param indices defines the data to update
  56553. * @param offset defines the offset in the target index buffer where update should start
  56554. */
  56555. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  56556. /**
  56557. * Updates a dynamic vertex buffer.
  56558. * @param vertexBuffer the vertex buffer to update
  56559. * @param vertices the data used to update the vertex buffer
  56560. * @param byteOffset the byte offset of the data (optional)
  56561. * @param byteLength the byte length of the data (optional)
  56562. */
  56563. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  56564. /** @hidden */
  56565. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  56566. /** @hidden */
  56567. _bindTexture(channel: number, texture: InternalTexture): void;
  56568. protected _deleteBuffer(buffer: WebGLBuffer): void;
  56569. /**
  56570. * 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
  56571. */
  56572. releaseEffects(): void;
  56573. displayLoadingUI(): void;
  56574. hideLoadingUI(): void;
  56575. /** @hidden */
  56576. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56577. /** @hidden */
  56578. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56579. /** @hidden */
  56580. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56581. /** @hidden */
  56582. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56583. }
  56584. }
  56585. declare module BABYLON {
  56586. /**
  56587. * @hidden
  56588. **/
  56589. export class _TimeToken {
  56590. _startTimeQuery: Nullable<WebGLQuery>;
  56591. _endTimeQuery: Nullable<WebGLQuery>;
  56592. _timeElapsedQuery: Nullable<WebGLQuery>;
  56593. _timeElapsedQueryEnded: boolean;
  56594. }
  56595. }
  56596. declare module BABYLON {
  56597. /** @hidden */
  56598. export class _OcclusionDataStorage {
  56599. /** @hidden */
  56600. occlusionInternalRetryCounter: number;
  56601. /** @hidden */
  56602. isOcclusionQueryInProgress: boolean;
  56603. /** @hidden */
  56604. isOccluded: boolean;
  56605. /** @hidden */
  56606. occlusionRetryCount: number;
  56607. /** @hidden */
  56608. occlusionType: number;
  56609. /** @hidden */
  56610. occlusionQueryAlgorithmType: number;
  56611. }
  56612. interface Engine {
  56613. /**
  56614. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  56615. * @return the new query
  56616. */
  56617. createQuery(): WebGLQuery;
  56618. /**
  56619. * Delete and release a webGL query
  56620. * @param query defines the query to delete
  56621. * @return the current engine
  56622. */
  56623. deleteQuery(query: WebGLQuery): Engine;
  56624. /**
  56625. * Check if a given query has resolved and got its value
  56626. * @param query defines the query to check
  56627. * @returns true if the query got its value
  56628. */
  56629. isQueryResultAvailable(query: WebGLQuery): boolean;
  56630. /**
  56631. * Gets the value of a given query
  56632. * @param query defines the query to check
  56633. * @returns the value of the query
  56634. */
  56635. getQueryResult(query: WebGLQuery): number;
  56636. /**
  56637. * Initiates an occlusion query
  56638. * @param algorithmType defines the algorithm to use
  56639. * @param query defines the query to use
  56640. * @returns the current engine
  56641. * @see https://doc.babylonjs.com/features/occlusionquery
  56642. */
  56643. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  56644. /**
  56645. * Ends an occlusion query
  56646. * @see https://doc.babylonjs.com/features/occlusionquery
  56647. * @param algorithmType defines the algorithm to use
  56648. * @returns the current engine
  56649. */
  56650. endOcclusionQuery(algorithmType: number): Engine;
  56651. /**
  56652. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  56653. * Please note that only one query can be issued at a time
  56654. * @returns a time token used to track the time span
  56655. */
  56656. startTimeQuery(): Nullable<_TimeToken>;
  56657. /**
  56658. * Ends a time query
  56659. * @param token defines the token used to measure the time span
  56660. * @returns the time spent (in ns)
  56661. */
  56662. endTimeQuery(token: _TimeToken): int;
  56663. /** @hidden */
  56664. _currentNonTimestampToken: Nullable<_TimeToken>;
  56665. /** @hidden */
  56666. _createTimeQuery(): WebGLQuery;
  56667. /** @hidden */
  56668. _deleteTimeQuery(query: WebGLQuery): void;
  56669. /** @hidden */
  56670. _getGlAlgorithmType(algorithmType: number): number;
  56671. /** @hidden */
  56672. _getTimeQueryResult(query: WebGLQuery): any;
  56673. /** @hidden */
  56674. _getTimeQueryAvailability(query: WebGLQuery): any;
  56675. }
  56676. interface AbstractMesh {
  56677. /**
  56678. * Backing filed
  56679. * @hidden
  56680. */
  56681. __occlusionDataStorage: _OcclusionDataStorage;
  56682. /**
  56683. * Access property
  56684. * @hidden
  56685. */
  56686. _occlusionDataStorage: _OcclusionDataStorage;
  56687. /**
  56688. * 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.
  56689. * The default value is -1 which means don't break the query and wait till the result
  56690. * @see https://doc.babylonjs.com/features/occlusionquery
  56691. */
  56692. occlusionRetryCount: number;
  56693. /**
  56694. * 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:
  56695. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  56696. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  56697. * * 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.
  56698. * @see https://doc.babylonjs.com/features/occlusionquery
  56699. */
  56700. occlusionType: number;
  56701. /**
  56702. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  56703. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  56704. * * 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.
  56705. * @see https://doc.babylonjs.com/features/occlusionquery
  56706. */
  56707. occlusionQueryAlgorithmType: number;
  56708. /**
  56709. * 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
  56710. * @see https://doc.babylonjs.com/features/occlusionquery
  56711. */
  56712. isOccluded: boolean;
  56713. /**
  56714. * Flag to check the progress status of the query
  56715. * @see https://doc.babylonjs.com/features/occlusionquery
  56716. */
  56717. isOcclusionQueryInProgress: boolean;
  56718. }
  56719. }
  56720. declare module BABYLON {
  56721. /** @hidden */
  56722. export var _forceTransformFeedbackToBundle: boolean;
  56723. interface Engine {
  56724. /**
  56725. * Creates a webGL transform feedback object
  56726. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  56727. * @returns the webGL transform feedback object
  56728. */
  56729. createTransformFeedback(): WebGLTransformFeedback;
  56730. /**
  56731. * Delete a webGL transform feedback object
  56732. * @param value defines the webGL transform feedback object to delete
  56733. */
  56734. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  56735. /**
  56736. * Bind a webGL transform feedback object to the webgl context
  56737. * @param value defines the webGL transform feedback object to bind
  56738. */
  56739. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  56740. /**
  56741. * Begins a transform feedback operation
  56742. * @param usePoints defines if points or triangles must be used
  56743. */
  56744. beginTransformFeedback(usePoints: boolean): void;
  56745. /**
  56746. * Ends a transform feedback operation
  56747. */
  56748. endTransformFeedback(): void;
  56749. /**
  56750. * Specify the varyings to use with transform feedback
  56751. * @param program defines the associated webGL program
  56752. * @param value defines the list of strings representing the varying names
  56753. */
  56754. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  56755. /**
  56756. * Bind a webGL buffer for a transform feedback operation
  56757. * @param value defines the webGL buffer to bind
  56758. */
  56759. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  56760. }
  56761. }
  56762. declare module BABYLON {
  56763. /**
  56764. * Class used to define an additional view for the engine
  56765. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56766. */
  56767. export class EngineView {
  56768. /** Defines the canvas where to render the view */
  56769. target: HTMLCanvasElement;
  56770. /** Defines an optional camera used to render the view (will use active camera else) */
  56771. camera?: Camera;
  56772. }
  56773. interface Engine {
  56774. /**
  56775. * Gets or sets the HTML element to use for attaching events
  56776. */
  56777. inputElement: Nullable<HTMLElement>;
  56778. /**
  56779. * Gets the current engine view
  56780. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56781. */
  56782. activeView: Nullable<EngineView>;
  56783. /** Gets or sets the list of views */
  56784. views: EngineView[];
  56785. /**
  56786. * Register a new child canvas
  56787. * @param canvas defines the canvas to register
  56788. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  56789. * @returns the associated view
  56790. */
  56791. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  56792. /**
  56793. * Remove a registered child canvas
  56794. * @param canvas defines the canvas to remove
  56795. * @returns the current engine
  56796. */
  56797. unRegisterView(canvas: HTMLCanvasElement): Engine;
  56798. }
  56799. }
  56800. declare module BABYLON {
  56801. interface Engine {
  56802. /** @hidden */
  56803. _excludedCompressedTextures: string[];
  56804. /** @hidden */
  56805. _textureFormatInUse: string;
  56806. /**
  56807. * Gets the list of texture formats supported
  56808. */
  56809. readonly texturesSupported: Array<string>;
  56810. /**
  56811. * Gets the texture format in use
  56812. */
  56813. readonly textureFormatInUse: Nullable<string>;
  56814. /**
  56815. * Set the compressed texture extensions or file names to skip.
  56816. *
  56817. * @param skippedFiles defines the list of those texture files you want to skip
  56818. * Example: [".dds", ".env", "myfile.png"]
  56819. */
  56820. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  56821. /**
  56822. * Set the compressed texture format to use, based on the formats you have, and the formats
  56823. * supported by the hardware / browser.
  56824. *
  56825. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  56826. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  56827. * to API arguments needed to compressed textures. This puts the burden on the container
  56828. * generator to house the arcane code for determining these for current & future formats.
  56829. *
  56830. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56831. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56832. *
  56833. * Note: The result of this call is not taken into account when a texture is base64.
  56834. *
  56835. * @param formatsAvailable defines the list of those format families you have created
  56836. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  56837. *
  56838. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  56839. * @returns The extension selected.
  56840. */
  56841. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  56842. }
  56843. }
  56844. declare module BABYLON {
  56845. /** @hidden */
  56846. export var rgbdEncodePixelShader: {
  56847. name: string;
  56848. shader: string;
  56849. };
  56850. }
  56851. declare module BABYLON {
  56852. /**
  56853. * Raw texture data and descriptor sufficient for WebGL texture upload
  56854. */
  56855. export interface EnvironmentTextureInfo {
  56856. /**
  56857. * Version of the environment map
  56858. */
  56859. version: number;
  56860. /**
  56861. * Width of image
  56862. */
  56863. width: number;
  56864. /**
  56865. * Irradiance information stored in the file.
  56866. */
  56867. irradiance: any;
  56868. /**
  56869. * Specular information stored in the file.
  56870. */
  56871. specular: any;
  56872. }
  56873. /**
  56874. * Defines One Image in the file. It requires only the position in the file
  56875. * as well as the length.
  56876. */
  56877. interface BufferImageData {
  56878. /**
  56879. * Length of the image data.
  56880. */
  56881. length: number;
  56882. /**
  56883. * Position of the data from the null terminator delimiting the end of the JSON.
  56884. */
  56885. position: number;
  56886. }
  56887. /**
  56888. * Defines the specular data enclosed in the file.
  56889. * This corresponds to the version 1 of the data.
  56890. */
  56891. export interface EnvironmentTextureSpecularInfoV1 {
  56892. /**
  56893. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  56894. */
  56895. specularDataPosition?: number;
  56896. /**
  56897. * This contains all the images data needed to reconstruct the cubemap.
  56898. */
  56899. mipmaps: Array<BufferImageData>;
  56900. /**
  56901. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  56902. */
  56903. lodGenerationScale: number;
  56904. }
  56905. /**
  56906. * Sets of helpers addressing the serialization and deserialization of environment texture
  56907. * stored in a BabylonJS env file.
  56908. * Those files are usually stored as .env files.
  56909. */
  56910. export class EnvironmentTextureTools {
  56911. /**
  56912. * Magic number identifying the env file.
  56913. */
  56914. private static _MagicBytes;
  56915. /**
  56916. * Gets the environment info from an env file.
  56917. * @param data The array buffer containing the .env bytes.
  56918. * @returns the environment file info (the json header) if successfully parsed.
  56919. */
  56920. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  56921. /**
  56922. * Creates an environment texture from a loaded cube texture.
  56923. * @param texture defines the cube texture to convert in env file
  56924. * @return a promise containing the environment data if succesfull.
  56925. */
  56926. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  56927. /**
  56928. * Creates a JSON representation of the spherical data.
  56929. * @param texture defines the texture containing the polynomials
  56930. * @return the JSON representation of the spherical info
  56931. */
  56932. private static _CreateEnvTextureIrradiance;
  56933. /**
  56934. * Creates the ArrayBufferViews used for initializing environment texture image data.
  56935. * @param data the image data
  56936. * @param info parameters that determine what views will be created for accessing the underlying buffer
  56937. * @return the views described by info providing access to the underlying buffer
  56938. */
  56939. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  56940. /**
  56941. * Uploads the texture info contained in the env file to the GPU.
  56942. * @param texture defines the internal texture to upload to
  56943. * @param data defines the data to load
  56944. * @param info defines the texture info retrieved through the GetEnvInfo method
  56945. * @returns a promise
  56946. */
  56947. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  56948. private static _OnImageReadyAsync;
  56949. /**
  56950. * Uploads the levels of image data to the GPU.
  56951. * @param texture defines the internal texture to upload to
  56952. * @param imageData defines the array buffer views of image data [mipmap][face]
  56953. * @returns a promise
  56954. */
  56955. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  56956. /**
  56957. * Uploads spherical polynomials information to the texture.
  56958. * @param texture defines the texture we are trying to upload the information to
  56959. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  56960. */
  56961. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  56962. /** @hidden */
  56963. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56964. }
  56965. }
  56966. declare module BABYLON {
  56967. /**
  56968. * Class used to inline functions in shader code
  56969. */
  56970. export class ShaderCodeInliner {
  56971. private static readonly _RegexpFindFunctionNameAndType;
  56972. private _sourceCode;
  56973. private _functionDescr;
  56974. private _numMaxIterations;
  56975. /** Gets or sets the token used to mark the functions to inline */
  56976. inlineToken: string;
  56977. /** Gets or sets the debug mode */
  56978. debug: boolean;
  56979. /** Gets the code after the inlining process */
  56980. get code(): string;
  56981. /**
  56982. * Initializes the inliner
  56983. * @param sourceCode shader code source to inline
  56984. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  56985. */
  56986. constructor(sourceCode: string, numMaxIterations?: number);
  56987. /**
  56988. * Start the processing of the shader code
  56989. */
  56990. processCode(): void;
  56991. private _collectFunctions;
  56992. private _processInlining;
  56993. private _extractBetweenMarkers;
  56994. private _skipWhitespaces;
  56995. private _removeComments;
  56996. private _replaceFunctionCallsByCode;
  56997. private _findBackward;
  56998. private _escapeRegExp;
  56999. private _replaceNames;
  57000. }
  57001. }
  57002. declare module BABYLON {
  57003. /**
  57004. * Container for accessors for natively-stored mesh data buffers.
  57005. */
  57006. class NativeDataBuffer extends DataBuffer {
  57007. /**
  57008. * Accessor value used to identify/retrieve a natively-stored index buffer.
  57009. */
  57010. nativeIndexBuffer?: any;
  57011. /**
  57012. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  57013. */
  57014. nativeVertexBuffer?: any;
  57015. }
  57016. /** @hidden */
  57017. class NativeTexture extends InternalTexture {
  57018. getInternalTexture(): InternalTexture;
  57019. getViewCount(): number;
  57020. }
  57021. /** @hidden */
  57022. export class NativeEngine extends Engine {
  57023. private readonly _native;
  57024. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  57025. private readonly INVALID_HANDLE;
  57026. private _boundBuffersVertexArray;
  57027. private _currentDepthTest;
  57028. getHardwareScalingLevel(): number;
  57029. constructor();
  57030. dispose(): void;
  57031. /**
  57032. * Can be used to override the current requestAnimationFrame requester.
  57033. * @hidden
  57034. */
  57035. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  57036. /**
  57037. * Override default engine behavior.
  57038. * @param color
  57039. * @param backBuffer
  57040. * @param depth
  57041. * @param stencil
  57042. */
  57043. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  57044. /**
  57045. * Gets host document
  57046. * @returns the host document object
  57047. */
  57048. getHostDocument(): Nullable<Document>;
  57049. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57050. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  57051. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  57052. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  57053. [key: string]: VertexBuffer;
  57054. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  57055. bindBuffers(vertexBuffers: {
  57056. [key: string]: VertexBuffer;
  57057. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  57058. recordVertexArrayObject(vertexBuffers: {
  57059. [key: string]: VertexBuffer;
  57060. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  57061. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  57062. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  57063. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57064. /**
  57065. * Draw a list of indexed primitives
  57066. * @param fillMode defines the primitive to use
  57067. * @param indexStart defines the starting index
  57068. * @param indexCount defines the number of index to draw
  57069. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57070. */
  57071. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57072. /**
  57073. * Draw a list of unindexed primitives
  57074. * @param fillMode defines the primitive to use
  57075. * @param verticesStart defines the index of first vertex to draw
  57076. * @param verticesCount defines the count of vertices to draw
  57077. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57078. */
  57079. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57080. createPipelineContext(): IPipelineContext;
  57081. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  57082. /** @hidden */
  57083. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  57084. /** @hidden */
  57085. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  57086. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  57087. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  57088. protected _setProgram(program: WebGLProgram): void;
  57089. _releaseEffect(effect: Effect): void;
  57090. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  57091. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  57092. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  57093. bindSamplers(effect: Effect): void;
  57094. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  57095. getRenderWidth(useScreen?: boolean): number;
  57096. getRenderHeight(useScreen?: boolean): number;
  57097. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  57098. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57099. /**
  57100. * Set the z offset to apply to current rendering
  57101. * @param value defines the offset to apply
  57102. */
  57103. setZOffset(value: number): void;
  57104. /**
  57105. * Gets the current value of the zOffset
  57106. * @returns the current zOffset state
  57107. */
  57108. getZOffset(): number;
  57109. /**
  57110. * Enable or disable depth buffering
  57111. * @param enable defines the state to set
  57112. */
  57113. setDepthBuffer(enable: boolean): void;
  57114. /**
  57115. * Gets a boolean indicating if depth writing is enabled
  57116. * @returns the current depth writing state
  57117. */
  57118. getDepthWrite(): boolean;
  57119. setDepthFunctionToGreater(): void;
  57120. setDepthFunctionToGreaterOrEqual(): void;
  57121. setDepthFunctionToLess(): void;
  57122. setDepthFunctionToLessOrEqual(): void;
  57123. /**
  57124. * Enable or disable depth writing
  57125. * @param enable defines the state to set
  57126. */
  57127. setDepthWrite(enable: boolean): void;
  57128. /**
  57129. * Enable or disable color writing
  57130. * @param enable defines the state to set
  57131. */
  57132. setColorWrite(enable: boolean): void;
  57133. /**
  57134. * Gets a boolean indicating if color writing is enabled
  57135. * @returns the current color writing state
  57136. */
  57137. getColorWrite(): boolean;
  57138. /**
  57139. * Sets alpha constants used by some alpha blending modes
  57140. * @param r defines the red component
  57141. * @param g defines the green component
  57142. * @param b defines the blue component
  57143. * @param a defines the alpha component
  57144. */
  57145. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  57146. /**
  57147. * Sets the current alpha mode
  57148. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  57149. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57150. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57151. */
  57152. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57153. /**
  57154. * Gets the current alpha mode
  57155. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57156. * @returns the current alpha mode
  57157. */
  57158. getAlphaMode(): number;
  57159. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  57160. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57161. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57162. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57163. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57164. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57165. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57166. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57167. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57168. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57169. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57170. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57171. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57172. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57173. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57174. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57175. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57176. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57177. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57178. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57179. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  57180. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  57181. wipeCaches(bruteForce?: boolean): void;
  57182. _createTexture(): WebGLTexture;
  57183. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  57184. /**
  57185. * Update the content of a dynamic texture
  57186. * @param texture defines the texture to update
  57187. * @param canvas defines the canvas containing the source
  57188. * @param invertY defines if data must be stored with Y axis inverted
  57189. * @param premulAlpha defines if alpha is stored as premultiplied
  57190. * @param format defines the format of the data
  57191. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57192. */
  57193. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57194. /**
  57195. * Usually called from Texture.ts.
  57196. * Passed information to create a WebGLTexture
  57197. * @param url defines a value which contains one of the following:
  57198. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57199. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57200. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57201. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57202. * @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)
  57203. * @param scene needed for loading to the correct scene
  57204. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57205. * @param onLoad optional callback to be called upon successful completion
  57206. * @param onError optional callback to be called upon failure
  57207. * @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
  57208. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57209. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57210. * @param forcedExtension defines the extension to use to pick the right loader
  57211. * @param mimeType defines an optional mime type
  57212. * @param loaderOptions options to be passed to the loader
  57213. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57214. */
  57215. 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;
  57216. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  57217. _releaseFramebufferObjects(texture: InternalTexture): void;
  57218. /**
  57219. * Creates a cube texture
  57220. * @param rootUrl defines the url where the files to load is located
  57221. * @param scene defines the current scene
  57222. * @param files defines the list of files to load (1 per face)
  57223. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  57224. * @param onLoad defines an optional callback raised when the texture is loaded
  57225. * @param onError defines an optional callback raised if there is an issue to load the texture
  57226. * @param format defines the format of the data
  57227. * @param forcedExtension defines the extension to use to pick the right loader
  57228. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  57229. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57230. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57231. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  57232. * @returns the cube texture as an InternalTexture
  57233. */
  57234. 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;
  57235. createRenderTargetTexture(size: number | {
  57236. width: number;
  57237. height: number;
  57238. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  57239. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57240. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57241. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57242. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  57243. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  57244. /**
  57245. * Updates a dynamic vertex buffer.
  57246. * @param vertexBuffer the vertex buffer to update
  57247. * @param data the data used to update the vertex buffer
  57248. * @param byteOffset the byte offset of the data (optional)
  57249. * @param byteLength the byte length of the data (optional)
  57250. */
  57251. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  57252. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  57253. private _updateAnisotropicLevel;
  57254. private _getAddressMode;
  57255. /** @hidden */
  57256. _bindTexture(channel: number, texture: InternalTexture): void;
  57257. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  57258. releaseEffects(): void;
  57259. /** @hidden */
  57260. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57261. /** @hidden */
  57262. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57263. /** @hidden */
  57264. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57265. /** @hidden */
  57266. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57267. private _getNativeSamplingMode;
  57268. private _getNativeTextureFormat;
  57269. private _getNativeAlphaMode;
  57270. private _getNativeAttribType;
  57271. }
  57272. }
  57273. declare module BABYLON {
  57274. /**
  57275. * Gather the list of clipboard event types as constants.
  57276. */
  57277. export class ClipboardEventTypes {
  57278. /**
  57279. * The clipboard event is fired when a copy command is active (pressed).
  57280. */
  57281. static readonly COPY: number;
  57282. /**
  57283. * The clipboard event is fired when a cut command is active (pressed).
  57284. */
  57285. static readonly CUT: number;
  57286. /**
  57287. * The clipboard event is fired when a paste command is active (pressed).
  57288. */
  57289. static readonly PASTE: number;
  57290. }
  57291. /**
  57292. * This class is used to store clipboard related info for the onClipboardObservable event.
  57293. */
  57294. export class ClipboardInfo {
  57295. /**
  57296. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57297. */
  57298. type: number;
  57299. /**
  57300. * Defines the related dom event
  57301. */
  57302. event: ClipboardEvent;
  57303. /**
  57304. *Creates an instance of ClipboardInfo.
  57305. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  57306. * @param event Defines the related dom event
  57307. */
  57308. constructor(
  57309. /**
  57310. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57311. */
  57312. type: number,
  57313. /**
  57314. * Defines the related dom event
  57315. */
  57316. event: ClipboardEvent);
  57317. /**
  57318. * Get the clipboard event's type from the keycode.
  57319. * @param keyCode Defines the keyCode for the current keyboard event.
  57320. * @return {number}
  57321. */
  57322. static GetTypeFromCharacter(keyCode: number): number;
  57323. }
  57324. }
  57325. declare module BABYLON {
  57326. /**
  57327. * Google Daydream controller
  57328. */
  57329. export class DaydreamController extends WebVRController {
  57330. /**
  57331. * Base Url for the controller model.
  57332. */
  57333. static MODEL_BASE_URL: string;
  57334. /**
  57335. * File name for the controller model.
  57336. */
  57337. static MODEL_FILENAME: string;
  57338. /**
  57339. * Gamepad Id prefix used to identify Daydream Controller.
  57340. */
  57341. static readonly GAMEPAD_ID_PREFIX: string;
  57342. /**
  57343. * Creates a new DaydreamController from a gamepad
  57344. * @param vrGamepad the gamepad that the controller should be created from
  57345. */
  57346. constructor(vrGamepad: any);
  57347. /**
  57348. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57349. * @param scene scene in which to add meshes
  57350. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57351. */
  57352. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57353. /**
  57354. * Called once for each button that changed state since the last frame
  57355. * @param buttonIdx Which button index changed
  57356. * @param state New state of the button
  57357. * @param changes Which properties on the state changed since last frame
  57358. */
  57359. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57360. }
  57361. }
  57362. declare module BABYLON {
  57363. /**
  57364. * Gear VR Controller
  57365. */
  57366. export class GearVRController extends WebVRController {
  57367. /**
  57368. * Base Url for the controller model.
  57369. */
  57370. static MODEL_BASE_URL: string;
  57371. /**
  57372. * File name for the controller model.
  57373. */
  57374. static MODEL_FILENAME: string;
  57375. /**
  57376. * Gamepad Id prefix used to identify this controller.
  57377. */
  57378. static readonly GAMEPAD_ID_PREFIX: string;
  57379. private readonly _buttonIndexToObservableNameMap;
  57380. /**
  57381. * Creates a new GearVRController from a gamepad
  57382. * @param vrGamepad the gamepad that the controller should be created from
  57383. */
  57384. constructor(vrGamepad: any);
  57385. /**
  57386. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57387. * @param scene scene in which to add meshes
  57388. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57389. */
  57390. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57391. /**
  57392. * Called once for each button that changed state since the last frame
  57393. * @param buttonIdx Which button index changed
  57394. * @param state New state of the button
  57395. * @param changes Which properties on the state changed since last frame
  57396. */
  57397. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57398. }
  57399. }
  57400. declare module BABYLON {
  57401. /**
  57402. * Generic Controller
  57403. */
  57404. export class GenericController extends WebVRController {
  57405. /**
  57406. * Base Url for the controller model.
  57407. */
  57408. static readonly MODEL_BASE_URL: string;
  57409. /**
  57410. * File name for the controller model.
  57411. */
  57412. static readonly MODEL_FILENAME: string;
  57413. /**
  57414. * Creates a new GenericController from a gamepad
  57415. * @param vrGamepad the gamepad that the controller should be created from
  57416. */
  57417. constructor(vrGamepad: any);
  57418. /**
  57419. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57420. * @param scene scene in which to add meshes
  57421. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57422. */
  57423. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57424. /**
  57425. * Called once for each button that changed state since the last frame
  57426. * @param buttonIdx Which button index changed
  57427. * @param state New state of the button
  57428. * @param changes Which properties on the state changed since last frame
  57429. */
  57430. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57431. }
  57432. }
  57433. declare module BABYLON {
  57434. /**
  57435. * Oculus Touch Controller
  57436. */
  57437. export class OculusTouchController extends WebVRController {
  57438. /**
  57439. * Base Url for the controller model.
  57440. */
  57441. static MODEL_BASE_URL: string;
  57442. /**
  57443. * File name for the left controller model.
  57444. */
  57445. static MODEL_LEFT_FILENAME: string;
  57446. /**
  57447. * File name for the right controller model.
  57448. */
  57449. static MODEL_RIGHT_FILENAME: string;
  57450. /**
  57451. * Base Url for the Quest controller model.
  57452. */
  57453. static QUEST_MODEL_BASE_URL: string;
  57454. /**
  57455. * @hidden
  57456. * If the controllers are running on a device that needs the updated Quest controller models
  57457. */
  57458. static _IsQuest: boolean;
  57459. /**
  57460. * Fired when the secondary trigger on this controller is modified
  57461. */
  57462. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  57463. /**
  57464. * Fired when the thumb rest on this controller is modified
  57465. */
  57466. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  57467. /**
  57468. * Creates a new OculusTouchController from a gamepad
  57469. * @param vrGamepad the gamepad that the controller should be created from
  57470. */
  57471. constructor(vrGamepad: any);
  57472. /**
  57473. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57474. * @param scene scene in which to add meshes
  57475. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57476. */
  57477. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57478. /**
  57479. * Fired when the A button on this controller is modified
  57480. */
  57481. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57482. /**
  57483. * Fired when the B button on this controller is modified
  57484. */
  57485. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57486. /**
  57487. * Fired when the X button on this controller is modified
  57488. */
  57489. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57490. /**
  57491. * Fired when the Y button on this controller is modified
  57492. */
  57493. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57494. /**
  57495. * Called once for each button that changed state since the last frame
  57496. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  57497. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  57498. * 2) secondary trigger (same)
  57499. * 3) A (right) X (left), touch, pressed = value
  57500. * 4) B / Y
  57501. * 5) thumb rest
  57502. * @param buttonIdx Which button index changed
  57503. * @param state New state of the button
  57504. * @param changes Which properties on the state changed since last frame
  57505. */
  57506. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57507. }
  57508. }
  57509. declare module BABYLON {
  57510. /**
  57511. * Vive Controller
  57512. */
  57513. export class ViveController extends WebVRController {
  57514. /**
  57515. * Base Url for the controller model.
  57516. */
  57517. static MODEL_BASE_URL: string;
  57518. /**
  57519. * File name for the controller model.
  57520. */
  57521. static MODEL_FILENAME: string;
  57522. /**
  57523. * Creates a new ViveController from a gamepad
  57524. * @param vrGamepad the gamepad that the controller should be created from
  57525. */
  57526. constructor(vrGamepad: any);
  57527. /**
  57528. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57529. * @param scene scene in which to add meshes
  57530. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57531. */
  57532. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57533. /**
  57534. * Fired when the left button on this controller is modified
  57535. */
  57536. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57537. /**
  57538. * Fired when the right button on this controller is modified
  57539. */
  57540. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57541. /**
  57542. * Fired when the menu button on this controller is modified
  57543. */
  57544. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57545. /**
  57546. * Called once for each button that changed state since the last frame
  57547. * Vive mapping:
  57548. * 0: touchpad
  57549. * 1: trigger
  57550. * 2: left AND right buttons
  57551. * 3: menu button
  57552. * @param buttonIdx Which button index changed
  57553. * @param state New state of the button
  57554. * @param changes Which properties on the state changed since last frame
  57555. */
  57556. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57557. }
  57558. }
  57559. declare module BABYLON {
  57560. /**
  57561. * Defines the WindowsMotionController object that the state of the windows motion controller
  57562. */
  57563. export class WindowsMotionController extends WebVRController {
  57564. /**
  57565. * The base url used to load the left and right controller models
  57566. */
  57567. static MODEL_BASE_URL: string;
  57568. /**
  57569. * The name of the left controller model file
  57570. */
  57571. static MODEL_LEFT_FILENAME: string;
  57572. /**
  57573. * The name of the right controller model file
  57574. */
  57575. static MODEL_RIGHT_FILENAME: string;
  57576. /**
  57577. * The controller name prefix for this controller type
  57578. */
  57579. static readonly GAMEPAD_ID_PREFIX: string;
  57580. /**
  57581. * The controller id pattern for this controller type
  57582. */
  57583. private static readonly GAMEPAD_ID_PATTERN;
  57584. private _loadedMeshInfo;
  57585. protected readonly _mapping: {
  57586. buttons: string[];
  57587. buttonMeshNames: {
  57588. trigger: string;
  57589. menu: string;
  57590. grip: string;
  57591. thumbstick: string;
  57592. trackpad: string;
  57593. };
  57594. buttonObservableNames: {
  57595. trigger: string;
  57596. menu: string;
  57597. grip: string;
  57598. thumbstick: string;
  57599. trackpad: string;
  57600. };
  57601. axisMeshNames: string[];
  57602. pointingPoseMeshName: string;
  57603. };
  57604. /**
  57605. * Fired when the trackpad on this controller is clicked
  57606. */
  57607. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57608. /**
  57609. * Fired when the trackpad on this controller is modified
  57610. */
  57611. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57612. /**
  57613. * The current x and y values of this controller's trackpad
  57614. */
  57615. trackpad: StickValues;
  57616. /**
  57617. * Creates a new WindowsMotionController from a gamepad
  57618. * @param vrGamepad the gamepad that the controller should be created from
  57619. */
  57620. constructor(vrGamepad: any);
  57621. /**
  57622. * Fired when the trigger on this controller is modified
  57623. */
  57624. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57625. /**
  57626. * Fired when the menu button on this controller is modified
  57627. */
  57628. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57629. /**
  57630. * Fired when the grip button on this controller is modified
  57631. */
  57632. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57633. /**
  57634. * Fired when the thumbstick button on this controller is modified
  57635. */
  57636. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57637. /**
  57638. * Fired when the touchpad button on this controller is modified
  57639. */
  57640. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57641. /**
  57642. * Fired when the touchpad values on this controller are modified
  57643. */
  57644. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  57645. protected _updateTrackpad(): void;
  57646. /**
  57647. * Called once per frame by the engine.
  57648. */
  57649. update(): void;
  57650. /**
  57651. * Called once for each button that changed state since the last frame
  57652. * @param buttonIdx Which button index changed
  57653. * @param state New state of the button
  57654. * @param changes Which properties on the state changed since last frame
  57655. */
  57656. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57657. /**
  57658. * Moves the buttons on the controller mesh based on their current state
  57659. * @param buttonName the name of the button to move
  57660. * @param buttonValue the value of the button which determines the buttons new position
  57661. */
  57662. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  57663. /**
  57664. * Moves the axis on the controller mesh based on its current state
  57665. * @param axis the index of the axis
  57666. * @param axisValue the value of the axis which determines the meshes new position
  57667. * @hidden
  57668. */
  57669. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  57670. /**
  57671. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57672. * @param scene scene in which to add meshes
  57673. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57674. */
  57675. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  57676. /**
  57677. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  57678. * can be transformed by button presses and axes values, based on this._mapping.
  57679. *
  57680. * @param scene scene in which the meshes exist
  57681. * @param meshes list of meshes that make up the controller model to process
  57682. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  57683. */
  57684. private processModel;
  57685. private createMeshInfo;
  57686. /**
  57687. * Gets the ray of the controller in the direction the controller is pointing
  57688. * @param length the length the resulting ray should be
  57689. * @returns a ray in the direction the controller is pointing
  57690. */
  57691. getForwardRay(length?: number): Ray;
  57692. /**
  57693. * Disposes of the controller
  57694. */
  57695. dispose(): void;
  57696. }
  57697. /**
  57698. * This class represents a new windows motion controller in XR.
  57699. */
  57700. export class XRWindowsMotionController extends WindowsMotionController {
  57701. /**
  57702. * Changing the original WIndowsMotionController mapping to fir the new mapping
  57703. */
  57704. protected readonly _mapping: {
  57705. buttons: string[];
  57706. buttonMeshNames: {
  57707. trigger: string;
  57708. menu: string;
  57709. grip: string;
  57710. thumbstick: string;
  57711. trackpad: string;
  57712. };
  57713. buttonObservableNames: {
  57714. trigger: string;
  57715. menu: string;
  57716. grip: string;
  57717. thumbstick: string;
  57718. trackpad: string;
  57719. };
  57720. axisMeshNames: string[];
  57721. pointingPoseMeshName: string;
  57722. };
  57723. /**
  57724. * Construct a new XR-Based windows motion controller
  57725. *
  57726. * @param gamepadInfo the gamepad object from the browser
  57727. */
  57728. constructor(gamepadInfo: any);
  57729. /**
  57730. * holds the thumbstick values (X,Y)
  57731. */
  57732. thumbstickValues: StickValues;
  57733. /**
  57734. * Fired when the thumbstick on this controller is clicked
  57735. */
  57736. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  57737. /**
  57738. * Fired when the thumbstick on this controller is modified
  57739. */
  57740. onThumbstickValuesChangedObservable: Observable<StickValues>;
  57741. /**
  57742. * Fired when the touchpad button on this controller is modified
  57743. */
  57744. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57745. /**
  57746. * Fired when the touchpad values on this controller are modified
  57747. */
  57748. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57749. /**
  57750. * Fired when the thumbstick button on this controller is modified
  57751. * here to prevent breaking changes
  57752. */
  57753. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57754. /**
  57755. * updating the thumbstick(!) and not the trackpad.
  57756. * This is named this way due to the difference between WebVR and XR and to avoid
  57757. * changing the parent class.
  57758. */
  57759. protected _updateTrackpad(): void;
  57760. /**
  57761. * Disposes the class with joy
  57762. */
  57763. dispose(): void;
  57764. }
  57765. }
  57766. declare module BABYLON {
  57767. /**
  57768. * A directional light is defined by a direction (what a surprise!).
  57769. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57770. * 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.
  57771. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57772. */
  57773. export class DirectionalLight extends ShadowLight {
  57774. private _shadowFrustumSize;
  57775. /**
  57776. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57777. */
  57778. get shadowFrustumSize(): number;
  57779. /**
  57780. * Specifies a fix frustum size for the shadow generation.
  57781. */
  57782. set shadowFrustumSize(value: number);
  57783. private _shadowOrthoScale;
  57784. /**
  57785. * Gets the shadow projection scale against the optimal computed one.
  57786. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57787. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57788. */
  57789. get shadowOrthoScale(): number;
  57790. /**
  57791. * Sets the shadow projection scale against the optimal computed one.
  57792. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57793. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57794. */
  57795. set shadowOrthoScale(value: number);
  57796. /**
  57797. * Automatically compute the projection matrix to best fit (including all the casters)
  57798. * on each frame.
  57799. */
  57800. autoUpdateExtends: boolean;
  57801. /**
  57802. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57803. * on each frame. autoUpdateExtends must be set to true for this to work
  57804. */
  57805. autoCalcShadowZBounds: boolean;
  57806. private _orthoLeft;
  57807. private _orthoRight;
  57808. private _orthoTop;
  57809. private _orthoBottom;
  57810. /**
  57811. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57812. * The directional light is emitted from everywhere in the given direction.
  57813. * It can cast shadows.
  57814. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57815. * @param name The friendly name of the light
  57816. * @param direction The direction of the light
  57817. * @param scene The scene the light belongs to
  57818. */
  57819. constructor(name: string, direction: Vector3, scene: Scene);
  57820. /**
  57821. * Returns the string "DirectionalLight".
  57822. * @return The class name
  57823. */
  57824. getClassName(): string;
  57825. /**
  57826. * Returns the integer 1.
  57827. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57828. */
  57829. getTypeID(): number;
  57830. /**
  57831. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57832. * Returns the DirectionalLight Shadow projection matrix.
  57833. */
  57834. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57835. /**
  57836. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57837. * Returns the DirectionalLight Shadow projection matrix.
  57838. */
  57839. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57840. /**
  57841. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57842. * Returns the DirectionalLight Shadow projection matrix.
  57843. */
  57844. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57845. protected _buildUniformLayout(): void;
  57846. /**
  57847. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57848. * @param effect The effect to update
  57849. * @param lightIndex The index of the light in the effect to update
  57850. * @returns The directional light
  57851. */
  57852. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57853. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57854. /**
  57855. * Gets the minZ used for shadow according to both the scene and the light.
  57856. *
  57857. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57858. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57859. * @param activeCamera The camera we are returning the min for
  57860. * @returns the depth min z
  57861. */
  57862. getDepthMinZ(activeCamera: Camera): number;
  57863. /**
  57864. * Gets the maxZ used for shadow according to both the scene and the light.
  57865. *
  57866. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57867. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57868. * @param activeCamera The camera we are returning the max for
  57869. * @returns the depth max z
  57870. */
  57871. getDepthMaxZ(activeCamera: Camera): number;
  57872. /**
  57873. * Prepares the list of defines specific to the light type.
  57874. * @param defines the list of defines
  57875. * @param lightIndex defines the index of the light for the effect
  57876. */
  57877. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57878. }
  57879. }
  57880. declare module BABYLON {
  57881. /**
  57882. * Class containing static functions to help procedurally build meshes
  57883. */
  57884. export class HemisphereBuilder {
  57885. /**
  57886. * Creates a hemisphere mesh
  57887. * @param name defines the name of the mesh
  57888. * @param options defines the options used to create the mesh
  57889. * @param scene defines the hosting scene
  57890. * @returns the hemisphere mesh
  57891. */
  57892. static CreateHemisphere(name: string, options: {
  57893. segments?: number;
  57894. diameter?: number;
  57895. sideOrientation?: number;
  57896. }, scene: any): Mesh;
  57897. }
  57898. }
  57899. declare module BABYLON {
  57900. /**
  57901. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57902. * These values define a cone of light starting from the position, emitting toward the direction.
  57903. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57904. * and the exponent defines the speed of the decay of the light with distance (reach).
  57905. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57906. */
  57907. export class SpotLight extends ShadowLight {
  57908. private _angle;
  57909. private _innerAngle;
  57910. private _cosHalfAngle;
  57911. private _lightAngleScale;
  57912. private _lightAngleOffset;
  57913. /**
  57914. * Gets the cone angle of the spot light in Radians.
  57915. */
  57916. get angle(): number;
  57917. /**
  57918. * Sets the cone angle of the spot light in Radians.
  57919. */
  57920. set angle(value: number);
  57921. /**
  57922. * Only used in gltf falloff mode, this defines the angle where
  57923. * the directional falloff will start before cutting at angle which could be seen
  57924. * as outer angle.
  57925. */
  57926. get innerAngle(): number;
  57927. /**
  57928. * Only used in gltf falloff mode, this defines the angle where
  57929. * the directional falloff will start before cutting at angle which could be seen
  57930. * as outer angle.
  57931. */
  57932. set innerAngle(value: number);
  57933. private _shadowAngleScale;
  57934. /**
  57935. * Allows scaling the angle of the light for shadow generation only.
  57936. */
  57937. get shadowAngleScale(): number;
  57938. /**
  57939. * Allows scaling the angle of the light for shadow generation only.
  57940. */
  57941. set shadowAngleScale(value: number);
  57942. /**
  57943. * The light decay speed with the distance from the emission spot.
  57944. */
  57945. exponent: number;
  57946. private _projectionTextureMatrix;
  57947. /**
  57948. * Allows reading the projecton texture
  57949. */
  57950. get projectionTextureMatrix(): Matrix;
  57951. protected _projectionTextureLightNear: number;
  57952. /**
  57953. * Gets the near clip of the Spotlight for texture projection.
  57954. */
  57955. get projectionTextureLightNear(): number;
  57956. /**
  57957. * Sets the near clip of the Spotlight for texture projection.
  57958. */
  57959. set projectionTextureLightNear(value: number);
  57960. protected _projectionTextureLightFar: number;
  57961. /**
  57962. * Gets the far clip of the Spotlight for texture projection.
  57963. */
  57964. get projectionTextureLightFar(): number;
  57965. /**
  57966. * Sets the far clip of the Spotlight for texture projection.
  57967. */
  57968. set projectionTextureLightFar(value: number);
  57969. protected _projectionTextureUpDirection: Vector3;
  57970. /**
  57971. * Gets the Up vector of the Spotlight for texture projection.
  57972. */
  57973. get projectionTextureUpDirection(): Vector3;
  57974. /**
  57975. * Sets the Up vector of the Spotlight for texture projection.
  57976. */
  57977. set projectionTextureUpDirection(value: Vector3);
  57978. private _projectionTexture;
  57979. /**
  57980. * Gets the projection texture of the light.
  57981. */
  57982. get projectionTexture(): Nullable<BaseTexture>;
  57983. /**
  57984. * Sets the projection texture of the light.
  57985. */
  57986. set projectionTexture(value: Nullable<BaseTexture>);
  57987. private static _IsProceduralTexture;
  57988. private static _IsTexture;
  57989. private _projectionTextureViewLightDirty;
  57990. private _projectionTextureProjectionLightDirty;
  57991. private _projectionTextureDirty;
  57992. private _projectionTextureViewTargetVector;
  57993. private _projectionTextureViewLightMatrix;
  57994. private _projectionTextureProjectionLightMatrix;
  57995. private _projectionTextureScalingMatrix;
  57996. /**
  57997. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57998. * It can cast shadows.
  57999. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58000. * @param name The light friendly name
  58001. * @param position The position of the spot light in the scene
  58002. * @param direction The direction of the light in the scene
  58003. * @param angle The cone angle of the light in Radians
  58004. * @param exponent The light decay speed with the distance from the emission spot
  58005. * @param scene The scene the lights belongs to
  58006. */
  58007. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  58008. /**
  58009. * Returns the string "SpotLight".
  58010. * @returns the class name
  58011. */
  58012. getClassName(): string;
  58013. /**
  58014. * Returns the integer 2.
  58015. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58016. */
  58017. getTypeID(): number;
  58018. /**
  58019. * Overrides the direction setter to recompute the projection texture view light Matrix.
  58020. */
  58021. protected _setDirection(value: Vector3): void;
  58022. /**
  58023. * Overrides the position setter to recompute the projection texture view light Matrix.
  58024. */
  58025. protected _setPosition(value: Vector3): void;
  58026. /**
  58027. * 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.
  58028. * Returns the SpotLight.
  58029. */
  58030. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58031. protected _computeProjectionTextureViewLightMatrix(): void;
  58032. protected _computeProjectionTextureProjectionLightMatrix(): void;
  58033. /**
  58034. * Main function for light texture projection matrix computing.
  58035. */
  58036. protected _computeProjectionTextureMatrix(): void;
  58037. protected _buildUniformLayout(): void;
  58038. private _computeAngleValues;
  58039. /**
  58040. * Sets the passed Effect "effect" with the Light textures.
  58041. * @param effect The effect to update
  58042. * @param lightIndex The index of the light in the effect to update
  58043. * @returns The light
  58044. */
  58045. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  58046. /**
  58047. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  58048. * @param effect The effect to update
  58049. * @param lightIndex The index of the light in the effect to update
  58050. * @returns The spot light
  58051. */
  58052. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  58053. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58054. /**
  58055. * Disposes the light and the associated resources.
  58056. */
  58057. dispose(): void;
  58058. /**
  58059. * Prepares the list of defines specific to the light type.
  58060. * @param defines the list of defines
  58061. * @param lightIndex defines the index of the light for the effect
  58062. */
  58063. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58064. }
  58065. }
  58066. declare module BABYLON {
  58067. /**
  58068. * Gizmo that enables viewing a light
  58069. */
  58070. export class LightGizmo extends Gizmo {
  58071. private _lightMesh;
  58072. private _material;
  58073. private _cachedPosition;
  58074. private _cachedForward;
  58075. private _attachedMeshParent;
  58076. private _pointerObserver;
  58077. /**
  58078. * Event that fires each time the gizmo is clicked
  58079. */
  58080. onClickedObservable: Observable<Light>;
  58081. /**
  58082. * Creates a LightGizmo
  58083. * @param gizmoLayer The utility layer the gizmo will be added to
  58084. */
  58085. constructor(gizmoLayer?: UtilityLayerRenderer);
  58086. private _light;
  58087. /**
  58088. * The light that the gizmo is attached to
  58089. */
  58090. set light(light: Nullable<Light>);
  58091. get light(): Nullable<Light>;
  58092. /**
  58093. * Gets the material used to render the light gizmo
  58094. */
  58095. get material(): StandardMaterial;
  58096. /**
  58097. * @hidden
  58098. * Updates the gizmo to match the attached mesh's position/rotation
  58099. */
  58100. protected _update(): void;
  58101. private static _Scale;
  58102. /**
  58103. * Creates the lines for a light mesh
  58104. */
  58105. private static _CreateLightLines;
  58106. /**
  58107. * Disposes of the light gizmo
  58108. */
  58109. dispose(): void;
  58110. private static _CreateHemisphericLightMesh;
  58111. private static _CreatePointLightMesh;
  58112. private static _CreateSpotLightMesh;
  58113. private static _CreateDirectionalLightMesh;
  58114. }
  58115. }
  58116. declare module BABYLON {
  58117. /**
  58118. * Gizmo that enables viewing a camera
  58119. */
  58120. export class CameraGizmo extends Gizmo {
  58121. private _cameraMesh;
  58122. private _cameraLinesMesh;
  58123. private _material;
  58124. private _pointerObserver;
  58125. /**
  58126. * Event that fires each time the gizmo is clicked
  58127. */
  58128. onClickedObservable: Observable<Camera>;
  58129. /**
  58130. * Creates a CameraGizmo
  58131. * @param gizmoLayer The utility layer the gizmo will be added to
  58132. */
  58133. constructor(gizmoLayer?: UtilityLayerRenderer);
  58134. private _camera;
  58135. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  58136. get displayFrustum(): boolean;
  58137. set displayFrustum(value: boolean);
  58138. /**
  58139. * The camera that the gizmo is attached to
  58140. */
  58141. set camera(camera: Nullable<Camera>);
  58142. get camera(): Nullable<Camera>;
  58143. /**
  58144. * Gets the material used to render the camera gizmo
  58145. */
  58146. get material(): StandardMaterial;
  58147. /**
  58148. * @hidden
  58149. * Updates the gizmo to match the attached mesh's position/rotation
  58150. */
  58151. protected _update(): void;
  58152. private static _Scale;
  58153. private _invProjection;
  58154. /**
  58155. * Disposes of the camera gizmo
  58156. */
  58157. dispose(): void;
  58158. private static _CreateCameraMesh;
  58159. private static _CreateCameraFrustum;
  58160. }
  58161. }
  58162. declare module BABYLON {
  58163. /** @hidden */
  58164. export var backgroundFragmentDeclaration: {
  58165. name: string;
  58166. shader: string;
  58167. };
  58168. }
  58169. declare module BABYLON {
  58170. /** @hidden */
  58171. export var backgroundUboDeclaration: {
  58172. name: string;
  58173. shader: string;
  58174. };
  58175. }
  58176. declare module BABYLON {
  58177. /** @hidden */
  58178. export var backgroundPixelShader: {
  58179. name: string;
  58180. shader: string;
  58181. };
  58182. }
  58183. declare module BABYLON {
  58184. /** @hidden */
  58185. export var backgroundVertexDeclaration: {
  58186. name: string;
  58187. shader: string;
  58188. };
  58189. }
  58190. declare module BABYLON {
  58191. /** @hidden */
  58192. export var backgroundVertexShader: {
  58193. name: string;
  58194. shader: string;
  58195. };
  58196. }
  58197. declare module BABYLON {
  58198. /**
  58199. * Background material used to create an efficient environement around your scene.
  58200. */
  58201. export class BackgroundMaterial extends PushMaterial {
  58202. /**
  58203. * Standard reflectance value at parallel view angle.
  58204. */
  58205. static StandardReflectance0: number;
  58206. /**
  58207. * Standard reflectance value at grazing angle.
  58208. */
  58209. static StandardReflectance90: number;
  58210. protected _primaryColor: Color3;
  58211. /**
  58212. * Key light Color (multiply against the environement texture)
  58213. */
  58214. primaryColor: Color3;
  58215. protected __perceptualColor: Nullable<Color3>;
  58216. /**
  58217. * Experimental Internal Use Only.
  58218. *
  58219. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  58220. * This acts as a helper to set the primary color to a more "human friendly" value.
  58221. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  58222. * output color as close as possible from the chosen value.
  58223. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  58224. * part of lighting setup.)
  58225. */
  58226. get _perceptualColor(): Nullable<Color3>;
  58227. set _perceptualColor(value: Nullable<Color3>);
  58228. protected _primaryColorShadowLevel: float;
  58229. /**
  58230. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  58231. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  58232. */
  58233. get primaryColorShadowLevel(): float;
  58234. set primaryColorShadowLevel(value: float);
  58235. protected _primaryColorHighlightLevel: float;
  58236. /**
  58237. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  58238. * The primary color is used at the level chosen to define what the white area would look.
  58239. */
  58240. get primaryColorHighlightLevel(): float;
  58241. set primaryColorHighlightLevel(value: float);
  58242. protected _reflectionTexture: Nullable<BaseTexture>;
  58243. /**
  58244. * Reflection Texture used in the material.
  58245. * Should be author in a specific way for the best result (refer to the documentation).
  58246. */
  58247. reflectionTexture: Nullable<BaseTexture>;
  58248. protected _reflectionBlur: float;
  58249. /**
  58250. * Reflection Texture level of blur.
  58251. *
  58252. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  58253. * texture twice.
  58254. */
  58255. reflectionBlur: float;
  58256. protected _diffuseTexture: Nullable<BaseTexture>;
  58257. /**
  58258. * Diffuse Texture used in the material.
  58259. * Should be author in a specific way for the best result (refer to the documentation).
  58260. */
  58261. diffuseTexture: Nullable<BaseTexture>;
  58262. protected _shadowLights: Nullable<IShadowLight[]>;
  58263. /**
  58264. * Specify the list of lights casting shadow on the material.
  58265. * All scene shadow lights will be included if null.
  58266. */
  58267. shadowLights: Nullable<IShadowLight[]>;
  58268. protected _shadowLevel: float;
  58269. /**
  58270. * Helps adjusting the shadow to a softer level if required.
  58271. * 0 means black shadows and 1 means no shadows.
  58272. */
  58273. shadowLevel: float;
  58274. protected _sceneCenter: Vector3;
  58275. /**
  58276. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  58277. * It is usually zero but might be interesting to modify according to your setup.
  58278. */
  58279. sceneCenter: Vector3;
  58280. protected _opacityFresnel: boolean;
  58281. /**
  58282. * This helps specifying that the material is falling off to the sky box at grazing angle.
  58283. * This helps ensuring a nice transition when the camera goes under the ground.
  58284. */
  58285. opacityFresnel: boolean;
  58286. protected _reflectionFresnel: boolean;
  58287. /**
  58288. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  58289. * This helps adding a mirror texture on the ground.
  58290. */
  58291. reflectionFresnel: boolean;
  58292. protected _reflectionFalloffDistance: number;
  58293. /**
  58294. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  58295. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  58296. */
  58297. reflectionFalloffDistance: number;
  58298. protected _reflectionAmount: number;
  58299. /**
  58300. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  58301. */
  58302. reflectionAmount: number;
  58303. protected _reflectionReflectance0: number;
  58304. /**
  58305. * This specifies the weight of the reflection at grazing angle.
  58306. */
  58307. reflectionReflectance0: number;
  58308. protected _reflectionReflectance90: number;
  58309. /**
  58310. * This specifies the weight of the reflection at a perpendicular point of view.
  58311. */
  58312. reflectionReflectance90: number;
  58313. /**
  58314. * Sets the reflection reflectance fresnel values according to the default standard
  58315. * empirically know to work well :-)
  58316. */
  58317. set reflectionStandardFresnelWeight(value: number);
  58318. protected _useRGBColor: boolean;
  58319. /**
  58320. * Helps to directly use the maps channels instead of their level.
  58321. */
  58322. useRGBColor: boolean;
  58323. protected _enableNoise: boolean;
  58324. /**
  58325. * This helps reducing the banding effect that could occur on the background.
  58326. */
  58327. enableNoise: boolean;
  58328. /**
  58329. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58330. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  58331. * Recommended to be keep at 1.0 except for special cases.
  58332. */
  58333. get fovMultiplier(): number;
  58334. set fovMultiplier(value: number);
  58335. private _fovMultiplier;
  58336. /**
  58337. * Enable the FOV adjustment feature controlled by fovMultiplier.
  58338. */
  58339. useEquirectangularFOV: boolean;
  58340. private _maxSimultaneousLights;
  58341. /**
  58342. * Number of Simultaneous lights allowed on the material.
  58343. */
  58344. maxSimultaneousLights: int;
  58345. private _shadowOnly;
  58346. /**
  58347. * Make the material only render shadows
  58348. */
  58349. shadowOnly: boolean;
  58350. /**
  58351. * Default configuration related to image processing available in the Background Material.
  58352. */
  58353. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58354. /**
  58355. * Keep track of the image processing observer to allow dispose and replace.
  58356. */
  58357. private _imageProcessingObserver;
  58358. /**
  58359. * Attaches a new image processing configuration to the PBR Material.
  58360. * @param configuration (if null the scene configuration will be use)
  58361. */
  58362. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58363. /**
  58364. * Gets the image processing configuration used either in this material.
  58365. */
  58366. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  58367. /**
  58368. * Sets the Default image processing configuration used either in the this material.
  58369. *
  58370. * If sets to null, the scene one is in use.
  58371. */
  58372. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  58373. /**
  58374. * Gets wether the color curves effect is enabled.
  58375. */
  58376. get cameraColorCurvesEnabled(): boolean;
  58377. /**
  58378. * Sets wether the color curves effect is enabled.
  58379. */
  58380. set cameraColorCurvesEnabled(value: boolean);
  58381. /**
  58382. * Gets wether the color grading effect is enabled.
  58383. */
  58384. get cameraColorGradingEnabled(): boolean;
  58385. /**
  58386. * Gets wether the color grading effect is enabled.
  58387. */
  58388. set cameraColorGradingEnabled(value: boolean);
  58389. /**
  58390. * Gets wether tonemapping is enabled or not.
  58391. */
  58392. get cameraToneMappingEnabled(): boolean;
  58393. /**
  58394. * Sets wether tonemapping is enabled or not
  58395. */
  58396. set cameraToneMappingEnabled(value: boolean);
  58397. /**
  58398. * The camera exposure used on this material.
  58399. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58400. * This corresponds to a photographic exposure.
  58401. */
  58402. get cameraExposure(): float;
  58403. /**
  58404. * The camera exposure used on this material.
  58405. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58406. * This corresponds to a photographic exposure.
  58407. */
  58408. set cameraExposure(value: float);
  58409. /**
  58410. * Gets The camera contrast used on this material.
  58411. */
  58412. get cameraContrast(): float;
  58413. /**
  58414. * Sets The camera contrast used on this material.
  58415. */
  58416. set cameraContrast(value: float);
  58417. /**
  58418. * Gets the Color Grading 2D Lookup Texture.
  58419. */
  58420. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58421. /**
  58422. * Sets the Color Grading 2D Lookup Texture.
  58423. */
  58424. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58425. /**
  58426. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58427. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58428. * 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;
  58429. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58430. */
  58431. get cameraColorCurves(): Nullable<ColorCurves>;
  58432. /**
  58433. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58434. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58435. * 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;
  58436. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58437. */
  58438. set cameraColorCurves(value: Nullable<ColorCurves>);
  58439. /**
  58440. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  58441. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  58442. */
  58443. switchToBGR: boolean;
  58444. private _renderTargets;
  58445. private _reflectionControls;
  58446. private _white;
  58447. private _primaryShadowColor;
  58448. private _primaryHighlightColor;
  58449. /**
  58450. * Instantiates a Background Material in the given scene
  58451. * @param name The friendly name of the material
  58452. * @param scene The scene to add the material to
  58453. */
  58454. constructor(name: string, scene: Scene);
  58455. /**
  58456. * Gets a boolean indicating that current material needs to register RTT
  58457. */
  58458. get hasRenderTargetTextures(): boolean;
  58459. /**
  58460. * The entire material has been created in order to prevent overdraw.
  58461. * @returns false
  58462. */
  58463. needAlphaTesting(): boolean;
  58464. /**
  58465. * The entire material has been created in order to prevent overdraw.
  58466. * @returns true if blending is enable
  58467. */
  58468. needAlphaBlending(): boolean;
  58469. /**
  58470. * Checks wether the material is ready to be rendered for a given mesh.
  58471. * @param mesh The mesh to render
  58472. * @param subMesh The submesh to check against
  58473. * @param useInstances Specify wether or not the material is used with instances
  58474. * @returns true if all the dependencies are ready (Textures, Effects...)
  58475. */
  58476. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58477. /**
  58478. * Compute the primary color according to the chosen perceptual color.
  58479. */
  58480. private _computePrimaryColorFromPerceptualColor;
  58481. /**
  58482. * Compute the highlights and shadow colors according to their chosen levels.
  58483. */
  58484. private _computePrimaryColors;
  58485. /**
  58486. * Build the uniform buffer used in the material.
  58487. */
  58488. buildUniformLayout(): void;
  58489. /**
  58490. * Unbind the material.
  58491. */
  58492. unbind(): void;
  58493. /**
  58494. * Bind only the world matrix to the material.
  58495. * @param world The world matrix to bind.
  58496. */
  58497. bindOnlyWorldMatrix(world: Matrix): void;
  58498. /**
  58499. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  58500. * @param world The world matrix to bind.
  58501. * @param subMesh The submesh to bind for.
  58502. */
  58503. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58504. /**
  58505. * Checks to see if a texture is used in the material.
  58506. * @param texture - Base texture to use.
  58507. * @returns - Boolean specifying if a texture is used in the material.
  58508. */
  58509. hasTexture(texture: BaseTexture): boolean;
  58510. /**
  58511. * Dispose the material.
  58512. * @param forceDisposeEffect Force disposal of the associated effect.
  58513. * @param forceDisposeTextures Force disposal of the associated textures.
  58514. */
  58515. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58516. /**
  58517. * Clones the material.
  58518. * @param name The cloned name.
  58519. * @returns The cloned material.
  58520. */
  58521. clone(name: string): BackgroundMaterial;
  58522. /**
  58523. * Serializes the current material to its JSON representation.
  58524. * @returns The JSON representation.
  58525. */
  58526. serialize(): any;
  58527. /**
  58528. * Gets the class name of the material
  58529. * @returns "BackgroundMaterial"
  58530. */
  58531. getClassName(): string;
  58532. /**
  58533. * Parse a JSON input to create back a background material.
  58534. * @param source The JSON data to parse
  58535. * @param scene The scene to create the parsed material in
  58536. * @param rootUrl The root url of the assets the material depends upon
  58537. * @returns the instantiated BackgroundMaterial.
  58538. */
  58539. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  58540. }
  58541. }
  58542. declare module BABYLON {
  58543. /**
  58544. * Represents the different options available during the creation of
  58545. * a Environment helper.
  58546. *
  58547. * This can control the default ground, skybox and image processing setup of your scene.
  58548. */
  58549. export interface IEnvironmentHelperOptions {
  58550. /**
  58551. * Specifies whether or not to create a ground.
  58552. * True by default.
  58553. */
  58554. createGround: boolean;
  58555. /**
  58556. * Specifies the ground size.
  58557. * 15 by default.
  58558. */
  58559. groundSize: number;
  58560. /**
  58561. * The texture used on the ground for the main color.
  58562. * Comes from the BabylonJS CDN by default.
  58563. *
  58564. * Remarks: Can be either a texture or a url.
  58565. */
  58566. groundTexture: string | BaseTexture;
  58567. /**
  58568. * The color mixed in the ground texture by default.
  58569. * BabylonJS clearColor by default.
  58570. */
  58571. groundColor: Color3;
  58572. /**
  58573. * Specifies the ground opacity.
  58574. * 1 by default.
  58575. */
  58576. groundOpacity: number;
  58577. /**
  58578. * Enables the ground to receive shadows.
  58579. * True by default.
  58580. */
  58581. enableGroundShadow: boolean;
  58582. /**
  58583. * Helps preventing the shadow to be fully black on the ground.
  58584. * 0.5 by default.
  58585. */
  58586. groundShadowLevel: number;
  58587. /**
  58588. * Creates a mirror texture attach to the ground.
  58589. * false by default.
  58590. */
  58591. enableGroundMirror: boolean;
  58592. /**
  58593. * Specifies the ground mirror size ratio.
  58594. * 0.3 by default as the default kernel is 64.
  58595. */
  58596. groundMirrorSizeRatio: number;
  58597. /**
  58598. * Specifies the ground mirror blur kernel size.
  58599. * 64 by default.
  58600. */
  58601. groundMirrorBlurKernel: number;
  58602. /**
  58603. * Specifies the ground mirror visibility amount.
  58604. * 1 by default
  58605. */
  58606. groundMirrorAmount: number;
  58607. /**
  58608. * Specifies the ground mirror reflectance weight.
  58609. * This uses the standard weight of the background material to setup the fresnel effect
  58610. * of the mirror.
  58611. * 1 by default.
  58612. */
  58613. groundMirrorFresnelWeight: number;
  58614. /**
  58615. * Specifies the ground mirror Falloff distance.
  58616. * This can helps reducing the size of the reflection.
  58617. * 0 by Default.
  58618. */
  58619. groundMirrorFallOffDistance: number;
  58620. /**
  58621. * Specifies the ground mirror texture type.
  58622. * Unsigned Int by Default.
  58623. */
  58624. groundMirrorTextureType: number;
  58625. /**
  58626. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  58627. * the shown objects.
  58628. */
  58629. groundYBias: number;
  58630. /**
  58631. * Specifies whether or not to create a skybox.
  58632. * True by default.
  58633. */
  58634. createSkybox: boolean;
  58635. /**
  58636. * Specifies the skybox size.
  58637. * 20 by default.
  58638. */
  58639. skyboxSize: number;
  58640. /**
  58641. * The texture used on the skybox for the main color.
  58642. * Comes from the BabylonJS CDN by default.
  58643. *
  58644. * Remarks: Can be either a texture or a url.
  58645. */
  58646. skyboxTexture: string | BaseTexture;
  58647. /**
  58648. * The color mixed in the skybox texture by default.
  58649. * BabylonJS clearColor by default.
  58650. */
  58651. skyboxColor: Color3;
  58652. /**
  58653. * The background rotation around the Y axis of the scene.
  58654. * This helps aligning the key lights of your scene with the background.
  58655. * 0 by default.
  58656. */
  58657. backgroundYRotation: number;
  58658. /**
  58659. * Compute automatically the size of the elements to best fit with the scene.
  58660. */
  58661. sizeAuto: boolean;
  58662. /**
  58663. * Default position of the rootMesh if autoSize is not true.
  58664. */
  58665. rootPosition: Vector3;
  58666. /**
  58667. * Sets up the image processing in the scene.
  58668. * true by default.
  58669. */
  58670. setupImageProcessing: boolean;
  58671. /**
  58672. * The texture used as your environment texture in the scene.
  58673. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  58674. *
  58675. * Remarks: Can be either a texture or a url.
  58676. */
  58677. environmentTexture: string | BaseTexture;
  58678. /**
  58679. * The value of the exposure to apply to the scene.
  58680. * 0.6 by default if setupImageProcessing is true.
  58681. */
  58682. cameraExposure: number;
  58683. /**
  58684. * The value of the contrast to apply to the scene.
  58685. * 1.6 by default if setupImageProcessing is true.
  58686. */
  58687. cameraContrast: number;
  58688. /**
  58689. * Specifies whether or not tonemapping should be enabled in the scene.
  58690. * true by default if setupImageProcessing is true.
  58691. */
  58692. toneMappingEnabled: boolean;
  58693. }
  58694. /**
  58695. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  58696. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  58697. * It also helps with the default setup of your imageProcessing configuration.
  58698. */
  58699. export class EnvironmentHelper {
  58700. /**
  58701. * Default ground texture URL.
  58702. */
  58703. private static _groundTextureCDNUrl;
  58704. /**
  58705. * Default skybox texture URL.
  58706. */
  58707. private static _skyboxTextureCDNUrl;
  58708. /**
  58709. * Default environment texture URL.
  58710. */
  58711. private static _environmentTextureCDNUrl;
  58712. /**
  58713. * Creates the default options for the helper.
  58714. */
  58715. private static _getDefaultOptions;
  58716. private _rootMesh;
  58717. /**
  58718. * Gets the root mesh created by the helper.
  58719. */
  58720. get rootMesh(): Mesh;
  58721. private _skybox;
  58722. /**
  58723. * Gets the skybox created by the helper.
  58724. */
  58725. get skybox(): Nullable<Mesh>;
  58726. private _skyboxTexture;
  58727. /**
  58728. * Gets the skybox texture created by the helper.
  58729. */
  58730. get skyboxTexture(): Nullable<BaseTexture>;
  58731. private _skyboxMaterial;
  58732. /**
  58733. * Gets the skybox material created by the helper.
  58734. */
  58735. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58736. private _ground;
  58737. /**
  58738. * Gets the ground mesh created by the helper.
  58739. */
  58740. get ground(): Nullable<Mesh>;
  58741. private _groundTexture;
  58742. /**
  58743. * Gets the ground texture created by the helper.
  58744. */
  58745. get groundTexture(): Nullable<BaseTexture>;
  58746. private _groundMirror;
  58747. /**
  58748. * Gets the ground mirror created by the helper.
  58749. */
  58750. get groundMirror(): Nullable<MirrorTexture>;
  58751. /**
  58752. * Gets the ground mirror render list to helps pushing the meshes
  58753. * you wish in the ground reflection.
  58754. */
  58755. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58756. private _groundMaterial;
  58757. /**
  58758. * Gets the ground material created by the helper.
  58759. */
  58760. get groundMaterial(): Nullable<BackgroundMaterial>;
  58761. /**
  58762. * Stores the creation options.
  58763. */
  58764. private readonly _scene;
  58765. private _options;
  58766. /**
  58767. * This observable will be notified with any error during the creation of the environment,
  58768. * mainly texture creation errors.
  58769. */
  58770. onErrorObservable: Observable<{
  58771. message?: string;
  58772. exception?: any;
  58773. }>;
  58774. /**
  58775. * constructor
  58776. * @param options Defines the options we want to customize the helper
  58777. * @param scene The scene to add the material to
  58778. */
  58779. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58780. /**
  58781. * Updates the background according to the new options
  58782. * @param options
  58783. */
  58784. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58785. /**
  58786. * Sets the primary color of all the available elements.
  58787. * @param color the main color to affect to the ground and the background
  58788. */
  58789. setMainColor(color: Color3): void;
  58790. /**
  58791. * Setup the image processing according to the specified options.
  58792. */
  58793. private _setupImageProcessing;
  58794. /**
  58795. * Setup the environment texture according to the specified options.
  58796. */
  58797. private _setupEnvironmentTexture;
  58798. /**
  58799. * Setup the background according to the specified options.
  58800. */
  58801. private _setupBackground;
  58802. /**
  58803. * Get the scene sizes according to the setup.
  58804. */
  58805. private _getSceneSize;
  58806. /**
  58807. * Setup the ground according to the specified options.
  58808. */
  58809. private _setupGround;
  58810. /**
  58811. * Setup the ground material according to the specified options.
  58812. */
  58813. private _setupGroundMaterial;
  58814. /**
  58815. * Setup the ground diffuse texture according to the specified options.
  58816. */
  58817. private _setupGroundDiffuseTexture;
  58818. /**
  58819. * Setup the ground mirror texture according to the specified options.
  58820. */
  58821. private _setupGroundMirrorTexture;
  58822. /**
  58823. * Setup the ground to receive the mirror texture.
  58824. */
  58825. private _setupMirrorInGroundMaterial;
  58826. /**
  58827. * Setup the skybox according to the specified options.
  58828. */
  58829. private _setupSkybox;
  58830. /**
  58831. * Setup the skybox material according to the specified options.
  58832. */
  58833. private _setupSkyboxMaterial;
  58834. /**
  58835. * Setup the skybox reflection texture according to the specified options.
  58836. */
  58837. private _setupSkyboxReflectionTexture;
  58838. private _errorHandler;
  58839. /**
  58840. * Dispose all the elements created by the Helper.
  58841. */
  58842. dispose(): void;
  58843. }
  58844. }
  58845. declare module BABYLON {
  58846. /**
  58847. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58848. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58849. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58850. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58851. */
  58852. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58853. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58854. /**
  58855. * Define the source as a Monoscopic panoramic 360/180.
  58856. */
  58857. static readonly MODE_MONOSCOPIC: number;
  58858. /**
  58859. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58860. */
  58861. static readonly MODE_TOPBOTTOM: number;
  58862. /**
  58863. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58864. */
  58865. static readonly MODE_SIDEBYSIDE: number;
  58866. private _halfDome;
  58867. private _crossEye;
  58868. protected _useDirectMapping: boolean;
  58869. /**
  58870. * The texture being displayed on the sphere
  58871. */
  58872. protected _texture: T;
  58873. /**
  58874. * Gets the texture being displayed on the sphere
  58875. */
  58876. get texture(): T;
  58877. /**
  58878. * Sets the texture being displayed on the sphere
  58879. */
  58880. set texture(newTexture: T);
  58881. /**
  58882. * The skybox material
  58883. */
  58884. protected _material: BackgroundMaterial;
  58885. /**
  58886. * The surface used for the dome
  58887. */
  58888. protected _mesh: Mesh;
  58889. /**
  58890. * Gets the mesh used for the dome.
  58891. */
  58892. get mesh(): Mesh;
  58893. /**
  58894. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58895. */
  58896. private _halfDomeMask;
  58897. /**
  58898. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58899. * Also see the options.resolution property.
  58900. */
  58901. get fovMultiplier(): number;
  58902. set fovMultiplier(value: number);
  58903. protected _textureMode: number;
  58904. /**
  58905. * Gets or set the current texture mode for the texture. It can be:
  58906. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58907. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58908. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58909. */
  58910. get textureMode(): number;
  58911. /**
  58912. * Sets the current texture mode for the texture. It can be:
  58913. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58914. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58915. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58916. */
  58917. set textureMode(value: number);
  58918. /**
  58919. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58920. */
  58921. get halfDome(): boolean;
  58922. /**
  58923. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58924. */
  58925. set halfDome(enabled: boolean);
  58926. /**
  58927. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58928. */
  58929. set crossEye(enabled: boolean);
  58930. /**
  58931. * Is it a cross-eye texture?
  58932. */
  58933. get crossEye(): boolean;
  58934. /**
  58935. * The background material of this dome.
  58936. */
  58937. get material(): BackgroundMaterial;
  58938. /**
  58939. * Oberserver used in Stereoscopic VR Mode.
  58940. */
  58941. private _onBeforeCameraRenderObserver;
  58942. /**
  58943. * Observable raised when an error occured while loading the 360 image
  58944. */
  58945. onLoadErrorObservable: Observable<string>;
  58946. /**
  58947. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58948. * @param name Element's name, child elements will append suffixes for their own names.
  58949. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58950. * @param options An object containing optional or exposed sub element properties
  58951. */
  58952. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58953. resolution?: number;
  58954. clickToPlay?: boolean;
  58955. autoPlay?: boolean;
  58956. loop?: boolean;
  58957. size?: number;
  58958. poster?: string;
  58959. faceForward?: boolean;
  58960. useDirectMapping?: boolean;
  58961. halfDomeMode?: boolean;
  58962. crossEyeMode?: boolean;
  58963. generateMipMaps?: boolean;
  58964. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58965. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58966. protected _changeTextureMode(value: number): void;
  58967. /**
  58968. * Releases resources associated with this node.
  58969. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58970. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58971. */
  58972. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58973. }
  58974. }
  58975. declare module BABYLON {
  58976. /**
  58977. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58978. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58979. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58980. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58981. */
  58982. export class PhotoDome extends TextureDome<Texture> {
  58983. /**
  58984. * Define the image as a Monoscopic panoramic 360 image.
  58985. */
  58986. static readonly MODE_MONOSCOPIC: number;
  58987. /**
  58988. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58989. */
  58990. static readonly MODE_TOPBOTTOM: number;
  58991. /**
  58992. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58993. */
  58994. static readonly MODE_SIDEBYSIDE: number;
  58995. /**
  58996. * Gets or sets the texture being displayed on the sphere
  58997. */
  58998. get photoTexture(): Texture;
  58999. /**
  59000. * sets the texture being displayed on the sphere
  59001. */
  59002. set photoTexture(value: Texture);
  59003. /**
  59004. * Gets the current video mode for the video. It can be:
  59005. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  59006. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  59007. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  59008. */
  59009. get imageMode(): number;
  59010. /**
  59011. * Sets the current video mode for the video. It can be:
  59012. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  59013. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  59014. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  59015. */
  59016. set imageMode(value: number);
  59017. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  59018. }
  59019. }
  59020. declare module BABYLON {
  59021. /**
  59022. * Direct draw surface info
  59023. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59024. */
  59025. export interface DDSInfo {
  59026. /**
  59027. * Width of the texture
  59028. */
  59029. width: number;
  59030. /**
  59031. * Width of the texture
  59032. */
  59033. height: number;
  59034. /**
  59035. * Number of Mipmaps for the texture
  59036. * @see https://en.wikipedia.org/wiki/Mipmap
  59037. */
  59038. mipmapCount: number;
  59039. /**
  59040. * If the textures format is a known fourCC format
  59041. * @see https://www.fourcc.org/
  59042. */
  59043. isFourCC: boolean;
  59044. /**
  59045. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59046. */
  59047. isRGB: boolean;
  59048. /**
  59049. * If the texture is a lumincance format
  59050. */
  59051. isLuminance: boolean;
  59052. /**
  59053. * If this is a cube texture
  59054. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59055. */
  59056. isCube: boolean;
  59057. /**
  59058. * If the texture is a compressed format eg. FOURCC_DXT1
  59059. */
  59060. isCompressed: boolean;
  59061. /**
  59062. * The dxgiFormat of the texture
  59063. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59064. */
  59065. dxgiFormat: number;
  59066. /**
  59067. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59068. */
  59069. textureType: number;
  59070. /**
  59071. * Sphericle polynomial created for the dds texture
  59072. */
  59073. sphericalPolynomial?: SphericalPolynomial;
  59074. }
  59075. /**
  59076. * Class used to provide DDS decompression tools
  59077. */
  59078. export class DDSTools {
  59079. /**
  59080. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59081. */
  59082. static StoreLODInAlphaChannel: boolean;
  59083. /**
  59084. * Gets DDS information from an array buffer
  59085. * @param data defines the array buffer view to read data from
  59086. * @returns the DDS information
  59087. */
  59088. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59089. private static _FloatView;
  59090. private static _Int32View;
  59091. private static _ToHalfFloat;
  59092. private static _FromHalfFloat;
  59093. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59094. private static _GetHalfFloatRGBAArrayBuffer;
  59095. private static _GetFloatRGBAArrayBuffer;
  59096. private static _GetFloatAsUIntRGBAArrayBuffer;
  59097. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59098. private static _GetRGBAArrayBuffer;
  59099. private static _ExtractLongWordOrder;
  59100. private static _GetRGBArrayBuffer;
  59101. private static _GetLuminanceArrayBuffer;
  59102. /**
  59103. * Uploads DDS Levels to a Babylon Texture
  59104. * @hidden
  59105. */
  59106. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59107. }
  59108. interface ThinEngine {
  59109. /**
  59110. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59111. * @param rootUrl defines the url where the file to load is located
  59112. * @param scene defines the current scene
  59113. * @param lodScale defines scale to apply to the mip map selection
  59114. * @param lodOffset defines offset to apply to the mip map selection
  59115. * @param onLoad defines an optional callback raised when the texture is loaded
  59116. * @param onError defines an optional callback raised if there is an issue to load the texture
  59117. * @param format defines the format of the data
  59118. * @param forcedExtension defines the extension to use to pick the right loader
  59119. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59120. * @returns the cube texture as an InternalTexture
  59121. */
  59122. 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;
  59123. }
  59124. }
  59125. declare module BABYLON {
  59126. /**
  59127. * Implementation of the DDS Texture Loader.
  59128. * @hidden
  59129. */
  59130. export class _DDSTextureLoader implements IInternalTextureLoader {
  59131. /**
  59132. * Defines wether the loader supports cascade loading the different faces.
  59133. */
  59134. readonly supportCascades: boolean;
  59135. /**
  59136. * This returns if the loader support the current file information.
  59137. * @param extension defines the file extension of the file being loaded
  59138. * @returns true if the loader can load the specified file
  59139. */
  59140. canLoad(extension: string): boolean;
  59141. /**
  59142. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59143. * @param data contains the texture data
  59144. * @param texture defines the BabylonJS internal texture
  59145. * @param createPolynomials will be true if polynomials have been requested
  59146. * @param onLoad defines the callback to trigger once the texture is ready
  59147. * @param onError defines the callback to trigger in case of error
  59148. */
  59149. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59150. /**
  59151. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59152. * @param data contains the texture data
  59153. * @param texture defines the BabylonJS internal texture
  59154. * @param callback defines the method to call once ready to upload
  59155. */
  59156. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59157. }
  59158. }
  59159. declare module BABYLON {
  59160. /**
  59161. * Implementation of the ENV Texture Loader.
  59162. * @hidden
  59163. */
  59164. export class _ENVTextureLoader implements IInternalTextureLoader {
  59165. /**
  59166. * Defines wether the loader supports cascade loading the different faces.
  59167. */
  59168. readonly supportCascades: boolean;
  59169. /**
  59170. * This returns if the loader support the current file information.
  59171. * @param extension defines the file extension of the file being loaded
  59172. * @returns true if the loader can load the specified file
  59173. */
  59174. canLoad(extension: string): boolean;
  59175. /**
  59176. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59177. * @param data contains the texture data
  59178. * @param texture defines the BabylonJS internal texture
  59179. * @param createPolynomials will be true if polynomials have been requested
  59180. * @param onLoad defines the callback to trigger once the texture is ready
  59181. * @param onError defines the callback to trigger in case of error
  59182. */
  59183. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59184. /**
  59185. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59186. * @param data contains the texture data
  59187. * @param texture defines the BabylonJS internal texture
  59188. * @param callback defines the method to call once ready to upload
  59189. */
  59190. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59191. }
  59192. }
  59193. declare module BABYLON {
  59194. /**
  59195. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59196. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59197. */
  59198. export class KhronosTextureContainer {
  59199. /** contents of the KTX container file */
  59200. data: ArrayBufferView;
  59201. private static HEADER_LEN;
  59202. private static COMPRESSED_2D;
  59203. private static COMPRESSED_3D;
  59204. private static TEX_2D;
  59205. private static TEX_3D;
  59206. /**
  59207. * Gets the openGL type
  59208. */
  59209. glType: number;
  59210. /**
  59211. * Gets the openGL type size
  59212. */
  59213. glTypeSize: number;
  59214. /**
  59215. * Gets the openGL format
  59216. */
  59217. glFormat: number;
  59218. /**
  59219. * Gets the openGL internal format
  59220. */
  59221. glInternalFormat: number;
  59222. /**
  59223. * Gets the base internal format
  59224. */
  59225. glBaseInternalFormat: number;
  59226. /**
  59227. * Gets image width in pixel
  59228. */
  59229. pixelWidth: number;
  59230. /**
  59231. * Gets image height in pixel
  59232. */
  59233. pixelHeight: number;
  59234. /**
  59235. * Gets image depth in pixels
  59236. */
  59237. pixelDepth: number;
  59238. /**
  59239. * Gets the number of array elements
  59240. */
  59241. numberOfArrayElements: number;
  59242. /**
  59243. * Gets the number of faces
  59244. */
  59245. numberOfFaces: number;
  59246. /**
  59247. * Gets the number of mipmap levels
  59248. */
  59249. numberOfMipmapLevels: number;
  59250. /**
  59251. * Gets the bytes of key value data
  59252. */
  59253. bytesOfKeyValueData: number;
  59254. /**
  59255. * Gets the load type
  59256. */
  59257. loadType: number;
  59258. /**
  59259. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59260. */
  59261. isInvalid: boolean;
  59262. /**
  59263. * Creates a new KhronosTextureContainer
  59264. * @param data contents of the KTX container file
  59265. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59266. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59267. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59268. */
  59269. constructor(
  59270. /** contents of the KTX container file */
  59271. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59272. /**
  59273. * Uploads KTX content to a Babylon Texture.
  59274. * It is assumed that the texture has already been created & is currently bound
  59275. * @hidden
  59276. */
  59277. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59278. private _upload2DCompressedLevels;
  59279. /**
  59280. * Checks if the given data starts with a KTX file identifier.
  59281. * @param data the data to check
  59282. * @returns true if the data is a KTX file or false otherwise
  59283. */
  59284. static IsValid(data: ArrayBufferView): boolean;
  59285. }
  59286. }
  59287. declare module BABYLON {
  59288. /**
  59289. * Helper class to push actions to a pool of workers.
  59290. */
  59291. export class WorkerPool implements IDisposable {
  59292. private _workerInfos;
  59293. private _pendingActions;
  59294. /**
  59295. * Constructor
  59296. * @param workers Array of workers to use for actions
  59297. */
  59298. constructor(workers: Array<Worker>);
  59299. /**
  59300. * Terminates all workers and clears any pending actions.
  59301. */
  59302. dispose(): void;
  59303. /**
  59304. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59305. * pended until a worker has completed its action.
  59306. * @param action The action to perform. Call onComplete when the action is complete.
  59307. */
  59308. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59309. private _execute;
  59310. }
  59311. }
  59312. declare module BABYLON {
  59313. /**
  59314. * Class for loading KTX2 files
  59315. */
  59316. export class KhronosTextureContainer2 {
  59317. private static _WorkerPoolPromise?;
  59318. private static _Initialized;
  59319. private static _Ktx2Decoder;
  59320. /**
  59321. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  59322. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  59323. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  59324. * Urls you can change:
  59325. * URLConfig.jsDecoderModule
  59326. * URLConfig.wasmUASTCToASTC
  59327. * URLConfig.wasmUASTCToBC7
  59328. * URLConfig.wasmUASTCToRGBA_UNORM
  59329. * URLConfig.wasmUASTCToRGBA_SRGB
  59330. * URLConfig.jsMSCTranscoder
  59331. * URLConfig.wasmMSCTranscoder
  59332. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  59333. */
  59334. static URLConfig: {
  59335. jsDecoderModule: string;
  59336. wasmUASTCToASTC: null;
  59337. wasmUASTCToBC7: null;
  59338. wasmUASTCToRGBA_UNORM: null;
  59339. wasmUASTCToRGBA_SRGB: null;
  59340. jsMSCTranscoder: null;
  59341. wasmMSCTranscoder: null;
  59342. };
  59343. /**
  59344. * Default number of workers used to handle data decoding
  59345. */
  59346. static DefaultNumWorkers: number;
  59347. private static GetDefaultNumWorkers;
  59348. private _engine;
  59349. private static _CreateWorkerPool;
  59350. /**
  59351. * Constructor
  59352. * @param engine The engine to use
  59353. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59354. */
  59355. constructor(engine: ThinEngine, numWorkers?: number);
  59356. /** @hidden */
  59357. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  59358. /**
  59359. * Stop all async operations and release resources.
  59360. */
  59361. dispose(): void;
  59362. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  59363. /**
  59364. * Checks if the given data starts with a KTX2 file identifier.
  59365. * @param data the data to check
  59366. * @returns true if the data is a KTX2 file or false otherwise
  59367. */
  59368. static IsValid(data: ArrayBufferView): boolean;
  59369. }
  59370. }
  59371. declare module BABYLON {
  59372. /**
  59373. * Implementation of the KTX Texture Loader.
  59374. * @hidden
  59375. */
  59376. export class _KTXTextureLoader implements IInternalTextureLoader {
  59377. /**
  59378. * Defines wether the loader supports cascade loading the different faces.
  59379. */
  59380. readonly supportCascades: boolean;
  59381. /**
  59382. * This returns if the loader support the current file information.
  59383. * @param extension defines the file extension of the file being loaded
  59384. * @param mimeType defines the optional mime type of the file being loaded
  59385. * @returns true if the loader can load the specified file
  59386. */
  59387. canLoad(extension: string, mimeType?: string): boolean;
  59388. /**
  59389. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59390. * @param data contains the texture data
  59391. * @param texture defines the BabylonJS internal texture
  59392. * @param createPolynomials will be true if polynomials have been requested
  59393. * @param onLoad defines the callback to trigger once the texture is ready
  59394. * @param onError defines the callback to trigger in case of error
  59395. */
  59396. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59397. /**
  59398. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59399. * @param data contains the texture data
  59400. * @param texture defines the BabylonJS internal texture
  59401. * @param callback defines the method to call once ready to upload
  59402. */
  59403. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  59404. }
  59405. }
  59406. declare module BABYLON {
  59407. /** @hidden */
  59408. export var _forceSceneHelpersToBundle: boolean;
  59409. interface Scene {
  59410. /**
  59411. * Creates a default light for the scene.
  59412. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59413. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59414. */
  59415. createDefaultLight(replace?: boolean): void;
  59416. /**
  59417. * Creates a default camera for the scene.
  59418. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59419. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59420. * @param replace has default false, when true replaces the active camera in the scene
  59421. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59422. */
  59423. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59424. /**
  59425. * Creates a default camera and a default light.
  59426. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59427. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59428. * @param replace has the default false, when true replaces the active camera/light in the scene
  59429. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59430. */
  59431. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59432. /**
  59433. * Creates a new sky box
  59434. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59435. * @param environmentTexture defines the texture to use as environment texture
  59436. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59437. * @param scale defines the overall scale of the skybox
  59438. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59439. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59440. * @returns a new mesh holding the sky box
  59441. */
  59442. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59443. /**
  59444. * Creates a new environment
  59445. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59446. * @param options defines the options you can use to configure the environment
  59447. * @returns the new EnvironmentHelper
  59448. */
  59449. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59450. /**
  59451. * Creates a new VREXperienceHelper
  59452. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59453. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59454. * @returns a new VREXperienceHelper
  59455. */
  59456. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59457. /**
  59458. * Creates a new WebXRDefaultExperience
  59459. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59460. * @param options experience options
  59461. * @returns a promise for a new WebXRDefaultExperience
  59462. */
  59463. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59464. }
  59465. }
  59466. declare module BABYLON {
  59467. /**
  59468. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59469. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59470. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59471. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59472. */
  59473. export class VideoDome extends TextureDome<VideoTexture> {
  59474. /**
  59475. * Define the video source as a Monoscopic panoramic 360 video.
  59476. */
  59477. static readonly MODE_MONOSCOPIC: number;
  59478. /**
  59479. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59480. */
  59481. static readonly MODE_TOPBOTTOM: number;
  59482. /**
  59483. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59484. */
  59485. static readonly MODE_SIDEBYSIDE: number;
  59486. /**
  59487. * Get the video texture associated with this video dome
  59488. */
  59489. get videoTexture(): VideoTexture;
  59490. /**
  59491. * Get the video mode of this dome
  59492. */
  59493. get videoMode(): number;
  59494. /**
  59495. * Set the video mode of this dome.
  59496. * @see textureMode
  59497. */
  59498. set videoMode(value: number);
  59499. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  59500. }
  59501. }
  59502. declare module BABYLON {
  59503. /**
  59504. * This class can be used to get instrumentation data from a Babylon engine
  59505. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59506. */
  59507. export class EngineInstrumentation implements IDisposable {
  59508. /**
  59509. * Define the instrumented engine.
  59510. */
  59511. engine: Engine;
  59512. private _captureGPUFrameTime;
  59513. private _gpuFrameTimeToken;
  59514. private _gpuFrameTime;
  59515. private _captureShaderCompilationTime;
  59516. private _shaderCompilationTime;
  59517. private _onBeginFrameObserver;
  59518. private _onEndFrameObserver;
  59519. private _onBeforeShaderCompilationObserver;
  59520. private _onAfterShaderCompilationObserver;
  59521. /**
  59522. * Gets the perf counter used for GPU frame time
  59523. */
  59524. get gpuFrameTimeCounter(): PerfCounter;
  59525. /**
  59526. * Gets the GPU frame time capture status
  59527. */
  59528. get captureGPUFrameTime(): boolean;
  59529. /**
  59530. * Enable or disable the GPU frame time capture
  59531. */
  59532. set captureGPUFrameTime(value: boolean);
  59533. /**
  59534. * Gets the perf counter used for shader compilation time
  59535. */
  59536. get shaderCompilationTimeCounter(): PerfCounter;
  59537. /**
  59538. * Gets the shader compilation time capture status
  59539. */
  59540. get captureShaderCompilationTime(): boolean;
  59541. /**
  59542. * Enable or disable the shader compilation time capture
  59543. */
  59544. set captureShaderCompilationTime(value: boolean);
  59545. /**
  59546. * Instantiates a new engine instrumentation.
  59547. * This class can be used to get instrumentation data from a Babylon engine
  59548. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59549. * @param engine Defines the engine to instrument
  59550. */
  59551. constructor(
  59552. /**
  59553. * Define the instrumented engine.
  59554. */
  59555. engine: Engine);
  59556. /**
  59557. * Dispose and release associated resources.
  59558. */
  59559. dispose(): void;
  59560. }
  59561. }
  59562. declare module BABYLON {
  59563. /**
  59564. * This class can be used to get instrumentation data from a Babylon engine
  59565. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59566. */
  59567. export class SceneInstrumentation implements IDisposable {
  59568. /**
  59569. * Defines the scene to instrument
  59570. */
  59571. scene: Scene;
  59572. private _captureActiveMeshesEvaluationTime;
  59573. private _activeMeshesEvaluationTime;
  59574. private _captureRenderTargetsRenderTime;
  59575. private _renderTargetsRenderTime;
  59576. private _captureFrameTime;
  59577. private _frameTime;
  59578. private _captureRenderTime;
  59579. private _renderTime;
  59580. private _captureInterFrameTime;
  59581. private _interFrameTime;
  59582. private _captureParticlesRenderTime;
  59583. private _particlesRenderTime;
  59584. private _captureSpritesRenderTime;
  59585. private _spritesRenderTime;
  59586. private _capturePhysicsTime;
  59587. private _physicsTime;
  59588. private _captureAnimationsTime;
  59589. private _animationsTime;
  59590. private _captureCameraRenderTime;
  59591. private _cameraRenderTime;
  59592. private _onBeforeActiveMeshesEvaluationObserver;
  59593. private _onAfterActiveMeshesEvaluationObserver;
  59594. private _onBeforeRenderTargetsRenderObserver;
  59595. private _onAfterRenderTargetsRenderObserver;
  59596. private _onAfterRenderObserver;
  59597. private _onBeforeDrawPhaseObserver;
  59598. private _onAfterDrawPhaseObserver;
  59599. private _onBeforeAnimationsObserver;
  59600. private _onBeforeParticlesRenderingObserver;
  59601. private _onAfterParticlesRenderingObserver;
  59602. private _onBeforeSpritesRenderingObserver;
  59603. private _onAfterSpritesRenderingObserver;
  59604. private _onBeforePhysicsObserver;
  59605. private _onAfterPhysicsObserver;
  59606. private _onAfterAnimationsObserver;
  59607. private _onBeforeCameraRenderObserver;
  59608. private _onAfterCameraRenderObserver;
  59609. /**
  59610. * Gets the perf counter used for active meshes evaluation time
  59611. */
  59612. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59613. /**
  59614. * Gets the active meshes evaluation time capture status
  59615. */
  59616. get captureActiveMeshesEvaluationTime(): boolean;
  59617. /**
  59618. * Enable or disable the active meshes evaluation time capture
  59619. */
  59620. set captureActiveMeshesEvaluationTime(value: boolean);
  59621. /**
  59622. * Gets the perf counter used for render targets render time
  59623. */
  59624. get renderTargetsRenderTimeCounter(): PerfCounter;
  59625. /**
  59626. * Gets the render targets render time capture status
  59627. */
  59628. get captureRenderTargetsRenderTime(): boolean;
  59629. /**
  59630. * Enable or disable the render targets render time capture
  59631. */
  59632. set captureRenderTargetsRenderTime(value: boolean);
  59633. /**
  59634. * Gets the perf counter used for particles render time
  59635. */
  59636. get particlesRenderTimeCounter(): PerfCounter;
  59637. /**
  59638. * Gets the particles render time capture status
  59639. */
  59640. get captureParticlesRenderTime(): boolean;
  59641. /**
  59642. * Enable or disable the particles render time capture
  59643. */
  59644. set captureParticlesRenderTime(value: boolean);
  59645. /**
  59646. * Gets the perf counter used for sprites render time
  59647. */
  59648. get spritesRenderTimeCounter(): PerfCounter;
  59649. /**
  59650. * Gets the sprites render time capture status
  59651. */
  59652. get captureSpritesRenderTime(): boolean;
  59653. /**
  59654. * Enable or disable the sprites render time capture
  59655. */
  59656. set captureSpritesRenderTime(value: boolean);
  59657. /**
  59658. * Gets the perf counter used for physics time
  59659. */
  59660. get physicsTimeCounter(): PerfCounter;
  59661. /**
  59662. * Gets the physics time capture status
  59663. */
  59664. get capturePhysicsTime(): boolean;
  59665. /**
  59666. * Enable or disable the physics time capture
  59667. */
  59668. set capturePhysicsTime(value: boolean);
  59669. /**
  59670. * Gets the perf counter used for animations time
  59671. */
  59672. get animationsTimeCounter(): PerfCounter;
  59673. /**
  59674. * Gets the animations time capture status
  59675. */
  59676. get captureAnimationsTime(): boolean;
  59677. /**
  59678. * Enable or disable the animations time capture
  59679. */
  59680. set captureAnimationsTime(value: boolean);
  59681. /**
  59682. * Gets the perf counter used for frame time capture
  59683. */
  59684. get frameTimeCounter(): PerfCounter;
  59685. /**
  59686. * Gets the frame time capture status
  59687. */
  59688. get captureFrameTime(): boolean;
  59689. /**
  59690. * Enable or disable the frame time capture
  59691. */
  59692. set captureFrameTime(value: boolean);
  59693. /**
  59694. * Gets the perf counter used for inter-frames time capture
  59695. */
  59696. get interFrameTimeCounter(): PerfCounter;
  59697. /**
  59698. * Gets the inter-frames time capture status
  59699. */
  59700. get captureInterFrameTime(): boolean;
  59701. /**
  59702. * Enable or disable the inter-frames time capture
  59703. */
  59704. set captureInterFrameTime(value: boolean);
  59705. /**
  59706. * Gets the perf counter used for render time capture
  59707. */
  59708. get renderTimeCounter(): PerfCounter;
  59709. /**
  59710. * Gets the render time capture status
  59711. */
  59712. get captureRenderTime(): boolean;
  59713. /**
  59714. * Enable or disable the render time capture
  59715. */
  59716. set captureRenderTime(value: boolean);
  59717. /**
  59718. * Gets the perf counter used for camera render time capture
  59719. */
  59720. get cameraRenderTimeCounter(): PerfCounter;
  59721. /**
  59722. * Gets the camera render time capture status
  59723. */
  59724. get captureCameraRenderTime(): boolean;
  59725. /**
  59726. * Enable or disable the camera render time capture
  59727. */
  59728. set captureCameraRenderTime(value: boolean);
  59729. /**
  59730. * Gets the perf counter used for draw calls
  59731. */
  59732. get drawCallsCounter(): PerfCounter;
  59733. /**
  59734. * Instantiates a new scene instrumentation.
  59735. * This class can be used to get instrumentation data from a Babylon engine
  59736. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59737. * @param scene Defines the scene to instrument
  59738. */
  59739. constructor(
  59740. /**
  59741. * Defines the scene to instrument
  59742. */
  59743. scene: Scene);
  59744. /**
  59745. * Dispose and release associated resources.
  59746. */
  59747. dispose(): void;
  59748. }
  59749. }
  59750. declare module BABYLON {
  59751. /** @hidden */
  59752. export var glowMapGenerationPixelShader: {
  59753. name: string;
  59754. shader: string;
  59755. };
  59756. }
  59757. declare module BABYLON {
  59758. /** @hidden */
  59759. export var glowMapGenerationVertexShader: {
  59760. name: string;
  59761. shader: string;
  59762. };
  59763. }
  59764. declare module BABYLON {
  59765. /**
  59766. * Effect layer options. This helps customizing the behaviour
  59767. * of the effect layer.
  59768. */
  59769. export interface IEffectLayerOptions {
  59770. /**
  59771. * Multiplication factor apply to the canvas size to compute the render target size
  59772. * used to generated the objects (the smaller the faster).
  59773. */
  59774. mainTextureRatio: number;
  59775. /**
  59776. * Enforces a fixed size texture to ensure effect stability across devices.
  59777. */
  59778. mainTextureFixedSize?: number;
  59779. /**
  59780. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59781. */
  59782. alphaBlendingMode: number;
  59783. /**
  59784. * The camera attached to the layer.
  59785. */
  59786. camera: Nullable<Camera>;
  59787. /**
  59788. * The rendering group to draw the layer in.
  59789. */
  59790. renderingGroupId: number;
  59791. }
  59792. /**
  59793. * The effect layer Helps adding post process effect blended with the main pass.
  59794. *
  59795. * This can be for instance use to generate glow or higlight effects on the scene.
  59796. *
  59797. * The effect layer class can not be used directly and is intented to inherited from to be
  59798. * customized per effects.
  59799. */
  59800. export abstract class EffectLayer {
  59801. private _vertexBuffers;
  59802. private _indexBuffer;
  59803. private _cachedDefines;
  59804. private _effectLayerMapGenerationEffect;
  59805. private _effectLayerOptions;
  59806. private _mergeEffect;
  59807. protected _scene: Scene;
  59808. protected _engine: Engine;
  59809. protected _maxSize: number;
  59810. protected _mainTextureDesiredSize: ISize;
  59811. protected _mainTexture: RenderTargetTexture;
  59812. protected _shouldRender: boolean;
  59813. protected _postProcesses: PostProcess[];
  59814. protected _textures: BaseTexture[];
  59815. protected _emissiveTextureAndColor: {
  59816. texture: Nullable<BaseTexture>;
  59817. color: Color4;
  59818. };
  59819. /**
  59820. * The name of the layer
  59821. */
  59822. name: string;
  59823. /**
  59824. * The clear color of the texture used to generate the glow map.
  59825. */
  59826. neutralColor: Color4;
  59827. /**
  59828. * Specifies whether the highlight layer is enabled or not.
  59829. */
  59830. isEnabled: boolean;
  59831. /**
  59832. * Gets the camera attached to the layer.
  59833. */
  59834. get camera(): Nullable<Camera>;
  59835. /**
  59836. * Gets the rendering group id the layer should render in.
  59837. */
  59838. get renderingGroupId(): number;
  59839. set renderingGroupId(renderingGroupId: number);
  59840. /**
  59841. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59842. */
  59843. disableBoundingBoxesFromEffectLayer: boolean;
  59844. /**
  59845. * An event triggered when the effect layer has been disposed.
  59846. */
  59847. onDisposeObservable: Observable<EffectLayer>;
  59848. /**
  59849. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59850. */
  59851. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59852. /**
  59853. * An event triggered when the generated texture is being merged in the scene.
  59854. */
  59855. onBeforeComposeObservable: Observable<EffectLayer>;
  59856. /**
  59857. * An event triggered when the mesh is rendered into the effect render target.
  59858. */
  59859. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59860. /**
  59861. * An event triggered after the mesh has been rendered into the effect render target.
  59862. */
  59863. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59864. /**
  59865. * An event triggered when the generated texture has been merged in the scene.
  59866. */
  59867. onAfterComposeObservable: Observable<EffectLayer>;
  59868. /**
  59869. * An event triggered when the efffect layer changes its size.
  59870. */
  59871. onSizeChangedObservable: Observable<EffectLayer>;
  59872. /** @hidden */
  59873. static _SceneComponentInitialization: (scene: Scene) => void;
  59874. /**
  59875. * Instantiates a new effect Layer and references it in the scene.
  59876. * @param name The name of the layer
  59877. * @param scene The scene to use the layer in
  59878. */
  59879. constructor(
  59880. /** The Friendly of the effect in the scene */
  59881. name: string, scene: Scene);
  59882. /**
  59883. * Get the effect name of the layer.
  59884. * @return The effect name
  59885. */
  59886. abstract getEffectName(): string;
  59887. /**
  59888. * Checks for the readiness of the element composing the layer.
  59889. * @param subMesh the mesh to check for
  59890. * @param useInstances specify whether or not to use instances to render the mesh
  59891. * @return true if ready otherwise, false
  59892. */
  59893. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59894. /**
  59895. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59896. * @returns true if the effect requires stencil during the main canvas render pass.
  59897. */
  59898. abstract needStencil(): boolean;
  59899. /**
  59900. * Create the merge effect. This is the shader use to blit the information back
  59901. * to the main canvas at the end of the scene rendering.
  59902. * @returns The effect containing the shader used to merge the effect on the main canvas
  59903. */
  59904. protected abstract _createMergeEffect(): Effect;
  59905. /**
  59906. * Creates the render target textures and post processes used in the effect layer.
  59907. */
  59908. protected abstract _createTextureAndPostProcesses(): void;
  59909. /**
  59910. * Implementation specific of rendering the generating effect on the main canvas.
  59911. * @param effect The effect used to render through
  59912. */
  59913. protected abstract _internalRender(effect: Effect): void;
  59914. /**
  59915. * Sets the required values for both the emissive texture and and the main color.
  59916. */
  59917. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59918. /**
  59919. * Free any resources and references associated to a mesh.
  59920. * Internal use
  59921. * @param mesh The mesh to free.
  59922. */
  59923. abstract _disposeMesh(mesh: Mesh): void;
  59924. /**
  59925. * Serializes this layer (Glow or Highlight for example)
  59926. * @returns a serialized layer object
  59927. */
  59928. abstract serialize?(): any;
  59929. /**
  59930. * Initializes the effect layer with the required options.
  59931. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59932. */
  59933. protected _init(options: Partial<IEffectLayerOptions>): void;
  59934. /**
  59935. * Generates the index buffer of the full screen quad blending to the main canvas.
  59936. */
  59937. private _generateIndexBuffer;
  59938. /**
  59939. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59940. */
  59941. private _generateVertexBuffer;
  59942. /**
  59943. * Sets the main texture desired size which is the closest power of two
  59944. * of the engine canvas size.
  59945. */
  59946. private _setMainTextureSize;
  59947. /**
  59948. * Creates the main texture for the effect layer.
  59949. */
  59950. protected _createMainTexture(): void;
  59951. /**
  59952. * Adds specific effects defines.
  59953. * @param defines The defines to add specifics to.
  59954. */
  59955. protected _addCustomEffectDefines(defines: string[]): void;
  59956. /**
  59957. * Checks for the readiness of the element composing the layer.
  59958. * @param subMesh the mesh to check for
  59959. * @param useInstances specify whether or not to use instances to render the mesh
  59960. * @param emissiveTexture the associated emissive texture used to generate the glow
  59961. * @return true if ready otherwise, false
  59962. */
  59963. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59964. /**
  59965. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59966. */
  59967. render(): void;
  59968. /**
  59969. * Determine if a given mesh will be used in the current effect.
  59970. * @param mesh mesh to test
  59971. * @returns true if the mesh will be used
  59972. */
  59973. hasMesh(mesh: AbstractMesh): boolean;
  59974. /**
  59975. * Returns true if the layer contains information to display, otherwise false.
  59976. * @returns true if the glow layer should be rendered
  59977. */
  59978. shouldRender(): boolean;
  59979. /**
  59980. * Returns true if the mesh should render, otherwise false.
  59981. * @param mesh The mesh to render
  59982. * @returns true if it should render otherwise false
  59983. */
  59984. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59985. /**
  59986. * Returns true if the mesh can be rendered, otherwise false.
  59987. * @param mesh The mesh to render
  59988. * @param material The material used on the mesh
  59989. * @returns true if it can be rendered otherwise false
  59990. */
  59991. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59992. /**
  59993. * Returns true if the mesh should render, otherwise false.
  59994. * @param mesh The mesh to render
  59995. * @returns true if it should render otherwise false
  59996. */
  59997. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59998. /**
  59999. * Renders the submesh passed in parameter to the generation map.
  60000. */
  60001. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60002. /**
  60003. * Defines whether the current material of the mesh should be use to render the effect.
  60004. * @param mesh defines the current mesh to render
  60005. */
  60006. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60007. /**
  60008. * Rebuild the required buffers.
  60009. * @hidden Internal use only.
  60010. */
  60011. _rebuild(): void;
  60012. /**
  60013. * Dispose only the render target textures and post process.
  60014. */
  60015. private _disposeTextureAndPostProcesses;
  60016. /**
  60017. * Dispose the highlight layer and free resources.
  60018. */
  60019. dispose(): void;
  60020. /**
  60021. * Gets the class name of the effect layer
  60022. * @returns the string with the class name of the effect layer
  60023. */
  60024. getClassName(): string;
  60025. /**
  60026. * Creates an effect layer from parsed effect layer data
  60027. * @param parsedEffectLayer defines effect layer data
  60028. * @param scene defines the current scene
  60029. * @param rootUrl defines the root URL containing the effect layer information
  60030. * @returns a parsed effect Layer
  60031. */
  60032. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60033. }
  60034. }
  60035. declare module BABYLON {
  60036. interface AbstractScene {
  60037. /**
  60038. * The list of effect layers (highlights/glow) added to the scene
  60039. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60040. * @see https://doc.babylonjs.com/how_to/glow_layer
  60041. */
  60042. effectLayers: Array<EffectLayer>;
  60043. /**
  60044. * Removes the given effect layer from this scene.
  60045. * @param toRemove defines the effect layer to remove
  60046. * @returns the index of the removed effect layer
  60047. */
  60048. removeEffectLayer(toRemove: EffectLayer): number;
  60049. /**
  60050. * Adds the given effect layer to this scene
  60051. * @param newEffectLayer defines the effect layer to add
  60052. */
  60053. addEffectLayer(newEffectLayer: EffectLayer): void;
  60054. }
  60055. /**
  60056. * Defines the layer scene component responsible to manage any effect layers
  60057. * in a given scene.
  60058. */
  60059. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60060. /**
  60061. * The component name helpfull to identify the component in the list of scene components.
  60062. */
  60063. readonly name: string;
  60064. /**
  60065. * The scene the component belongs to.
  60066. */
  60067. scene: Scene;
  60068. private _engine;
  60069. private _renderEffects;
  60070. private _needStencil;
  60071. private _previousStencilState;
  60072. /**
  60073. * Creates a new instance of the component for the given scene
  60074. * @param scene Defines the scene to register the component in
  60075. */
  60076. constructor(scene: Scene);
  60077. /**
  60078. * Registers the component in a given scene
  60079. */
  60080. register(): void;
  60081. /**
  60082. * Rebuilds the elements related to this component in case of
  60083. * context lost for instance.
  60084. */
  60085. rebuild(): void;
  60086. /**
  60087. * Serializes the component data to the specified json object
  60088. * @param serializationObject The object to serialize to
  60089. */
  60090. serialize(serializationObject: any): void;
  60091. /**
  60092. * Adds all the elements from the container to the scene
  60093. * @param container the container holding the elements
  60094. */
  60095. addFromContainer(container: AbstractScene): void;
  60096. /**
  60097. * Removes all the elements in the container from the scene
  60098. * @param container contains the elements to remove
  60099. * @param dispose if the removed element should be disposed (default: false)
  60100. */
  60101. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60102. /**
  60103. * Disposes the component and the associated ressources.
  60104. */
  60105. dispose(): void;
  60106. private _isReadyForMesh;
  60107. private _renderMainTexture;
  60108. private _setStencil;
  60109. private _setStencilBack;
  60110. private _draw;
  60111. private _drawCamera;
  60112. private _drawRenderingGroup;
  60113. }
  60114. }
  60115. declare module BABYLON {
  60116. /** @hidden */
  60117. export var glowMapMergePixelShader: {
  60118. name: string;
  60119. shader: string;
  60120. };
  60121. }
  60122. declare module BABYLON {
  60123. /** @hidden */
  60124. export var glowMapMergeVertexShader: {
  60125. name: string;
  60126. shader: string;
  60127. };
  60128. }
  60129. declare module BABYLON {
  60130. interface AbstractScene {
  60131. /**
  60132. * Return a the first highlight layer of the scene with a given name.
  60133. * @param name The name of the highlight layer to look for.
  60134. * @return The highlight layer if found otherwise null.
  60135. */
  60136. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60137. }
  60138. /**
  60139. * Glow layer options. This helps customizing the behaviour
  60140. * of the glow layer.
  60141. */
  60142. export interface IGlowLayerOptions {
  60143. /**
  60144. * Multiplication factor apply to the canvas size to compute the render target size
  60145. * used to generated the glowing objects (the smaller the faster).
  60146. */
  60147. mainTextureRatio: number;
  60148. /**
  60149. * Enforces a fixed size texture to ensure resize independant blur.
  60150. */
  60151. mainTextureFixedSize?: number;
  60152. /**
  60153. * How big is the kernel of the blur texture.
  60154. */
  60155. blurKernelSize: number;
  60156. /**
  60157. * The camera attached to the layer.
  60158. */
  60159. camera: Nullable<Camera>;
  60160. /**
  60161. * Enable MSAA by chosing the number of samples.
  60162. */
  60163. mainTextureSamples?: number;
  60164. /**
  60165. * The rendering group to draw the layer in.
  60166. */
  60167. renderingGroupId: number;
  60168. }
  60169. /**
  60170. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60171. *
  60172. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60173. *
  60174. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60175. */
  60176. export class GlowLayer extends EffectLayer {
  60177. /**
  60178. * Effect Name of the layer.
  60179. */
  60180. static readonly EffectName: string;
  60181. /**
  60182. * The default blur kernel size used for the glow.
  60183. */
  60184. static DefaultBlurKernelSize: number;
  60185. /**
  60186. * The default texture size ratio used for the glow.
  60187. */
  60188. static DefaultTextureRatio: number;
  60189. /**
  60190. * Sets the kernel size of the blur.
  60191. */
  60192. set blurKernelSize(value: number);
  60193. /**
  60194. * Gets the kernel size of the blur.
  60195. */
  60196. get blurKernelSize(): number;
  60197. /**
  60198. * Sets the glow intensity.
  60199. */
  60200. set intensity(value: number);
  60201. /**
  60202. * Gets the glow intensity.
  60203. */
  60204. get intensity(): number;
  60205. private _options;
  60206. private _intensity;
  60207. private _horizontalBlurPostprocess1;
  60208. private _verticalBlurPostprocess1;
  60209. private _horizontalBlurPostprocess2;
  60210. private _verticalBlurPostprocess2;
  60211. private _blurTexture1;
  60212. private _blurTexture2;
  60213. private _postProcesses1;
  60214. private _postProcesses2;
  60215. private _includedOnlyMeshes;
  60216. private _excludedMeshes;
  60217. private _meshesUsingTheirOwnMaterials;
  60218. /**
  60219. * Callback used to let the user override the color selection on a per mesh basis
  60220. */
  60221. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60222. /**
  60223. * Callback used to let the user override the texture selection on a per mesh basis
  60224. */
  60225. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60226. /**
  60227. * Instantiates a new glow Layer and references it to the scene.
  60228. * @param name The name of the layer
  60229. * @param scene The scene to use the layer in
  60230. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60231. */
  60232. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60233. /**
  60234. * Get the effect name of the layer.
  60235. * @return The effect name
  60236. */
  60237. getEffectName(): string;
  60238. /**
  60239. * Create the merge effect. This is the shader use to blit the information back
  60240. * to the main canvas at the end of the scene rendering.
  60241. */
  60242. protected _createMergeEffect(): Effect;
  60243. /**
  60244. * Creates the render target textures and post processes used in the glow layer.
  60245. */
  60246. protected _createTextureAndPostProcesses(): void;
  60247. /**
  60248. * Checks for the readiness of the element composing the layer.
  60249. * @param subMesh the mesh to check for
  60250. * @param useInstances specify wether or not to use instances to render the mesh
  60251. * @param emissiveTexture the associated emissive texture used to generate the glow
  60252. * @return true if ready otherwise, false
  60253. */
  60254. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60255. /**
  60256. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60257. */
  60258. needStencil(): boolean;
  60259. /**
  60260. * Returns true if the mesh can be rendered, otherwise false.
  60261. * @param mesh The mesh to render
  60262. * @param material The material used on the mesh
  60263. * @returns true if it can be rendered otherwise false
  60264. */
  60265. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60266. /**
  60267. * Implementation specific of rendering the generating effect on the main canvas.
  60268. * @param effect The effect used to render through
  60269. */
  60270. protected _internalRender(effect: Effect): void;
  60271. /**
  60272. * Sets the required values for both the emissive texture and and the main color.
  60273. */
  60274. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60275. /**
  60276. * Returns true if the mesh should render, otherwise false.
  60277. * @param mesh The mesh to render
  60278. * @returns true if it should render otherwise false
  60279. */
  60280. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60281. /**
  60282. * Adds specific effects defines.
  60283. * @param defines The defines to add specifics to.
  60284. */
  60285. protected _addCustomEffectDefines(defines: string[]): void;
  60286. /**
  60287. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60288. * @param mesh The mesh to exclude from the glow layer
  60289. */
  60290. addExcludedMesh(mesh: Mesh): void;
  60291. /**
  60292. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60293. * @param mesh The mesh to remove
  60294. */
  60295. removeExcludedMesh(mesh: Mesh): void;
  60296. /**
  60297. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60298. * @param mesh The mesh to include in the glow layer
  60299. */
  60300. addIncludedOnlyMesh(mesh: Mesh): void;
  60301. /**
  60302. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60303. * @param mesh The mesh to remove
  60304. */
  60305. removeIncludedOnlyMesh(mesh: Mesh): void;
  60306. /**
  60307. * Determine if a given mesh will be used in the glow layer
  60308. * @param mesh The mesh to test
  60309. * @returns true if the mesh will be highlighted by the current glow layer
  60310. */
  60311. hasMesh(mesh: AbstractMesh): boolean;
  60312. /**
  60313. * Defines whether the current material of the mesh should be use to render the effect.
  60314. * @param mesh defines the current mesh to render
  60315. */
  60316. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60317. /**
  60318. * Add a mesh to be rendered through its own material and not with emissive only.
  60319. * @param mesh The mesh for which we need to use its material
  60320. */
  60321. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60322. /**
  60323. * Remove a mesh from being rendered through its own material and not with emissive only.
  60324. * @param mesh The mesh for which we need to not use its material
  60325. */
  60326. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60327. /**
  60328. * Free any resources and references associated to a mesh.
  60329. * Internal use
  60330. * @param mesh The mesh to free.
  60331. * @hidden
  60332. */
  60333. _disposeMesh(mesh: Mesh): void;
  60334. /**
  60335. * Gets the class name of the effect layer
  60336. * @returns the string with the class name of the effect layer
  60337. */
  60338. getClassName(): string;
  60339. /**
  60340. * Serializes this glow layer
  60341. * @returns a serialized glow layer object
  60342. */
  60343. serialize(): any;
  60344. /**
  60345. * Creates a Glow Layer from parsed glow layer data
  60346. * @param parsedGlowLayer defines glow layer data
  60347. * @param scene defines the current scene
  60348. * @param rootUrl defines the root URL containing the glow layer information
  60349. * @returns a parsed Glow Layer
  60350. */
  60351. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60352. }
  60353. }
  60354. declare module BABYLON {
  60355. /** @hidden */
  60356. export var glowBlurPostProcessPixelShader: {
  60357. name: string;
  60358. shader: string;
  60359. };
  60360. }
  60361. declare module BABYLON {
  60362. interface AbstractScene {
  60363. /**
  60364. * Return a the first highlight layer of the scene with a given name.
  60365. * @param name The name of the highlight layer to look for.
  60366. * @return The highlight layer if found otherwise null.
  60367. */
  60368. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60369. }
  60370. /**
  60371. * Highlight layer options. This helps customizing the behaviour
  60372. * of the highlight layer.
  60373. */
  60374. export interface IHighlightLayerOptions {
  60375. /**
  60376. * Multiplication factor apply to the canvas size to compute the render target size
  60377. * used to generated the glowing objects (the smaller the faster).
  60378. */
  60379. mainTextureRatio: number;
  60380. /**
  60381. * Enforces a fixed size texture to ensure resize independant blur.
  60382. */
  60383. mainTextureFixedSize?: number;
  60384. /**
  60385. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60386. * of the picture to blur (the smaller the faster).
  60387. */
  60388. blurTextureSizeRatio: number;
  60389. /**
  60390. * How big in texel of the blur texture is the vertical blur.
  60391. */
  60392. blurVerticalSize: number;
  60393. /**
  60394. * How big in texel of the blur texture is the horizontal blur.
  60395. */
  60396. blurHorizontalSize: number;
  60397. /**
  60398. * Alpha blending mode used to apply the blur. Default is combine.
  60399. */
  60400. alphaBlendingMode: number;
  60401. /**
  60402. * The camera attached to the layer.
  60403. */
  60404. camera: Nullable<Camera>;
  60405. /**
  60406. * Should we display highlight as a solid stroke?
  60407. */
  60408. isStroke?: boolean;
  60409. /**
  60410. * The rendering group to draw the layer in.
  60411. */
  60412. renderingGroupId: number;
  60413. }
  60414. /**
  60415. * The highlight layer Helps adding a glow effect around a mesh.
  60416. *
  60417. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60418. * glowy meshes to your scene.
  60419. *
  60420. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60421. */
  60422. export class HighlightLayer extends EffectLayer {
  60423. name: string;
  60424. /**
  60425. * Effect Name of the highlight layer.
  60426. */
  60427. static readonly EffectName: string;
  60428. /**
  60429. * The neutral color used during the preparation of the glow effect.
  60430. * This is black by default as the blend operation is a blend operation.
  60431. */
  60432. static NeutralColor: Color4;
  60433. /**
  60434. * Stencil value used for glowing meshes.
  60435. */
  60436. static GlowingMeshStencilReference: number;
  60437. /**
  60438. * Stencil value used for the other meshes in the scene.
  60439. */
  60440. static NormalMeshStencilReference: number;
  60441. /**
  60442. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60443. */
  60444. innerGlow: boolean;
  60445. /**
  60446. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60447. */
  60448. outerGlow: boolean;
  60449. /**
  60450. * Specifies the horizontal size of the blur.
  60451. */
  60452. set blurHorizontalSize(value: number);
  60453. /**
  60454. * Specifies the vertical size of the blur.
  60455. */
  60456. set blurVerticalSize(value: number);
  60457. /**
  60458. * Gets the horizontal size of the blur.
  60459. */
  60460. get blurHorizontalSize(): number;
  60461. /**
  60462. * Gets the vertical size of the blur.
  60463. */
  60464. get blurVerticalSize(): number;
  60465. /**
  60466. * An event triggered when the highlight layer is being blurred.
  60467. */
  60468. onBeforeBlurObservable: Observable<HighlightLayer>;
  60469. /**
  60470. * An event triggered when the highlight layer has been blurred.
  60471. */
  60472. onAfterBlurObservable: Observable<HighlightLayer>;
  60473. private _instanceGlowingMeshStencilReference;
  60474. private _options;
  60475. private _downSamplePostprocess;
  60476. private _horizontalBlurPostprocess;
  60477. private _verticalBlurPostprocess;
  60478. private _blurTexture;
  60479. private _meshes;
  60480. private _excludedMeshes;
  60481. /**
  60482. * Instantiates a new highlight Layer and references it to the scene..
  60483. * @param name The name of the layer
  60484. * @param scene The scene to use the layer in
  60485. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60486. */
  60487. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60488. /**
  60489. * Get the effect name of the layer.
  60490. * @return The effect name
  60491. */
  60492. getEffectName(): string;
  60493. /**
  60494. * Create the merge effect. This is the shader use to blit the information back
  60495. * to the main canvas at the end of the scene rendering.
  60496. */
  60497. protected _createMergeEffect(): Effect;
  60498. /**
  60499. * Creates the render target textures and post processes used in the highlight layer.
  60500. */
  60501. protected _createTextureAndPostProcesses(): void;
  60502. /**
  60503. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60504. */
  60505. needStencil(): boolean;
  60506. /**
  60507. * Checks for the readiness of the element composing the layer.
  60508. * @param subMesh the mesh to check for
  60509. * @param useInstances specify wether or not to use instances to render the mesh
  60510. * @param emissiveTexture the associated emissive texture used to generate the glow
  60511. * @return true if ready otherwise, false
  60512. */
  60513. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60514. /**
  60515. * Implementation specific of rendering the generating effect on the main canvas.
  60516. * @param effect The effect used to render through
  60517. */
  60518. protected _internalRender(effect: Effect): void;
  60519. /**
  60520. * Returns true if the layer contains information to display, otherwise false.
  60521. */
  60522. shouldRender(): boolean;
  60523. /**
  60524. * Returns true if the mesh should render, otherwise false.
  60525. * @param mesh The mesh to render
  60526. * @returns true if it should render otherwise false
  60527. */
  60528. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60529. /**
  60530. * Returns true if the mesh can be rendered, otherwise false.
  60531. * @param mesh The mesh to render
  60532. * @param material The material used on the mesh
  60533. * @returns true if it can be rendered otherwise false
  60534. */
  60535. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60536. /**
  60537. * Adds specific effects defines.
  60538. * @param defines The defines to add specifics to.
  60539. */
  60540. protected _addCustomEffectDefines(defines: string[]): void;
  60541. /**
  60542. * Sets the required values for both the emissive texture and and the main color.
  60543. */
  60544. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60545. /**
  60546. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60547. * @param mesh The mesh to exclude from the highlight layer
  60548. */
  60549. addExcludedMesh(mesh: Mesh): void;
  60550. /**
  60551. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60552. * @param mesh The mesh to highlight
  60553. */
  60554. removeExcludedMesh(mesh: Mesh): void;
  60555. /**
  60556. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60557. * @param mesh mesh to test
  60558. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60559. */
  60560. hasMesh(mesh: AbstractMesh): boolean;
  60561. /**
  60562. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60563. * @param mesh The mesh to highlight
  60564. * @param color The color of the highlight
  60565. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60566. */
  60567. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60568. /**
  60569. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60570. * @param mesh The mesh to highlight
  60571. */
  60572. removeMesh(mesh: Mesh): void;
  60573. /**
  60574. * Remove all the meshes currently referenced in the highlight layer
  60575. */
  60576. removeAllMeshes(): void;
  60577. /**
  60578. * Force the stencil to the normal expected value for none glowing parts
  60579. */
  60580. private _defaultStencilReference;
  60581. /**
  60582. * Free any resources and references associated to a mesh.
  60583. * Internal use
  60584. * @param mesh The mesh to free.
  60585. * @hidden
  60586. */
  60587. _disposeMesh(mesh: Mesh): void;
  60588. /**
  60589. * Dispose the highlight layer and free resources.
  60590. */
  60591. dispose(): void;
  60592. /**
  60593. * Gets the class name of the effect layer
  60594. * @returns the string with the class name of the effect layer
  60595. */
  60596. getClassName(): string;
  60597. /**
  60598. * Serializes this Highlight layer
  60599. * @returns a serialized Highlight layer object
  60600. */
  60601. serialize(): any;
  60602. /**
  60603. * Creates a Highlight layer from parsed Highlight layer data
  60604. * @param parsedHightlightLayer defines the Highlight layer data
  60605. * @param scene defines the current scene
  60606. * @param rootUrl defines the root URL containing the Highlight layer information
  60607. * @returns a parsed Highlight layer
  60608. */
  60609. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60610. }
  60611. }
  60612. declare module BABYLON {
  60613. interface AbstractScene {
  60614. /**
  60615. * The list of layers (background and foreground) of the scene
  60616. */
  60617. layers: Array<Layer>;
  60618. }
  60619. /**
  60620. * Defines the layer scene component responsible to manage any layers
  60621. * in a given scene.
  60622. */
  60623. export class LayerSceneComponent implements ISceneComponent {
  60624. /**
  60625. * The component name helpfull to identify the component in the list of scene components.
  60626. */
  60627. readonly name: string;
  60628. /**
  60629. * The scene the component belongs to.
  60630. */
  60631. scene: Scene;
  60632. private _engine;
  60633. /**
  60634. * Creates a new instance of the component for the given scene
  60635. * @param scene Defines the scene to register the component in
  60636. */
  60637. constructor(scene: Scene);
  60638. /**
  60639. * Registers the component in a given scene
  60640. */
  60641. register(): void;
  60642. /**
  60643. * Rebuilds the elements related to this component in case of
  60644. * context lost for instance.
  60645. */
  60646. rebuild(): void;
  60647. /**
  60648. * Disposes the component and the associated ressources.
  60649. */
  60650. dispose(): void;
  60651. private _draw;
  60652. private _drawCameraPredicate;
  60653. private _drawCameraBackground;
  60654. private _drawCameraForeground;
  60655. private _drawRenderTargetPredicate;
  60656. private _drawRenderTargetBackground;
  60657. private _drawRenderTargetForeground;
  60658. /**
  60659. * Adds all the elements from the container to the scene
  60660. * @param container the container holding the elements
  60661. */
  60662. addFromContainer(container: AbstractScene): void;
  60663. /**
  60664. * Removes all the elements in the container from the scene
  60665. * @param container contains the elements to remove
  60666. * @param dispose if the removed element should be disposed (default: false)
  60667. */
  60668. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60669. }
  60670. }
  60671. declare module BABYLON {
  60672. /** @hidden */
  60673. export var layerPixelShader: {
  60674. name: string;
  60675. shader: string;
  60676. };
  60677. }
  60678. declare module BABYLON {
  60679. /** @hidden */
  60680. export var layerVertexShader: {
  60681. name: string;
  60682. shader: string;
  60683. };
  60684. }
  60685. declare module BABYLON {
  60686. /**
  60687. * This represents a full screen 2d layer.
  60688. * This can be useful to display a picture in the background of your scene for instance.
  60689. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60690. */
  60691. export class Layer {
  60692. /**
  60693. * Define the name of the layer.
  60694. */
  60695. name: string;
  60696. /**
  60697. * Define the texture the layer should display.
  60698. */
  60699. texture: Nullable<Texture>;
  60700. /**
  60701. * Is the layer in background or foreground.
  60702. */
  60703. isBackground: boolean;
  60704. /**
  60705. * Define the color of the layer (instead of texture).
  60706. */
  60707. color: Color4;
  60708. /**
  60709. * Define the scale of the layer in order to zoom in out of the texture.
  60710. */
  60711. scale: Vector2;
  60712. /**
  60713. * Define an offset for the layer in order to shift the texture.
  60714. */
  60715. offset: Vector2;
  60716. /**
  60717. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60718. */
  60719. alphaBlendingMode: number;
  60720. /**
  60721. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60722. * Alpha test will not mix with the background color in case of transparency.
  60723. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60724. */
  60725. alphaTest: boolean;
  60726. /**
  60727. * Define a mask to restrict the layer to only some of the scene cameras.
  60728. */
  60729. layerMask: number;
  60730. /**
  60731. * Define the list of render target the layer is visible into.
  60732. */
  60733. renderTargetTextures: RenderTargetTexture[];
  60734. /**
  60735. * Define if the layer is only used in renderTarget or if it also
  60736. * renders in the main frame buffer of the canvas.
  60737. */
  60738. renderOnlyInRenderTargetTextures: boolean;
  60739. private _scene;
  60740. private _vertexBuffers;
  60741. private _indexBuffer;
  60742. private _effect;
  60743. private _previousDefines;
  60744. /**
  60745. * An event triggered when the layer is disposed.
  60746. */
  60747. onDisposeObservable: Observable<Layer>;
  60748. private _onDisposeObserver;
  60749. /**
  60750. * Back compatibility with callback before the onDisposeObservable existed.
  60751. * The set callback will be triggered when the layer has been disposed.
  60752. */
  60753. set onDispose(callback: () => void);
  60754. /**
  60755. * An event triggered before rendering the scene
  60756. */
  60757. onBeforeRenderObservable: Observable<Layer>;
  60758. private _onBeforeRenderObserver;
  60759. /**
  60760. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60761. * The set callback will be triggered just before rendering the layer.
  60762. */
  60763. set onBeforeRender(callback: () => void);
  60764. /**
  60765. * An event triggered after rendering the scene
  60766. */
  60767. onAfterRenderObservable: Observable<Layer>;
  60768. private _onAfterRenderObserver;
  60769. /**
  60770. * Back compatibility with callback before the onAfterRenderObservable existed.
  60771. * The set callback will be triggered just after rendering the layer.
  60772. */
  60773. set onAfterRender(callback: () => void);
  60774. /**
  60775. * Instantiates a new layer.
  60776. * This represents a full screen 2d layer.
  60777. * This can be useful to display a picture in the background of your scene for instance.
  60778. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60779. * @param name Define the name of the layer in the scene
  60780. * @param imgUrl Define the url of the texture to display in the layer
  60781. * @param scene Define the scene the layer belongs to
  60782. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60783. * @param color Defines a color for the layer
  60784. */
  60785. constructor(
  60786. /**
  60787. * Define the name of the layer.
  60788. */
  60789. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60790. private _createIndexBuffer;
  60791. /** @hidden */
  60792. _rebuild(): void;
  60793. /**
  60794. * Renders the layer in the scene.
  60795. */
  60796. render(): void;
  60797. /**
  60798. * Disposes and releases the associated ressources.
  60799. */
  60800. dispose(): void;
  60801. }
  60802. }
  60803. declare module BABYLON {
  60804. /** @hidden */
  60805. export var lensFlarePixelShader: {
  60806. name: string;
  60807. shader: string;
  60808. };
  60809. }
  60810. declare module BABYLON {
  60811. /** @hidden */
  60812. export var lensFlareVertexShader: {
  60813. name: string;
  60814. shader: string;
  60815. };
  60816. }
  60817. declare module BABYLON {
  60818. /**
  60819. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60820. * It is usually composed of several `lensFlare`.
  60821. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60822. */
  60823. export class LensFlareSystem {
  60824. /**
  60825. * Define the name of the lens flare system
  60826. */
  60827. name: string;
  60828. /**
  60829. * List of lens flares used in this system.
  60830. */
  60831. lensFlares: LensFlare[];
  60832. /**
  60833. * Define a limit from the border the lens flare can be visible.
  60834. */
  60835. borderLimit: number;
  60836. /**
  60837. * Define a viewport border we do not want to see the lens flare in.
  60838. */
  60839. viewportBorder: number;
  60840. /**
  60841. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60842. */
  60843. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60844. /**
  60845. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60846. */
  60847. layerMask: number;
  60848. /**
  60849. * Define the id of the lens flare system in the scene.
  60850. * (equal to name by default)
  60851. */
  60852. id: string;
  60853. private _scene;
  60854. private _emitter;
  60855. private _vertexBuffers;
  60856. private _indexBuffer;
  60857. private _effect;
  60858. private _positionX;
  60859. private _positionY;
  60860. private _isEnabled;
  60861. /** @hidden */
  60862. static _SceneComponentInitialization: (scene: Scene) => void;
  60863. /**
  60864. * Instantiates a lens flare system.
  60865. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60866. * It is usually composed of several `lensFlare`.
  60867. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60868. * @param name Define the name of the lens flare system in the scene
  60869. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60870. * @param scene Define the scene the lens flare system belongs to
  60871. */
  60872. constructor(
  60873. /**
  60874. * Define the name of the lens flare system
  60875. */
  60876. name: string, emitter: any, scene: Scene);
  60877. /**
  60878. * Define if the lens flare system is enabled.
  60879. */
  60880. get isEnabled(): boolean;
  60881. set isEnabled(value: boolean);
  60882. /**
  60883. * Get the scene the effects belongs to.
  60884. * @returns the scene holding the lens flare system
  60885. */
  60886. getScene(): Scene;
  60887. /**
  60888. * Get the emitter of the lens flare system.
  60889. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60890. * @returns the emitter of the lens flare system
  60891. */
  60892. getEmitter(): any;
  60893. /**
  60894. * Set the emitter of the lens flare system.
  60895. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60896. * @param newEmitter Define the new emitter of the system
  60897. */
  60898. setEmitter(newEmitter: any): void;
  60899. /**
  60900. * Get the lens flare system emitter position.
  60901. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60902. * @returns the position
  60903. */
  60904. getEmitterPosition(): Vector3;
  60905. /**
  60906. * @hidden
  60907. */
  60908. computeEffectivePosition(globalViewport: Viewport): boolean;
  60909. /** @hidden */
  60910. _isVisible(): boolean;
  60911. /**
  60912. * @hidden
  60913. */
  60914. render(): boolean;
  60915. /**
  60916. * Dispose and release the lens flare with its associated resources.
  60917. */
  60918. dispose(): void;
  60919. /**
  60920. * Parse a lens flare system from a JSON repressentation
  60921. * @param parsedLensFlareSystem Define the JSON to parse
  60922. * @param scene Define the scene the parsed system should be instantiated in
  60923. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60924. * @returns the parsed system
  60925. */
  60926. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60927. /**
  60928. * Serialize the current Lens Flare System into a JSON representation.
  60929. * @returns the serialized JSON
  60930. */
  60931. serialize(): any;
  60932. }
  60933. }
  60934. declare module BABYLON {
  60935. /**
  60936. * This represents one of the lens effect in a `lensFlareSystem`.
  60937. * It controls one of the indiviual texture used in the effect.
  60938. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60939. */
  60940. export class LensFlare {
  60941. /**
  60942. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60943. */
  60944. size: number;
  60945. /**
  60946. * 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.
  60947. */
  60948. position: number;
  60949. /**
  60950. * Define the lens color.
  60951. */
  60952. color: Color3;
  60953. /**
  60954. * Define the lens texture.
  60955. */
  60956. texture: Nullable<Texture>;
  60957. /**
  60958. * Define the alpha mode to render this particular lens.
  60959. */
  60960. alphaMode: number;
  60961. private _system;
  60962. /**
  60963. * Creates a new Lens Flare.
  60964. * This represents one of the lens effect in a `lensFlareSystem`.
  60965. * It controls one of the indiviual texture used in the effect.
  60966. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60967. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60968. * @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.
  60969. * @param color Define the lens color
  60970. * @param imgUrl Define the lens texture url
  60971. * @param system Define the `lensFlareSystem` this flare is part of
  60972. * @returns The newly created Lens Flare
  60973. */
  60974. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60975. /**
  60976. * Instantiates a new Lens Flare.
  60977. * This represents one of the lens effect in a `lensFlareSystem`.
  60978. * It controls one of the indiviual texture used in the effect.
  60979. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60980. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60981. * @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.
  60982. * @param color Define the lens color
  60983. * @param imgUrl Define the lens texture url
  60984. * @param system Define the `lensFlareSystem` this flare is part of
  60985. */
  60986. constructor(
  60987. /**
  60988. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60989. */
  60990. size: number,
  60991. /**
  60992. * 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.
  60993. */
  60994. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60995. /**
  60996. * Dispose and release the lens flare with its associated resources.
  60997. */
  60998. dispose(): void;
  60999. }
  61000. }
  61001. declare module BABYLON {
  61002. interface AbstractScene {
  61003. /**
  61004. * The list of lens flare system added to the scene
  61005. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61006. */
  61007. lensFlareSystems: Array<LensFlareSystem>;
  61008. /**
  61009. * Removes the given lens flare system from this scene.
  61010. * @param toRemove The lens flare system to remove
  61011. * @returns The index of the removed lens flare system
  61012. */
  61013. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61014. /**
  61015. * Adds the given lens flare system to this scene
  61016. * @param newLensFlareSystem The lens flare system to add
  61017. */
  61018. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61019. /**
  61020. * Gets a lens flare system using its name
  61021. * @param name defines the name to look for
  61022. * @returns the lens flare system or null if not found
  61023. */
  61024. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61025. /**
  61026. * Gets a lens flare system using its id
  61027. * @param id defines the id to look for
  61028. * @returns the lens flare system or null if not found
  61029. */
  61030. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61031. }
  61032. /**
  61033. * Defines the lens flare scene component responsible to manage any lens flares
  61034. * in a given scene.
  61035. */
  61036. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61037. /**
  61038. * The component name helpfull to identify the component in the list of scene components.
  61039. */
  61040. readonly name: string;
  61041. /**
  61042. * The scene the component belongs to.
  61043. */
  61044. scene: Scene;
  61045. /**
  61046. * Creates a new instance of the component for the given scene
  61047. * @param scene Defines the scene to register the component in
  61048. */
  61049. constructor(scene: Scene);
  61050. /**
  61051. * Registers the component in a given scene
  61052. */
  61053. register(): void;
  61054. /**
  61055. * Rebuilds the elements related to this component in case of
  61056. * context lost for instance.
  61057. */
  61058. rebuild(): void;
  61059. /**
  61060. * Adds all the elements from the container to the scene
  61061. * @param container the container holding the elements
  61062. */
  61063. addFromContainer(container: AbstractScene): void;
  61064. /**
  61065. * Removes all the elements in the container from the scene
  61066. * @param container contains the elements to remove
  61067. * @param dispose if the removed element should be disposed (default: false)
  61068. */
  61069. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61070. /**
  61071. * Serializes the component data to the specified json object
  61072. * @param serializationObject The object to serialize to
  61073. */
  61074. serialize(serializationObject: any): void;
  61075. /**
  61076. * Disposes the component and the associated ressources.
  61077. */
  61078. dispose(): void;
  61079. private _draw;
  61080. }
  61081. }
  61082. declare module BABYLON {
  61083. /** @hidden */
  61084. export var depthPixelShader: {
  61085. name: string;
  61086. shader: string;
  61087. };
  61088. }
  61089. declare module BABYLON {
  61090. /** @hidden */
  61091. export var depthVertexShader: {
  61092. name: string;
  61093. shader: string;
  61094. };
  61095. }
  61096. declare module BABYLON {
  61097. /**
  61098. * This represents a depth renderer in Babylon.
  61099. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61100. */
  61101. export class DepthRenderer {
  61102. private _scene;
  61103. private _depthMap;
  61104. private _effect;
  61105. private readonly _storeNonLinearDepth;
  61106. private readonly _clearColor;
  61107. /** Get if the depth renderer is using packed depth or not */
  61108. readonly isPacked: boolean;
  61109. private _cachedDefines;
  61110. private _camera;
  61111. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61112. enabled: boolean;
  61113. /**
  61114. * Specifiess that the depth renderer will only be used within
  61115. * the camera it is created for.
  61116. * This can help forcing its rendering during the camera processing.
  61117. */
  61118. useOnlyInActiveCamera: boolean;
  61119. /** @hidden */
  61120. static _SceneComponentInitialization: (scene: Scene) => void;
  61121. /**
  61122. * Instantiates a depth renderer
  61123. * @param scene The scene the renderer belongs to
  61124. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61125. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61126. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61127. */
  61128. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61129. /**
  61130. * Creates the depth rendering effect and checks if the effect is ready.
  61131. * @param subMesh The submesh to be used to render the depth map of
  61132. * @param useInstances If multiple world instances should be used
  61133. * @returns if the depth renderer is ready to render the depth map
  61134. */
  61135. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61136. /**
  61137. * Gets the texture which the depth map will be written to.
  61138. * @returns The depth map texture
  61139. */
  61140. getDepthMap(): RenderTargetTexture;
  61141. /**
  61142. * Disposes of the depth renderer.
  61143. */
  61144. dispose(): void;
  61145. }
  61146. }
  61147. declare module BABYLON {
  61148. /** @hidden */
  61149. export var minmaxReduxPixelShader: {
  61150. name: string;
  61151. shader: string;
  61152. };
  61153. }
  61154. declare module BABYLON {
  61155. /**
  61156. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61157. * and maximum values from all values of the texture.
  61158. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61159. * The source values are read from the red channel of the texture.
  61160. */
  61161. export class MinMaxReducer {
  61162. /**
  61163. * Observable triggered when the computation has been performed
  61164. */
  61165. onAfterReductionPerformed: Observable<{
  61166. min: number;
  61167. max: number;
  61168. }>;
  61169. protected _camera: Camera;
  61170. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61171. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61172. protected _postProcessManager: PostProcessManager;
  61173. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61174. protected _forceFullscreenViewport: boolean;
  61175. /**
  61176. * Creates a min/max reducer
  61177. * @param camera The camera to use for the post processes
  61178. */
  61179. constructor(camera: Camera);
  61180. /**
  61181. * Gets the texture used to read the values from.
  61182. */
  61183. get sourceTexture(): Nullable<RenderTargetTexture>;
  61184. /**
  61185. * Sets the source texture to read the values from.
  61186. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61187. * because in such textures '1' value must not be taken into account to compute the maximum
  61188. * as this value is used to clear the texture.
  61189. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61190. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61191. * @param depthRedux Indicates if the texture is a depth texture or not
  61192. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61193. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61194. */
  61195. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61196. /**
  61197. * Defines the refresh rate of the computation.
  61198. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61199. */
  61200. get refreshRate(): number;
  61201. set refreshRate(value: number);
  61202. protected _activated: boolean;
  61203. /**
  61204. * Gets the activation status of the reducer
  61205. */
  61206. get activated(): boolean;
  61207. /**
  61208. * Activates the reduction computation.
  61209. * When activated, the observers registered in onAfterReductionPerformed are
  61210. * called after the compuation is performed
  61211. */
  61212. activate(): void;
  61213. /**
  61214. * Deactivates the reduction computation.
  61215. */
  61216. deactivate(): void;
  61217. /**
  61218. * Disposes the min/max reducer
  61219. * @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.
  61220. */
  61221. dispose(disposeAll?: boolean): void;
  61222. }
  61223. }
  61224. declare module BABYLON {
  61225. /**
  61226. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61227. */
  61228. export class DepthReducer extends MinMaxReducer {
  61229. private _depthRenderer;
  61230. private _depthRendererId;
  61231. /**
  61232. * Gets the depth renderer used for the computation.
  61233. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61234. */
  61235. get depthRenderer(): Nullable<DepthRenderer>;
  61236. /**
  61237. * Creates a depth reducer
  61238. * @param camera The camera used to render the depth texture
  61239. */
  61240. constructor(camera: Camera);
  61241. /**
  61242. * Sets the depth renderer to use to generate the depth map
  61243. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61244. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61245. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61246. */
  61247. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61248. /** @hidden */
  61249. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61250. /**
  61251. * Activates the reduction computation.
  61252. * When activated, the observers registered in onAfterReductionPerformed are
  61253. * called after the compuation is performed
  61254. */
  61255. activate(): void;
  61256. /**
  61257. * Deactivates the reduction computation.
  61258. */
  61259. deactivate(): void;
  61260. /**
  61261. * Disposes the depth reducer
  61262. * @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.
  61263. */
  61264. dispose(disposeAll?: boolean): void;
  61265. }
  61266. }
  61267. declare module BABYLON {
  61268. /**
  61269. * A CSM implementation allowing casting shadows on large scenes.
  61270. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61271. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61272. */
  61273. export class CascadedShadowGenerator extends ShadowGenerator {
  61274. private static readonly frustumCornersNDCSpace;
  61275. /**
  61276. * Name of the CSM class
  61277. */
  61278. static CLASSNAME: string;
  61279. /**
  61280. * Defines the default number of cascades used by the CSM.
  61281. */
  61282. static readonly DEFAULT_CASCADES_COUNT: number;
  61283. /**
  61284. * Defines the minimum number of cascades used by the CSM.
  61285. */
  61286. static readonly MIN_CASCADES_COUNT: number;
  61287. /**
  61288. * Defines the maximum number of cascades used by the CSM.
  61289. */
  61290. static readonly MAX_CASCADES_COUNT: number;
  61291. protected _validateFilter(filter: number): number;
  61292. /**
  61293. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61294. */
  61295. penumbraDarkness: number;
  61296. private _numCascades;
  61297. /**
  61298. * Gets or set the number of cascades used by the CSM.
  61299. */
  61300. get numCascades(): number;
  61301. set numCascades(value: number);
  61302. /**
  61303. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61304. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61305. */
  61306. stabilizeCascades: boolean;
  61307. private _freezeShadowCastersBoundingInfo;
  61308. private _freezeShadowCastersBoundingInfoObservable;
  61309. /**
  61310. * Enables or disables the shadow casters bounding info computation.
  61311. * If your shadow casters don't move, you can disable this feature.
  61312. * If it is enabled, the bounding box computation is done every frame.
  61313. */
  61314. get freezeShadowCastersBoundingInfo(): boolean;
  61315. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61316. private _scbiMin;
  61317. private _scbiMax;
  61318. protected _computeShadowCastersBoundingInfo(): void;
  61319. protected _shadowCastersBoundingInfo: BoundingInfo;
  61320. /**
  61321. * Gets or sets the shadow casters bounding info.
  61322. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61323. * so that the system won't overwrite the bounds you provide
  61324. */
  61325. get shadowCastersBoundingInfo(): BoundingInfo;
  61326. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61327. protected _breaksAreDirty: boolean;
  61328. protected _minDistance: number;
  61329. protected _maxDistance: number;
  61330. /**
  61331. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61332. *
  61333. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61334. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61335. * @param min minimal distance for the breaks (default to 0.)
  61336. * @param max maximal distance for the breaks (default to 1.)
  61337. */
  61338. setMinMaxDistance(min: number, max: number): void;
  61339. /** Gets the minimal distance used in the cascade break computation */
  61340. get minDistance(): number;
  61341. /** Gets the maximal distance used in the cascade break computation */
  61342. get maxDistance(): number;
  61343. /**
  61344. * Gets the class name of that object
  61345. * @returns "CascadedShadowGenerator"
  61346. */
  61347. getClassName(): string;
  61348. private _cascadeMinExtents;
  61349. private _cascadeMaxExtents;
  61350. /**
  61351. * Gets a cascade minimum extents
  61352. * @param cascadeIndex index of the cascade
  61353. * @returns the minimum cascade extents
  61354. */
  61355. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61356. /**
  61357. * Gets a cascade maximum extents
  61358. * @param cascadeIndex index of the cascade
  61359. * @returns the maximum cascade extents
  61360. */
  61361. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61362. private _cascades;
  61363. private _currentLayer;
  61364. private _viewSpaceFrustumsZ;
  61365. private _viewMatrices;
  61366. private _projectionMatrices;
  61367. private _transformMatrices;
  61368. private _transformMatricesAsArray;
  61369. private _frustumLengths;
  61370. private _lightSizeUVCorrection;
  61371. private _depthCorrection;
  61372. private _frustumCornersWorldSpace;
  61373. private _frustumCenter;
  61374. private _shadowCameraPos;
  61375. private _shadowMaxZ;
  61376. /**
  61377. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61378. * It defaults to camera.maxZ
  61379. */
  61380. get shadowMaxZ(): number;
  61381. /**
  61382. * Sets the shadow max z distance.
  61383. */
  61384. set shadowMaxZ(value: number);
  61385. protected _debug: boolean;
  61386. /**
  61387. * Gets or sets the debug flag.
  61388. * When enabled, the cascades are materialized by different colors on the screen.
  61389. */
  61390. get debug(): boolean;
  61391. set debug(dbg: boolean);
  61392. private _depthClamp;
  61393. /**
  61394. * Gets or sets the depth clamping value.
  61395. *
  61396. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61397. * to account for the shadow casters far away.
  61398. *
  61399. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61400. */
  61401. get depthClamp(): boolean;
  61402. set depthClamp(value: boolean);
  61403. private _cascadeBlendPercentage;
  61404. /**
  61405. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61406. * It defaults to 0.1 (10% blending).
  61407. */
  61408. get cascadeBlendPercentage(): number;
  61409. set cascadeBlendPercentage(value: number);
  61410. private _lambda;
  61411. /**
  61412. * Gets or set the lambda parameter.
  61413. * This parameter is used to split the camera frustum and create the cascades.
  61414. * 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.
  61415. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61416. */
  61417. get lambda(): number;
  61418. set lambda(value: number);
  61419. /**
  61420. * Gets the view matrix corresponding to a given cascade
  61421. * @param cascadeNum cascade to retrieve the view matrix from
  61422. * @returns the cascade view matrix
  61423. */
  61424. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61425. /**
  61426. * Gets the projection matrix corresponding to a given cascade
  61427. * @param cascadeNum cascade to retrieve the projection matrix from
  61428. * @returns the cascade projection matrix
  61429. */
  61430. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61431. /**
  61432. * Gets the transformation matrix corresponding to a given cascade
  61433. * @param cascadeNum cascade to retrieve the transformation matrix from
  61434. * @returns the cascade transformation matrix
  61435. */
  61436. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61437. private _depthRenderer;
  61438. /**
  61439. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61440. *
  61441. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61442. *
  61443. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61444. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61445. * @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
  61446. */
  61447. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61448. private _depthReducer;
  61449. private _autoCalcDepthBounds;
  61450. /**
  61451. * Gets or sets the autoCalcDepthBounds property.
  61452. *
  61453. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61454. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61455. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61456. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61457. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61458. */
  61459. get autoCalcDepthBounds(): boolean;
  61460. set autoCalcDepthBounds(value: boolean);
  61461. /**
  61462. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61463. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61464. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61465. * for setting the refresh rate on the renderer yourself!
  61466. */
  61467. get autoCalcDepthBoundsRefreshRate(): number;
  61468. set autoCalcDepthBoundsRefreshRate(value: number);
  61469. /**
  61470. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61471. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61472. * you change the camera near/far planes!
  61473. */
  61474. splitFrustum(): void;
  61475. private _splitFrustum;
  61476. private _computeMatrices;
  61477. private _computeFrustumInWorldSpace;
  61478. private _computeCascadeFrustum;
  61479. /**
  61480. * Support test.
  61481. */
  61482. static get IsSupported(): boolean;
  61483. /** @hidden */
  61484. static _SceneComponentInitialization: (scene: Scene) => void;
  61485. /**
  61486. * Creates a Cascaded Shadow Generator object.
  61487. * A ShadowGenerator is the required tool to use the shadows.
  61488. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61489. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61490. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61491. * @param light The directional light object generating the shadows.
  61492. * @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.
  61493. */
  61494. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61495. protected _initializeGenerator(): void;
  61496. protected _createTargetRenderTexture(): void;
  61497. protected _initializeShadowMap(): void;
  61498. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61499. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61500. /**
  61501. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61502. * @param defines Defines of the material we want to update
  61503. * @param lightIndex Index of the light in the enabled light list of the material
  61504. */
  61505. prepareDefines(defines: any, lightIndex: number): void;
  61506. /**
  61507. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61508. * defined in the generator but impacting the effect).
  61509. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61510. * @param effect The effect we are binfing the information for
  61511. */
  61512. bindShadowLight(lightIndex: string, effect: Effect): void;
  61513. /**
  61514. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61515. * (eq to view projection * shadow projection matrices)
  61516. * @returns The transform matrix used to create the shadow map
  61517. */
  61518. getTransformMatrix(): Matrix;
  61519. /**
  61520. * Disposes the ShadowGenerator.
  61521. * Returns nothing.
  61522. */
  61523. dispose(): void;
  61524. /**
  61525. * Serializes the shadow generator setup to a json object.
  61526. * @returns The serialized JSON object
  61527. */
  61528. serialize(): any;
  61529. /**
  61530. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61531. * @param parsedShadowGenerator The JSON object to parse
  61532. * @param scene The scene to create the shadow map for
  61533. * @returns The parsed shadow generator
  61534. */
  61535. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61536. }
  61537. }
  61538. declare module BABYLON {
  61539. /**
  61540. * Defines the shadow generator component responsible to manage any shadow generators
  61541. * in a given scene.
  61542. */
  61543. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61544. /**
  61545. * The component name helpfull to identify the component in the list of scene components.
  61546. */
  61547. readonly name: string;
  61548. /**
  61549. * The scene the component belongs to.
  61550. */
  61551. scene: Scene;
  61552. /**
  61553. * Creates a new instance of the component for the given scene
  61554. * @param scene Defines the scene to register the component in
  61555. */
  61556. constructor(scene: Scene);
  61557. /**
  61558. * Registers the component in a given scene
  61559. */
  61560. register(): void;
  61561. /**
  61562. * Rebuilds the elements related to this component in case of
  61563. * context lost for instance.
  61564. */
  61565. rebuild(): void;
  61566. /**
  61567. * Serializes the component data to the specified json object
  61568. * @param serializationObject The object to serialize to
  61569. */
  61570. serialize(serializationObject: any): void;
  61571. /**
  61572. * Adds all the elements from the container to the scene
  61573. * @param container the container holding the elements
  61574. */
  61575. addFromContainer(container: AbstractScene): void;
  61576. /**
  61577. * Removes all the elements in the container from the scene
  61578. * @param container contains the elements to remove
  61579. * @param dispose if the removed element should be disposed (default: false)
  61580. */
  61581. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61582. /**
  61583. * Rebuilds the elements related to this component in case of
  61584. * context lost for instance.
  61585. */
  61586. dispose(): void;
  61587. private _gatherRenderTargets;
  61588. }
  61589. }
  61590. declare module BABYLON {
  61591. /**
  61592. * A point light is a light defined by an unique point in world space.
  61593. * The light is emitted in every direction from this point.
  61594. * A good example of a point light is a standard light bulb.
  61595. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61596. */
  61597. export class PointLight extends ShadowLight {
  61598. private _shadowAngle;
  61599. /**
  61600. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61601. * This specifies what angle the shadow will use to be created.
  61602. *
  61603. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61604. */
  61605. get shadowAngle(): number;
  61606. /**
  61607. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61608. * This specifies what angle the shadow will use to be created.
  61609. *
  61610. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61611. */
  61612. set shadowAngle(value: number);
  61613. /**
  61614. * Gets the direction if it has been set.
  61615. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61616. */
  61617. get direction(): Vector3;
  61618. /**
  61619. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61620. */
  61621. set direction(value: Vector3);
  61622. /**
  61623. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61624. * A PointLight emits the light in every direction.
  61625. * It can cast shadows.
  61626. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61627. * ```javascript
  61628. * var pointLight = new PointLight("pl", camera.position, scene);
  61629. * ```
  61630. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61631. * @param name The light friendly name
  61632. * @param position The position of the point light in the scene
  61633. * @param scene The scene the lights belongs to
  61634. */
  61635. constructor(name: string, position: Vector3, scene: Scene);
  61636. /**
  61637. * Returns the string "PointLight"
  61638. * @returns the class name
  61639. */
  61640. getClassName(): string;
  61641. /**
  61642. * Returns the integer 0.
  61643. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61644. */
  61645. getTypeID(): number;
  61646. /**
  61647. * Specifies wether or not the shadowmap should be a cube texture.
  61648. * @returns true if the shadowmap needs to be a cube texture.
  61649. */
  61650. needCube(): boolean;
  61651. /**
  61652. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61653. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61654. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61655. */
  61656. getShadowDirection(faceIndex?: number): Vector3;
  61657. /**
  61658. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61659. * - fov = PI / 2
  61660. * - aspect ratio : 1.0
  61661. * - z-near and far equal to the active camera minZ and maxZ.
  61662. * Returns the PointLight.
  61663. */
  61664. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61665. protected _buildUniformLayout(): void;
  61666. /**
  61667. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61668. * @param effect The effect to update
  61669. * @param lightIndex The index of the light in the effect to update
  61670. * @returns The point light
  61671. */
  61672. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61673. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61674. /**
  61675. * Prepares the list of defines specific to the light type.
  61676. * @param defines the list of defines
  61677. * @param lightIndex defines the index of the light for the effect
  61678. */
  61679. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61680. }
  61681. }
  61682. declare module BABYLON {
  61683. /**
  61684. * Header information of HDR texture files.
  61685. */
  61686. export interface HDRInfo {
  61687. /**
  61688. * The height of the texture in pixels.
  61689. */
  61690. height: number;
  61691. /**
  61692. * The width of the texture in pixels.
  61693. */
  61694. width: number;
  61695. /**
  61696. * The index of the beginning of the data in the binary file.
  61697. */
  61698. dataPosition: number;
  61699. }
  61700. /**
  61701. * This groups tools to convert HDR texture to native colors array.
  61702. */
  61703. export class HDRTools {
  61704. private static Ldexp;
  61705. private static Rgbe2float;
  61706. private static readStringLine;
  61707. /**
  61708. * Reads header information from an RGBE texture stored in a native array.
  61709. * More information on this format are available here:
  61710. * https://en.wikipedia.org/wiki/RGBE_image_format
  61711. *
  61712. * @param uint8array The binary file stored in native array.
  61713. * @return The header information.
  61714. */
  61715. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61716. /**
  61717. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61718. * This RGBE texture needs to store the information as a panorama.
  61719. *
  61720. * More information on this format are available here:
  61721. * https://en.wikipedia.org/wiki/RGBE_image_format
  61722. *
  61723. * @param buffer The binary file stored in an array buffer.
  61724. * @param size The expected size of the extracted cubemap.
  61725. * @return The Cube Map information.
  61726. */
  61727. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61728. /**
  61729. * Returns the pixels data extracted from an RGBE texture.
  61730. * This pixels will be stored left to right up to down in the R G B order in one array.
  61731. *
  61732. * More information on this format are available here:
  61733. * https://en.wikipedia.org/wiki/RGBE_image_format
  61734. *
  61735. * @param uint8array The binary file stored in an array buffer.
  61736. * @param hdrInfo The header information of the file.
  61737. * @return The pixels data in RGB right to left up to down order.
  61738. */
  61739. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61740. private static RGBE_ReadPixels_RLE;
  61741. private static RGBE_ReadPixels_NOT_RLE;
  61742. }
  61743. }
  61744. declare module BABYLON {
  61745. /**
  61746. * Effect Render Options
  61747. */
  61748. export interface IEffectRendererOptions {
  61749. /**
  61750. * Defines the vertices positions.
  61751. */
  61752. positions?: number[];
  61753. /**
  61754. * Defines the indices.
  61755. */
  61756. indices?: number[];
  61757. }
  61758. /**
  61759. * Helper class to render one or more effects.
  61760. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61761. */
  61762. export class EffectRenderer {
  61763. private engine;
  61764. private static _DefaultOptions;
  61765. private _vertexBuffers;
  61766. private _indexBuffer;
  61767. private _fullscreenViewport;
  61768. /**
  61769. * Creates an effect renderer
  61770. * @param engine the engine to use for rendering
  61771. * @param options defines the options of the effect renderer
  61772. */
  61773. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61774. /**
  61775. * Sets the current viewport in normalized coordinates 0-1
  61776. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61777. */
  61778. setViewport(viewport?: Viewport): void;
  61779. /**
  61780. * Binds the embedded attributes buffer to the effect.
  61781. * @param effect Defines the effect to bind the attributes for
  61782. */
  61783. bindBuffers(effect: Effect): void;
  61784. /**
  61785. * Sets the current effect wrapper to use during draw.
  61786. * The effect needs to be ready before calling this api.
  61787. * This also sets the default full screen position attribute.
  61788. * @param effectWrapper Defines the effect to draw with
  61789. */
  61790. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61791. /**
  61792. * Restores engine states
  61793. */
  61794. restoreStates(): void;
  61795. /**
  61796. * Draws a full screen quad.
  61797. */
  61798. draw(): void;
  61799. private isRenderTargetTexture;
  61800. /**
  61801. * renders one or more effects to a specified texture
  61802. * @param effectWrapper the effect to renderer
  61803. * @param outputTexture texture to draw to, if null it will render to the screen.
  61804. */
  61805. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61806. /**
  61807. * Disposes of the effect renderer
  61808. */
  61809. dispose(): void;
  61810. }
  61811. /**
  61812. * Options to create an EffectWrapper
  61813. */
  61814. interface EffectWrapperCreationOptions {
  61815. /**
  61816. * Engine to use to create the effect
  61817. */
  61818. engine: ThinEngine;
  61819. /**
  61820. * Fragment shader for the effect
  61821. */
  61822. fragmentShader: string;
  61823. /**
  61824. * Use the shader store instead of direct source code
  61825. */
  61826. useShaderStore?: boolean;
  61827. /**
  61828. * Vertex shader for the effect
  61829. */
  61830. vertexShader?: string;
  61831. /**
  61832. * Attributes to use in the shader
  61833. */
  61834. attributeNames?: Array<string>;
  61835. /**
  61836. * Uniforms to use in the shader
  61837. */
  61838. uniformNames?: Array<string>;
  61839. /**
  61840. * Texture sampler names to use in the shader
  61841. */
  61842. samplerNames?: Array<string>;
  61843. /**
  61844. * Defines to use in the shader
  61845. */
  61846. defines?: Array<string>;
  61847. /**
  61848. * Callback when effect is compiled
  61849. */
  61850. onCompiled?: Nullable<(effect: Effect) => void>;
  61851. /**
  61852. * The friendly name of the effect displayed in Spector.
  61853. */
  61854. name?: string;
  61855. }
  61856. /**
  61857. * Wraps an effect to be used for rendering
  61858. */
  61859. export class EffectWrapper {
  61860. /**
  61861. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61862. */
  61863. onApplyObservable: Observable<{}>;
  61864. /**
  61865. * The underlying effect
  61866. */
  61867. effect: Effect;
  61868. /**
  61869. * Creates an effect to be renderer
  61870. * @param creationOptions options to create the effect
  61871. */
  61872. constructor(creationOptions: EffectWrapperCreationOptions);
  61873. /**
  61874. * Disposes of the effect wrapper
  61875. */
  61876. dispose(): void;
  61877. }
  61878. }
  61879. declare module BABYLON {
  61880. /** @hidden */
  61881. export var hdrFilteringVertexShader: {
  61882. name: string;
  61883. shader: string;
  61884. };
  61885. }
  61886. declare module BABYLON {
  61887. /** @hidden */
  61888. export var hdrFilteringPixelShader: {
  61889. name: string;
  61890. shader: string;
  61891. };
  61892. }
  61893. declare module BABYLON {
  61894. /**
  61895. * Options for texture filtering
  61896. */
  61897. interface IHDRFilteringOptions {
  61898. /**
  61899. * Scales pixel intensity for the input HDR map.
  61900. */
  61901. hdrScale?: number;
  61902. /**
  61903. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61904. */
  61905. quality?: number;
  61906. }
  61907. /**
  61908. * Filters HDR maps to get correct renderings of PBR reflections
  61909. */
  61910. export class HDRFiltering {
  61911. private _engine;
  61912. private _effectRenderer;
  61913. private _effectWrapper;
  61914. private _lodGenerationOffset;
  61915. private _lodGenerationScale;
  61916. /**
  61917. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61918. * you care about baking speed.
  61919. */
  61920. quality: number;
  61921. /**
  61922. * Scales pixel intensity for the input HDR map.
  61923. */
  61924. hdrScale: number;
  61925. /**
  61926. * Instantiates HDR filter for reflection maps
  61927. *
  61928. * @param engine Thin engine
  61929. * @param options Options
  61930. */
  61931. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61932. private _createRenderTarget;
  61933. private _prefilterInternal;
  61934. private _createEffect;
  61935. /**
  61936. * Get a value indicating if the filter is ready to be used
  61937. * @param texture Texture to filter
  61938. * @returns true if the filter is ready
  61939. */
  61940. isReady(texture: BaseTexture): boolean;
  61941. /**
  61942. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61943. * Prefiltering will be invoked at the end of next rendering pass.
  61944. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61945. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61946. * @param texture Texture to filter
  61947. * @param onFinished Callback when filtering is done
  61948. * @return Promise called when prefiltering is done
  61949. */
  61950. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61951. }
  61952. }
  61953. declare module BABYLON {
  61954. /**
  61955. * This represents a texture coming from an HDR input.
  61956. *
  61957. * The only supported format is currently panorama picture stored in RGBE format.
  61958. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61959. */
  61960. export class HDRCubeTexture extends BaseTexture {
  61961. private static _facesMapping;
  61962. private _generateHarmonics;
  61963. private _noMipmap;
  61964. private _prefilterOnLoad;
  61965. private _textureMatrix;
  61966. private _size;
  61967. private _onLoad;
  61968. private _onError;
  61969. /**
  61970. * The texture URL.
  61971. */
  61972. url: string;
  61973. protected _isBlocking: boolean;
  61974. /**
  61975. * Sets wether or not the texture is blocking during loading.
  61976. */
  61977. set isBlocking(value: boolean);
  61978. /**
  61979. * Gets wether or not the texture is blocking during loading.
  61980. */
  61981. get isBlocking(): boolean;
  61982. protected _rotationY: number;
  61983. /**
  61984. * Sets texture matrix rotation angle around Y axis in radians.
  61985. */
  61986. set rotationY(value: number);
  61987. /**
  61988. * Gets texture matrix rotation angle around Y axis radians.
  61989. */
  61990. get rotationY(): number;
  61991. /**
  61992. * Gets or sets the center of the bounding box associated with the cube texture
  61993. * It must define where the camera used to render the texture was set
  61994. */
  61995. boundingBoxPosition: Vector3;
  61996. private _boundingBoxSize;
  61997. /**
  61998. * Gets or sets the size of the bounding box associated with the cube texture
  61999. * When defined, the cubemap will switch to local mode
  62000. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62001. * @example https://www.babylonjs-playground.com/#RNASML
  62002. */
  62003. set boundingBoxSize(value: Vector3);
  62004. get boundingBoxSize(): Vector3;
  62005. /**
  62006. * Instantiates an HDRTexture from the following parameters.
  62007. *
  62008. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  62009. * @param sceneOrEngine The scene or engine the texture will be used in
  62010. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62011. * @param noMipmap Forces to not generate the mipmap if true
  62012. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  62013. * @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)
  62014. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  62015. */
  62016. 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>);
  62017. /**
  62018. * Get the current class name of the texture useful for serialization or dynamic coding.
  62019. * @returns "HDRCubeTexture"
  62020. */
  62021. getClassName(): string;
  62022. /**
  62023. * Occurs when the file is raw .hdr file.
  62024. */
  62025. private loadTexture;
  62026. clone(): HDRCubeTexture;
  62027. delayLoad(): void;
  62028. /**
  62029. * Get the texture reflection matrix used to rotate/transform the reflection.
  62030. * @returns the reflection matrix
  62031. */
  62032. getReflectionTextureMatrix(): Matrix;
  62033. /**
  62034. * Set the texture reflection matrix used to rotate/transform the reflection.
  62035. * @param value Define the reflection matrix to set
  62036. */
  62037. setReflectionTextureMatrix(value: Matrix): void;
  62038. /**
  62039. * Parses a JSON representation of an HDR Texture in order to create the texture
  62040. * @param parsedTexture Define the JSON representation
  62041. * @param scene Define the scene the texture should be created in
  62042. * @param rootUrl Define the root url in case we need to load relative dependencies
  62043. * @returns the newly created texture after parsing
  62044. */
  62045. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62046. serialize(): any;
  62047. }
  62048. }
  62049. declare module BABYLON {
  62050. /**
  62051. * Class used to control physics engine
  62052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62053. */
  62054. export class PhysicsEngine implements IPhysicsEngine {
  62055. private _physicsPlugin;
  62056. /**
  62057. * Global value used to control the smallest number supported by the simulation
  62058. */
  62059. static Epsilon: number;
  62060. private _impostors;
  62061. private _joints;
  62062. private _subTimeStep;
  62063. /**
  62064. * Gets the gravity vector used by the simulation
  62065. */
  62066. gravity: Vector3;
  62067. /**
  62068. * Factory used to create the default physics plugin.
  62069. * @returns The default physics plugin
  62070. */
  62071. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62072. /**
  62073. * Creates a new Physics Engine
  62074. * @param gravity defines the gravity vector used by the simulation
  62075. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62076. */
  62077. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62078. /**
  62079. * Sets the gravity vector used by the simulation
  62080. * @param gravity defines the gravity vector to use
  62081. */
  62082. setGravity(gravity: Vector3): void;
  62083. /**
  62084. * Set the time step of the physics engine.
  62085. * Default is 1/60.
  62086. * To slow it down, enter 1/600 for example.
  62087. * To speed it up, 1/30
  62088. * @param newTimeStep defines the new timestep to apply to this world.
  62089. */
  62090. setTimeStep(newTimeStep?: number): void;
  62091. /**
  62092. * Get the time step of the physics engine.
  62093. * @returns the current time step
  62094. */
  62095. getTimeStep(): number;
  62096. /**
  62097. * Set the sub time step of the physics engine.
  62098. * Default is 0 meaning there is no sub steps
  62099. * To increase physics resolution precision, set a small value (like 1 ms)
  62100. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62101. */
  62102. setSubTimeStep(subTimeStep?: number): void;
  62103. /**
  62104. * Get the sub time step of the physics engine.
  62105. * @returns the current sub time step
  62106. */
  62107. getSubTimeStep(): number;
  62108. /**
  62109. * Release all resources
  62110. */
  62111. dispose(): void;
  62112. /**
  62113. * Gets the name of the current physics plugin
  62114. * @returns the name of the plugin
  62115. */
  62116. getPhysicsPluginName(): string;
  62117. /**
  62118. * Adding a new impostor for the impostor tracking.
  62119. * This will be done by the impostor itself.
  62120. * @param impostor the impostor to add
  62121. */
  62122. addImpostor(impostor: PhysicsImpostor): void;
  62123. /**
  62124. * Remove an impostor from the engine.
  62125. * This impostor and its mesh will not longer be updated by the physics engine.
  62126. * @param impostor the impostor to remove
  62127. */
  62128. removeImpostor(impostor: PhysicsImpostor): void;
  62129. /**
  62130. * Add a joint to the physics engine
  62131. * @param mainImpostor defines the main impostor to which the joint is added.
  62132. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62133. * @param joint defines the joint that will connect both impostors.
  62134. */
  62135. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62136. /**
  62137. * Removes a joint from the simulation
  62138. * @param mainImpostor defines the impostor used with the joint
  62139. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62140. * @param joint defines the joint to remove
  62141. */
  62142. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62143. /**
  62144. * Called by the scene. No need to call it.
  62145. * @param delta defines the timespam between frames
  62146. */
  62147. _step(delta: number): void;
  62148. /**
  62149. * Gets the current plugin used to run the simulation
  62150. * @returns current plugin
  62151. */
  62152. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62153. /**
  62154. * Gets the list of physic impostors
  62155. * @returns an array of PhysicsImpostor
  62156. */
  62157. getImpostors(): Array<PhysicsImpostor>;
  62158. /**
  62159. * Gets the impostor for a physics enabled object
  62160. * @param object defines the object impersonated by the impostor
  62161. * @returns the PhysicsImpostor or null if not found
  62162. */
  62163. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62164. /**
  62165. * Gets the impostor for a physics body object
  62166. * @param body defines physics body used by the impostor
  62167. * @returns the PhysicsImpostor or null if not found
  62168. */
  62169. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62170. /**
  62171. * Does a raycast in the physics world
  62172. * @param from when should the ray start?
  62173. * @param to when should the ray end?
  62174. * @returns PhysicsRaycastResult
  62175. */
  62176. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62177. }
  62178. }
  62179. declare module BABYLON {
  62180. /** @hidden */
  62181. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62182. private _useDeltaForWorldStep;
  62183. world: any;
  62184. name: string;
  62185. private _physicsMaterials;
  62186. private _fixedTimeStep;
  62187. private _cannonRaycastResult;
  62188. private _raycastResult;
  62189. private _physicsBodysToRemoveAfterStep;
  62190. private _firstFrame;
  62191. BJSCANNON: any;
  62192. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62193. setGravity(gravity: Vector3): void;
  62194. setTimeStep(timeStep: number): void;
  62195. getTimeStep(): number;
  62196. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62197. private _removeMarkedPhysicsBodiesFromWorld;
  62198. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62199. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62200. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62201. private _processChildMeshes;
  62202. removePhysicsBody(impostor: PhysicsImpostor): void;
  62203. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62204. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62205. private _addMaterial;
  62206. private _checkWithEpsilon;
  62207. private _createShape;
  62208. private _createHeightmap;
  62209. private _minus90X;
  62210. private _plus90X;
  62211. private _tmpPosition;
  62212. private _tmpDeltaPosition;
  62213. private _tmpUnityRotation;
  62214. private _updatePhysicsBodyTransformation;
  62215. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62216. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62217. isSupported(): boolean;
  62218. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62219. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62220. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62221. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62222. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62223. getBodyMass(impostor: PhysicsImpostor): number;
  62224. getBodyFriction(impostor: PhysicsImpostor): number;
  62225. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62226. getBodyRestitution(impostor: PhysicsImpostor): number;
  62227. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62228. sleepBody(impostor: PhysicsImpostor): void;
  62229. wakeUpBody(impostor: PhysicsImpostor): void;
  62230. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62231. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62232. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62233. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62234. getRadius(impostor: PhysicsImpostor): number;
  62235. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62236. dispose(): void;
  62237. private _extendNamespace;
  62238. /**
  62239. * Does a raycast in the physics world
  62240. * @param from when should the ray start?
  62241. * @param to when should the ray end?
  62242. * @returns PhysicsRaycastResult
  62243. */
  62244. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62245. }
  62246. }
  62247. declare module BABYLON {
  62248. /** @hidden */
  62249. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62250. private _useDeltaForWorldStep;
  62251. world: any;
  62252. name: string;
  62253. BJSOIMO: any;
  62254. private _raycastResult;
  62255. private _fixedTimeStep;
  62256. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62257. setGravity(gravity: Vector3): void;
  62258. setTimeStep(timeStep: number): void;
  62259. getTimeStep(): number;
  62260. private _tmpImpostorsArray;
  62261. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62262. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62263. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62264. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62265. private _tmpPositionVector;
  62266. removePhysicsBody(impostor: PhysicsImpostor): void;
  62267. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62268. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62269. isSupported(): boolean;
  62270. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62271. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62272. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62273. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62274. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62275. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62276. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62277. getBodyMass(impostor: PhysicsImpostor): number;
  62278. getBodyFriction(impostor: PhysicsImpostor): number;
  62279. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62280. getBodyRestitution(impostor: PhysicsImpostor): number;
  62281. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62282. sleepBody(impostor: PhysicsImpostor): void;
  62283. wakeUpBody(impostor: PhysicsImpostor): void;
  62284. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62285. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62286. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62287. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62288. getRadius(impostor: PhysicsImpostor): number;
  62289. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62290. dispose(): void;
  62291. /**
  62292. * Does a raycast in the physics world
  62293. * @param from when should the ray start?
  62294. * @param to when should the ray end?
  62295. * @returns PhysicsRaycastResult
  62296. */
  62297. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62298. }
  62299. }
  62300. declare module BABYLON {
  62301. /**
  62302. * AmmoJS Physics plugin
  62303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62304. * @see https://github.com/kripken/ammo.js/
  62305. */
  62306. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62307. private _useDeltaForWorldStep;
  62308. /**
  62309. * Reference to the Ammo library
  62310. */
  62311. bjsAMMO: any;
  62312. /**
  62313. * Created ammoJS world which physics bodies are added to
  62314. */
  62315. world: any;
  62316. /**
  62317. * Name of the plugin
  62318. */
  62319. name: string;
  62320. private _timeStep;
  62321. private _fixedTimeStep;
  62322. private _maxSteps;
  62323. private _tmpQuaternion;
  62324. private _tmpAmmoTransform;
  62325. private _tmpAmmoQuaternion;
  62326. private _tmpAmmoConcreteContactResultCallback;
  62327. private _collisionConfiguration;
  62328. private _dispatcher;
  62329. private _overlappingPairCache;
  62330. private _solver;
  62331. private _softBodySolver;
  62332. private _tmpAmmoVectorA;
  62333. private _tmpAmmoVectorB;
  62334. private _tmpAmmoVectorC;
  62335. private _tmpAmmoVectorD;
  62336. private _tmpContactCallbackResult;
  62337. private _tmpAmmoVectorRCA;
  62338. private _tmpAmmoVectorRCB;
  62339. private _raycastResult;
  62340. private _tmpContactPoint;
  62341. private static readonly DISABLE_COLLISION_FLAG;
  62342. private static readonly KINEMATIC_FLAG;
  62343. private static readonly DISABLE_DEACTIVATION_FLAG;
  62344. /**
  62345. * Initializes the ammoJS plugin
  62346. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62347. * @param ammoInjection can be used to inject your own ammo reference
  62348. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62349. */
  62350. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62351. /**
  62352. * Sets the gravity of the physics world (m/(s^2))
  62353. * @param gravity Gravity to set
  62354. */
  62355. setGravity(gravity: Vector3): void;
  62356. /**
  62357. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62358. * @param timeStep timestep to use in seconds
  62359. */
  62360. setTimeStep(timeStep: number): void;
  62361. /**
  62362. * 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)
  62363. * @param fixedTimeStep fixedTimeStep to use in seconds
  62364. */
  62365. setFixedTimeStep(fixedTimeStep: number): void;
  62366. /**
  62367. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62368. * @param maxSteps the maximum number of steps by the physics engine per frame
  62369. */
  62370. setMaxSteps(maxSteps: number): void;
  62371. /**
  62372. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62373. * @returns the current timestep in seconds
  62374. */
  62375. getTimeStep(): number;
  62376. /**
  62377. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62378. */
  62379. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62380. private _isImpostorInContact;
  62381. private _isImpostorPairInContact;
  62382. private _stepSimulation;
  62383. /**
  62384. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62385. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62386. * After the step the babylon meshes are set to the position of the physics imposters
  62387. * @param delta amount of time to step forward
  62388. * @param impostors array of imposters to update before/after the step
  62389. */
  62390. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62391. /**
  62392. * Update babylon mesh to match physics world object
  62393. * @param impostor imposter to match
  62394. */
  62395. private _afterSoftStep;
  62396. /**
  62397. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62398. * @param impostor imposter to match
  62399. */
  62400. private _ropeStep;
  62401. /**
  62402. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62403. * @param impostor imposter to match
  62404. */
  62405. private _softbodyOrClothStep;
  62406. private _tmpMatrix;
  62407. /**
  62408. * Applies an impulse on the imposter
  62409. * @param impostor imposter to apply impulse to
  62410. * @param force amount of force to be applied to the imposter
  62411. * @param contactPoint the location to apply the impulse on the imposter
  62412. */
  62413. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62414. /**
  62415. * Applies a force on the imposter
  62416. * @param impostor imposter to apply force
  62417. * @param force amount of force to be applied to the imposter
  62418. * @param contactPoint the location to apply the force on the imposter
  62419. */
  62420. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62421. /**
  62422. * Creates a physics body using the plugin
  62423. * @param impostor the imposter to create the physics body on
  62424. */
  62425. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62426. /**
  62427. * Removes the physics body from the imposter and disposes of the body's memory
  62428. * @param impostor imposter to remove the physics body from
  62429. */
  62430. removePhysicsBody(impostor: PhysicsImpostor): void;
  62431. /**
  62432. * Generates a joint
  62433. * @param impostorJoint the imposter joint to create the joint with
  62434. */
  62435. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62436. /**
  62437. * Removes a joint
  62438. * @param impostorJoint the imposter joint to remove the joint from
  62439. */
  62440. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62441. private _addMeshVerts;
  62442. /**
  62443. * Initialise the soft body vertices to match its object's (mesh) vertices
  62444. * Softbody vertices (nodes) are in world space and to match this
  62445. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62446. * @param impostor to create the softbody for
  62447. */
  62448. private _softVertexData;
  62449. /**
  62450. * Create an impostor's soft body
  62451. * @param impostor to create the softbody for
  62452. */
  62453. private _createSoftbody;
  62454. /**
  62455. * Create cloth for an impostor
  62456. * @param impostor to create the softbody for
  62457. */
  62458. private _createCloth;
  62459. /**
  62460. * Create rope for an impostor
  62461. * @param impostor to create the softbody for
  62462. */
  62463. private _createRope;
  62464. /**
  62465. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62466. * @param impostor to create the custom physics shape for
  62467. */
  62468. private _createCustom;
  62469. private _addHullVerts;
  62470. private _createShape;
  62471. /**
  62472. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62473. * @param impostor imposter containing the physics body and babylon object
  62474. */
  62475. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62476. /**
  62477. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62478. * @param impostor imposter containing the physics body and babylon object
  62479. * @param newPosition new position
  62480. * @param newRotation new rotation
  62481. */
  62482. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62483. /**
  62484. * If this plugin is supported
  62485. * @returns true if its supported
  62486. */
  62487. isSupported(): boolean;
  62488. /**
  62489. * Sets the linear velocity of the physics body
  62490. * @param impostor imposter to set the velocity on
  62491. * @param velocity velocity to set
  62492. */
  62493. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62494. /**
  62495. * Sets the angular velocity of the physics body
  62496. * @param impostor imposter to set the velocity on
  62497. * @param velocity velocity to set
  62498. */
  62499. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62500. /**
  62501. * gets the linear velocity
  62502. * @param impostor imposter to get linear velocity from
  62503. * @returns linear velocity
  62504. */
  62505. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62506. /**
  62507. * gets the angular velocity
  62508. * @param impostor imposter to get angular velocity from
  62509. * @returns angular velocity
  62510. */
  62511. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62512. /**
  62513. * Sets the mass of physics body
  62514. * @param impostor imposter to set the mass on
  62515. * @param mass mass to set
  62516. */
  62517. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62518. /**
  62519. * Gets the mass of the physics body
  62520. * @param impostor imposter to get the mass from
  62521. * @returns mass
  62522. */
  62523. getBodyMass(impostor: PhysicsImpostor): number;
  62524. /**
  62525. * Gets friction of the impostor
  62526. * @param impostor impostor to get friction from
  62527. * @returns friction value
  62528. */
  62529. getBodyFriction(impostor: PhysicsImpostor): number;
  62530. /**
  62531. * Sets friction of the impostor
  62532. * @param impostor impostor to set friction on
  62533. * @param friction friction value
  62534. */
  62535. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62536. /**
  62537. * Gets restitution of the impostor
  62538. * @param impostor impostor to get restitution from
  62539. * @returns restitution value
  62540. */
  62541. getBodyRestitution(impostor: PhysicsImpostor): number;
  62542. /**
  62543. * Sets resitution of the impostor
  62544. * @param impostor impostor to set resitution on
  62545. * @param restitution resitution value
  62546. */
  62547. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62548. /**
  62549. * Gets pressure inside the impostor
  62550. * @param impostor impostor to get pressure from
  62551. * @returns pressure value
  62552. */
  62553. getBodyPressure(impostor: PhysicsImpostor): number;
  62554. /**
  62555. * Sets pressure inside a soft body impostor
  62556. * Cloth and rope must remain 0 pressure
  62557. * @param impostor impostor to set pressure on
  62558. * @param pressure pressure value
  62559. */
  62560. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62561. /**
  62562. * Gets stiffness of the impostor
  62563. * @param impostor impostor to get stiffness from
  62564. * @returns pressure value
  62565. */
  62566. getBodyStiffness(impostor: PhysicsImpostor): number;
  62567. /**
  62568. * Sets stiffness of the impostor
  62569. * @param impostor impostor to set stiffness on
  62570. * @param stiffness stiffness value from 0 to 1
  62571. */
  62572. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62573. /**
  62574. * Gets velocityIterations of the impostor
  62575. * @param impostor impostor to get velocity iterations from
  62576. * @returns velocityIterations value
  62577. */
  62578. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62579. /**
  62580. * Sets velocityIterations of the impostor
  62581. * @param impostor impostor to set velocity iterations on
  62582. * @param velocityIterations velocityIterations value
  62583. */
  62584. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62585. /**
  62586. * Gets positionIterations of the impostor
  62587. * @param impostor impostor to get position iterations from
  62588. * @returns positionIterations value
  62589. */
  62590. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62591. /**
  62592. * Sets positionIterations of the impostor
  62593. * @param impostor impostor to set position on
  62594. * @param positionIterations positionIterations value
  62595. */
  62596. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62597. /**
  62598. * Append an anchor to a cloth object
  62599. * @param impostor is the cloth impostor to add anchor to
  62600. * @param otherImpostor is the rigid impostor to anchor to
  62601. * @param width ratio across width from 0 to 1
  62602. * @param height ratio up height from 0 to 1
  62603. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62604. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62605. */
  62606. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62607. /**
  62608. * Append an hook to a rope object
  62609. * @param impostor is the rope impostor to add hook to
  62610. * @param otherImpostor is the rigid impostor to hook to
  62611. * @param length ratio along the rope from 0 to 1
  62612. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62613. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62614. */
  62615. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62616. /**
  62617. * Sleeps the physics body and stops it from being active
  62618. * @param impostor impostor to sleep
  62619. */
  62620. sleepBody(impostor: PhysicsImpostor): void;
  62621. /**
  62622. * Activates the physics body
  62623. * @param impostor impostor to activate
  62624. */
  62625. wakeUpBody(impostor: PhysicsImpostor): void;
  62626. /**
  62627. * Updates the distance parameters of the joint
  62628. * @param joint joint to update
  62629. * @param maxDistance maximum distance of the joint
  62630. * @param minDistance minimum distance of the joint
  62631. */
  62632. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62633. /**
  62634. * Sets a motor on the joint
  62635. * @param joint joint to set motor on
  62636. * @param speed speed of the motor
  62637. * @param maxForce maximum force of the motor
  62638. * @param motorIndex index of the motor
  62639. */
  62640. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62641. /**
  62642. * Sets the motors limit
  62643. * @param joint joint to set limit on
  62644. * @param upperLimit upper limit
  62645. * @param lowerLimit lower limit
  62646. */
  62647. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62648. /**
  62649. * Syncs the position and rotation of a mesh with the impostor
  62650. * @param mesh mesh to sync
  62651. * @param impostor impostor to update the mesh with
  62652. */
  62653. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62654. /**
  62655. * Gets the radius of the impostor
  62656. * @param impostor impostor to get radius from
  62657. * @returns the radius
  62658. */
  62659. getRadius(impostor: PhysicsImpostor): number;
  62660. /**
  62661. * Gets the box size of the impostor
  62662. * @param impostor impostor to get box size from
  62663. * @param result the resulting box size
  62664. */
  62665. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62666. /**
  62667. * Disposes of the impostor
  62668. */
  62669. dispose(): void;
  62670. /**
  62671. * Does a raycast in the physics world
  62672. * @param from when should the ray start?
  62673. * @param to when should the ray end?
  62674. * @returns PhysicsRaycastResult
  62675. */
  62676. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62677. }
  62678. }
  62679. declare module BABYLON {
  62680. interface AbstractScene {
  62681. /**
  62682. * The list of reflection probes added to the scene
  62683. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62684. */
  62685. reflectionProbes: Array<ReflectionProbe>;
  62686. /**
  62687. * Removes the given reflection probe from this scene.
  62688. * @param toRemove The reflection probe to remove
  62689. * @returns The index of the removed reflection probe
  62690. */
  62691. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62692. /**
  62693. * Adds the given reflection probe to this scene.
  62694. * @param newReflectionProbe The reflection probe to add
  62695. */
  62696. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62697. }
  62698. /**
  62699. * Class used to generate realtime reflection / refraction cube textures
  62700. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62701. */
  62702. export class ReflectionProbe {
  62703. /** defines the name of the probe */
  62704. name: string;
  62705. private _scene;
  62706. private _renderTargetTexture;
  62707. private _projectionMatrix;
  62708. private _viewMatrix;
  62709. private _target;
  62710. private _add;
  62711. private _attachedMesh;
  62712. private _invertYAxis;
  62713. /** Gets or sets probe position (center of the cube map) */
  62714. position: Vector3;
  62715. /**
  62716. * Creates a new reflection probe
  62717. * @param name defines the name of the probe
  62718. * @param size defines the texture resolution (for each face)
  62719. * @param scene defines the hosting scene
  62720. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62721. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62722. */
  62723. constructor(
  62724. /** defines the name of the probe */
  62725. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62726. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62727. get samples(): number;
  62728. set samples(value: number);
  62729. /** Gets or sets the refresh rate to use (on every frame by default) */
  62730. get refreshRate(): number;
  62731. set refreshRate(value: number);
  62732. /**
  62733. * Gets the hosting scene
  62734. * @returns a Scene
  62735. */
  62736. getScene(): Scene;
  62737. /** Gets the internal CubeTexture used to render to */
  62738. get cubeTexture(): RenderTargetTexture;
  62739. /** Gets the list of meshes to render */
  62740. get renderList(): Nullable<AbstractMesh[]>;
  62741. /**
  62742. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62743. * @param mesh defines the mesh to attach to
  62744. */
  62745. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62746. /**
  62747. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62748. * @param renderingGroupId The rendering group id corresponding to its index
  62749. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62750. */
  62751. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62752. /**
  62753. * Clean all associated resources
  62754. */
  62755. dispose(): void;
  62756. /**
  62757. * Converts the reflection probe information to a readable string for debug purpose.
  62758. * @param fullDetails Supports for multiple levels of logging within scene loading
  62759. * @returns the human readable reflection probe info
  62760. */
  62761. toString(fullDetails?: boolean): string;
  62762. /**
  62763. * Get the class name of the relfection probe.
  62764. * @returns "ReflectionProbe"
  62765. */
  62766. getClassName(): string;
  62767. /**
  62768. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62769. * @returns The JSON representation of the texture
  62770. */
  62771. serialize(): any;
  62772. /**
  62773. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62774. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62775. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62776. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62777. * @returns The parsed reflection probe if successful
  62778. */
  62779. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62780. }
  62781. }
  62782. declare module BABYLON {
  62783. /** @hidden */
  62784. export var _BabylonLoaderRegistered: boolean;
  62785. /**
  62786. * Helps setting up some configuration for the babylon file loader.
  62787. */
  62788. export class BabylonFileLoaderConfiguration {
  62789. /**
  62790. * The loader does not allow injecting custom physix engine into the plugins.
  62791. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62792. * So you could set this variable to your engine import to make it work.
  62793. */
  62794. static LoaderInjectedPhysicsEngine: any;
  62795. }
  62796. }
  62797. declare module BABYLON {
  62798. /**
  62799. * The Physically based simple base material of BJS.
  62800. *
  62801. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62802. * It is used as the base class for both the specGloss and metalRough conventions.
  62803. */
  62804. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62805. /**
  62806. * Number of Simultaneous lights allowed on the material.
  62807. */
  62808. maxSimultaneousLights: number;
  62809. /**
  62810. * If sets to true, disables all the lights affecting the material.
  62811. */
  62812. disableLighting: boolean;
  62813. /**
  62814. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62815. */
  62816. environmentTexture: BaseTexture;
  62817. /**
  62818. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62819. */
  62820. invertNormalMapX: boolean;
  62821. /**
  62822. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62823. */
  62824. invertNormalMapY: boolean;
  62825. /**
  62826. * Normal map used in the model.
  62827. */
  62828. normalTexture: BaseTexture;
  62829. /**
  62830. * Emissivie color used to self-illuminate the model.
  62831. */
  62832. emissiveColor: Color3;
  62833. /**
  62834. * Emissivie texture used to self-illuminate the model.
  62835. */
  62836. emissiveTexture: BaseTexture;
  62837. /**
  62838. * Occlusion Channel Strenght.
  62839. */
  62840. occlusionStrength: number;
  62841. /**
  62842. * Occlusion Texture of the material (adding extra occlusion effects).
  62843. */
  62844. occlusionTexture: BaseTexture;
  62845. /**
  62846. * Defines the alpha limits in alpha test mode.
  62847. */
  62848. alphaCutOff: number;
  62849. /**
  62850. * Gets the current double sided mode.
  62851. */
  62852. get doubleSided(): boolean;
  62853. /**
  62854. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62855. */
  62856. set doubleSided(value: boolean);
  62857. /**
  62858. * Stores the pre-calculated light information of a mesh in a texture.
  62859. */
  62860. lightmapTexture: BaseTexture;
  62861. /**
  62862. * If true, the light map contains occlusion information instead of lighting info.
  62863. */
  62864. useLightmapAsShadowmap: boolean;
  62865. /**
  62866. * Instantiates a new PBRMaterial instance.
  62867. *
  62868. * @param name The material name
  62869. * @param scene The scene the material will be use in.
  62870. */
  62871. constructor(name: string, scene: Scene);
  62872. getClassName(): string;
  62873. }
  62874. }
  62875. declare module BABYLON {
  62876. /**
  62877. * The PBR material of BJS following the metal roughness convention.
  62878. *
  62879. * This fits to the PBR convention in the GLTF definition:
  62880. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62881. */
  62882. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62883. /**
  62884. * The base color has two different interpretations depending on the value of metalness.
  62885. * When the material is a metal, the base color is the specific measured reflectance value
  62886. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62887. * of the material.
  62888. */
  62889. baseColor: Color3;
  62890. /**
  62891. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62892. * well as opacity information in the alpha channel.
  62893. */
  62894. baseTexture: BaseTexture;
  62895. /**
  62896. * Specifies the metallic scalar value of the material.
  62897. * Can also be used to scale the metalness values of the metallic texture.
  62898. */
  62899. metallic: number;
  62900. /**
  62901. * Specifies the roughness scalar value of the material.
  62902. * Can also be used to scale the roughness values of the metallic texture.
  62903. */
  62904. roughness: number;
  62905. /**
  62906. * Texture containing both the metallic value in the B channel and the
  62907. * roughness value in the G channel to keep better precision.
  62908. */
  62909. metallicRoughnessTexture: BaseTexture;
  62910. /**
  62911. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62912. *
  62913. * @param name The material name
  62914. * @param scene The scene the material will be use in.
  62915. */
  62916. constructor(name: string, scene: Scene);
  62917. /**
  62918. * Return the currrent class name of the material.
  62919. */
  62920. getClassName(): string;
  62921. /**
  62922. * Makes a duplicate of the current material.
  62923. * @param name - name to use for the new material.
  62924. */
  62925. clone(name: string): PBRMetallicRoughnessMaterial;
  62926. /**
  62927. * Serialize the material to a parsable JSON object.
  62928. */
  62929. serialize(): any;
  62930. /**
  62931. * Parses a JSON object correponding to the serialize function.
  62932. */
  62933. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62934. }
  62935. }
  62936. declare module BABYLON {
  62937. /**
  62938. * The PBR material of BJS following the specular glossiness convention.
  62939. *
  62940. * This fits to the PBR convention in the GLTF definition:
  62941. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62942. */
  62943. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62944. /**
  62945. * Specifies the diffuse color of the material.
  62946. */
  62947. diffuseColor: Color3;
  62948. /**
  62949. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62950. * channel.
  62951. */
  62952. diffuseTexture: BaseTexture;
  62953. /**
  62954. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62955. */
  62956. specularColor: Color3;
  62957. /**
  62958. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62959. */
  62960. glossiness: number;
  62961. /**
  62962. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62963. */
  62964. specularGlossinessTexture: BaseTexture;
  62965. /**
  62966. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62967. *
  62968. * @param name The material name
  62969. * @param scene The scene the material will be use in.
  62970. */
  62971. constructor(name: string, scene: Scene);
  62972. /**
  62973. * Return the currrent class name of the material.
  62974. */
  62975. getClassName(): string;
  62976. /**
  62977. * Makes a duplicate of the current material.
  62978. * @param name - name to use for the new material.
  62979. */
  62980. clone(name: string): PBRSpecularGlossinessMaterial;
  62981. /**
  62982. * Serialize the material to a parsable JSON object.
  62983. */
  62984. serialize(): any;
  62985. /**
  62986. * Parses a JSON object correponding to the serialize function.
  62987. */
  62988. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62989. }
  62990. }
  62991. declare module BABYLON {
  62992. /**
  62993. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62994. * It can help converting any input color in a desired output one. This can then be used to create effects
  62995. * from sepia, black and white to sixties or futuristic rendering...
  62996. *
  62997. * The only supported format is currently 3dl.
  62998. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62999. */
  63000. export class ColorGradingTexture extends BaseTexture {
  63001. /**
  63002. * The texture URL.
  63003. */
  63004. url: string;
  63005. /**
  63006. * Empty line regex stored for GC.
  63007. */
  63008. private static _noneEmptyLineRegex;
  63009. private _textureMatrix;
  63010. private _onLoad;
  63011. /**
  63012. * Instantiates a ColorGradingTexture from the following parameters.
  63013. *
  63014. * @param url The location of the color gradind data (currently only supporting 3dl)
  63015. * @param sceneOrEngine The scene or engine the texture will be used in
  63016. * @param onLoad defines a callback triggered when the texture has been loaded
  63017. */
  63018. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63019. /**
  63020. * Fires the onload event from the constructor if requested.
  63021. */
  63022. private _triggerOnLoad;
  63023. /**
  63024. * Returns the texture matrix used in most of the material.
  63025. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63026. */
  63027. getTextureMatrix(): Matrix;
  63028. /**
  63029. * Occurs when the file being loaded is a .3dl LUT file.
  63030. */
  63031. private load3dlTexture;
  63032. /**
  63033. * Starts the loading process of the texture.
  63034. */
  63035. private loadTexture;
  63036. /**
  63037. * Clones the color gradind texture.
  63038. */
  63039. clone(): ColorGradingTexture;
  63040. /**
  63041. * Called during delayed load for textures.
  63042. */
  63043. delayLoad(): void;
  63044. /**
  63045. * Parses a color grading texture serialized by Babylon.
  63046. * @param parsedTexture The texture information being parsedTexture
  63047. * @param scene The scene to load the texture in
  63048. * @param rootUrl The root url of the data assets to load
  63049. * @return A color gradind texture
  63050. */
  63051. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63052. /**
  63053. * Serializes the LUT texture to json format.
  63054. */
  63055. serialize(): any;
  63056. }
  63057. }
  63058. declare module BABYLON {
  63059. /**
  63060. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63061. */
  63062. export class EquiRectangularCubeTexture extends BaseTexture {
  63063. /** The six faces of the cube. */
  63064. private static _FacesMapping;
  63065. private _noMipmap;
  63066. private _onLoad;
  63067. private _onError;
  63068. /** The size of the cubemap. */
  63069. private _size;
  63070. /** The buffer of the image. */
  63071. private _buffer;
  63072. /** The width of the input image. */
  63073. private _width;
  63074. /** The height of the input image. */
  63075. private _height;
  63076. /** The URL to the image. */
  63077. url: string;
  63078. /**
  63079. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63080. * @param url The location of the image
  63081. * @param scene The scene the texture will be used in
  63082. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63083. * @param noMipmap Forces to not generate the mipmap if true
  63084. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63085. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63086. * @param onLoad — defines a callback called when texture is loaded
  63087. * @param onError — defines a callback called if there is an error
  63088. */
  63089. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63090. /**
  63091. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63092. */
  63093. private loadImage;
  63094. /**
  63095. * Convert the image buffer into a cubemap and create a CubeTexture.
  63096. */
  63097. private loadTexture;
  63098. /**
  63099. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63100. * @param buffer The ArrayBuffer that should be converted.
  63101. * @returns The buffer as Float32Array.
  63102. */
  63103. private getFloat32ArrayFromArrayBuffer;
  63104. /**
  63105. * Get the current class name of the texture useful for serialization or dynamic coding.
  63106. * @returns "EquiRectangularCubeTexture"
  63107. */
  63108. getClassName(): string;
  63109. /**
  63110. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63111. * @returns A clone of the current EquiRectangularCubeTexture.
  63112. */
  63113. clone(): EquiRectangularCubeTexture;
  63114. }
  63115. }
  63116. declare module BABYLON {
  63117. /**
  63118. * Defines the options related to the creation of an HtmlElementTexture
  63119. */
  63120. export interface IHtmlElementTextureOptions {
  63121. /**
  63122. * Defines wether mip maps should be created or not.
  63123. */
  63124. generateMipMaps?: boolean;
  63125. /**
  63126. * Defines the sampling mode of the texture.
  63127. */
  63128. samplingMode?: number;
  63129. /**
  63130. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63131. */
  63132. engine: Nullable<ThinEngine>;
  63133. /**
  63134. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63135. */
  63136. scene: Nullable<Scene>;
  63137. }
  63138. /**
  63139. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63140. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63141. * is automatically managed.
  63142. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63143. * in your application.
  63144. *
  63145. * As the update is not automatic, you need to call them manually.
  63146. */
  63147. export class HtmlElementTexture extends BaseTexture {
  63148. /**
  63149. * The texture URL.
  63150. */
  63151. element: HTMLVideoElement | HTMLCanvasElement;
  63152. private static readonly DefaultOptions;
  63153. private _textureMatrix;
  63154. private _isVideo;
  63155. private _generateMipMaps;
  63156. private _samplingMode;
  63157. /**
  63158. * Instantiates a HtmlElementTexture from the following parameters.
  63159. *
  63160. * @param name Defines the name of the texture
  63161. * @param element Defines the video or canvas the texture is filled with
  63162. * @param options Defines the other none mandatory texture creation options
  63163. */
  63164. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63165. private _createInternalTexture;
  63166. /**
  63167. * Returns the texture matrix used in most of the material.
  63168. */
  63169. getTextureMatrix(): Matrix;
  63170. /**
  63171. * Updates the content of the texture.
  63172. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63173. */
  63174. update(invertY?: Nullable<boolean>): void;
  63175. }
  63176. }
  63177. declare module BABYLON {
  63178. /**
  63179. * Based on jsTGALoader - Javascript loader for TGA file
  63180. * By Vincent Thibault
  63181. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63182. */
  63183. export class TGATools {
  63184. private static _TYPE_INDEXED;
  63185. private static _TYPE_RGB;
  63186. private static _TYPE_GREY;
  63187. private static _TYPE_RLE_INDEXED;
  63188. private static _TYPE_RLE_RGB;
  63189. private static _TYPE_RLE_GREY;
  63190. private static _ORIGIN_MASK;
  63191. private static _ORIGIN_SHIFT;
  63192. private static _ORIGIN_BL;
  63193. private static _ORIGIN_BR;
  63194. private static _ORIGIN_UL;
  63195. private static _ORIGIN_UR;
  63196. /**
  63197. * Gets the header of a TGA file
  63198. * @param data defines the TGA data
  63199. * @returns the header
  63200. */
  63201. static GetTGAHeader(data: Uint8Array): any;
  63202. /**
  63203. * Uploads TGA content to a Babylon Texture
  63204. * @hidden
  63205. */
  63206. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63207. /** @hidden */
  63208. 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;
  63209. /** @hidden */
  63210. 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;
  63211. /** @hidden */
  63212. 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;
  63213. /** @hidden */
  63214. 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;
  63215. /** @hidden */
  63216. 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;
  63217. /** @hidden */
  63218. 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;
  63219. }
  63220. }
  63221. declare module BABYLON {
  63222. /**
  63223. * Implementation of the TGA Texture Loader.
  63224. * @hidden
  63225. */
  63226. export class _TGATextureLoader implements IInternalTextureLoader {
  63227. /**
  63228. * Defines wether the loader supports cascade loading the different faces.
  63229. */
  63230. readonly supportCascades: boolean;
  63231. /**
  63232. * This returns if the loader support the current file information.
  63233. * @param extension defines the file extension of the file being loaded
  63234. * @returns true if the loader can load the specified file
  63235. */
  63236. canLoad(extension: string): boolean;
  63237. /**
  63238. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63239. * @param data contains the texture data
  63240. * @param texture defines the BabylonJS internal texture
  63241. * @param createPolynomials will be true if polynomials have been requested
  63242. * @param onLoad defines the callback to trigger once the texture is ready
  63243. * @param onError defines the callback to trigger in case of error
  63244. */
  63245. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63246. /**
  63247. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63248. * @param data contains the texture data
  63249. * @param texture defines the BabylonJS internal texture
  63250. * @param callback defines the method to call once ready to upload
  63251. */
  63252. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63253. }
  63254. }
  63255. declare module BABYLON {
  63256. /**
  63257. * Info about the .basis files
  63258. */
  63259. class BasisFileInfo {
  63260. /**
  63261. * If the file has alpha
  63262. */
  63263. hasAlpha: boolean;
  63264. /**
  63265. * Info about each image of the basis file
  63266. */
  63267. images: Array<{
  63268. levels: Array<{
  63269. width: number;
  63270. height: number;
  63271. transcodedPixels: ArrayBufferView;
  63272. }>;
  63273. }>;
  63274. }
  63275. /**
  63276. * Result of transcoding a basis file
  63277. */
  63278. class TranscodeResult {
  63279. /**
  63280. * Info about the .basis file
  63281. */
  63282. fileInfo: BasisFileInfo;
  63283. /**
  63284. * Format to use when loading the file
  63285. */
  63286. format: number;
  63287. }
  63288. /**
  63289. * Configuration options for the Basis transcoder
  63290. */
  63291. export class BasisTranscodeConfiguration {
  63292. /**
  63293. * Supported compression formats used to determine the supported output format of the transcoder
  63294. */
  63295. supportedCompressionFormats?: {
  63296. /**
  63297. * etc1 compression format
  63298. */
  63299. etc1?: boolean;
  63300. /**
  63301. * s3tc compression format
  63302. */
  63303. s3tc?: boolean;
  63304. /**
  63305. * pvrtc compression format
  63306. */
  63307. pvrtc?: boolean;
  63308. /**
  63309. * etc2 compression format
  63310. */
  63311. etc2?: boolean;
  63312. };
  63313. /**
  63314. * If mipmap levels should be loaded for transcoded images (Default: true)
  63315. */
  63316. loadMipmapLevels?: boolean;
  63317. /**
  63318. * Index of a single image to load (Default: all images)
  63319. */
  63320. loadSingleImage?: number;
  63321. }
  63322. /**
  63323. * Used to load .Basis files
  63324. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63325. */
  63326. export class BasisTools {
  63327. private static _IgnoreSupportedFormats;
  63328. /**
  63329. * URL to use when loading the basis transcoder
  63330. */
  63331. static JSModuleURL: string;
  63332. /**
  63333. * URL to use when loading the wasm module for the transcoder
  63334. */
  63335. static WasmModuleURL: string;
  63336. /**
  63337. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63338. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63339. * @returns internal format corresponding to the Basis format
  63340. */
  63341. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63342. private static _WorkerPromise;
  63343. private static _Worker;
  63344. private static _actionId;
  63345. private static _CreateWorkerAsync;
  63346. /**
  63347. * Transcodes a loaded image file to compressed pixel data
  63348. * @param data image data to transcode
  63349. * @param config configuration options for the transcoding
  63350. * @returns a promise resulting in the transcoded image
  63351. */
  63352. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63353. /**
  63354. * Loads a texture from the transcode result
  63355. * @param texture texture load to
  63356. * @param transcodeResult the result of transcoding the basis file to load from
  63357. */
  63358. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63359. }
  63360. }
  63361. declare module BABYLON {
  63362. /**
  63363. * Loader for .basis file format
  63364. */
  63365. export class _BasisTextureLoader implements IInternalTextureLoader {
  63366. /**
  63367. * Defines whether the loader supports cascade loading the different faces.
  63368. */
  63369. readonly supportCascades: boolean;
  63370. /**
  63371. * This returns if the loader support the current file information.
  63372. * @param extension defines the file extension of the file being loaded
  63373. * @returns true if the loader can load the specified file
  63374. */
  63375. canLoad(extension: string): boolean;
  63376. /**
  63377. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63378. * @param data contains the texture data
  63379. * @param texture defines the BabylonJS internal texture
  63380. * @param createPolynomials will be true if polynomials have been requested
  63381. * @param onLoad defines the callback to trigger once the texture is ready
  63382. * @param onError defines the callback to trigger in case of error
  63383. */
  63384. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63385. /**
  63386. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63387. * @param data contains the texture data
  63388. * @param texture defines the BabylonJS internal texture
  63389. * @param callback defines the method to call once ready to upload
  63390. */
  63391. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63392. }
  63393. }
  63394. declare module BABYLON {
  63395. /**
  63396. * Defines the basic options interface of a TexturePacker Frame
  63397. */
  63398. export interface ITexturePackerFrame {
  63399. /**
  63400. * The frame ID
  63401. */
  63402. id: number;
  63403. /**
  63404. * The frames Scale
  63405. */
  63406. scale: Vector2;
  63407. /**
  63408. * The Frames offset
  63409. */
  63410. offset: Vector2;
  63411. }
  63412. /**
  63413. * This is a support class for frame Data on texture packer sets.
  63414. */
  63415. export class TexturePackerFrame implements ITexturePackerFrame {
  63416. /**
  63417. * The frame ID
  63418. */
  63419. id: number;
  63420. /**
  63421. * The frames Scale
  63422. */
  63423. scale: Vector2;
  63424. /**
  63425. * The Frames offset
  63426. */
  63427. offset: Vector2;
  63428. /**
  63429. * Initializes a texture package frame.
  63430. * @param id The numerical frame identifier
  63431. * @param scale Scalar Vector2 for UV frame
  63432. * @param offset Vector2 for the frame position in UV units.
  63433. * @returns TexturePackerFrame
  63434. */
  63435. constructor(id: number, scale: Vector2, offset: Vector2);
  63436. }
  63437. }
  63438. declare module BABYLON {
  63439. /**
  63440. * Defines the basic options interface of a TexturePacker
  63441. */
  63442. export interface ITexturePackerOptions {
  63443. /**
  63444. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63445. */
  63446. map?: string[];
  63447. /**
  63448. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63449. */
  63450. uvsIn?: string;
  63451. /**
  63452. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63453. */
  63454. uvsOut?: string;
  63455. /**
  63456. * number representing the layout style. Defaults to LAYOUT_STRIP
  63457. */
  63458. layout?: number;
  63459. /**
  63460. * number of columns if using custom column count layout(2). This defaults to 4.
  63461. */
  63462. colnum?: number;
  63463. /**
  63464. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63465. */
  63466. updateInputMeshes?: boolean;
  63467. /**
  63468. * boolean flag to dispose all the source textures. Defaults to true.
  63469. */
  63470. disposeSources?: boolean;
  63471. /**
  63472. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63473. */
  63474. fillBlanks?: boolean;
  63475. /**
  63476. * string value representing the context fill style color. Defaults to 'black'.
  63477. */
  63478. customFillColor?: string;
  63479. /**
  63480. * Width and Height Value of each Frame in the TexturePacker Sets
  63481. */
  63482. frameSize?: number;
  63483. /**
  63484. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63485. */
  63486. paddingRatio?: number;
  63487. /**
  63488. * Number that declares the fill method for the padding gutter.
  63489. */
  63490. paddingMode?: number;
  63491. /**
  63492. * If in SUBUV_COLOR padding mode what color to use.
  63493. */
  63494. paddingColor?: Color3 | Color4;
  63495. }
  63496. /**
  63497. * Defines the basic interface of a TexturePacker JSON File
  63498. */
  63499. export interface ITexturePackerJSON {
  63500. /**
  63501. * The frame ID
  63502. */
  63503. name: string;
  63504. /**
  63505. * The base64 channel data
  63506. */
  63507. sets: any;
  63508. /**
  63509. * The options of the Packer
  63510. */
  63511. options: ITexturePackerOptions;
  63512. /**
  63513. * The frame data of the Packer
  63514. */
  63515. frames: Array<number>;
  63516. }
  63517. /**
  63518. * This is a support class that generates a series of packed texture sets.
  63519. * @see https://doc.babylonjs.com/babylon101/materials
  63520. */
  63521. export class TexturePacker {
  63522. /** Packer Layout Constant 0 */
  63523. static readonly LAYOUT_STRIP: number;
  63524. /** Packer Layout Constant 1 */
  63525. static readonly LAYOUT_POWER2: number;
  63526. /** Packer Layout Constant 2 */
  63527. static readonly LAYOUT_COLNUM: number;
  63528. /** Packer Layout Constant 0 */
  63529. static readonly SUBUV_WRAP: number;
  63530. /** Packer Layout Constant 1 */
  63531. static readonly SUBUV_EXTEND: number;
  63532. /** Packer Layout Constant 2 */
  63533. static readonly SUBUV_COLOR: number;
  63534. /** The Name of the Texture Package */
  63535. name: string;
  63536. /** The scene scope of the TexturePacker */
  63537. scene: Scene;
  63538. /** The Meshes to target */
  63539. meshes: AbstractMesh[];
  63540. /** Arguments passed with the Constructor */
  63541. options: ITexturePackerOptions;
  63542. /** The promise that is started upon initialization */
  63543. promise: Nullable<Promise<TexturePacker | string>>;
  63544. /** The Container object for the channel sets that are generated */
  63545. sets: object;
  63546. /** The Container array for the frames that are generated */
  63547. frames: TexturePackerFrame[];
  63548. /** The expected number of textures the system is parsing. */
  63549. private _expecting;
  63550. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63551. private _paddingValue;
  63552. /**
  63553. * Initializes a texture package series from an array of meshes or a single mesh.
  63554. * @param name The name of the package
  63555. * @param meshes The target meshes to compose the package from
  63556. * @param options The arguments that texture packer should follow while building.
  63557. * @param scene The scene which the textures are scoped to.
  63558. * @returns TexturePacker
  63559. */
  63560. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63561. /**
  63562. * Starts the package process
  63563. * @param resolve The promises resolution function
  63564. * @returns TexturePacker
  63565. */
  63566. private _createFrames;
  63567. /**
  63568. * Calculates the Size of the Channel Sets
  63569. * @returns Vector2
  63570. */
  63571. private _calculateSize;
  63572. /**
  63573. * Calculates the UV data for the frames.
  63574. * @param baseSize the base frameSize
  63575. * @param padding the base frame padding
  63576. * @param dtSize size of the Dynamic Texture for that channel
  63577. * @param dtUnits is 1/dtSize
  63578. * @param update flag to update the input meshes
  63579. */
  63580. private _calculateMeshUVFrames;
  63581. /**
  63582. * Calculates the frames Offset.
  63583. * @param index of the frame
  63584. * @returns Vector2
  63585. */
  63586. private _getFrameOffset;
  63587. /**
  63588. * Updates a Mesh to the frame data
  63589. * @param mesh that is the target
  63590. * @param frameID or the frame index
  63591. */
  63592. private _updateMeshUV;
  63593. /**
  63594. * Updates a Meshes materials to use the texture packer channels
  63595. * @param m is the mesh to target
  63596. * @param force all channels on the packer to be set.
  63597. */
  63598. private _updateTextureReferences;
  63599. /**
  63600. * Public method to set a Mesh to a frame
  63601. * @param m that is the target
  63602. * @param frameID or the frame index
  63603. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63604. */
  63605. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63606. /**
  63607. * Starts the async promise to compile the texture packer.
  63608. * @returns Promise<void>
  63609. */
  63610. processAsync(): Promise<void>;
  63611. /**
  63612. * Disposes all textures associated with this packer
  63613. */
  63614. dispose(): void;
  63615. /**
  63616. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63617. * @param imageType is the image type to use.
  63618. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63619. */
  63620. download(imageType?: string, quality?: number): void;
  63621. /**
  63622. * Public method to load a texturePacker JSON file.
  63623. * @param data of the JSON file in string format.
  63624. */
  63625. updateFromJSON(data: string): void;
  63626. }
  63627. }
  63628. declare module BABYLON {
  63629. /**
  63630. * 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.
  63631. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63632. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63633. */
  63634. export class CustomProceduralTexture extends ProceduralTexture {
  63635. private _animate;
  63636. private _time;
  63637. private _config;
  63638. private _texturePath;
  63639. /**
  63640. * Instantiates a new Custom Procedural Texture.
  63641. * 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.
  63642. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63643. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63644. * @param name Define the name of the texture
  63645. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63646. * @param size Define the size of the texture to create
  63647. * @param scene Define the scene the texture belongs to
  63648. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63649. * @param generateMipMaps Define if the texture should creates mip maps or not
  63650. */
  63651. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63652. private _loadJson;
  63653. /**
  63654. * Is the texture ready to be used ? (rendered at least once)
  63655. * @returns true if ready, otherwise, false.
  63656. */
  63657. isReady(): boolean;
  63658. /**
  63659. * Render the texture to its associated render target.
  63660. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63661. */
  63662. render(useCameraPostProcess?: boolean): void;
  63663. /**
  63664. * Update the list of dependant textures samplers in the shader.
  63665. */
  63666. updateTextures(): void;
  63667. /**
  63668. * Update the uniform values of the procedural texture in the shader.
  63669. */
  63670. updateShaderUniforms(): void;
  63671. /**
  63672. * Define if the texture animates or not.
  63673. */
  63674. get animate(): boolean;
  63675. set animate(value: boolean);
  63676. }
  63677. }
  63678. declare module BABYLON {
  63679. /** @hidden */
  63680. export var noisePixelShader: {
  63681. name: string;
  63682. shader: string;
  63683. };
  63684. }
  63685. declare module BABYLON {
  63686. /**
  63687. * Class used to generate noise procedural textures
  63688. */
  63689. export class NoiseProceduralTexture extends ProceduralTexture {
  63690. /** Gets or sets the start time (default is 0) */
  63691. time: number;
  63692. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63693. brightness: number;
  63694. /** Defines the number of octaves to process */
  63695. octaves: number;
  63696. /** Defines the level of persistence (0.8 by default) */
  63697. persistence: number;
  63698. /** Gets or sets animation speed factor (default is 1) */
  63699. animationSpeedFactor: number;
  63700. /**
  63701. * Creates a new NoiseProceduralTexture
  63702. * @param name defines the name fo the texture
  63703. * @param size defines the size of the texture (default is 256)
  63704. * @param scene defines the hosting scene
  63705. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63706. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63707. */
  63708. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63709. private _updateShaderUniforms;
  63710. protected _getDefines(): string;
  63711. /** Generate the current state of the procedural texture */
  63712. render(useCameraPostProcess?: boolean): void;
  63713. /**
  63714. * Serializes this noise procedural texture
  63715. * @returns a serialized noise procedural texture object
  63716. */
  63717. serialize(): any;
  63718. /**
  63719. * Clone the texture.
  63720. * @returns the cloned texture
  63721. */
  63722. clone(): NoiseProceduralTexture;
  63723. /**
  63724. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63725. * @param parsedTexture defines parsed texture data
  63726. * @param scene defines the current scene
  63727. * @param rootUrl defines the root URL containing noise procedural texture information
  63728. * @returns a parsed NoiseProceduralTexture
  63729. */
  63730. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63731. }
  63732. }
  63733. declare module BABYLON {
  63734. /**
  63735. * Raw cube texture where the raw buffers are passed in
  63736. */
  63737. export class RawCubeTexture extends CubeTexture {
  63738. /**
  63739. * Creates a cube texture where the raw buffers are passed in.
  63740. * @param scene defines the scene the texture is attached to
  63741. * @param data defines the array of data to use to create each face
  63742. * @param size defines the size of the textures
  63743. * @param format defines the format of the data
  63744. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63745. * @param generateMipMaps defines if the engine should generate the mip levels
  63746. * @param invertY defines if data must be stored with Y axis inverted
  63747. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63748. * @param compression defines the compression used (null by default)
  63749. */
  63750. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63751. /**
  63752. * Updates the raw cube texture.
  63753. * @param data defines the data to store
  63754. * @param format defines the data format
  63755. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63756. * @param invertY defines if data must be stored with Y axis inverted
  63757. * @param compression defines the compression used (null by default)
  63758. * @param level defines which level of the texture to update
  63759. */
  63760. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63761. /**
  63762. * Updates a raw cube texture with RGBD encoded data.
  63763. * @param data defines the array of data [mipmap][face] to use to create each face
  63764. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63765. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63766. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63767. * @returns a promsie that resolves when the operation is complete
  63768. */
  63769. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63770. /**
  63771. * Clones the raw cube texture.
  63772. * @return a new cube texture
  63773. */
  63774. clone(): CubeTexture;
  63775. /** @hidden */
  63776. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63777. }
  63778. }
  63779. declare module BABYLON {
  63780. /**
  63781. * Class used to store 2D array textures containing user data
  63782. */
  63783. export class RawTexture2DArray extends Texture {
  63784. /** Gets or sets the texture format to use */
  63785. format: number;
  63786. /**
  63787. * Create a new RawTexture2DArray
  63788. * @param data defines the data of the texture
  63789. * @param width defines the width of the texture
  63790. * @param height defines the height of the texture
  63791. * @param depth defines the number of layers of the texture
  63792. * @param format defines the texture format to use
  63793. * @param scene defines the hosting scene
  63794. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63795. * @param invertY defines if texture must be stored with Y axis inverted
  63796. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63797. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63798. */
  63799. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63800. /** Gets or sets the texture format to use */
  63801. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63802. /**
  63803. * Update the texture with new data
  63804. * @param data defines the data to store in the texture
  63805. */
  63806. update(data: ArrayBufferView): void;
  63807. }
  63808. }
  63809. declare module BABYLON {
  63810. /**
  63811. * Class used to store 3D textures containing user data
  63812. */
  63813. export class RawTexture3D extends Texture {
  63814. /** Gets or sets the texture format to use */
  63815. format: number;
  63816. /**
  63817. * Create a new RawTexture3D
  63818. * @param data defines the data of the texture
  63819. * @param width defines the width of the texture
  63820. * @param height defines the height of the texture
  63821. * @param depth defines the depth of the texture
  63822. * @param format defines the texture format to use
  63823. * @param scene defines the hosting scene
  63824. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63825. * @param invertY defines if texture must be stored with Y axis inverted
  63826. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63827. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63828. */
  63829. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63830. /** Gets or sets the texture format to use */
  63831. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63832. /**
  63833. * Update the texture with new data
  63834. * @param data defines the data to store in the texture
  63835. */
  63836. update(data: ArrayBufferView): void;
  63837. }
  63838. }
  63839. declare module BABYLON {
  63840. /**
  63841. * Creates a refraction texture used by refraction channel of the standard material.
  63842. * It is like a mirror but to see through a material.
  63843. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63844. */
  63845. export class RefractionTexture extends RenderTargetTexture {
  63846. /**
  63847. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63848. * 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.
  63849. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63850. */
  63851. refractionPlane: Plane;
  63852. /**
  63853. * Define how deep under the surface we should see.
  63854. */
  63855. depth: number;
  63856. /**
  63857. * Creates a refraction texture used by refraction channel of the standard material.
  63858. * It is like a mirror but to see through a material.
  63859. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63860. * @param name Define the texture name
  63861. * @param size Define the size of the underlying texture
  63862. * @param scene Define the scene the refraction belongs to
  63863. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63864. */
  63865. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63866. /**
  63867. * Clone the refraction texture.
  63868. * @returns the cloned texture
  63869. */
  63870. clone(): RefractionTexture;
  63871. /**
  63872. * Serialize the texture to a JSON representation you could use in Parse later on
  63873. * @returns the serialized JSON representation
  63874. */
  63875. serialize(): any;
  63876. }
  63877. }
  63878. declare module BABYLON {
  63879. /**
  63880. * Block used to add support for vertex skinning (bones)
  63881. */
  63882. export class BonesBlock extends NodeMaterialBlock {
  63883. /**
  63884. * Creates a new BonesBlock
  63885. * @param name defines the block name
  63886. */
  63887. constructor(name: string);
  63888. /**
  63889. * Initialize the block and prepare the context for build
  63890. * @param state defines the state that will be used for the build
  63891. */
  63892. initialize(state: NodeMaterialBuildState): void;
  63893. /**
  63894. * Gets the current class name
  63895. * @returns the class name
  63896. */
  63897. getClassName(): string;
  63898. /**
  63899. * Gets the matrix indices input component
  63900. */
  63901. get matricesIndices(): NodeMaterialConnectionPoint;
  63902. /**
  63903. * Gets the matrix weights input component
  63904. */
  63905. get matricesWeights(): NodeMaterialConnectionPoint;
  63906. /**
  63907. * Gets the extra matrix indices input component
  63908. */
  63909. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63910. /**
  63911. * Gets the extra matrix weights input component
  63912. */
  63913. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63914. /**
  63915. * Gets the world input component
  63916. */
  63917. get world(): NodeMaterialConnectionPoint;
  63918. /**
  63919. * Gets the output component
  63920. */
  63921. get output(): NodeMaterialConnectionPoint;
  63922. autoConfigure(material: NodeMaterial): void;
  63923. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63924. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63926. protected _buildBlock(state: NodeMaterialBuildState): this;
  63927. }
  63928. }
  63929. declare module BABYLON {
  63930. /**
  63931. * Block used to add support for instances
  63932. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63933. */
  63934. export class InstancesBlock extends NodeMaterialBlock {
  63935. /**
  63936. * Creates a new InstancesBlock
  63937. * @param name defines the block name
  63938. */
  63939. constructor(name: string);
  63940. /**
  63941. * Gets the current class name
  63942. * @returns the class name
  63943. */
  63944. getClassName(): string;
  63945. /**
  63946. * Gets the first world row input component
  63947. */
  63948. get world0(): NodeMaterialConnectionPoint;
  63949. /**
  63950. * Gets the second world row input component
  63951. */
  63952. get world1(): NodeMaterialConnectionPoint;
  63953. /**
  63954. * Gets the third world row input component
  63955. */
  63956. get world2(): NodeMaterialConnectionPoint;
  63957. /**
  63958. * Gets the forth world row input component
  63959. */
  63960. get world3(): NodeMaterialConnectionPoint;
  63961. /**
  63962. * Gets the world input component
  63963. */
  63964. get world(): NodeMaterialConnectionPoint;
  63965. /**
  63966. * Gets the output component
  63967. */
  63968. get output(): NodeMaterialConnectionPoint;
  63969. /**
  63970. * Gets the isntanceID component
  63971. */
  63972. get instanceID(): NodeMaterialConnectionPoint;
  63973. autoConfigure(material: NodeMaterial): void;
  63974. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63975. protected _buildBlock(state: NodeMaterialBuildState): this;
  63976. }
  63977. }
  63978. declare module BABYLON {
  63979. /**
  63980. * Block used to add morph targets support to vertex shader
  63981. */
  63982. export class MorphTargetsBlock extends NodeMaterialBlock {
  63983. private _repeatableContentAnchor;
  63984. /**
  63985. * Create a new MorphTargetsBlock
  63986. * @param name defines the block name
  63987. */
  63988. constructor(name: string);
  63989. /**
  63990. * Gets the current class name
  63991. * @returns the class name
  63992. */
  63993. getClassName(): string;
  63994. /**
  63995. * Gets the position input component
  63996. */
  63997. get position(): NodeMaterialConnectionPoint;
  63998. /**
  63999. * Gets the normal input component
  64000. */
  64001. get normal(): NodeMaterialConnectionPoint;
  64002. /**
  64003. * Gets the tangent input component
  64004. */
  64005. get tangent(): NodeMaterialConnectionPoint;
  64006. /**
  64007. * Gets the tangent input component
  64008. */
  64009. get uv(): NodeMaterialConnectionPoint;
  64010. /**
  64011. * Gets the position output component
  64012. */
  64013. get positionOutput(): NodeMaterialConnectionPoint;
  64014. /**
  64015. * Gets the normal output component
  64016. */
  64017. get normalOutput(): NodeMaterialConnectionPoint;
  64018. /**
  64019. * Gets the tangent output component
  64020. */
  64021. get tangentOutput(): NodeMaterialConnectionPoint;
  64022. /**
  64023. * Gets the tangent output component
  64024. */
  64025. get uvOutput(): NodeMaterialConnectionPoint;
  64026. initialize(state: NodeMaterialBuildState): void;
  64027. autoConfigure(material: NodeMaterial): void;
  64028. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64029. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64030. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64031. protected _buildBlock(state: NodeMaterialBuildState): this;
  64032. }
  64033. }
  64034. declare module BABYLON {
  64035. /**
  64036. * Block used to get data information from a light
  64037. */
  64038. export class LightInformationBlock extends NodeMaterialBlock {
  64039. private _lightDataUniformName;
  64040. private _lightColorUniformName;
  64041. private _lightTypeDefineName;
  64042. /**
  64043. * Gets or sets the light associated with this block
  64044. */
  64045. light: Nullable<Light>;
  64046. /**
  64047. * Creates a new LightInformationBlock
  64048. * @param name defines the block name
  64049. */
  64050. constructor(name: string);
  64051. /**
  64052. * Gets the current class name
  64053. * @returns the class name
  64054. */
  64055. getClassName(): string;
  64056. /**
  64057. * Gets the world position input component
  64058. */
  64059. get worldPosition(): NodeMaterialConnectionPoint;
  64060. /**
  64061. * Gets the direction output component
  64062. */
  64063. get direction(): NodeMaterialConnectionPoint;
  64064. /**
  64065. * Gets the direction output component
  64066. */
  64067. get color(): NodeMaterialConnectionPoint;
  64068. /**
  64069. * Gets the direction output component
  64070. */
  64071. get intensity(): NodeMaterialConnectionPoint;
  64072. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64073. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64074. protected _buildBlock(state: NodeMaterialBuildState): this;
  64075. serialize(): any;
  64076. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64077. }
  64078. }
  64079. declare module BABYLON {
  64080. /**
  64081. * Block used to add image processing support to fragment shader
  64082. */
  64083. export class ImageProcessingBlock extends NodeMaterialBlock {
  64084. /**
  64085. * Create a new ImageProcessingBlock
  64086. * @param name defines the block name
  64087. */
  64088. constructor(name: string);
  64089. /**
  64090. * Gets the current class name
  64091. * @returns the class name
  64092. */
  64093. getClassName(): string;
  64094. /**
  64095. * Gets the color input component
  64096. */
  64097. get color(): NodeMaterialConnectionPoint;
  64098. /**
  64099. * Gets the output component
  64100. */
  64101. get output(): NodeMaterialConnectionPoint;
  64102. /**
  64103. * Initialize the block and prepare the context for build
  64104. * @param state defines the state that will be used for the build
  64105. */
  64106. initialize(state: NodeMaterialBuildState): void;
  64107. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64108. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64109. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64110. protected _buildBlock(state: NodeMaterialBuildState): this;
  64111. }
  64112. }
  64113. declare module BABYLON {
  64114. /**
  64115. * Block used to pertub normals based on a normal map
  64116. */
  64117. export class PerturbNormalBlock extends NodeMaterialBlock {
  64118. private _tangentSpaceParameterName;
  64119. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64120. invertX: boolean;
  64121. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64122. invertY: boolean;
  64123. /**
  64124. * Create a new PerturbNormalBlock
  64125. * @param name defines the block name
  64126. */
  64127. constructor(name: string);
  64128. /**
  64129. * Gets the current class name
  64130. * @returns the class name
  64131. */
  64132. getClassName(): string;
  64133. /**
  64134. * Gets the world position input component
  64135. */
  64136. get worldPosition(): NodeMaterialConnectionPoint;
  64137. /**
  64138. * Gets the world normal input component
  64139. */
  64140. get worldNormal(): NodeMaterialConnectionPoint;
  64141. /**
  64142. * Gets the world tangent input component
  64143. */
  64144. get worldTangent(): NodeMaterialConnectionPoint;
  64145. /**
  64146. * Gets the uv input component
  64147. */
  64148. get uv(): NodeMaterialConnectionPoint;
  64149. /**
  64150. * Gets the normal map color input component
  64151. */
  64152. get normalMapColor(): NodeMaterialConnectionPoint;
  64153. /**
  64154. * Gets the strength input component
  64155. */
  64156. get strength(): NodeMaterialConnectionPoint;
  64157. /**
  64158. * Gets the output component
  64159. */
  64160. get output(): NodeMaterialConnectionPoint;
  64161. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64162. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64163. autoConfigure(material: NodeMaterial): void;
  64164. protected _buildBlock(state: NodeMaterialBuildState): this;
  64165. protected _dumpPropertiesCode(): string;
  64166. serialize(): any;
  64167. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64168. }
  64169. }
  64170. declare module BABYLON {
  64171. /**
  64172. * Block used to discard a pixel if a value is smaller than a cutoff
  64173. */
  64174. export class DiscardBlock extends NodeMaterialBlock {
  64175. /**
  64176. * Create a new DiscardBlock
  64177. * @param name defines the block name
  64178. */
  64179. constructor(name: string);
  64180. /**
  64181. * Gets the current class name
  64182. * @returns the class name
  64183. */
  64184. getClassName(): string;
  64185. /**
  64186. * Gets the color input component
  64187. */
  64188. get value(): NodeMaterialConnectionPoint;
  64189. /**
  64190. * Gets the cutoff input component
  64191. */
  64192. get cutoff(): NodeMaterialConnectionPoint;
  64193. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64194. }
  64195. }
  64196. declare module BABYLON {
  64197. /**
  64198. * Block used to test if the fragment shader is front facing
  64199. */
  64200. export class FrontFacingBlock extends NodeMaterialBlock {
  64201. /**
  64202. * Creates a new FrontFacingBlock
  64203. * @param name defines the block name
  64204. */
  64205. constructor(name: string);
  64206. /**
  64207. * Gets the current class name
  64208. * @returns the class name
  64209. */
  64210. getClassName(): string;
  64211. /**
  64212. * Gets the output component
  64213. */
  64214. get output(): NodeMaterialConnectionPoint;
  64215. protected _buildBlock(state: NodeMaterialBuildState): this;
  64216. }
  64217. }
  64218. declare module BABYLON {
  64219. /**
  64220. * Block used to get the derivative value on x and y of a given input
  64221. */
  64222. export class DerivativeBlock extends NodeMaterialBlock {
  64223. /**
  64224. * Create a new DerivativeBlock
  64225. * @param name defines the block name
  64226. */
  64227. constructor(name: string);
  64228. /**
  64229. * Gets the current class name
  64230. * @returns the class name
  64231. */
  64232. getClassName(): string;
  64233. /**
  64234. * Gets the input component
  64235. */
  64236. get input(): NodeMaterialConnectionPoint;
  64237. /**
  64238. * Gets the derivative output on x
  64239. */
  64240. get dx(): NodeMaterialConnectionPoint;
  64241. /**
  64242. * Gets the derivative output on y
  64243. */
  64244. get dy(): NodeMaterialConnectionPoint;
  64245. protected _buildBlock(state: NodeMaterialBuildState): this;
  64246. }
  64247. }
  64248. declare module BABYLON {
  64249. /**
  64250. * Block used to make gl_FragCoord available
  64251. */
  64252. export class FragCoordBlock extends NodeMaterialBlock {
  64253. /**
  64254. * Creates a new FragCoordBlock
  64255. * @param name defines the block name
  64256. */
  64257. constructor(name: string);
  64258. /**
  64259. * Gets the current class name
  64260. * @returns the class name
  64261. */
  64262. getClassName(): string;
  64263. /**
  64264. * Gets the xy component
  64265. */
  64266. get xy(): NodeMaterialConnectionPoint;
  64267. /**
  64268. * Gets the xyz component
  64269. */
  64270. get xyz(): NodeMaterialConnectionPoint;
  64271. /**
  64272. * Gets the xyzw component
  64273. */
  64274. get xyzw(): NodeMaterialConnectionPoint;
  64275. /**
  64276. * Gets the x component
  64277. */
  64278. get x(): NodeMaterialConnectionPoint;
  64279. /**
  64280. * Gets the y component
  64281. */
  64282. get y(): NodeMaterialConnectionPoint;
  64283. /**
  64284. * Gets the z component
  64285. */
  64286. get z(): NodeMaterialConnectionPoint;
  64287. /**
  64288. * Gets the w component
  64289. */
  64290. get output(): NodeMaterialConnectionPoint;
  64291. protected writeOutputs(state: NodeMaterialBuildState): string;
  64292. protected _buildBlock(state: NodeMaterialBuildState): this;
  64293. }
  64294. }
  64295. declare module BABYLON {
  64296. /**
  64297. * Block used to get the screen sizes
  64298. */
  64299. export class ScreenSizeBlock extends NodeMaterialBlock {
  64300. private _varName;
  64301. private _scene;
  64302. /**
  64303. * Creates a new ScreenSizeBlock
  64304. * @param name defines the block name
  64305. */
  64306. constructor(name: string);
  64307. /**
  64308. * Gets the current class name
  64309. * @returns the class name
  64310. */
  64311. getClassName(): string;
  64312. /**
  64313. * Gets the xy component
  64314. */
  64315. get xy(): NodeMaterialConnectionPoint;
  64316. /**
  64317. * Gets the x component
  64318. */
  64319. get x(): NodeMaterialConnectionPoint;
  64320. /**
  64321. * Gets the y component
  64322. */
  64323. get y(): NodeMaterialConnectionPoint;
  64324. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64325. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64326. protected _buildBlock(state: NodeMaterialBuildState): this;
  64327. }
  64328. }
  64329. declare module BABYLON {
  64330. /**
  64331. * Block used to add support for scene fog
  64332. */
  64333. export class FogBlock extends NodeMaterialBlock {
  64334. private _fogDistanceName;
  64335. private _fogParameters;
  64336. /**
  64337. * Create a new FogBlock
  64338. * @param name defines the block name
  64339. */
  64340. constructor(name: string);
  64341. /**
  64342. * Gets the current class name
  64343. * @returns the class name
  64344. */
  64345. getClassName(): string;
  64346. /**
  64347. * Gets the world position input component
  64348. */
  64349. get worldPosition(): NodeMaterialConnectionPoint;
  64350. /**
  64351. * Gets the view input component
  64352. */
  64353. get view(): NodeMaterialConnectionPoint;
  64354. /**
  64355. * Gets the color input component
  64356. */
  64357. get input(): NodeMaterialConnectionPoint;
  64358. /**
  64359. * Gets the fog color input component
  64360. */
  64361. get fogColor(): NodeMaterialConnectionPoint;
  64362. /**
  64363. * Gets the output component
  64364. */
  64365. get output(): NodeMaterialConnectionPoint;
  64366. autoConfigure(material: NodeMaterial): void;
  64367. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64368. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64369. protected _buildBlock(state: NodeMaterialBuildState): this;
  64370. }
  64371. }
  64372. declare module BABYLON {
  64373. /**
  64374. * Block used to add light in the fragment shader
  64375. */
  64376. export class LightBlock extends NodeMaterialBlock {
  64377. private _lightId;
  64378. /**
  64379. * Gets or sets the light associated with this block
  64380. */
  64381. light: Nullable<Light>;
  64382. /**
  64383. * Create a new LightBlock
  64384. * @param name defines the block name
  64385. */
  64386. constructor(name: string);
  64387. /**
  64388. * Gets the current class name
  64389. * @returns the class name
  64390. */
  64391. getClassName(): string;
  64392. /**
  64393. * Gets the world position input component
  64394. */
  64395. get worldPosition(): NodeMaterialConnectionPoint;
  64396. /**
  64397. * Gets the world normal input component
  64398. */
  64399. get worldNormal(): NodeMaterialConnectionPoint;
  64400. /**
  64401. * Gets the camera (or eye) position component
  64402. */
  64403. get cameraPosition(): NodeMaterialConnectionPoint;
  64404. /**
  64405. * Gets the glossiness component
  64406. */
  64407. get glossiness(): NodeMaterialConnectionPoint;
  64408. /**
  64409. * Gets the glossinness power component
  64410. */
  64411. get glossPower(): NodeMaterialConnectionPoint;
  64412. /**
  64413. * Gets the diffuse color component
  64414. */
  64415. get diffuseColor(): NodeMaterialConnectionPoint;
  64416. /**
  64417. * Gets the specular color component
  64418. */
  64419. get specularColor(): NodeMaterialConnectionPoint;
  64420. /**
  64421. * Gets the view matrix component
  64422. */
  64423. get view(): NodeMaterialConnectionPoint;
  64424. /**
  64425. * Gets the diffuse output component
  64426. */
  64427. get diffuseOutput(): NodeMaterialConnectionPoint;
  64428. /**
  64429. * Gets the specular output component
  64430. */
  64431. get specularOutput(): NodeMaterialConnectionPoint;
  64432. /**
  64433. * Gets the shadow output component
  64434. */
  64435. get shadow(): NodeMaterialConnectionPoint;
  64436. autoConfigure(material: NodeMaterial): void;
  64437. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64438. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64439. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64440. private _injectVertexCode;
  64441. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64442. serialize(): any;
  64443. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64444. }
  64445. }
  64446. declare module BABYLON {
  64447. /**
  64448. * Block used to read a reflection texture from a sampler
  64449. */
  64450. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64451. /**
  64452. * Create a new ReflectionTextureBlock
  64453. * @param name defines the block name
  64454. */
  64455. constructor(name: string);
  64456. /**
  64457. * Gets the current class name
  64458. * @returns the class name
  64459. */
  64460. getClassName(): string;
  64461. /**
  64462. * Gets the world position input component
  64463. */
  64464. get position(): NodeMaterialConnectionPoint;
  64465. /**
  64466. * Gets the world position input component
  64467. */
  64468. get worldPosition(): NodeMaterialConnectionPoint;
  64469. /**
  64470. * Gets the world normal input component
  64471. */
  64472. get worldNormal(): NodeMaterialConnectionPoint;
  64473. /**
  64474. * Gets the world input component
  64475. */
  64476. get world(): NodeMaterialConnectionPoint;
  64477. /**
  64478. * Gets the camera (or eye) position component
  64479. */
  64480. get cameraPosition(): NodeMaterialConnectionPoint;
  64481. /**
  64482. * Gets the view input component
  64483. */
  64484. get view(): NodeMaterialConnectionPoint;
  64485. /**
  64486. * Gets the rgb output component
  64487. */
  64488. get rgb(): NodeMaterialConnectionPoint;
  64489. /**
  64490. * Gets the rgba output component
  64491. */
  64492. get rgba(): NodeMaterialConnectionPoint;
  64493. /**
  64494. * Gets the r output component
  64495. */
  64496. get r(): NodeMaterialConnectionPoint;
  64497. /**
  64498. * Gets the g output component
  64499. */
  64500. get g(): NodeMaterialConnectionPoint;
  64501. /**
  64502. * Gets the b output component
  64503. */
  64504. get b(): NodeMaterialConnectionPoint;
  64505. /**
  64506. * Gets the a output component
  64507. */
  64508. get a(): NodeMaterialConnectionPoint;
  64509. autoConfigure(material: NodeMaterial): void;
  64510. protected _buildBlock(state: NodeMaterialBuildState): this;
  64511. }
  64512. }
  64513. declare module BABYLON {
  64514. /**
  64515. * Block used to add 2 vectors
  64516. */
  64517. export class AddBlock extends NodeMaterialBlock {
  64518. /**
  64519. * Creates a new AddBlock
  64520. * @param name defines the block name
  64521. */
  64522. constructor(name: string);
  64523. /**
  64524. * Gets the current class name
  64525. * @returns the class name
  64526. */
  64527. getClassName(): string;
  64528. /**
  64529. * Gets the left operand input component
  64530. */
  64531. get left(): NodeMaterialConnectionPoint;
  64532. /**
  64533. * Gets the right operand input component
  64534. */
  64535. get right(): NodeMaterialConnectionPoint;
  64536. /**
  64537. * Gets the output component
  64538. */
  64539. get output(): NodeMaterialConnectionPoint;
  64540. protected _buildBlock(state: NodeMaterialBuildState): this;
  64541. }
  64542. }
  64543. declare module BABYLON {
  64544. /**
  64545. * Block used to scale a vector by a float
  64546. */
  64547. export class ScaleBlock extends NodeMaterialBlock {
  64548. /**
  64549. * Creates a new ScaleBlock
  64550. * @param name defines the block name
  64551. */
  64552. constructor(name: string);
  64553. /**
  64554. * Gets the current class name
  64555. * @returns the class name
  64556. */
  64557. getClassName(): string;
  64558. /**
  64559. * Gets the input component
  64560. */
  64561. get input(): NodeMaterialConnectionPoint;
  64562. /**
  64563. * Gets the factor input component
  64564. */
  64565. get factor(): NodeMaterialConnectionPoint;
  64566. /**
  64567. * Gets the output component
  64568. */
  64569. get output(): NodeMaterialConnectionPoint;
  64570. protected _buildBlock(state: NodeMaterialBuildState): this;
  64571. }
  64572. }
  64573. declare module BABYLON {
  64574. /**
  64575. * Block used to clamp a float
  64576. */
  64577. export class ClampBlock extends NodeMaterialBlock {
  64578. /** Gets or sets the minimum range */
  64579. minimum: number;
  64580. /** Gets or sets the maximum range */
  64581. maximum: number;
  64582. /**
  64583. * Creates a new ClampBlock
  64584. * @param name defines the block name
  64585. */
  64586. constructor(name: string);
  64587. /**
  64588. * Gets the current class name
  64589. * @returns the class name
  64590. */
  64591. getClassName(): string;
  64592. /**
  64593. * Gets the value input component
  64594. */
  64595. get value(): NodeMaterialConnectionPoint;
  64596. /**
  64597. * Gets the output component
  64598. */
  64599. get output(): NodeMaterialConnectionPoint;
  64600. protected _buildBlock(state: NodeMaterialBuildState): this;
  64601. protected _dumpPropertiesCode(): string;
  64602. serialize(): any;
  64603. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64604. }
  64605. }
  64606. declare module BABYLON {
  64607. /**
  64608. * Block used to apply a cross product between 2 vectors
  64609. */
  64610. export class CrossBlock extends NodeMaterialBlock {
  64611. /**
  64612. * Creates a new CrossBlock
  64613. * @param name defines the block name
  64614. */
  64615. constructor(name: string);
  64616. /**
  64617. * Gets the current class name
  64618. * @returns the class name
  64619. */
  64620. getClassName(): string;
  64621. /**
  64622. * Gets the left operand input component
  64623. */
  64624. get left(): NodeMaterialConnectionPoint;
  64625. /**
  64626. * Gets the right operand input component
  64627. */
  64628. get right(): NodeMaterialConnectionPoint;
  64629. /**
  64630. * Gets the output component
  64631. */
  64632. get output(): NodeMaterialConnectionPoint;
  64633. protected _buildBlock(state: NodeMaterialBuildState): this;
  64634. }
  64635. }
  64636. declare module BABYLON {
  64637. /**
  64638. * Block used to apply a dot product between 2 vectors
  64639. */
  64640. export class DotBlock extends NodeMaterialBlock {
  64641. /**
  64642. * Creates a new DotBlock
  64643. * @param name defines the block name
  64644. */
  64645. constructor(name: string);
  64646. /**
  64647. * Gets the current class name
  64648. * @returns the class name
  64649. */
  64650. getClassName(): string;
  64651. /**
  64652. * Gets the left operand input component
  64653. */
  64654. get left(): NodeMaterialConnectionPoint;
  64655. /**
  64656. * Gets the right operand input component
  64657. */
  64658. get right(): NodeMaterialConnectionPoint;
  64659. /**
  64660. * Gets the output component
  64661. */
  64662. get output(): NodeMaterialConnectionPoint;
  64663. protected _buildBlock(state: NodeMaterialBuildState): this;
  64664. }
  64665. }
  64666. declare module BABYLON {
  64667. /**
  64668. * Block used to normalize a vector
  64669. */
  64670. export class NormalizeBlock extends NodeMaterialBlock {
  64671. /**
  64672. * Creates a new NormalizeBlock
  64673. * @param name defines the block name
  64674. */
  64675. constructor(name: string);
  64676. /**
  64677. * Gets the current class name
  64678. * @returns the class name
  64679. */
  64680. getClassName(): string;
  64681. /**
  64682. * Gets the input component
  64683. */
  64684. get input(): NodeMaterialConnectionPoint;
  64685. /**
  64686. * Gets the output component
  64687. */
  64688. get output(): NodeMaterialConnectionPoint;
  64689. protected _buildBlock(state: NodeMaterialBuildState): this;
  64690. }
  64691. }
  64692. declare module BABYLON {
  64693. /**
  64694. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64695. */
  64696. export class ColorMergerBlock extends NodeMaterialBlock {
  64697. /**
  64698. * Create a new ColorMergerBlock
  64699. * @param name defines the block name
  64700. */
  64701. constructor(name: string);
  64702. /**
  64703. * Gets the current class name
  64704. * @returns the class name
  64705. */
  64706. getClassName(): string;
  64707. /**
  64708. * Gets the rgb component (input)
  64709. */
  64710. get rgbIn(): NodeMaterialConnectionPoint;
  64711. /**
  64712. * Gets the r component (input)
  64713. */
  64714. get r(): NodeMaterialConnectionPoint;
  64715. /**
  64716. * Gets the g component (input)
  64717. */
  64718. get g(): NodeMaterialConnectionPoint;
  64719. /**
  64720. * Gets the b component (input)
  64721. */
  64722. get b(): NodeMaterialConnectionPoint;
  64723. /**
  64724. * Gets the a component (input)
  64725. */
  64726. get a(): NodeMaterialConnectionPoint;
  64727. /**
  64728. * Gets the rgba component (output)
  64729. */
  64730. get rgba(): NodeMaterialConnectionPoint;
  64731. /**
  64732. * Gets the rgb component (output)
  64733. */
  64734. get rgbOut(): NodeMaterialConnectionPoint;
  64735. /**
  64736. * Gets the rgb component (output)
  64737. * @deprecated Please use rgbOut instead.
  64738. */
  64739. get rgb(): NodeMaterialConnectionPoint;
  64740. protected _buildBlock(state: NodeMaterialBuildState): this;
  64741. }
  64742. }
  64743. declare module BABYLON {
  64744. /**
  64745. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64746. */
  64747. export class VectorSplitterBlock extends NodeMaterialBlock {
  64748. /**
  64749. * Create a new VectorSplitterBlock
  64750. * @param name defines the block name
  64751. */
  64752. constructor(name: string);
  64753. /**
  64754. * Gets the current class name
  64755. * @returns the class name
  64756. */
  64757. getClassName(): string;
  64758. /**
  64759. * Gets the xyzw component (input)
  64760. */
  64761. get xyzw(): NodeMaterialConnectionPoint;
  64762. /**
  64763. * Gets the xyz component (input)
  64764. */
  64765. get xyzIn(): NodeMaterialConnectionPoint;
  64766. /**
  64767. * Gets the xy component (input)
  64768. */
  64769. get xyIn(): NodeMaterialConnectionPoint;
  64770. /**
  64771. * Gets the xyz component (output)
  64772. */
  64773. get xyzOut(): NodeMaterialConnectionPoint;
  64774. /**
  64775. * Gets the xy component (output)
  64776. */
  64777. get xyOut(): NodeMaterialConnectionPoint;
  64778. /**
  64779. * Gets the x component (output)
  64780. */
  64781. get x(): NodeMaterialConnectionPoint;
  64782. /**
  64783. * Gets the y component (output)
  64784. */
  64785. get y(): NodeMaterialConnectionPoint;
  64786. /**
  64787. * Gets the z component (output)
  64788. */
  64789. get z(): NodeMaterialConnectionPoint;
  64790. /**
  64791. * Gets the w component (output)
  64792. */
  64793. get w(): NodeMaterialConnectionPoint;
  64794. protected _inputRename(name: string): string;
  64795. protected _outputRename(name: string): string;
  64796. protected _buildBlock(state: NodeMaterialBuildState): this;
  64797. }
  64798. }
  64799. declare module BABYLON {
  64800. /**
  64801. * Block used to lerp between 2 values
  64802. */
  64803. export class LerpBlock extends NodeMaterialBlock {
  64804. /**
  64805. * Creates a new LerpBlock
  64806. * @param name defines the block name
  64807. */
  64808. constructor(name: string);
  64809. /**
  64810. * Gets the current class name
  64811. * @returns the class name
  64812. */
  64813. getClassName(): string;
  64814. /**
  64815. * Gets the left operand input component
  64816. */
  64817. get left(): NodeMaterialConnectionPoint;
  64818. /**
  64819. * Gets the right operand input component
  64820. */
  64821. get right(): NodeMaterialConnectionPoint;
  64822. /**
  64823. * Gets the gradient operand input component
  64824. */
  64825. get gradient(): NodeMaterialConnectionPoint;
  64826. /**
  64827. * Gets the output component
  64828. */
  64829. get output(): NodeMaterialConnectionPoint;
  64830. protected _buildBlock(state: NodeMaterialBuildState): this;
  64831. }
  64832. }
  64833. declare module BABYLON {
  64834. /**
  64835. * Block used to divide 2 vectors
  64836. */
  64837. export class DivideBlock extends NodeMaterialBlock {
  64838. /**
  64839. * Creates a new DivideBlock
  64840. * @param name defines the block name
  64841. */
  64842. constructor(name: string);
  64843. /**
  64844. * Gets the current class name
  64845. * @returns the class name
  64846. */
  64847. getClassName(): string;
  64848. /**
  64849. * Gets the left operand input component
  64850. */
  64851. get left(): NodeMaterialConnectionPoint;
  64852. /**
  64853. * Gets the right operand input component
  64854. */
  64855. get right(): NodeMaterialConnectionPoint;
  64856. /**
  64857. * Gets the output component
  64858. */
  64859. get output(): NodeMaterialConnectionPoint;
  64860. protected _buildBlock(state: NodeMaterialBuildState): this;
  64861. }
  64862. }
  64863. declare module BABYLON {
  64864. /**
  64865. * Block used to subtract 2 vectors
  64866. */
  64867. export class SubtractBlock extends NodeMaterialBlock {
  64868. /**
  64869. * Creates a new SubtractBlock
  64870. * @param name defines the block name
  64871. */
  64872. constructor(name: string);
  64873. /**
  64874. * Gets the current class name
  64875. * @returns the class name
  64876. */
  64877. getClassName(): string;
  64878. /**
  64879. * Gets the left operand input component
  64880. */
  64881. get left(): NodeMaterialConnectionPoint;
  64882. /**
  64883. * Gets the right operand input component
  64884. */
  64885. get right(): NodeMaterialConnectionPoint;
  64886. /**
  64887. * Gets the output component
  64888. */
  64889. get output(): NodeMaterialConnectionPoint;
  64890. protected _buildBlock(state: NodeMaterialBuildState): this;
  64891. }
  64892. }
  64893. declare module BABYLON {
  64894. /**
  64895. * Block used to step a value
  64896. */
  64897. export class StepBlock extends NodeMaterialBlock {
  64898. /**
  64899. * Creates a new StepBlock
  64900. * @param name defines the block name
  64901. */
  64902. constructor(name: string);
  64903. /**
  64904. * Gets the current class name
  64905. * @returns the class name
  64906. */
  64907. getClassName(): string;
  64908. /**
  64909. * Gets the value operand input component
  64910. */
  64911. get value(): NodeMaterialConnectionPoint;
  64912. /**
  64913. * Gets the edge operand input component
  64914. */
  64915. get edge(): NodeMaterialConnectionPoint;
  64916. /**
  64917. * Gets the output component
  64918. */
  64919. get output(): NodeMaterialConnectionPoint;
  64920. protected _buildBlock(state: NodeMaterialBuildState): this;
  64921. }
  64922. }
  64923. declare module BABYLON {
  64924. /**
  64925. * Block used to get the opposite (1 - x) of a value
  64926. */
  64927. export class OneMinusBlock extends NodeMaterialBlock {
  64928. /**
  64929. * Creates a new OneMinusBlock
  64930. * @param name defines the block name
  64931. */
  64932. constructor(name: string);
  64933. /**
  64934. * Gets the current class name
  64935. * @returns the class name
  64936. */
  64937. getClassName(): string;
  64938. /**
  64939. * Gets the input component
  64940. */
  64941. get input(): NodeMaterialConnectionPoint;
  64942. /**
  64943. * Gets the output component
  64944. */
  64945. get output(): NodeMaterialConnectionPoint;
  64946. protected _buildBlock(state: NodeMaterialBuildState): this;
  64947. }
  64948. }
  64949. declare module BABYLON {
  64950. /**
  64951. * Block used to get the view direction
  64952. */
  64953. export class ViewDirectionBlock extends NodeMaterialBlock {
  64954. /**
  64955. * Creates a new ViewDirectionBlock
  64956. * @param name defines the block name
  64957. */
  64958. constructor(name: string);
  64959. /**
  64960. * Gets the current class name
  64961. * @returns the class name
  64962. */
  64963. getClassName(): string;
  64964. /**
  64965. * Gets the world position component
  64966. */
  64967. get worldPosition(): NodeMaterialConnectionPoint;
  64968. /**
  64969. * Gets the camera position component
  64970. */
  64971. get cameraPosition(): NodeMaterialConnectionPoint;
  64972. /**
  64973. * Gets the output component
  64974. */
  64975. get output(): NodeMaterialConnectionPoint;
  64976. autoConfigure(material: NodeMaterial): void;
  64977. protected _buildBlock(state: NodeMaterialBuildState): this;
  64978. }
  64979. }
  64980. declare module BABYLON {
  64981. /**
  64982. * Block used to compute fresnel value
  64983. */
  64984. export class FresnelBlock extends NodeMaterialBlock {
  64985. /**
  64986. * Create a new FresnelBlock
  64987. * @param name defines the block name
  64988. */
  64989. constructor(name: string);
  64990. /**
  64991. * Gets the current class name
  64992. * @returns the class name
  64993. */
  64994. getClassName(): string;
  64995. /**
  64996. * Gets the world normal input component
  64997. */
  64998. get worldNormal(): NodeMaterialConnectionPoint;
  64999. /**
  65000. * Gets the view direction input component
  65001. */
  65002. get viewDirection(): NodeMaterialConnectionPoint;
  65003. /**
  65004. * Gets the bias input component
  65005. */
  65006. get bias(): NodeMaterialConnectionPoint;
  65007. /**
  65008. * Gets the camera (or eye) position component
  65009. */
  65010. get power(): NodeMaterialConnectionPoint;
  65011. /**
  65012. * Gets the fresnel output component
  65013. */
  65014. get fresnel(): NodeMaterialConnectionPoint;
  65015. autoConfigure(material: NodeMaterial): void;
  65016. protected _buildBlock(state: NodeMaterialBuildState): this;
  65017. }
  65018. }
  65019. declare module BABYLON {
  65020. /**
  65021. * Block used to get the max of 2 values
  65022. */
  65023. export class MaxBlock extends NodeMaterialBlock {
  65024. /**
  65025. * Creates a new MaxBlock
  65026. * @param name defines the block name
  65027. */
  65028. constructor(name: string);
  65029. /**
  65030. * Gets the current class name
  65031. * @returns the class name
  65032. */
  65033. getClassName(): string;
  65034. /**
  65035. * Gets the left operand input component
  65036. */
  65037. get left(): NodeMaterialConnectionPoint;
  65038. /**
  65039. * Gets the right operand input component
  65040. */
  65041. get right(): NodeMaterialConnectionPoint;
  65042. /**
  65043. * Gets the output component
  65044. */
  65045. get output(): NodeMaterialConnectionPoint;
  65046. protected _buildBlock(state: NodeMaterialBuildState): this;
  65047. }
  65048. }
  65049. declare module BABYLON {
  65050. /**
  65051. * Block used to get the min of 2 values
  65052. */
  65053. export class MinBlock extends NodeMaterialBlock {
  65054. /**
  65055. * Creates a new MinBlock
  65056. * @param name defines the block name
  65057. */
  65058. constructor(name: string);
  65059. /**
  65060. * Gets the current class name
  65061. * @returns the class name
  65062. */
  65063. getClassName(): string;
  65064. /**
  65065. * Gets the left operand input component
  65066. */
  65067. get left(): NodeMaterialConnectionPoint;
  65068. /**
  65069. * Gets the right operand input component
  65070. */
  65071. get right(): NodeMaterialConnectionPoint;
  65072. /**
  65073. * Gets the output component
  65074. */
  65075. get output(): NodeMaterialConnectionPoint;
  65076. protected _buildBlock(state: NodeMaterialBuildState): this;
  65077. }
  65078. }
  65079. declare module BABYLON {
  65080. /**
  65081. * Block used to get the distance between 2 values
  65082. */
  65083. export class DistanceBlock extends NodeMaterialBlock {
  65084. /**
  65085. * Creates a new DistanceBlock
  65086. * @param name defines the block name
  65087. */
  65088. constructor(name: string);
  65089. /**
  65090. * Gets the current class name
  65091. * @returns the class name
  65092. */
  65093. getClassName(): string;
  65094. /**
  65095. * Gets the left operand input component
  65096. */
  65097. get left(): NodeMaterialConnectionPoint;
  65098. /**
  65099. * Gets the right operand input component
  65100. */
  65101. get right(): NodeMaterialConnectionPoint;
  65102. /**
  65103. * Gets the output component
  65104. */
  65105. get output(): NodeMaterialConnectionPoint;
  65106. protected _buildBlock(state: NodeMaterialBuildState): this;
  65107. }
  65108. }
  65109. declare module BABYLON {
  65110. /**
  65111. * Block used to get the length of a vector
  65112. */
  65113. export class LengthBlock extends NodeMaterialBlock {
  65114. /**
  65115. * Creates a new LengthBlock
  65116. * @param name defines the block name
  65117. */
  65118. constructor(name: string);
  65119. /**
  65120. * Gets the current class name
  65121. * @returns the class name
  65122. */
  65123. getClassName(): string;
  65124. /**
  65125. * Gets the value input component
  65126. */
  65127. get value(): NodeMaterialConnectionPoint;
  65128. /**
  65129. * Gets the output component
  65130. */
  65131. get output(): NodeMaterialConnectionPoint;
  65132. protected _buildBlock(state: NodeMaterialBuildState): this;
  65133. }
  65134. }
  65135. declare module BABYLON {
  65136. /**
  65137. * Block used to get negative version of a value (i.e. x * -1)
  65138. */
  65139. export class NegateBlock extends NodeMaterialBlock {
  65140. /**
  65141. * Creates a new NegateBlock
  65142. * @param name defines the block name
  65143. */
  65144. constructor(name: string);
  65145. /**
  65146. * Gets the current class name
  65147. * @returns the class name
  65148. */
  65149. getClassName(): string;
  65150. /**
  65151. * Gets the value input component
  65152. */
  65153. get value(): NodeMaterialConnectionPoint;
  65154. /**
  65155. * Gets the output component
  65156. */
  65157. get output(): NodeMaterialConnectionPoint;
  65158. protected _buildBlock(state: NodeMaterialBuildState): this;
  65159. }
  65160. }
  65161. declare module BABYLON {
  65162. /**
  65163. * Block used to get the value of the first parameter raised to the power of the second
  65164. */
  65165. export class PowBlock extends NodeMaterialBlock {
  65166. /**
  65167. * Creates a new PowBlock
  65168. * @param name defines the block name
  65169. */
  65170. constructor(name: string);
  65171. /**
  65172. * Gets the current class name
  65173. * @returns the class name
  65174. */
  65175. getClassName(): string;
  65176. /**
  65177. * Gets the value operand input component
  65178. */
  65179. get value(): NodeMaterialConnectionPoint;
  65180. /**
  65181. * Gets the power operand input component
  65182. */
  65183. get power(): NodeMaterialConnectionPoint;
  65184. /**
  65185. * Gets the output component
  65186. */
  65187. get output(): NodeMaterialConnectionPoint;
  65188. protected _buildBlock(state: NodeMaterialBuildState): this;
  65189. }
  65190. }
  65191. declare module BABYLON {
  65192. /**
  65193. * Block used to get a random number
  65194. */
  65195. export class RandomNumberBlock extends NodeMaterialBlock {
  65196. /**
  65197. * Creates a new RandomNumberBlock
  65198. * @param name defines the block name
  65199. */
  65200. constructor(name: string);
  65201. /**
  65202. * Gets the current class name
  65203. * @returns the class name
  65204. */
  65205. getClassName(): string;
  65206. /**
  65207. * Gets the seed input component
  65208. */
  65209. get seed(): NodeMaterialConnectionPoint;
  65210. /**
  65211. * Gets the output component
  65212. */
  65213. get output(): NodeMaterialConnectionPoint;
  65214. protected _buildBlock(state: NodeMaterialBuildState): this;
  65215. }
  65216. }
  65217. declare module BABYLON {
  65218. /**
  65219. * Block used to compute arc tangent of 2 values
  65220. */
  65221. export class ArcTan2Block extends NodeMaterialBlock {
  65222. /**
  65223. * Creates a new ArcTan2Block
  65224. * @param name defines the block name
  65225. */
  65226. constructor(name: string);
  65227. /**
  65228. * Gets the current class name
  65229. * @returns the class name
  65230. */
  65231. getClassName(): string;
  65232. /**
  65233. * Gets the x operand input component
  65234. */
  65235. get x(): NodeMaterialConnectionPoint;
  65236. /**
  65237. * Gets the y operand input component
  65238. */
  65239. get y(): NodeMaterialConnectionPoint;
  65240. /**
  65241. * Gets the output component
  65242. */
  65243. get output(): NodeMaterialConnectionPoint;
  65244. protected _buildBlock(state: NodeMaterialBuildState): this;
  65245. }
  65246. }
  65247. declare module BABYLON {
  65248. /**
  65249. * Block used to smooth step a value
  65250. */
  65251. export class SmoothStepBlock extends NodeMaterialBlock {
  65252. /**
  65253. * Creates a new SmoothStepBlock
  65254. * @param name defines the block name
  65255. */
  65256. constructor(name: string);
  65257. /**
  65258. * Gets the current class name
  65259. * @returns the class name
  65260. */
  65261. getClassName(): string;
  65262. /**
  65263. * Gets the value operand input component
  65264. */
  65265. get value(): NodeMaterialConnectionPoint;
  65266. /**
  65267. * Gets the first edge operand input component
  65268. */
  65269. get edge0(): NodeMaterialConnectionPoint;
  65270. /**
  65271. * Gets the second edge operand input component
  65272. */
  65273. get edge1(): NodeMaterialConnectionPoint;
  65274. /**
  65275. * Gets the output component
  65276. */
  65277. get output(): NodeMaterialConnectionPoint;
  65278. protected _buildBlock(state: NodeMaterialBuildState): this;
  65279. }
  65280. }
  65281. declare module BABYLON {
  65282. /**
  65283. * Block used to get the reciprocal (1 / x) of a value
  65284. */
  65285. export class ReciprocalBlock extends NodeMaterialBlock {
  65286. /**
  65287. * Creates a new ReciprocalBlock
  65288. * @param name defines the block name
  65289. */
  65290. constructor(name: string);
  65291. /**
  65292. * Gets the current class name
  65293. * @returns the class name
  65294. */
  65295. getClassName(): string;
  65296. /**
  65297. * Gets the input component
  65298. */
  65299. get input(): NodeMaterialConnectionPoint;
  65300. /**
  65301. * Gets the output component
  65302. */
  65303. get output(): NodeMaterialConnectionPoint;
  65304. protected _buildBlock(state: NodeMaterialBuildState): this;
  65305. }
  65306. }
  65307. declare module BABYLON {
  65308. /**
  65309. * Block used to replace a color by another one
  65310. */
  65311. export class ReplaceColorBlock extends NodeMaterialBlock {
  65312. /**
  65313. * Creates a new ReplaceColorBlock
  65314. * @param name defines the block name
  65315. */
  65316. constructor(name: string);
  65317. /**
  65318. * Gets the current class name
  65319. * @returns the class name
  65320. */
  65321. getClassName(): string;
  65322. /**
  65323. * Gets the value input component
  65324. */
  65325. get value(): NodeMaterialConnectionPoint;
  65326. /**
  65327. * Gets the reference input component
  65328. */
  65329. get reference(): NodeMaterialConnectionPoint;
  65330. /**
  65331. * Gets the distance input component
  65332. */
  65333. get distance(): NodeMaterialConnectionPoint;
  65334. /**
  65335. * Gets the replacement input component
  65336. */
  65337. get replacement(): NodeMaterialConnectionPoint;
  65338. /**
  65339. * Gets the output component
  65340. */
  65341. get output(): NodeMaterialConnectionPoint;
  65342. protected _buildBlock(state: NodeMaterialBuildState): this;
  65343. }
  65344. }
  65345. declare module BABYLON {
  65346. /**
  65347. * Block used to posterize a value
  65348. * @see https://en.wikipedia.org/wiki/Posterization
  65349. */
  65350. export class PosterizeBlock extends NodeMaterialBlock {
  65351. /**
  65352. * Creates a new PosterizeBlock
  65353. * @param name defines the block name
  65354. */
  65355. constructor(name: string);
  65356. /**
  65357. * Gets the current class name
  65358. * @returns the class name
  65359. */
  65360. getClassName(): string;
  65361. /**
  65362. * Gets the value input component
  65363. */
  65364. get value(): NodeMaterialConnectionPoint;
  65365. /**
  65366. * Gets the steps input component
  65367. */
  65368. get steps(): NodeMaterialConnectionPoint;
  65369. /**
  65370. * Gets the output component
  65371. */
  65372. get output(): NodeMaterialConnectionPoint;
  65373. protected _buildBlock(state: NodeMaterialBuildState): this;
  65374. }
  65375. }
  65376. declare module BABYLON {
  65377. /**
  65378. * Operations supported by the Wave block
  65379. */
  65380. export enum WaveBlockKind {
  65381. /** SawTooth */
  65382. SawTooth = 0,
  65383. /** Square */
  65384. Square = 1,
  65385. /** Triangle */
  65386. Triangle = 2
  65387. }
  65388. /**
  65389. * Block used to apply wave operation to floats
  65390. */
  65391. export class WaveBlock extends NodeMaterialBlock {
  65392. /**
  65393. * Gets or sets the kibnd of wave to be applied by the block
  65394. */
  65395. kind: WaveBlockKind;
  65396. /**
  65397. * Creates a new WaveBlock
  65398. * @param name defines the block name
  65399. */
  65400. constructor(name: string);
  65401. /**
  65402. * Gets the current class name
  65403. * @returns the class name
  65404. */
  65405. getClassName(): string;
  65406. /**
  65407. * Gets the input component
  65408. */
  65409. get input(): NodeMaterialConnectionPoint;
  65410. /**
  65411. * Gets the output component
  65412. */
  65413. get output(): NodeMaterialConnectionPoint;
  65414. protected _buildBlock(state: NodeMaterialBuildState): this;
  65415. serialize(): any;
  65416. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65417. }
  65418. }
  65419. declare module BABYLON {
  65420. /**
  65421. * Class used to store a color step for the GradientBlock
  65422. */
  65423. export class GradientBlockColorStep {
  65424. private _step;
  65425. /**
  65426. * Gets value indicating which step this color is associated with (between 0 and 1)
  65427. */
  65428. get step(): number;
  65429. /**
  65430. * Sets a value indicating which step this color is associated with (between 0 and 1)
  65431. */
  65432. set step(val: number);
  65433. private _color;
  65434. /**
  65435. * Gets the color associated with this step
  65436. */
  65437. get color(): Color3;
  65438. /**
  65439. * Sets the color associated with this step
  65440. */
  65441. set color(val: Color3);
  65442. /**
  65443. * Creates a new GradientBlockColorStep
  65444. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65445. * @param color defines the color associated with this step
  65446. */
  65447. constructor(step: number, color: Color3);
  65448. }
  65449. /**
  65450. * Block used to return a color from a gradient based on an input value between 0 and 1
  65451. */
  65452. export class GradientBlock extends NodeMaterialBlock {
  65453. /**
  65454. * Gets or sets the list of color steps
  65455. */
  65456. colorSteps: GradientBlockColorStep[];
  65457. /** Gets an observable raised when the value is changed */
  65458. onValueChangedObservable: Observable<GradientBlock>;
  65459. /** calls observable when the value is changed*/
  65460. colorStepsUpdated(): void;
  65461. /**
  65462. * Creates a new GradientBlock
  65463. * @param name defines the block name
  65464. */
  65465. constructor(name: string);
  65466. /**
  65467. * Gets the current class name
  65468. * @returns the class name
  65469. */
  65470. getClassName(): string;
  65471. /**
  65472. * Gets the gradient input component
  65473. */
  65474. get gradient(): NodeMaterialConnectionPoint;
  65475. /**
  65476. * Gets the output component
  65477. */
  65478. get output(): NodeMaterialConnectionPoint;
  65479. private _writeColorConstant;
  65480. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65481. serialize(): any;
  65482. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65483. protected _dumpPropertiesCode(): string;
  65484. }
  65485. }
  65486. declare module BABYLON {
  65487. /**
  65488. * Block used to normalize lerp between 2 values
  65489. */
  65490. export class NLerpBlock extends NodeMaterialBlock {
  65491. /**
  65492. * Creates a new NLerpBlock
  65493. * @param name defines the block name
  65494. */
  65495. constructor(name: string);
  65496. /**
  65497. * Gets the current class name
  65498. * @returns the class name
  65499. */
  65500. getClassName(): string;
  65501. /**
  65502. * Gets the left operand input component
  65503. */
  65504. get left(): NodeMaterialConnectionPoint;
  65505. /**
  65506. * Gets the right operand input component
  65507. */
  65508. get right(): NodeMaterialConnectionPoint;
  65509. /**
  65510. * Gets the gradient operand input component
  65511. */
  65512. get gradient(): NodeMaterialConnectionPoint;
  65513. /**
  65514. * Gets the output component
  65515. */
  65516. get output(): NodeMaterialConnectionPoint;
  65517. protected _buildBlock(state: NodeMaterialBuildState): this;
  65518. }
  65519. }
  65520. declare module BABYLON {
  65521. /**
  65522. * block used to Generate a Worley Noise 3D Noise Pattern
  65523. */
  65524. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65525. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65526. manhattanDistance: boolean;
  65527. /**
  65528. * Creates a new WorleyNoise3DBlock
  65529. * @param name defines the block name
  65530. */
  65531. constructor(name: string);
  65532. /**
  65533. * Gets the current class name
  65534. * @returns the class name
  65535. */
  65536. getClassName(): string;
  65537. /**
  65538. * Gets the seed input component
  65539. */
  65540. get seed(): NodeMaterialConnectionPoint;
  65541. /**
  65542. * Gets the jitter input component
  65543. */
  65544. get jitter(): NodeMaterialConnectionPoint;
  65545. /**
  65546. * Gets the output component
  65547. */
  65548. get output(): NodeMaterialConnectionPoint;
  65549. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65550. /**
  65551. * Exposes the properties to the UI?
  65552. */
  65553. protected _dumpPropertiesCode(): string;
  65554. /**
  65555. * Exposes the properties to the Seralize?
  65556. */
  65557. serialize(): any;
  65558. /**
  65559. * Exposes the properties to the deseralize?
  65560. */
  65561. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65562. }
  65563. }
  65564. declare module BABYLON {
  65565. /**
  65566. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65567. */
  65568. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65569. /**
  65570. * Creates a new SimplexPerlin3DBlock
  65571. * @param name defines the block name
  65572. */
  65573. constructor(name: string);
  65574. /**
  65575. * Gets the current class name
  65576. * @returns the class name
  65577. */
  65578. getClassName(): string;
  65579. /**
  65580. * Gets the seed operand input component
  65581. */
  65582. get seed(): NodeMaterialConnectionPoint;
  65583. /**
  65584. * Gets the output component
  65585. */
  65586. get output(): NodeMaterialConnectionPoint;
  65587. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65588. }
  65589. }
  65590. declare module BABYLON {
  65591. /**
  65592. * Block used to blend normals
  65593. */
  65594. export class NormalBlendBlock extends NodeMaterialBlock {
  65595. /**
  65596. * Creates a new NormalBlendBlock
  65597. * @param name defines the block name
  65598. */
  65599. constructor(name: string);
  65600. /**
  65601. * Gets the current class name
  65602. * @returns the class name
  65603. */
  65604. getClassName(): string;
  65605. /**
  65606. * Gets the first input component
  65607. */
  65608. get normalMap0(): NodeMaterialConnectionPoint;
  65609. /**
  65610. * Gets the second input component
  65611. */
  65612. get normalMap1(): NodeMaterialConnectionPoint;
  65613. /**
  65614. * Gets the output component
  65615. */
  65616. get output(): NodeMaterialConnectionPoint;
  65617. protected _buildBlock(state: NodeMaterialBuildState): this;
  65618. }
  65619. }
  65620. declare module BABYLON {
  65621. /**
  65622. * Block used to rotate a 2d vector by a given angle
  65623. */
  65624. export class Rotate2dBlock extends NodeMaterialBlock {
  65625. /**
  65626. * Creates a new Rotate2dBlock
  65627. * @param name defines the block name
  65628. */
  65629. constructor(name: string);
  65630. /**
  65631. * Gets the current class name
  65632. * @returns the class name
  65633. */
  65634. getClassName(): string;
  65635. /**
  65636. * Gets the input vector
  65637. */
  65638. get input(): NodeMaterialConnectionPoint;
  65639. /**
  65640. * Gets the input angle
  65641. */
  65642. get angle(): NodeMaterialConnectionPoint;
  65643. /**
  65644. * Gets the output component
  65645. */
  65646. get output(): NodeMaterialConnectionPoint;
  65647. autoConfigure(material: NodeMaterial): void;
  65648. protected _buildBlock(state: NodeMaterialBuildState): this;
  65649. }
  65650. }
  65651. declare module BABYLON {
  65652. /**
  65653. * Block used to get the reflected vector from a direction and a normal
  65654. */
  65655. export class ReflectBlock extends NodeMaterialBlock {
  65656. /**
  65657. * Creates a new ReflectBlock
  65658. * @param name defines the block name
  65659. */
  65660. constructor(name: string);
  65661. /**
  65662. * Gets the current class name
  65663. * @returns the class name
  65664. */
  65665. getClassName(): string;
  65666. /**
  65667. * Gets the incident component
  65668. */
  65669. get incident(): NodeMaterialConnectionPoint;
  65670. /**
  65671. * Gets the normal component
  65672. */
  65673. get normal(): NodeMaterialConnectionPoint;
  65674. /**
  65675. * Gets the output component
  65676. */
  65677. get output(): NodeMaterialConnectionPoint;
  65678. protected _buildBlock(state: NodeMaterialBuildState): this;
  65679. }
  65680. }
  65681. declare module BABYLON {
  65682. /**
  65683. * Block used to get the refracted vector from a direction and a normal
  65684. */
  65685. export class RefractBlock extends NodeMaterialBlock {
  65686. /**
  65687. * Creates a new RefractBlock
  65688. * @param name defines the block name
  65689. */
  65690. constructor(name: string);
  65691. /**
  65692. * Gets the current class name
  65693. * @returns the class name
  65694. */
  65695. getClassName(): string;
  65696. /**
  65697. * Gets the incident component
  65698. */
  65699. get incident(): NodeMaterialConnectionPoint;
  65700. /**
  65701. * Gets the normal component
  65702. */
  65703. get normal(): NodeMaterialConnectionPoint;
  65704. /**
  65705. * Gets the index of refraction component
  65706. */
  65707. get ior(): NodeMaterialConnectionPoint;
  65708. /**
  65709. * Gets the output component
  65710. */
  65711. get output(): NodeMaterialConnectionPoint;
  65712. protected _buildBlock(state: NodeMaterialBuildState): this;
  65713. }
  65714. }
  65715. declare module BABYLON {
  65716. /**
  65717. * Block used to desaturate a color
  65718. */
  65719. export class DesaturateBlock extends NodeMaterialBlock {
  65720. /**
  65721. * Creates a new DesaturateBlock
  65722. * @param name defines the block name
  65723. */
  65724. constructor(name: string);
  65725. /**
  65726. * Gets the current class name
  65727. * @returns the class name
  65728. */
  65729. getClassName(): string;
  65730. /**
  65731. * Gets the color operand input component
  65732. */
  65733. get color(): NodeMaterialConnectionPoint;
  65734. /**
  65735. * Gets the level operand input component
  65736. */
  65737. get level(): NodeMaterialConnectionPoint;
  65738. /**
  65739. * Gets the output component
  65740. */
  65741. get output(): NodeMaterialConnectionPoint;
  65742. protected _buildBlock(state: NodeMaterialBuildState): this;
  65743. }
  65744. }
  65745. declare module BABYLON {
  65746. /**
  65747. * Block used to implement the reflection module of the PBR material
  65748. */
  65749. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65750. /** @hidden */
  65751. _defineLODReflectionAlpha: string;
  65752. /** @hidden */
  65753. _defineLinearSpecularReflection: string;
  65754. private _vEnvironmentIrradianceName;
  65755. /** @hidden */
  65756. _vReflectionMicrosurfaceInfosName: string;
  65757. /** @hidden */
  65758. _vReflectionInfosName: string;
  65759. /** @hidden */
  65760. _vReflectionFilteringInfoName: string;
  65761. private _scene;
  65762. /**
  65763. * The properties below are set by the main PBR block prior to calling methods of this class.
  65764. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65765. * It's less burden on the user side in the editor part.
  65766. */
  65767. /** @hidden */
  65768. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65769. /** @hidden */
  65770. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65771. /** @hidden */
  65772. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65773. /** @hidden */
  65774. viewConnectionPoint: NodeMaterialConnectionPoint;
  65775. /**
  65776. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65777. * diffuse part of the IBL.
  65778. */
  65779. useSphericalHarmonics: boolean;
  65780. /**
  65781. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65782. */
  65783. forceIrradianceInFragment: boolean;
  65784. /**
  65785. * Create a new ReflectionBlock
  65786. * @param name defines the block name
  65787. */
  65788. constructor(name: string);
  65789. /**
  65790. * Gets the current class name
  65791. * @returns the class name
  65792. */
  65793. getClassName(): string;
  65794. /**
  65795. * Gets the position input component
  65796. */
  65797. get position(): NodeMaterialConnectionPoint;
  65798. /**
  65799. * Gets the world position input component
  65800. */
  65801. get worldPosition(): NodeMaterialConnectionPoint;
  65802. /**
  65803. * Gets the world normal input component
  65804. */
  65805. get worldNormal(): NodeMaterialConnectionPoint;
  65806. /**
  65807. * Gets the world input component
  65808. */
  65809. get world(): NodeMaterialConnectionPoint;
  65810. /**
  65811. * Gets the camera (or eye) position component
  65812. */
  65813. get cameraPosition(): NodeMaterialConnectionPoint;
  65814. /**
  65815. * Gets the view input component
  65816. */
  65817. get view(): NodeMaterialConnectionPoint;
  65818. /**
  65819. * Gets the color input component
  65820. */
  65821. get color(): NodeMaterialConnectionPoint;
  65822. /**
  65823. * Gets the reflection object output component
  65824. */
  65825. get reflection(): NodeMaterialConnectionPoint;
  65826. /**
  65827. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65828. */
  65829. get hasTexture(): boolean;
  65830. /**
  65831. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65832. */
  65833. get reflectionColor(): string;
  65834. protected _getTexture(): Nullable<BaseTexture>;
  65835. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65836. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65837. /**
  65838. * Gets the code to inject in the vertex shader
  65839. * @param state current state of the node material building
  65840. * @returns the shader code
  65841. */
  65842. handleVertexSide(state: NodeMaterialBuildState): string;
  65843. /**
  65844. * Gets the main code of the block (fragment side)
  65845. * @param state current state of the node material building
  65846. * @param normalVarName name of the existing variable corresponding to the normal
  65847. * @returns the shader code
  65848. */
  65849. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65850. protected _buildBlock(state: NodeMaterialBuildState): this;
  65851. protected _dumpPropertiesCode(): string;
  65852. serialize(): any;
  65853. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65854. }
  65855. }
  65856. declare module BABYLON {
  65857. /**
  65858. * Block used to implement the sheen module of the PBR material
  65859. */
  65860. export class SheenBlock extends NodeMaterialBlock {
  65861. /**
  65862. * Create a new SheenBlock
  65863. * @param name defines the block name
  65864. */
  65865. constructor(name: string);
  65866. /**
  65867. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65868. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65869. * making it easier to setup and tweak the effect
  65870. */
  65871. albedoScaling: boolean;
  65872. /**
  65873. * Defines if the sheen is linked to the sheen color.
  65874. */
  65875. linkSheenWithAlbedo: boolean;
  65876. /**
  65877. * Initialize the block and prepare the context for build
  65878. * @param state defines the state that will be used for the build
  65879. */
  65880. initialize(state: NodeMaterialBuildState): void;
  65881. /**
  65882. * Gets the current class name
  65883. * @returns the class name
  65884. */
  65885. getClassName(): string;
  65886. /**
  65887. * Gets the intensity input component
  65888. */
  65889. get intensity(): NodeMaterialConnectionPoint;
  65890. /**
  65891. * Gets the color input component
  65892. */
  65893. get color(): NodeMaterialConnectionPoint;
  65894. /**
  65895. * Gets the roughness input component
  65896. */
  65897. get roughness(): NodeMaterialConnectionPoint;
  65898. /**
  65899. * Gets the sheen object output component
  65900. */
  65901. get sheen(): NodeMaterialConnectionPoint;
  65902. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65903. /**
  65904. * Gets the main code of the block (fragment side)
  65905. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65906. * @returns the shader code
  65907. */
  65908. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65909. protected _buildBlock(state: NodeMaterialBuildState): this;
  65910. protected _dumpPropertiesCode(): string;
  65911. serialize(): any;
  65912. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65913. }
  65914. }
  65915. declare module BABYLON {
  65916. /**
  65917. * Block used to implement the anisotropy module of the PBR material
  65918. */
  65919. export class AnisotropyBlock extends NodeMaterialBlock {
  65920. /**
  65921. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65922. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65923. * It's less burden on the user side in the editor part.
  65924. */
  65925. /** @hidden */
  65926. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65927. /** @hidden */
  65928. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65929. /**
  65930. * Create a new AnisotropyBlock
  65931. * @param name defines the block name
  65932. */
  65933. constructor(name: string);
  65934. /**
  65935. * Initialize the block and prepare the context for build
  65936. * @param state defines the state that will be used for the build
  65937. */
  65938. initialize(state: NodeMaterialBuildState): void;
  65939. /**
  65940. * Gets the current class name
  65941. * @returns the class name
  65942. */
  65943. getClassName(): string;
  65944. /**
  65945. * Gets the intensity input component
  65946. */
  65947. get intensity(): NodeMaterialConnectionPoint;
  65948. /**
  65949. * Gets the direction input component
  65950. */
  65951. get direction(): NodeMaterialConnectionPoint;
  65952. /**
  65953. * Gets the uv input component
  65954. */
  65955. get uv(): NodeMaterialConnectionPoint;
  65956. /**
  65957. * Gets the worldTangent input component
  65958. */
  65959. get worldTangent(): NodeMaterialConnectionPoint;
  65960. /**
  65961. * Gets the anisotropy object output component
  65962. */
  65963. get anisotropy(): NodeMaterialConnectionPoint;
  65964. private _generateTBNSpace;
  65965. /**
  65966. * Gets the main code of the block (fragment side)
  65967. * @param state current state of the node material building
  65968. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65969. * @returns the shader code
  65970. */
  65971. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65972. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65973. protected _buildBlock(state: NodeMaterialBuildState): this;
  65974. }
  65975. }
  65976. declare module BABYLON {
  65977. /**
  65978. * Block used to implement the clear coat module of the PBR material
  65979. */
  65980. export class ClearCoatBlock extends NodeMaterialBlock {
  65981. private _scene;
  65982. /**
  65983. * Create a new ClearCoatBlock
  65984. * @param name defines the block name
  65985. */
  65986. constructor(name: string);
  65987. /**
  65988. * Defines if the F0 value should be remapped to account for the interface change in the material.
  65989. */
  65990. remapF0OnInterfaceChange: boolean;
  65991. /**
  65992. * Initialize the block and prepare the context for build
  65993. * @param state defines the state that will be used for the build
  65994. */
  65995. initialize(state: NodeMaterialBuildState): void;
  65996. /**
  65997. * Gets the current class name
  65998. * @returns the class name
  65999. */
  66000. getClassName(): string;
  66001. /**
  66002. * Gets the intensity input component
  66003. */
  66004. get intensity(): NodeMaterialConnectionPoint;
  66005. /**
  66006. * Gets the roughness input component
  66007. */
  66008. get roughness(): NodeMaterialConnectionPoint;
  66009. /**
  66010. * Gets the ior input component
  66011. */
  66012. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66013. /**
  66014. * Gets the bump texture input component
  66015. */
  66016. get normalMapColor(): NodeMaterialConnectionPoint;
  66017. /**
  66018. * Gets the uv input component
  66019. */
  66020. get uv(): NodeMaterialConnectionPoint;
  66021. /**
  66022. * Gets the tint color input component
  66023. */
  66024. get tintColor(): NodeMaterialConnectionPoint;
  66025. /**
  66026. * Gets the tint "at distance" input component
  66027. */
  66028. get tintAtDistance(): NodeMaterialConnectionPoint;
  66029. /**
  66030. * Gets the tint thickness input component
  66031. */
  66032. get tintThickness(): NodeMaterialConnectionPoint;
  66033. /**
  66034. * Gets the world tangent input component
  66035. */
  66036. get worldTangent(): NodeMaterialConnectionPoint;
  66037. /**
  66038. * Gets the clear coat object output component
  66039. */
  66040. get clearcoat(): NodeMaterialConnectionPoint;
  66041. autoConfigure(material: NodeMaterial): void;
  66042. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66043. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66044. private _generateTBNSpace;
  66045. /**
  66046. * Gets the main code of the block (fragment side)
  66047. * @param state current state of the node material building
  66048. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66049. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66050. * @param worldPosVarName name of the variable holding the world position
  66051. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66052. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66053. * @param worldNormalVarName name of the variable holding the world normal
  66054. * @returns the shader code
  66055. */
  66056. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66057. protected _buildBlock(state: NodeMaterialBuildState): this;
  66058. protected _dumpPropertiesCode(): string;
  66059. serialize(): any;
  66060. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66061. }
  66062. }
  66063. declare module BABYLON {
  66064. /**
  66065. * Block used to implement the sub surface module of the PBR material
  66066. */
  66067. export class SubSurfaceBlock extends NodeMaterialBlock {
  66068. /**
  66069. * Create a new SubSurfaceBlock
  66070. * @param name defines the block name
  66071. */
  66072. constructor(name: string);
  66073. /**
  66074. * Initialize the block and prepare the context for build
  66075. * @param state defines the state that will be used for the build
  66076. */
  66077. initialize(state: NodeMaterialBuildState): void;
  66078. /**
  66079. * Gets the current class name
  66080. * @returns the class name
  66081. */
  66082. getClassName(): string;
  66083. /**
  66084. * Gets the thickness component
  66085. */
  66086. get thickness(): NodeMaterialConnectionPoint;
  66087. /**
  66088. * Gets the tint color input component
  66089. */
  66090. get tintColor(): NodeMaterialConnectionPoint;
  66091. /**
  66092. * Gets the translucency intensity input component
  66093. */
  66094. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66095. /**
  66096. * Gets the translucency diffusion distance input component
  66097. */
  66098. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  66099. /**
  66100. * Gets the refraction object parameters
  66101. */
  66102. get refraction(): NodeMaterialConnectionPoint;
  66103. /**
  66104. * Gets the sub surface object output component
  66105. */
  66106. get subsurface(): NodeMaterialConnectionPoint;
  66107. autoConfigure(material: NodeMaterial): void;
  66108. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66109. /**
  66110. * Gets the main code of the block (fragment side)
  66111. * @param state current state of the node material building
  66112. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66113. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66114. * @param worldPosVarName name of the variable holding the world position
  66115. * @returns the shader code
  66116. */
  66117. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66118. protected _buildBlock(state: NodeMaterialBuildState): this;
  66119. }
  66120. }
  66121. declare module BABYLON {
  66122. /**
  66123. * Block used to implement the PBR metallic/roughness model
  66124. */
  66125. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66126. /**
  66127. * Gets or sets the light associated with this block
  66128. */
  66129. light: Nullable<Light>;
  66130. private _lightId;
  66131. private _scene;
  66132. private _environmentBRDFTexture;
  66133. private _environmentBrdfSamplerName;
  66134. private _vNormalWName;
  66135. private _invertNormalName;
  66136. private _metallicReflectanceColor;
  66137. private _metallicF0Factor;
  66138. private _vMetallicReflectanceFactorsName;
  66139. /**
  66140. * Create a new ReflectionBlock
  66141. * @param name defines the block name
  66142. */
  66143. constructor(name: string);
  66144. /**
  66145. * Intensity of the direct lights e.g. the four lights available in your scene.
  66146. * This impacts both the direct diffuse and specular highlights.
  66147. */
  66148. directIntensity: number;
  66149. /**
  66150. * Intensity of the environment e.g. how much the environment will light the object
  66151. * either through harmonics for rough material or through the refelction for shiny ones.
  66152. */
  66153. environmentIntensity: number;
  66154. /**
  66155. * This is a special control allowing the reduction of the specular highlights coming from the
  66156. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66157. */
  66158. specularIntensity: number;
  66159. /**
  66160. * Defines the falloff type used in this material.
  66161. * It by default is Physical.
  66162. */
  66163. lightFalloff: number;
  66164. /**
  66165. * Specifies that alpha test should be used
  66166. */
  66167. useAlphaTest: boolean;
  66168. /**
  66169. * Defines the alpha limits in alpha test mode.
  66170. */
  66171. alphaTestCutoff: number;
  66172. /**
  66173. * Specifies that alpha blending should be used
  66174. */
  66175. useAlphaBlending: boolean;
  66176. /**
  66177. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66178. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66179. */
  66180. useRadianceOverAlpha: boolean;
  66181. /**
  66182. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66183. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66184. */
  66185. useSpecularOverAlpha: boolean;
  66186. /**
  66187. * Enables specular anti aliasing in the PBR shader.
  66188. * It will both interacts on the Geometry for analytical and IBL lighting.
  66189. * It also prefilter the roughness map based on the bump values.
  66190. */
  66191. enableSpecularAntiAliasing: boolean;
  66192. /**
  66193. * Enables realtime filtering on the texture.
  66194. */
  66195. realTimeFiltering: boolean;
  66196. /**
  66197. * Quality switch for realtime filtering
  66198. */
  66199. realTimeFilteringQuality: number;
  66200. /**
  66201. * Defines if the material uses energy conservation.
  66202. */
  66203. useEnergyConservation: boolean;
  66204. /**
  66205. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66206. * too much the area relying on ambient texture to define their ambient occlusion.
  66207. */
  66208. useRadianceOcclusion: boolean;
  66209. /**
  66210. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66211. * makes the reflect vector face the model (under horizon).
  66212. */
  66213. useHorizonOcclusion: boolean;
  66214. /**
  66215. * If set to true, no lighting calculations will be applied.
  66216. */
  66217. unlit: boolean;
  66218. /**
  66219. * Force normal to face away from face.
  66220. */
  66221. forceNormalForward: boolean;
  66222. /**
  66223. * Defines the material debug mode.
  66224. * It helps seeing only some components of the material while troubleshooting.
  66225. */
  66226. debugMode: number;
  66227. /**
  66228. * Specify from where on screen the debug mode should start.
  66229. * The value goes from -1 (full screen) to 1 (not visible)
  66230. * It helps with side by side comparison against the final render
  66231. * This defaults to 0
  66232. */
  66233. debugLimit: number;
  66234. /**
  66235. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66236. * You can use the factor to better multiply the final value.
  66237. */
  66238. debugFactor: number;
  66239. /**
  66240. * Initialize the block and prepare the context for build
  66241. * @param state defines the state that will be used for the build
  66242. */
  66243. initialize(state: NodeMaterialBuildState): void;
  66244. /**
  66245. * Gets the current class name
  66246. * @returns the class name
  66247. */
  66248. getClassName(): string;
  66249. /**
  66250. * Gets the world position input component
  66251. */
  66252. get worldPosition(): NodeMaterialConnectionPoint;
  66253. /**
  66254. * Gets the world normal input component
  66255. */
  66256. get worldNormal(): NodeMaterialConnectionPoint;
  66257. /**
  66258. * Gets the view matrix parameter
  66259. */
  66260. get view(): NodeMaterialConnectionPoint;
  66261. /**
  66262. * Gets the camera position input component
  66263. */
  66264. get cameraPosition(): NodeMaterialConnectionPoint;
  66265. /**
  66266. * Gets the perturbed normal input component
  66267. */
  66268. get perturbedNormal(): NodeMaterialConnectionPoint;
  66269. /**
  66270. * Gets the base color input component
  66271. */
  66272. get baseColor(): NodeMaterialConnectionPoint;
  66273. /**
  66274. * Gets the metallic input component
  66275. */
  66276. get metallic(): NodeMaterialConnectionPoint;
  66277. /**
  66278. * Gets the roughness input component
  66279. */
  66280. get roughness(): NodeMaterialConnectionPoint;
  66281. /**
  66282. * Gets the ambient occlusion input component
  66283. */
  66284. get ambientOcc(): NodeMaterialConnectionPoint;
  66285. /**
  66286. * Gets the opacity input component
  66287. */
  66288. get opacity(): NodeMaterialConnectionPoint;
  66289. /**
  66290. * Gets the index of refraction input component
  66291. */
  66292. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66293. /**
  66294. * Gets the ambient color input component
  66295. */
  66296. get ambientColor(): NodeMaterialConnectionPoint;
  66297. /**
  66298. * Gets the reflection object parameters
  66299. */
  66300. get reflection(): NodeMaterialConnectionPoint;
  66301. /**
  66302. * Gets the clear coat object parameters
  66303. */
  66304. get clearcoat(): NodeMaterialConnectionPoint;
  66305. /**
  66306. * Gets the sheen object parameters
  66307. */
  66308. get sheen(): NodeMaterialConnectionPoint;
  66309. /**
  66310. * Gets the sub surface object parameters
  66311. */
  66312. get subsurface(): NodeMaterialConnectionPoint;
  66313. /**
  66314. * Gets the anisotropy object parameters
  66315. */
  66316. get anisotropy(): NodeMaterialConnectionPoint;
  66317. /**
  66318. * Gets the ambient output component
  66319. */
  66320. get ambientClr(): NodeMaterialConnectionPoint;
  66321. /**
  66322. * Gets the diffuse output component
  66323. */
  66324. get diffuseDir(): NodeMaterialConnectionPoint;
  66325. /**
  66326. * Gets the specular output component
  66327. */
  66328. get specularDir(): NodeMaterialConnectionPoint;
  66329. /**
  66330. * Gets the clear coat output component
  66331. */
  66332. get clearcoatDir(): NodeMaterialConnectionPoint;
  66333. /**
  66334. * Gets the sheen output component
  66335. */
  66336. get sheenDir(): NodeMaterialConnectionPoint;
  66337. /**
  66338. * Gets the indirect diffuse output component
  66339. */
  66340. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66341. /**
  66342. * Gets the indirect specular output component
  66343. */
  66344. get specularIndirect(): NodeMaterialConnectionPoint;
  66345. /**
  66346. * Gets the indirect clear coat output component
  66347. */
  66348. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66349. /**
  66350. * Gets the indirect sheen output component
  66351. */
  66352. get sheenIndirect(): NodeMaterialConnectionPoint;
  66353. /**
  66354. * Gets the refraction output component
  66355. */
  66356. get refraction(): NodeMaterialConnectionPoint;
  66357. /**
  66358. * Gets the global lighting output component
  66359. */
  66360. get lighting(): NodeMaterialConnectionPoint;
  66361. /**
  66362. * Gets the shadow output component
  66363. */
  66364. get shadow(): NodeMaterialConnectionPoint;
  66365. /**
  66366. * Gets the alpha output component
  66367. */
  66368. get alpha(): NodeMaterialConnectionPoint;
  66369. autoConfigure(material: NodeMaterial): void;
  66370. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66371. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66372. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66373. private _injectVertexCode;
  66374. private _getAlbedoOpacityCode;
  66375. private _getAmbientOcclusionCode;
  66376. private _getReflectivityCode;
  66377. protected _buildBlock(state: NodeMaterialBuildState): this;
  66378. protected _dumpPropertiesCode(): string;
  66379. serialize(): any;
  66380. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66381. }
  66382. }
  66383. declare module BABYLON {
  66384. /**
  66385. * Block used to compute value of one parameter modulo another
  66386. */
  66387. export class ModBlock extends NodeMaterialBlock {
  66388. /**
  66389. * Creates a new ModBlock
  66390. * @param name defines the block name
  66391. */
  66392. constructor(name: string);
  66393. /**
  66394. * Gets the current class name
  66395. * @returns the class name
  66396. */
  66397. getClassName(): string;
  66398. /**
  66399. * Gets the left operand input component
  66400. */
  66401. get left(): NodeMaterialConnectionPoint;
  66402. /**
  66403. * Gets the right operand input component
  66404. */
  66405. get right(): NodeMaterialConnectionPoint;
  66406. /**
  66407. * Gets the output component
  66408. */
  66409. get output(): NodeMaterialConnectionPoint;
  66410. protected _buildBlock(state: NodeMaterialBuildState): this;
  66411. }
  66412. }
  66413. declare module BABYLON {
  66414. /**
  66415. * Configuration for Draco compression
  66416. */
  66417. export interface IDracoCompressionConfiguration {
  66418. /**
  66419. * Configuration for the decoder.
  66420. */
  66421. decoder: {
  66422. /**
  66423. * The url to the WebAssembly module.
  66424. */
  66425. wasmUrl?: string;
  66426. /**
  66427. * The url to the WebAssembly binary.
  66428. */
  66429. wasmBinaryUrl?: string;
  66430. /**
  66431. * The url to the fallback JavaScript module.
  66432. */
  66433. fallbackUrl?: string;
  66434. };
  66435. }
  66436. /**
  66437. * Draco compression (https://google.github.io/draco/)
  66438. *
  66439. * This class wraps the Draco module.
  66440. *
  66441. * **Encoder**
  66442. *
  66443. * The encoder is not currently implemented.
  66444. *
  66445. * **Decoder**
  66446. *
  66447. * 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.
  66448. *
  66449. * To update the configuration, use the following code:
  66450. * ```javascript
  66451. * DracoCompression.Configuration = {
  66452. * decoder: {
  66453. * wasmUrl: "<url to the WebAssembly library>",
  66454. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66455. * fallbackUrl: "<url to the fallback JavaScript library>",
  66456. * }
  66457. * };
  66458. * ```
  66459. *
  66460. * 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.
  66461. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66462. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66463. *
  66464. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66465. * ```javascript
  66466. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66467. * ```
  66468. *
  66469. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66470. */
  66471. export class DracoCompression implements IDisposable {
  66472. private _workerPoolPromise?;
  66473. private _decoderModulePromise?;
  66474. /**
  66475. * The configuration. Defaults to the following urls:
  66476. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66477. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66478. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66479. */
  66480. static Configuration: IDracoCompressionConfiguration;
  66481. /**
  66482. * Returns true if the decoder configuration is available.
  66483. */
  66484. static get DecoderAvailable(): boolean;
  66485. /**
  66486. * Default number of workers to create when creating the draco compression object.
  66487. */
  66488. static DefaultNumWorkers: number;
  66489. private static GetDefaultNumWorkers;
  66490. private static _Default;
  66491. /**
  66492. * Default instance for the draco compression object.
  66493. */
  66494. static get Default(): DracoCompression;
  66495. /**
  66496. * Constructor
  66497. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66498. */
  66499. constructor(numWorkers?: number);
  66500. /**
  66501. * Stop all async operations and release resources.
  66502. */
  66503. dispose(): void;
  66504. /**
  66505. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66506. * @returns a promise that resolves when ready
  66507. */
  66508. whenReadyAsync(): Promise<void>;
  66509. /**
  66510. * Decode Draco compressed mesh data to vertex data.
  66511. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66512. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66513. * @returns A promise that resolves with the decoded vertex data
  66514. */
  66515. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66516. [kind: string]: number;
  66517. }): Promise<VertexData>;
  66518. }
  66519. }
  66520. declare module BABYLON {
  66521. /**
  66522. * Class for building Constructive Solid Geometry
  66523. */
  66524. export class CSG {
  66525. private polygons;
  66526. /**
  66527. * The world matrix
  66528. */
  66529. matrix: Matrix;
  66530. /**
  66531. * Stores the position
  66532. */
  66533. position: Vector3;
  66534. /**
  66535. * Stores the rotation
  66536. */
  66537. rotation: Vector3;
  66538. /**
  66539. * Stores the rotation quaternion
  66540. */
  66541. rotationQuaternion: Nullable<Quaternion>;
  66542. /**
  66543. * Stores the scaling vector
  66544. */
  66545. scaling: Vector3;
  66546. /**
  66547. * Convert the Mesh to CSG
  66548. * @param mesh The Mesh to convert to CSG
  66549. * @returns A new CSG from the Mesh
  66550. */
  66551. static FromMesh(mesh: Mesh): CSG;
  66552. /**
  66553. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66554. * @param polygons Polygons used to construct a CSG solid
  66555. */
  66556. private static FromPolygons;
  66557. /**
  66558. * Clones, or makes a deep copy, of the CSG
  66559. * @returns A new CSG
  66560. */
  66561. clone(): CSG;
  66562. /**
  66563. * Unions this CSG with another CSG
  66564. * @param csg The CSG to union against this CSG
  66565. * @returns The unioned CSG
  66566. */
  66567. union(csg: CSG): CSG;
  66568. /**
  66569. * Unions this CSG with another CSG in place
  66570. * @param csg The CSG to union against this CSG
  66571. */
  66572. unionInPlace(csg: CSG): void;
  66573. /**
  66574. * Subtracts this CSG with another CSG
  66575. * @param csg The CSG to subtract against this CSG
  66576. * @returns A new CSG
  66577. */
  66578. subtract(csg: CSG): CSG;
  66579. /**
  66580. * Subtracts this CSG with another CSG in place
  66581. * @param csg The CSG to subtact against this CSG
  66582. */
  66583. subtractInPlace(csg: CSG): void;
  66584. /**
  66585. * Intersect this CSG with another CSG
  66586. * @param csg The CSG to intersect against this CSG
  66587. * @returns A new CSG
  66588. */
  66589. intersect(csg: CSG): CSG;
  66590. /**
  66591. * Intersects this CSG with another CSG in place
  66592. * @param csg The CSG to intersect against this CSG
  66593. */
  66594. intersectInPlace(csg: CSG): void;
  66595. /**
  66596. * Return a new CSG solid with solid and empty space switched. This solid is
  66597. * not modified.
  66598. * @returns A new CSG solid with solid and empty space switched
  66599. */
  66600. inverse(): CSG;
  66601. /**
  66602. * Inverses the CSG in place
  66603. */
  66604. inverseInPlace(): void;
  66605. /**
  66606. * This is used to keep meshes transformations so they can be restored
  66607. * when we build back a Babylon Mesh
  66608. * NB : All CSG operations are performed in world coordinates
  66609. * @param csg The CSG to copy the transform attributes from
  66610. * @returns This CSG
  66611. */
  66612. copyTransformAttributes(csg: CSG): CSG;
  66613. /**
  66614. * Build Raw mesh from CSG
  66615. * Coordinates here are in world space
  66616. * @param name The name of the mesh geometry
  66617. * @param scene The Scene
  66618. * @param keepSubMeshes Specifies if the submeshes should be kept
  66619. * @returns A new Mesh
  66620. */
  66621. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66622. /**
  66623. * Build Mesh from CSG taking material and transforms into account
  66624. * @param name The name of the Mesh
  66625. * @param material The material of the Mesh
  66626. * @param scene The Scene
  66627. * @param keepSubMeshes Specifies if submeshes should be kept
  66628. * @returns The new Mesh
  66629. */
  66630. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66631. }
  66632. }
  66633. declare module BABYLON {
  66634. /**
  66635. * Class used to create a trail following a mesh
  66636. */
  66637. export class TrailMesh extends Mesh {
  66638. private _generator;
  66639. private _autoStart;
  66640. private _running;
  66641. private _diameter;
  66642. private _length;
  66643. private _sectionPolygonPointsCount;
  66644. private _sectionVectors;
  66645. private _sectionNormalVectors;
  66646. private _beforeRenderObserver;
  66647. /**
  66648. * @constructor
  66649. * @param name The value used by scene.getMeshByName() to do a lookup.
  66650. * @param generator The mesh or transform node to generate a trail.
  66651. * @param scene The scene to add this mesh to.
  66652. * @param diameter Diameter of trailing mesh. Default is 1.
  66653. * @param length Length of trailing mesh. Default is 60.
  66654. * @param autoStart Automatically start trailing mesh. Default true.
  66655. */
  66656. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66657. /**
  66658. * "TrailMesh"
  66659. * @returns "TrailMesh"
  66660. */
  66661. getClassName(): string;
  66662. private _createMesh;
  66663. /**
  66664. * Start trailing mesh.
  66665. */
  66666. start(): void;
  66667. /**
  66668. * Stop trailing mesh.
  66669. */
  66670. stop(): void;
  66671. /**
  66672. * Update trailing mesh geometry.
  66673. */
  66674. update(): void;
  66675. /**
  66676. * Returns a new TrailMesh object.
  66677. * @param name is a string, the name given to the new mesh
  66678. * @param newGenerator use new generator object for cloned trail mesh
  66679. * @returns a new mesh
  66680. */
  66681. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66682. /**
  66683. * Serializes this trail mesh
  66684. * @param serializationObject object to write serialization to
  66685. */
  66686. serialize(serializationObject: any): void;
  66687. /**
  66688. * Parses a serialized trail mesh
  66689. * @param parsedMesh the serialized mesh
  66690. * @param scene the scene to create the trail mesh in
  66691. * @returns the created trail mesh
  66692. */
  66693. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66694. }
  66695. }
  66696. declare module BABYLON {
  66697. /**
  66698. * Class containing static functions to help procedurally build meshes
  66699. */
  66700. export class TiledBoxBuilder {
  66701. /**
  66702. * Creates a box mesh
  66703. * 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)
  66704. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66706. * * 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
  66707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66708. * @param name defines the name of the mesh
  66709. * @param options defines the options used to create the mesh
  66710. * @param scene defines the hosting scene
  66711. * @returns the box mesh
  66712. */
  66713. static CreateTiledBox(name: string, options: {
  66714. pattern?: number;
  66715. width?: number;
  66716. height?: number;
  66717. depth?: number;
  66718. tileSize?: number;
  66719. tileWidth?: number;
  66720. tileHeight?: number;
  66721. alignHorizontal?: number;
  66722. alignVertical?: number;
  66723. faceUV?: Vector4[];
  66724. faceColors?: Color4[];
  66725. sideOrientation?: number;
  66726. updatable?: boolean;
  66727. }, scene?: Nullable<Scene>): Mesh;
  66728. }
  66729. }
  66730. declare module BABYLON {
  66731. /**
  66732. * Class containing static functions to help procedurally build meshes
  66733. */
  66734. export class TorusKnotBuilder {
  66735. /**
  66736. * Creates a torus knot mesh
  66737. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66738. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66739. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66740. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66742. * * 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
  66743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66744. * @param name defines the name of the mesh
  66745. * @param options defines the options used to create the mesh
  66746. * @param scene defines the hosting scene
  66747. * @returns the torus knot mesh
  66748. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66749. */
  66750. static CreateTorusKnot(name: string, options: {
  66751. radius?: number;
  66752. tube?: number;
  66753. radialSegments?: number;
  66754. tubularSegments?: number;
  66755. p?: number;
  66756. q?: number;
  66757. updatable?: boolean;
  66758. sideOrientation?: number;
  66759. frontUVs?: Vector4;
  66760. backUVs?: Vector4;
  66761. }, scene: any): Mesh;
  66762. }
  66763. }
  66764. declare module BABYLON {
  66765. /**
  66766. * Polygon
  66767. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66768. */
  66769. export class Polygon {
  66770. /**
  66771. * Creates a rectangle
  66772. * @param xmin bottom X coord
  66773. * @param ymin bottom Y coord
  66774. * @param xmax top X coord
  66775. * @param ymax top Y coord
  66776. * @returns points that make the resulting rectation
  66777. */
  66778. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66779. /**
  66780. * Creates a circle
  66781. * @param radius radius of circle
  66782. * @param cx scale in x
  66783. * @param cy scale in y
  66784. * @param numberOfSides number of sides that make up the circle
  66785. * @returns points that make the resulting circle
  66786. */
  66787. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66788. /**
  66789. * Creates a polygon from input string
  66790. * @param input Input polygon data
  66791. * @returns the parsed points
  66792. */
  66793. static Parse(input: string): Vector2[];
  66794. /**
  66795. * Starts building a polygon from x and y coordinates
  66796. * @param x x coordinate
  66797. * @param y y coordinate
  66798. * @returns the started path2
  66799. */
  66800. static StartingAt(x: number, y: number): Path2;
  66801. }
  66802. /**
  66803. * Builds a polygon
  66804. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66805. */
  66806. export class PolygonMeshBuilder {
  66807. private _points;
  66808. private _outlinepoints;
  66809. private _holes;
  66810. private _name;
  66811. private _scene;
  66812. private _epoints;
  66813. private _eholes;
  66814. private _addToepoint;
  66815. /**
  66816. * Babylon reference to the earcut plugin.
  66817. */
  66818. bjsEarcut: any;
  66819. /**
  66820. * Creates a PolygonMeshBuilder
  66821. * @param name name of the builder
  66822. * @param contours Path of the polygon
  66823. * @param scene scene to add to when creating the mesh
  66824. * @param earcutInjection can be used to inject your own earcut reference
  66825. */
  66826. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66827. /**
  66828. * Adds a whole within the polygon
  66829. * @param hole Array of points defining the hole
  66830. * @returns this
  66831. */
  66832. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66833. /**
  66834. * Creates the polygon
  66835. * @param updatable If the mesh should be updatable
  66836. * @param depth The depth of the mesh created
  66837. * @returns the created mesh
  66838. */
  66839. build(updatable?: boolean, depth?: number): Mesh;
  66840. /**
  66841. * Creates the polygon
  66842. * @param depth The depth of the mesh created
  66843. * @returns the created VertexData
  66844. */
  66845. buildVertexData(depth?: number): VertexData;
  66846. /**
  66847. * Adds a side to the polygon
  66848. * @param positions points that make the polygon
  66849. * @param normals normals of the polygon
  66850. * @param uvs uvs of the polygon
  66851. * @param indices indices of the polygon
  66852. * @param bounds bounds of the polygon
  66853. * @param points points of the polygon
  66854. * @param depth depth of the polygon
  66855. * @param flip flip of the polygon
  66856. */
  66857. private addSide;
  66858. }
  66859. }
  66860. declare module BABYLON {
  66861. /**
  66862. * Class containing static functions to help procedurally build meshes
  66863. */
  66864. export class PolygonBuilder {
  66865. /**
  66866. * Creates a polygon mesh
  66867. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66868. * * 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
  66869. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66871. * * 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)
  66872. * * Remember you can only change the shape positions, not their number when updating a polygon
  66873. * @param name defines the name of the mesh
  66874. * @param options defines the options used to create the mesh
  66875. * @param scene defines the hosting scene
  66876. * @param earcutInjection can be used to inject your own earcut reference
  66877. * @returns the polygon mesh
  66878. */
  66879. static CreatePolygon(name: string, options: {
  66880. shape: Vector3[];
  66881. holes?: Vector3[][];
  66882. depth?: number;
  66883. faceUV?: Vector4[];
  66884. faceColors?: Color4[];
  66885. updatable?: boolean;
  66886. sideOrientation?: number;
  66887. frontUVs?: Vector4;
  66888. backUVs?: Vector4;
  66889. wrap?: boolean;
  66890. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66891. /**
  66892. * Creates an extruded polygon mesh, with depth in the Y direction.
  66893. * * 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)
  66894. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66895. * @param name defines the name of the mesh
  66896. * @param options defines the options used to create the mesh
  66897. * @param scene defines the hosting scene
  66898. * @param earcutInjection can be used to inject your own earcut reference
  66899. * @returns the polygon mesh
  66900. */
  66901. static ExtrudePolygon(name: string, options: {
  66902. shape: Vector3[];
  66903. holes?: Vector3[][];
  66904. depth?: number;
  66905. faceUV?: Vector4[];
  66906. faceColors?: Color4[];
  66907. updatable?: boolean;
  66908. sideOrientation?: number;
  66909. frontUVs?: Vector4;
  66910. backUVs?: Vector4;
  66911. wrap?: boolean;
  66912. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66913. }
  66914. }
  66915. declare module BABYLON {
  66916. /**
  66917. * Class containing static functions to help procedurally build meshes
  66918. */
  66919. export class LatheBuilder {
  66920. /**
  66921. * Creates lathe mesh.
  66922. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66923. * * 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
  66924. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66925. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66926. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66927. * * 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
  66928. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66929. * * 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
  66930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66931. * * 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
  66932. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66934. * @param name defines the name of the mesh
  66935. * @param options defines the options used to create the mesh
  66936. * @param scene defines the hosting scene
  66937. * @returns the lathe mesh
  66938. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66939. */
  66940. static CreateLathe(name: string, options: {
  66941. shape: Vector3[];
  66942. radius?: number;
  66943. tessellation?: number;
  66944. clip?: number;
  66945. arc?: number;
  66946. closed?: boolean;
  66947. updatable?: boolean;
  66948. sideOrientation?: number;
  66949. frontUVs?: Vector4;
  66950. backUVs?: Vector4;
  66951. cap?: number;
  66952. invertUV?: boolean;
  66953. }, scene?: Nullable<Scene>): Mesh;
  66954. }
  66955. }
  66956. declare module BABYLON {
  66957. /**
  66958. * Class containing static functions to help procedurally build meshes
  66959. */
  66960. export class TiledPlaneBuilder {
  66961. /**
  66962. * Creates a tiled plane mesh
  66963. * * The parameter `pattern` will, depending on value, do nothing or
  66964. * * * flip (reflect about central vertical) alternate tiles across and up
  66965. * * * flip every tile on alternate rows
  66966. * * * rotate (180 degs) alternate tiles across and up
  66967. * * * rotate every tile on alternate rows
  66968. * * * flip and rotate alternate tiles across and up
  66969. * * * flip and rotate every tile on alternate rows
  66970. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66971. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66972. * * 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
  66973. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66974. * * 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)
  66975. * * 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)
  66976. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66977. * @param name defines the name of the mesh
  66978. * @param options defines the options used to create the mesh
  66979. * @param scene defines the hosting scene
  66980. * @returns the box mesh
  66981. */
  66982. static CreateTiledPlane(name: string, options: {
  66983. pattern?: number;
  66984. tileSize?: number;
  66985. tileWidth?: number;
  66986. tileHeight?: number;
  66987. size?: number;
  66988. width?: number;
  66989. height?: number;
  66990. alignHorizontal?: number;
  66991. alignVertical?: number;
  66992. sideOrientation?: number;
  66993. frontUVs?: Vector4;
  66994. backUVs?: Vector4;
  66995. updatable?: boolean;
  66996. }, scene?: Nullable<Scene>): Mesh;
  66997. }
  66998. }
  66999. declare module BABYLON {
  67000. /**
  67001. * Class containing static functions to help procedurally build meshes
  67002. */
  67003. export class TubeBuilder {
  67004. /**
  67005. * Creates a tube mesh.
  67006. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67007. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67008. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67009. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67010. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67011. * * 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)
  67012. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67013. * * 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
  67014. * * 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
  67015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67016. * * 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
  67017. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67019. * @param name defines the name of the mesh
  67020. * @param options defines the options used to create the mesh
  67021. * @param scene defines the hosting scene
  67022. * @returns the tube mesh
  67023. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67024. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67025. */
  67026. static CreateTube(name: string, options: {
  67027. path: Vector3[];
  67028. radius?: number;
  67029. tessellation?: number;
  67030. radiusFunction?: {
  67031. (i: number, distance: number): number;
  67032. };
  67033. cap?: number;
  67034. arc?: number;
  67035. updatable?: boolean;
  67036. sideOrientation?: number;
  67037. frontUVs?: Vector4;
  67038. backUVs?: Vector4;
  67039. instance?: Mesh;
  67040. invertUV?: boolean;
  67041. }, scene?: Nullable<Scene>): Mesh;
  67042. }
  67043. }
  67044. declare module BABYLON {
  67045. /**
  67046. * Class containing static functions to help procedurally build meshes
  67047. */
  67048. export class IcoSphereBuilder {
  67049. /**
  67050. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67051. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67052. * * 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`)
  67053. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67054. * * 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
  67055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67056. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67058. * @param name defines the name of the mesh
  67059. * @param options defines the options used to create the mesh
  67060. * @param scene defines the hosting scene
  67061. * @returns the icosahedron mesh
  67062. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67063. */
  67064. static CreateIcoSphere(name: string, options: {
  67065. radius?: number;
  67066. radiusX?: number;
  67067. radiusY?: number;
  67068. radiusZ?: number;
  67069. flat?: boolean;
  67070. subdivisions?: number;
  67071. sideOrientation?: number;
  67072. frontUVs?: Vector4;
  67073. backUVs?: Vector4;
  67074. updatable?: boolean;
  67075. }, scene?: Nullable<Scene>): Mesh;
  67076. }
  67077. }
  67078. declare module BABYLON {
  67079. /**
  67080. * Class containing static functions to help procedurally build meshes
  67081. */
  67082. export class DecalBuilder {
  67083. /**
  67084. * Creates a decal mesh.
  67085. * 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
  67086. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67087. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67088. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67089. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67090. * @param name defines the name of the mesh
  67091. * @param sourceMesh defines the mesh where the decal must be applied
  67092. * @param options defines the options used to create the mesh
  67093. * @param scene defines the hosting scene
  67094. * @returns the decal mesh
  67095. * @see https://doc.babylonjs.com/how_to/decals
  67096. */
  67097. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67098. position?: Vector3;
  67099. normal?: Vector3;
  67100. size?: Vector3;
  67101. angle?: number;
  67102. }): Mesh;
  67103. }
  67104. }
  67105. declare module BABYLON {
  67106. /**
  67107. * Class containing static functions to help procedurally build meshes
  67108. */
  67109. export class MeshBuilder {
  67110. /**
  67111. * Creates a box mesh
  67112. * * The parameter `size` sets the size (float) of each box side (default 1)
  67113. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67114. * * 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)
  67115. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67117. * * 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
  67118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67119. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67120. * @param name defines the name of the mesh
  67121. * @param options defines the options used to create the mesh
  67122. * @param scene defines the hosting scene
  67123. * @returns the box mesh
  67124. */
  67125. static CreateBox(name: string, options: {
  67126. size?: number;
  67127. width?: number;
  67128. height?: number;
  67129. depth?: number;
  67130. faceUV?: Vector4[];
  67131. faceColors?: Color4[];
  67132. sideOrientation?: number;
  67133. frontUVs?: Vector4;
  67134. backUVs?: Vector4;
  67135. wrap?: boolean;
  67136. topBaseAt?: number;
  67137. bottomBaseAt?: number;
  67138. updatable?: boolean;
  67139. }, scene?: Nullable<Scene>): Mesh;
  67140. /**
  67141. * Creates a tiled box mesh
  67142. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67144. * @param name defines the name of the mesh
  67145. * @param options defines the options used to create the mesh
  67146. * @param scene defines the hosting scene
  67147. * @returns the tiled box mesh
  67148. */
  67149. static CreateTiledBox(name: string, options: {
  67150. pattern?: number;
  67151. size?: number;
  67152. width?: number;
  67153. height?: number;
  67154. depth: number;
  67155. tileSize?: number;
  67156. tileWidth?: number;
  67157. tileHeight?: number;
  67158. faceUV?: Vector4[];
  67159. faceColors?: Color4[];
  67160. alignHorizontal?: number;
  67161. alignVertical?: number;
  67162. sideOrientation?: number;
  67163. updatable?: boolean;
  67164. }, scene?: Nullable<Scene>): Mesh;
  67165. /**
  67166. * Creates a sphere mesh
  67167. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67168. * * 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`)
  67169. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67170. * * 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
  67171. * * 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)
  67172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67173. * * 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
  67174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67175. * @param name defines the name of the mesh
  67176. * @param options defines the options used to create the mesh
  67177. * @param scene defines the hosting scene
  67178. * @returns the sphere mesh
  67179. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67180. */
  67181. static CreateSphere(name: string, options: {
  67182. segments?: number;
  67183. diameter?: number;
  67184. diameterX?: number;
  67185. diameterY?: number;
  67186. diameterZ?: number;
  67187. arc?: number;
  67188. slice?: number;
  67189. sideOrientation?: number;
  67190. frontUVs?: Vector4;
  67191. backUVs?: Vector4;
  67192. updatable?: boolean;
  67193. }, scene?: Nullable<Scene>): Mesh;
  67194. /**
  67195. * Creates a plane polygonal mesh. By default, this is a disc
  67196. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67197. * * 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
  67198. * * 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
  67199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67200. * * 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
  67201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67202. * @param name defines the name of the mesh
  67203. * @param options defines the options used to create the mesh
  67204. * @param scene defines the hosting scene
  67205. * @returns the plane polygonal mesh
  67206. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67207. */
  67208. static CreateDisc(name: string, options: {
  67209. radius?: number;
  67210. tessellation?: number;
  67211. arc?: number;
  67212. updatable?: boolean;
  67213. sideOrientation?: number;
  67214. frontUVs?: Vector4;
  67215. backUVs?: Vector4;
  67216. }, scene?: Nullable<Scene>): Mesh;
  67217. /**
  67218. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67219. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67220. * * 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`)
  67221. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67222. * * 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
  67223. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67224. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67226. * @param name defines the name of the mesh
  67227. * @param options defines the options used to create the mesh
  67228. * @param scene defines the hosting scene
  67229. * @returns the icosahedron mesh
  67230. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67231. */
  67232. static CreateIcoSphere(name: string, options: {
  67233. radius?: number;
  67234. radiusX?: number;
  67235. radiusY?: number;
  67236. radiusZ?: number;
  67237. flat?: boolean;
  67238. subdivisions?: number;
  67239. sideOrientation?: number;
  67240. frontUVs?: Vector4;
  67241. backUVs?: Vector4;
  67242. updatable?: boolean;
  67243. }, scene?: Nullable<Scene>): Mesh;
  67244. /**
  67245. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67246. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  67247. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  67248. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  67249. * * 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
  67250. * * 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
  67251. * * 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
  67252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67253. * * 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
  67254. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67255. * * 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
  67256. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  67257. * * 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
  67258. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  67259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67260. * @param name defines the name of the mesh
  67261. * @param options defines the options used to create the mesh
  67262. * @param scene defines the hosting scene
  67263. * @returns the ribbon mesh
  67264. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  67265. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67266. */
  67267. static CreateRibbon(name: string, options: {
  67268. pathArray: Vector3[][];
  67269. closeArray?: boolean;
  67270. closePath?: boolean;
  67271. offset?: number;
  67272. updatable?: boolean;
  67273. sideOrientation?: number;
  67274. frontUVs?: Vector4;
  67275. backUVs?: Vector4;
  67276. instance?: Mesh;
  67277. invertUV?: boolean;
  67278. uvs?: Vector2[];
  67279. colors?: Color4[];
  67280. }, scene?: Nullable<Scene>): Mesh;
  67281. /**
  67282. * Creates a cylinder or a cone mesh
  67283. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67284. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67285. * * 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.
  67286. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67287. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67288. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67289. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67290. * * 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).
  67291. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67292. * * 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).
  67293. * * 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
  67294. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67295. * * 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
  67296. * * 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.
  67297. * * If `enclose` is false, a ring surface is one element.
  67298. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67299. * * 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
  67300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67301. * * 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
  67302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67303. * @param name defines the name of the mesh
  67304. * @param options defines the options used to create the mesh
  67305. * @param scene defines the hosting scene
  67306. * @returns the cylinder mesh
  67307. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67308. */
  67309. static CreateCylinder(name: string, options: {
  67310. height?: number;
  67311. diameterTop?: number;
  67312. diameterBottom?: number;
  67313. diameter?: number;
  67314. tessellation?: number;
  67315. subdivisions?: number;
  67316. arc?: number;
  67317. faceColors?: Color4[];
  67318. faceUV?: Vector4[];
  67319. updatable?: boolean;
  67320. hasRings?: boolean;
  67321. enclose?: boolean;
  67322. cap?: number;
  67323. sideOrientation?: number;
  67324. frontUVs?: Vector4;
  67325. backUVs?: Vector4;
  67326. }, scene?: Nullable<Scene>): Mesh;
  67327. /**
  67328. * Creates a torus mesh
  67329. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67330. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67331. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67333. * * 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
  67334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67335. * @param name defines the name of the mesh
  67336. * @param options defines the options used to create the mesh
  67337. * @param scene defines the hosting scene
  67338. * @returns the torus mesh
  67339. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67340. */
  67341. static CreateTorus(name: string, options: {
  67342. diameter?: number;
  67343. thickness?: number;
  67344. tessellation?: number;
  67345. updatable?: boolean;
  67346. sideOrientation?: number;
  67347. frontUVs?: Vector4;
  67348. backUVs?: Vector4;
  67349. }, scene?: Nullable<Scene>): Mesh;
  67350. /**
  67351. * Creates a torus knot mesh
  67352. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67353. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67354. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67355. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67356. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67357. * * 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
  67358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67359. * @param name defines the name of the mesh
  67360. * @param options defines the options used to create the mesh
  67361. * @param scene defines the hosting scene
  67362. * @returns the torus knot mesh
  67363. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67364. */
  67365. static CreateTorusKnot(name: string, options: {
  67366. radius?: number;
  67367. tube?: number;
  67368. radialSegments?: number;
  67369. tubularSegments?: number;
  67370. p?: number;
  67371. q?: number;
  67372. updatable?: boolean;
  67373. sideOrientation?: number;
  67374. frontUVs?: Vector4;
  67375. backUVs?: Vector4;
  67376. }, scene?: Nullable<Scene>): Mesh;
  67377. /**
  67378. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67379. * * 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
  67380. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67381. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67382. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67383. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67384. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67385. * * 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
  67386. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67388. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67389. * @param name defines the name of the new line system
  67390. * @param options defines the options used to create the line system
  67391. * @param scene defines the hosting scene
  67392. * @returns a new line system mesh
  67393. */
  67394. static CreateLineSystem(name: string, options: {
  67395. lines: Vector3[][];
  67396. updatable?: boolean;
  67397. instance?: Nullable<LinesMesh>;
  67398. colors?: Nullable<Color4[][]>;
  67399. useVertexAlpha?: boolean;
  67400. }, scene: Nullable<Scene>): LinesMesh;
  67401. /**
  67402. * Creates a line mesh
  67403. * 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
  67404. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67405. * * The parameter `points` is an array successive Vector3
  67406. * * 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
  67407. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67408. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67409. * * When updating an instance, remember that only point positions can change, not the number of points
  67410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67411. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67412. * @param name defines the name of the new line system
  67413. * @param options defines the options used to create the line system
  67414. * @param scene defines the hosting scene
  67415. * @returns a new line mesh
  67416. */
  67417. static CreateLines(name: string, options: {
  67418. points: Vector3[];
  67419. updatable?: boolean;
  67420. instance?: Nullable<LinesMesh>;
  67421. colors?: Color4[];
  67422. useVertexAlpha?: boolean;
  67423. }, scene?: Nullable<Scene>): LinesMesh;
  67424. /**
  67425. * Creates a dashed line mesh
  67426. * * 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
  67427. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67428. * * The parameter `points` is an array successive Vector3
  67429. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67430. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67431. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67432. * * 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
  67433. * * When updating an instance, remember that only point positions can change, not the number of points
  67434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67435. * @param name defines the name of the mesh
  67436. * @param options defines the options used to create the mesh
  67437. * @param scene defines the hosting scene
  67438. * @returns the dashed line mesh
  67439. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67440. */
  67441. static CreateDashedLines(name: string, options: {
  67442. points: Vector3[];
  67443. dashSize?: number;
  67444. gapSize?: number;
  67445. dashNb?: number;
  67446. updatable?: boolean;
  67447. instance?: LinesMesh;
  67448. }, scene?: Nullable<Scene>): LinesMesh;
  67449. /**
  67450. * 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.
  67451. * * 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.
  67452. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67453. * * 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.
  67454. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67455. * * 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
  67456. * * 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
  67457. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67459. * * 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
  67460. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67462. * @param name defines the name of the mesh
  67463. * @param options defines the options used to create the mesh
  67464. * @param scene defines the hosting scene
  67465. * @returns the extruded shape mesh
  67466. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67468. */
  67469. static ExtrudeShape(name: string, options: {
  67470. shape: Vector3[];
  67471. path: Vector3[];
  67472. scale?: number;
  67473. rotation?: number;
  67474. cap?: number;
  67475. updatable?: boolean;
  67476. sideOrientation?: number;
  67477. frontUVs?: Vector4;
  67478. backUVs?: Vector4;
  67479. instance?: Mesh;
  67480. invertUV?: boolean;
  67481. }, scene?: Nullable<Scene>): Mesh;
  67482. /**
  67483. * Creates an custom extruded shape mesh.
  67484. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67485. * * 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.
  67486. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67487. * * 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
  67488. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67489. * * 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
  67490. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67491. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67492. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67493. * * 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
  67494. * * 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
  67495. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67497. * * 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
  67498. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67500. * @param name defines the name of the mesh
  67501. * @param options defines the options used to create the mesh
  67502. * @param scene defines the hosting scene
  67503. * @returns the custom extruded shape mesh
  67504. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67505. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67506. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67507. */
  67508. static ExtrudeShapeCustom(name: string, options: {
  67509. shape: Vector3[];
  67510. path: Vector3[];
  67511. scaleFunction?: any;
  67512. rotationFunction?: any;
  67513. ribbonCloseArray?: boolean;
  67514. ribbonClosePath?: boolean;
  67515. cap?: number;
  67516. updatable?: boolean;
  67517. sideOrientation?: number;
  67518. frontUVs?: Vector4;
  67519. backUVs?: Vector4;
  67520. instance?: Mesh;
  67521. invertUV?: boolean;
  67522. }, scene?: Nullable<Scene>): Mesh;
  67523. /**
  67524. * Creates lathe mesh.
  67525. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67526. * * 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
  67527. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67528. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67529. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67530. * * 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
  67531. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67532. * * 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
  67533. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67534. * * 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
  67535. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67537. * @param name defines the name of the mesh
  67538. * @param options defines the options used to create the mesh
  67539. * @param scene defines the hosting scene
  67540. * @returns the lathe mesh
  67541. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67542. */
  67543. static CreateLathe(name: string, options: {
  67544. shape: Vector3[];
  67545. radius?: number;
  67546. tessellation?: number;
  67547. clip?: number;
  67548. arc?: number;
  67549. closed?: boolean;
  67550. updatable?: boolean;
  67551. sideOrientation?: number;
  67552. frontUVs?: Vector4;
  67553. backUVs?: Vector4;
  67554. cap?: number;
  67555. invertUV?: boolean;
  67556. }, scene?: Nullable<Scene>): Mesh;
  67557. /**
  67558. * Creates a tiled plane mesh
  67559. * * You can set a limited pattern arrangement with the tiles
  67560. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67561. * * 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
  67562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67563. * @param name defines the name of the mesh
  67564. * @param options defines the options used to create the mesh
  67565. * @param scene defines the hosting scene
  67566. * @returns the plane mesh
  67567. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67568. */
  67569. static CreateTiledPlane(name: string, options: {
  67570. pattern?: number;
  67571. tileSize?: number;
  67572. tileWidth?: number;
  67573. tileHeight?: number;
  67574. size?: number;
  67575. width?: number;
  67576. height?: number;
  67577. alignHorizontal?: number;
  67578. alignVertical?: number;
  67579. sideOrientation?: number;
  67580. frontUVs?: Vector4;
  67581. backUVs?: Vector4;
  67582. updatable?: boolean;
  67583. }, scene?: Nullable<Scene>): Mesh;
  67584. /**
  67585. * Creates a plane mesh
  67586. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67587. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67588. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67590. * * 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
  67591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67592. * @param name defines the name of the mesh
  67593. * @param options defines the options used to create the mesh
  67594. * @param scene defines the hosting scene
  67595. * @returns the plane mesh
  67596. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67597. */
  67598. static CreatePlane(name: string, options: {
  67599. size?: number;
  67600. width?: number;
  67601. height?: number;
  67602. sideOrientation?: number;
  67603. frontUVs?: Vector4;
  67604. backUVs?: Vector4;
  67605. updatable?: boolean;
  67606. sourcePlane?: Plane;
  67607. }, scene?: Nullable<Scene>): Mesh;
  67608. /**
  67609. * Creates a ground mesh
  67610. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67611. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67613. * @param name defines the name of the mesh
  67614. * @param options defines the options used to create the mesh
  67615. * @param scene defines the hosting scene
  67616. * @returns the ground mesh
  67617. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67618. */
  67619. static CreateGround(name: string, options: {
  67620. width?: number;
  67621. height?: number;
  67622. subdivisions?: number;
  67623. subdivisionsX?: number;
  67624. subdivisionsY?: number;
  67625. updatable?: boolean;
  67626. }, scene?: Nullable<Scene>): Mesh;
  67627. /**
  67628. * Creates a tiled ground mesh
  67629. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67630. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67631. * * 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
  67632. * * 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
  67633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67634. * @param name defines the name of the mesh
  67635. * @param options defines the options used to create the mesh
  67636. * @param scene defines the hosting scene
  67637. * @returns the tiled ground mesh
  67638. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67639. */
  67640. static CreateTiledGround(name: string, options: {
  67641. xmin: number;
  67642. zmin: number;
  67643. xmax: number;
  67644. zmax: number;
  67645. subdivisions?: {
  67646. w: number;
  67647. h: number;
  67648. };
  67649. precision?: {
  67650. w: number;
  67651. h: number;
  67652. };
  67653. updatable?: boolean;
  67654. }, scene?: Nullable<Scene>): Mesh;
  67655. /**
  67656. * Creates a ground mesh from a height map
  67657. * * The parameter `url` sets the URL of the height map image resource.
  67658. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67659. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67660. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67661. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67662. * * 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.
  67663. * * 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).
  67664. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67666. * @param name defines the name of the mesh
  67667. * @param url defines the url to the height map
  67668. * @param options defines the options used to create the mesh
  67669. * @param scene defines the hosting scene
  67670. * @returns the ground mesh
  67671. * @see https://doc.babylonjs.com/babylon101/height_map
  67672. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67673. */
  67674. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67675. width?: number;
  67676. height?: number;
  67677. subdivisions?: number;
  67678. minHeight?: number;
  67679. maxHeight?: number;
  67680. colorFilter?: Color3;
  67681. alphaFilter?: number;
  67682. updatable?: boolean;
  67683. onReady?: (mesh: GroundMesh) => void;
  67684. }, scene?: Nullable<Scene>): GroundMesh;
  67685. /**
  67686. * Creates a polygon mesh
  67687. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67688. * * 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
  67689. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67691. * * 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)
  67692. * * Remember you can only change the shape positions, not their number when updating a polygon
  67693. * @param name defines the name of the mesh
  67694. * @param options defines the options used to create the mesh
  67695. * @param scene defines the hosting scene
  67696. * @param earcutInjection can be used to inject your own earcut reference
  67697. * @returns the polygon mesh
  67698. */
  67699. static CreatePolygon(name: string, options: {
  67700. shape: Vector3[];
  67701. holes?: Vector3[][];
  67702. depth?: number;
  67703. faceUV?: Vector4[];
  67704. faceColors?: Color4[];
  67705. updatable?: boolean;
  67706. sideOrientation?: number;
  67707. frontUVs?: Vector4;
  67708. backUVs?: Vector4;
  67709. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67710. /**
  67711. * Creates an extruded polygon mesh, with depth in the Y direction.
  67712. * * 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)
  67713. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67714. * @param name defines the name of the mesh
  67715. * @param options defines the options used to create the mesh
  67716. * @param scene defines the hosting scene
  67717. * @param earcutInjection can be used to inject your own earcut reference
  67718. * @returns the polygon mesh
  67719. */
  67720. static ExtrudePolygon(name: string, options: {
  67721. shape: Vector3[];
  67722. holes?: Vector3[][];
  67723. depth?: number;
  67724. faceUV?: Vector4[];
  67725. faceColors?: Color4[];
  67726. updatable?: boolean;
  67727. sideOrientation?: number;
  67728. frontUVs?: Vector4;
  67729. backUVs?: Vector4;
  67730. wrap?: boolean;
  67731. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67732. /**
  67733. * Creates a tube mesh.
  67734. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67735. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67736. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67737. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67738. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67739. * * 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)
  67740. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67741. * * 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
  67742. * * 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
  67743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67744. * * 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
  67745. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67747. * @param name defines the name of the mesh
  67748. * @param options defines the options used to create the mesh
  67749. * @param scene defines the hosting scene
  67750. * @returns the tube mesh
  67751. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67752. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67753. */
  67754. static CreateTube(name: string, options: {
  67755. path: Vector3[];
  67756. radius?: number;
  67757. tessellation?: number;
  67758. radiusFunction?: {
  67759. (i: number, distance: number): number;
  67760. };
  67761. cap?: number;
  67762. arc?: number;
  67763. updatable?: boolean;
  67764. sideOrientation?: number;
  67765. frontUVs?: Vector4;
  67766. backUVs?: Vector4;
  67767. instance?: Mesh;
  67768. invertUV?: boolean;
  67769. }, scene?: Nullable<Scene>): Mesh;
  67770. /**
  67771. * Creates a polyhedron mesh
  67772. * * 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
  67773. * * The parameter `size` (positive float, default 1) sets the polygon size
  67774. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67775. * * 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`
  67776. * * 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
  67777. * * 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)`)
  67778. * * 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
  67779. * * 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
  67780. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67781. * * 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
  67782. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67783. * @param name defines the name of the mesh
  67784. * @param options defines the options used to create the mesh
  67785. * @param scene defines the hosting scene
  67786. * @returns the polyhedron mesh
  67787. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67788. */
  67789. static CreatePolyhedron(name: string, options: {
  67790. type?: number;
  67791. size?: number;
  67792. sizeX?: number;
  67793. sizeY?: number;
  67794. sizeZ?: number;
  67795. custom?: any;
  67796. faceUV?: Vector4[];
  67797. faceColors?: Color4[];
  67798. flat?: boolean;
  67799. updatable?: boolean;
  67800. sideOrientation?: number;
  67801. frontUVs?: Vector4;
  67802. backUVs?: Vector4;
  67803. }, scene?: Nullable<Scene>): Mesh;
  67804. /**
  67805. * Creates a decal mesh.
  67806. * 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
  67807. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67808. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67809. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67810. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67811. * @param name defines the name of the mesh
  67812. * @param sourceMesh defines the mesh where the decal must be applied
  67813. * @param options defines the options used to create the mesh
  67814. * @param scene defines the hosting scene
  67815. * @returns the decal mesh
  67816. * @see https://doc.babylonjs.com/how_to/decals
  67817. */
  67818. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67819. position?: Vector3;
  67820. normal?: Vector3;
  67821. size?: Vector3;
  67822. angle?: number;
  67823. }): Mesh;
  67824. /**
  67825. * Creates a Capsule Mesh
  67826. * @param name defines the name of the mesh.
  67827. * @param options the constructors options used to shape the mesh.
  67828. * @param scene defines the scene the mesh is scoped to.
  67829. * @returns the capsule mesh
  67830. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67831. */
  67832. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67833. }
  67834. }
  67835. declare module BABYLON {
  67836. /**
  67837. * A simplifier interface for future simplification implementations
  67838. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67839. */
  67840. export interface ISimplifier {
  67841. /**
  67842. * Simplification of a given mesh according to the given settings.
  67843. * Since this requires computation, it is assumed that the function runs async.
  67844. * @param settings The settings of the simplification, including quality and distance
  67845. * @param successCallback A callback that will be called after the mesh was simplified.
  67846. * @param errorCallback in case of an error, this callback will be called. optional.
  67847. */
  67848. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67849. }
  67850. /**
  67851. * Expected simplification settings.
  67852. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67853. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67854. */
  67855. export interface ISimplificationSettings {
  67856. /**
  67857. * Gets or sets the expected quality
  67858. */
  67859. quality: number;
  67860. /**
  67861. * Gets or sets the distance when this optimized version should be used
  67862. */
  67863. distance: number;
  67864. /**
  67865. * Gets an already optimized mesh
  67866. */
  67867. optimizeMesh?: boolean;
  67868. }
  67869. /**
  67870. * Class used to specify simplification options
  67871. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67872. */
  67873. export class SimplificationSettings implements ISimplificationSettings {
  67874. /** expected quality */
  67875. quality: number;
  67876. /** distance when this optimized version should be used */
  67877. distance: number;
  67878. /** already optimized mesh */
  67879. optimizeMesh?: boolean | undefined;
  67880. /**
  67881. * Creates a SimplificationSettings
  67882. * @param quality expected quality
  67883. * @param distance distance when this optimized version should be used
  67884. * @param optimizeMesh already optimized mesh
  67885. */
  67886. constructor(
  67887. /** expected quality */
  67888. quality: number,
  67889. /** distance when this optimized version should be used */
  67890. distance: number,
  67891. /** already optimized mesh */
  67892. optimizeMesh?: boolean | undefined);
  67893. }
  67894. /**
  67895. * Interface used to define a simplification task
  67896. */
  67897. export interface ISimplificationTask {
  67898. /**
  67899. * Array of settings
  67900. */
  67901. settings: Array<ISimplificationSettings>;
  67902. /**
  67903. * Simplification type
  67904. */
  67905. simplificationType: SimplificationType;
  67906. /**
  67907. * Mesh to simplify
  67908. */
  67909. mesh: Mesh;
  67910. /**
  67911. * Callback called on success
  67912. */
  67913. successCallback?: () => void;
  67914. /**
  67915. * Defines if parallel processing can be used
  67916. */
  67917. parallelProcessing: boolean;
  67918. }
  67919. /**
  67920. * Queue used to order the simplification tasks
  67921. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67922. */
  67923. export class SimplificationQueue {
  67924. private _simplificationArray;
  67925. /**
  67926. * Gets a boolean indicating that the process is still running
  67927. */
  67928. running: boolean;
  67929. /**
  67930. * Creates a new queue
  67931. */
  67932. constructor();
  67933. /**
  67934. * Adds a new simplification task
  67935. * @param task defines a task to add
  67936. */
  67937. addTask(task: ISimplificationTask): void;
  67938. /**
  67939. * Execute next task
  67940. */
  67941. executeNext(): void;
  67942. /**
  67943. * Execute a simplification task
  67944. * @param task defines the task to run
  67945. */
  67946. runSimplification(task: ISimplificationTask): void;
  67947. private getSimplifier;
  67948. }
  67949. /**
  67950. * The implemented types of simplification
  67951. * At the moment only Quadratic Error Decimation is implemented
  67952. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67953. */
  67954. export enum SimplificationType {
  67955. /** Quadratic error decimation */
  67956. QUADRATIC = 0
  67957. }
  67958. /**
  67959. * An implementation of the Quadratic Error simplification algorithm.
  67960. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67961. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67962. * @author RaananW
  67963. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67964. */
  67965. export class QuadraticErrorSimplification implements ISimplifier {
  67966. private _mesh;
  67967. private triangles;
  67968. private vertices;
  67969. private references;
  67970. private _reconstructedMesh;
  67971. /** Gets or sets the number pf sync interations */
  67972. syncIterations: number;
  67973. /** Gets or sets the aggressiveness of the simplifier */
  67974. aggressiveness: number;
  67975. /** Gets or sets the number of allowed iterations for decimation */
  67976. decimationIterations: number;
  67977. /** Gets or sets the espilon to use for bounding box computation */
  67978. boundingBoxEpsilon: number;
  67979. /**
  67980. * Creates a new QuadraticErrorSimplification
  67981. * @param _mesh defines the target mesh
  67982. */
  67983. constructor(_mesh: Mesh);
  67984. /**
  67985. * Simplification of a given mesh according to the given settings.
  67986. * Since this requires computation, it is assumed that the function runs async.
  67987. * @param settings The settings of the simplification, including quality and distance
  67988. * @param successCallback A callback that will be called after the mesh was simplified.
  67989. */
  67990. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67991. private runDecimation;
  67992. private initWithMesh;
  67993. private init;
  67994. private reconstructMesh;
  67995. private initDecimatedMesh;
  67996. private isFlipped;
  67997. private updateTriangles;
  67998. private identifyBorder;
  67999. private updateMesh;
  68000. private vertexError;
  68001. private calculateError;
  68002. }
  68003. }
  68004. declare module BABYLON {
  68005. interface Scene {
  68006. /** @hidden (Backing field) */
  68007. _simplificationQueue: SimplificationQueue;
  68008. /**
  68009. * Gets or sets the simplification queue attached to the scene
  68010. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68011. */
  68012. simplificationQueue: SimplificationQueue;
  68013. }
  68014. interface Mesh {
  68015. /**
  68016. * Simplify the mesh according to the given array of settings.
  68017. * Function will return immediately and will simplify async
  68018. * @param settings a collection of simplification settings
  68019. * @param parallelProcessing should all levels calculate parallel or one after the other
  68020. * @param simplificationType the type of simplification to run
  68021. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68022. * @returns the current mesh
  68023. */
  68024. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68025. }
  68026. /**
  68027. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68028. * created in a scene
  68029. */
  68030. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68031. /**
  68032. * The component name helpfull to identify the component in the list of scene components.
  68033. */
  68034. readonly name: string;
  68035. /**
  68036. * The scene the component belongs to.
  68037. */
  68038. scene: Scene;
  68039. /**
  68040. * Creates a new instance of the component for the given scene
  68041. * @param scene Defines the scene to register the component in
  68042. */
  68043. constructor(scene: Scene);
  68044. /**
  68045. * Registers the component in a given scene
  68046. */
  68047. register(): void;
  68048. /**
  68049. * Rebuilds the elements related to this component in case of
  68050. * context lost for instance.
  68051. */
  68052. rebuild(): void;
  68053. /**
  68054. * Disposes the component and the associated ressources
  68055. */
  68056. dispose(): void;
  68057. private _beforeCameraUpdate;
  68058. }
  68059. }
  68060. declare module BABYLON {
  68061. interface Mesh {
  68062. /**
  68063. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  68064. */
  68065. thinInstanceEnablePicking: boolean;
  68066. /**
  68067. * Creates a new thin instance
  68068. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  68069. * @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
  68070. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  68071. */
  68072. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  68073. /**
  68074. * Adds the transformation (matrix) of the current mesh as a thin instance
  68075. * @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
  68076. * @returns the thin instance index number
  68077. */
  68078. thinInstanceAddSelf(refresh: boolean): number;
  68079. /**
  68080. * Registers a custom attribute to be used with thin instances
  68081. * @param kind name of the attribute
  68082. * @param stride size in floats of the attribute
  68083. */
  68084. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  68085. /**
  68086. * Sets the matrix of a thin instance
  68087. * @param index index of the thin instance
  68088. * @param matrix matrix to set
  68089. * @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
  68090. */
  68091. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  68092. /**
  68093. * Sets the value of a custom attribute for a thin instance
  68094. * @param kind name of the attribute
  68095. * @param index index of the thin instance
  68096. * @param value value to set
  68097. * @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
  68098. */
  68099. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  68100. /**
  68101. * 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.
  68102. */
  68103. thinInstanceCount: number;
  68104. /**
  68105. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  68106. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  68107. * @param buffer buffer to set
  68108. * @param stride size in floats of each value of the buffer
  68109. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  68110. */
  68111. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  68112. /**
  68113. * Gets the list of world matrices
  68114. * @return an array containing all the world matrices from the thin instances
  68115. */
  68116. thinInstanceGetWorldMatrices(): Matrix[];
  68117. /**
  68118. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  68119. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68120. */
  68121. thinInstanceBufferUpdated(kind: string): void;
  68122. /**
  68123. * Applies a partial update to a buffer directly on the GPU
  68124. * 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
  68125. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68126. * @param data the data to set in the GPU buffer
  68127. * @param offset the offset in the GPU buffer where to update the data
  68128. */
  68129. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  68130. /**
  68131. * Refreshes the bounding info, taking into account all the thin instances defined
  68132. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68133. */
  68134. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68135. /** @hidden */
  68136. _thinInstanceInitializeUserStorage(): void;
  68137. /** @hidden */
  68138. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68139. /** @hidden */
  68140. _userThinInstanceBuffersStorage: {
  68141. data: {
  68142. [key: string]: Float32Array;
  68143. };
  68144. sizes: {
  68145. [key: string]: number;
  68146. };
  68147. vertexBuffers: {
  68148. [key: string]: Nullable<VertexBuffer>;
  68149. };
  68150. strides: {
  68151. [key: string]: number;
  68152. };
  68153. };
  68154. }
  68155. }
  68156. declare module BABYLON {
  68157. /**
  68158. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68159. */
  68160. export interface INavigationEnginePlugin {
  68161. /**
  68162. * plugin name
  68163. */
  68164. name: string;
  68165. /**
  68166. * Creates a navigation mesh
  68167. * @param meshes array of all the geometry used to compute the navigatio mesh
  68168. * @param parameters bunch of parameters used to filter geometry
  68169. */
  68170. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68171. /**
  68172. * Create a navigation mesh debug mesh
  68173. * @param scene is where the mesh will be added
  68174. * @returns debug display mesh
  68175. */
  68176. createDebugNavMesh(scene: Scene): Mesh;
  68177. /**
  68178. * Get a navigation mesh constrained position, closest to the parameter position
  68179. * @param position world position
  68180. * @returns the closest point to position constrained by the navigation mesh
  68181. */
  68182. getClosestPoint(position: Vector3): Vector3;
  68183. /**
  68184. * Get a navigation mesh constrained position, closest to the parameter position
  68185. * @param position world position
  68186. * @param result output the closest point to position constrained by the navigation mesh
  68187. */
  68188. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68189. /**
  68190. * Get a navigation mesh constrained position, within a particular radius
  68191. * @param position world position
  68192. * @param maxRadius the maximum distance to the constrained world position
  68193. * @returns the closest point to position constrained by the navigation mesh
  68194. */
  68195. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68196. /**
  68197. * Get a navigation mesh constrained position, within a particular radius
  68198. * @param position world position
  68199. * @param maxRadius the maximum distance to the constrained world position
  68200. * @param result output the closest point to position constrained by the navigation mesh
  68201. */
  68202. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68203. /**
  68204. * Compute the final position from a segment made of destination-position
  68205. * @param position world position
  68206. * @param destination world position
  68207. * @returns the resulting point along the navmesh
  68208. */
  68209. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68210. /**
  68211. * Compute the final position from a segment made of destination-position
  68212. * @param position world position
  68213. * @param destination world position
  68214. * @param result output the resulting point along the navmesh
  68215. */
  68216. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68217. /**
  68218. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68219. * @param start world position
  68220. * @param end world position
  68221. * @returns array containing world position composing the path
  68222. */
  68223. computePath(start: Vector3, end: Vector3): Vector3[];
  68224. /**
  68225. * If this plugin is supported
  68226. * @returns true if plugin is supported
  68227. */
  68228. isSupported(): boolean;
  68229. /**
  68230. * Create a new Crowd so you can add agents
  68231. * @param maxAgents the maximum agent count in the crowd
  68232. * @param maxAgentRadius the maximum radius an agent can have
  68233. * @param scene to attach the crowd to
  68234. * @returns the crowd you can add agents to
  68235. */
  68236. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68237. /**
  68238. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68239. * The queries will try to find a solution within those bounds
  68240. * default is (1,1,1)
  68241. * @param extent x,y,z value that define the extent around the queries point of reference
  68242. */
  68243. setDefaultQueryExtent(extent: Vector3): void;
  68244. /**
  68245. * Get the Bounding box extent specified by setDefaultQueryExtent
  68246. * @returns the box extent values
  68247. */
  68248. getDefaultQueryExtent(): Vector3;
  68249. /**
  68250. * build the navmesh from a previously saved state using getNavmeshData
  68251. * @param data the Uint8Array returned by getNavmeshData
  68252. */
  68253. buildFromNavmeshData(data: Uint8Array): void;
  68254. /**
  68255. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68256. * @returns data the Uint8Array that can be saved and reused
  68257. */
  68258. getNavmeshData(): Uint8Array;
  68259. /**
  68260. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68261. * @param result output the box extent values
  68262. */
  68263. getDefaultQueryExtentToRef(result: Vector3): void;
  68264. /**
  68265. * Release all resources
  68266. */
  68267. dispose(): void;
  68268. }
  68269. /**
  68270. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68271. */
  68272. export interface ICrowd {
  68273. /**
  68274. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68275. * You can attach anything to that node. The node position is updated in the scene update tick.
  68276. * @param pos world position that will be constrained by the navigation mesh
  68277. * @param parameters agent parameters
  68278. * @param transform hooked to the agent that will be update by the scene
  68279. * @returns agent index
  68280. */
  68281. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68282. /**
  68283. * Returns the agent position in world space
  68284. * @param index agent index returned by addAgent
  68285. * @returns world space position
  68286. */
  68287. getAgentPosition(index: number): Vector3;
  68288. /**
  68289. * Gets the agent position result in world space
  68290. * @param index agent index returned by addAgent
  68291. * @param result output world space position
  68292. */
  68293. getAgentPositionToRef(index: number, result: Vector3): void;
  68294. /**
  68295. * Gets the agent velocity in world space
  68296. * @param index agent index returned by addAgent
  68297. * @returns world space velocity
  68298. */
  68299. getAgentVelocity(index: number): Vector3;
  68300. /**
  68301. * Gets the agent velocity result in world space
  68302. * @param index agent index returned by addAgent
  68303. * @param result output world space velocity
  68304. */
  68305. getAgentVelocityToRef(index: number, result: Vector3): void;
  68306. /**
  68307. * Gets the agent next target point on the path
  68308. * @param index agent index returned by addAgent
  68309. * @returns world space position
  68310. */
  68311. getAgentNextTargetPath(index: number): Vector3;
  68312. /**
  68313. * Gets the agent state
  68314. * @param index agent index returned by addAgent
  68315. * @returns agent state
  68316. */
  68317. getAgentState(index: number): number;
  68318. /**
  68319. * returns true if the agent in over an off mesh link connection
  68320. * @param index agent index returned by addAgent
  68321. * @returns true if over an off mesh link connection
  68322. */
  68323. overOffmeshConnection(index: number): boolean;
  68324. /**
  68325. * Gets the agent next target point on the path
  68326. * @param index agent index returned by addAgent
  68327. * @param result output world space position
  68328. */
  68329. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68330. /**
  68331. * remove a particular agent previously created
  68332. * @param index agent index returned by addAgent
  68333. */
  68334. removeAgent(index: number): void;
  68335. /**
  68336. * get the list of all agents attached to this crowd
  68337. * @returns list of agent indices
  68338. */
  68339. getAgents(): number[];
  68340. /**
  68341. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68342. * @param deltaTime in seconds
  68343. */
  68344. update(deltaTime: number): void;
  68345. /**
  68346. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68347. * @param index agent index returned by addAgent
  68348. * @param destination targeted world position
  68349. */
  68350. agentGoto(index: number, destination: Vector3): void;
  68351. /**
  68352. * Teleport the agent to a new position
  68353. * @param index agent index returned by addAgent
  68354. * @param destination targeted world position
  68355. */
  68356. agentTeleport(index: number, destination: Vector3): void;
  68357. /**
  68358. * Update agent parameters
  68359. * @param index agent index returned by addAgent
  68360. * @param parameters agent parameters
  68361. */
  68362. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68363. /**
  68364. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68365. * The queries will try to find a solution within those bounds
  68366. * default is (1,1,1)
  68367. * @param extent x,y,z value that define the extent around the queries point of reference
  68368. */
  68369. setDefaultQueryExtent(extent: Vector3): void;
  68370. /**
  68371. * Get the Bounding box extent specified by setDefaultQueryExtent
  68372. * @returns the box extent values
  68373. */
  68374. getDefaultQueryExtent(): Vector3;
  68375. /**
  68376. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68377. * @param result output the box extent values
  68378. */
  68379. getDefaultQueryExtentToRef(result: Vector3): void;
  68380. /**
  68381. * Release all resources
  68382. */
  68383. dispose(): void;
  68384. }
  68385. /**
  68386. * Configures an agent
  68387. */
  68388. export interface IAgentParameters {
  68389. /**
  68390. * Agent radius. [Limit: >= 0]
  68391. */
  68392. radius: number;
  68393. /**
  68394. * Agent height. [Limit: > 0]
  68395. */
  68396. height: number;
  68397. /**
  68398. * Maximum allowed acceleration. [Limit: >= 0]
  68399. */
  68400. maxAcceleration: number;
  68401. /**
  68402. * Maximum allowed speed. [Limit: >= 0]
  68403. */
  68404. maxSpeed: number;
  68405. /**
  68406. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68407. */
  68408. collisionQueryRange: number;
  68409. /**
  68410. * The path visibility optimization range. [Limit: > 0]
  68411. */
  68412. pathOptimizationRange: number;
  68413. /**
  68414. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68415. */
  68416. separationWeight: number;
  68417. }
  68418. /**
  68419. * Configures the navigation mesh creation
  68420. */
  68421. export interface INavMeshParameters {
  68422. /**
  68423. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68424. */
  68425. cs: number;
  68426. /**
  68427. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68428. */
  68429. ch: number;
  68430. /**
  68431. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68432. */
  68433. walkableSlopeAngle: number;
  68434. /**
  68435. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68436. * be considered walkable. [Limit: >= 3] [Units: vx]
  68437. */
  68438. walkableHeight: number;
  68439. /**
  68440. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68441. */
  68442. walkableClimb: number;
  68443. /**
  68444. * The distance to erode/shrink the walkable area of the heightfield away from
  68445. * obstructions. [Limit: >=0] [Units: vx]
  68446. */
  68447. walkableRadius: number;
  68448. /**
  68449. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68450. */
  68451. maxEdgeLen: number;
  68452. /**
  68453. * The maximum distance a simplfied contour's border edges should deviate
  68454. * the original raw contour. [Limit: >=0] [Units: vx]
  68455. */
  68456. maxSimplificationError: number;
  68457. /**
  68458. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68459. */
  68460. minRegionArea: number;
  68461. /**
  68462. * Any regions with a span count smaller than this value will, if possible,
  68463. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68464. */
  68465. mergeRegionArea: number;
  68466. /**
  68467. * The maximum number of vertices allowed for polygons generated during the
  68468. * contour to polygon conversion process. [Limit: >= 3]
  68469. */
  68470. maxVertsPerPoly: number;
  68471. /**
  68472. * Sets the sampling distance to use when generating the detail mesh.
  68473. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68474. */
  68475. detailSampleDist: number;
  68476. /**
  68477. * The maximum distance the detail mesh surface should deviate from heightfield
  68478. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68479. */
  68480. detailSampleMaxError: number;
  68481. }
  68482. }
  68483. declare module BABYLON {
  68484. /**
  68485. * RecastJS navigation plugin
  68486. */
  68487. export class RecastJSPlugin implements INavigationEnginePlugin {
  68488. /**
  68489. * Reference to the Recast library
  68490. */
  68491. bjsRECAST: any;
  68492. /**
  68493. * plugin name
  68494. */
  68495. name: string;
  68496. /**
  68497. * the first navmesh created. We might extend this to support multiple navmeshes
  68498. */
  68499. navMesh: any;
  68500. /**
  68501. * Initializes the recastJS plugin
  68502. * @param recastInjection can be used to inject your own recast reference
  68503. */
  68504. constructor(recastInjection?: any);
  68505. /**
  68506. * Creates a navigation mesh
  68507. * @param meshes array of all the geometry used to compute the navigatio mesh
  68508. * @param parameters bunch of parameters used to filter geometry
  68509. */
  68510. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68511. /**
  68512. * Create a navigation mesh debug mesh
  68513. * @param scene is where the mesh will be added
  68514. * @returns debug display mesh
  68515. */
  68516. createDebugNavMesh(scene: Scene): Mesh;
  68517. /**
  68518. * Get a navigation mesh constrained position, closest to the parameter position
  68519. * @param position world position
  68520. * @returns the closest point to position constrained by the navigation mesh
  68521. */
  68522. getClosestPoint(position: Vector3): Vector3;
  68523. /**
  68524. * Get a navigation mesh constrained position, closest to the parameter position
  68525. * @param position world position
  68526. * @param result output the closest point to position constrained by the navigation mesh
  68527. */
  68528. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68529. /**
  68530. * Get a navigation mesh constrained position, within a particular radius
  68531. * @param position world position
  68532. * @param maxRadius the maximum distance to the constrained world position
  68533. * @returns the closest point to position constrained by the navigation mesh
  68534. */
  68535. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68536. /**
  68537. * Get a navigation mesh constrained position, within a particular radius
  68538. * @param position world position
  68539. * @param maxRadius the maximum distance to the constrained world position
  68540. * @param result output the closest point to position constrained by the navigation mesh
  68541. */
  68542. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68543. /**
  68544. * Compute the final position from a segment made of destination-position
  68545. * @param position world position
  68546. * @param destination world position
  68547. * @returns the resulting point along the navmesh
  68548. */
  68549. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68550. /**
  68551. * Compute the final position from a segment made of destination-position
  68552. * @param position world position
  68553. * @param destination world position
  68554. * @param result output the resulting point along the navmesh
  68555. */
  68556. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68557. /**
  68558. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68559. * @param start world position
  68560. * @param end world position
  68561. * @returns array containing world position composing the path
  68562. */
  68563. computePath(start: Vector3, end: Vector3): Vector3[];
  68564. /**
  68565. * Create a new Crowd so you can add agents
  68566. * @param maxAgents the maximum agent count in the crowd
  68567. * @param maxAgentRadius the maximum radius an agent can have
  68568. * @param scene to attach the crowd to
  68569. * @returns the crowd you can add agents to
  68570. */
  68571. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68572. /**
  68573. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68574. * The queries will try to find a solution within those bounds
  68575. * default is (1,1,1)
  68576. * @param extent x,y,z value that define the extent around the queries point of reference
  68577. */
  68578. setDefaultQueryExtent(extent: Vector3): void;
  68579. /**
  68580. * Get the Bounding box extent specified by setDefaultQueryExtent
  68581. * @returns the box extent values
  68582. */
  68583. getDefaultQueryExtent(): Vector3;
  68584. /**
  68585. * build the navmesh from a previously saved state using getNavmeshData
  68586. * @param data the Uint8Array returned by getNavmeshData
  68587. */
  68588. buildFromNavmeshData(data: Uint8Array): void;
  68589. /**
  68590. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68591. * @returns data the Uint8Array that can be saved and reused
  68592. */
  68593. getNavmeshData(): Uint8Array;
  68594. /**
  68595. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68596. * @param result output the box extent values
  68597. */
  68598. getDefaultQueryExtentToRef(result: Vector3): void;
  68599. /**
  68600. * Disposes
  68601. */
  68602. dispose(): void;
  68603. /**
  68604. * If this plugin is supported
  68605. * @returns true if plugin is supported
  68606. */
  68607. isSupported(): boolean;
  68608. }
  68609. /**
  68610. * Recast detour crowd implementation
  68611. */
  68612. export class RecastJSCrowd implements ICrowd {
  68613. /**
  68614. * Recast/detour plugin
  68615. */
  68616. bjsRECASTPlugin: RecastJSPlugin;
  68617. /**
  68618. * Link to the detour crowd
  68619. */
  68620. recastCrowd: any;
  68621. /**
  68622. * One transform per agent
  68623. */
  68624. transforms: TransformNode[];
  68625. /**
  68626. * All agents created
  68627. */
  68628. agents: number[];
  68629. /**
  68630. * Link to the scene is kept to unregister the crowd from the scene
  68631. */
  68632. private _scene;
  68633. /**
  68634. * Observer for crowd updates
  68635. */
  68636. private _onBeforeAnimationsObserver;
  68637. /**
  68638. * Constructor
  68639. * @param plugin recastJS plugin
  68640. * @param maxAgents the maximum agent count in the crowd
  68641. * @param maxAgentRadius the maximum radius an agent can have
  68642. * @param scene to attach the crowd to
  68643. * @returns the crowd you can add agents to
  68644. */
  68645. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68646. /**
  68647. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68648. * You can attach anything to that node. The node position is updated in the scene update tick.
  68649. * @param pos world position that will be constrained by the navigation mesh
  68650. * @param parameters agent parameters
  68651. * @param transform hooked to the agent that will be update by the scene
  68652. * @returns agent index
  68653. */
  68654. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68655. /**
  68656. * Returns the agent position in world space
  68657. * @param index agent index returned by addAgent
  68658. * @returns world space position
  68659. */
  68660. getAgentPosition(index: number): Vector3;
  68661. /**
  68662. * Returns the agent position result in world space
  68663. * @param index agent index returned by addAgent
  68664. * @param result output world space position
  68665. */
  68666. getAgentPositionToRef(index: number, result: Vector3): void;
  68667. /**
  68668. * Returns the agent velocity in world space
  68669. * @param index agent index returned by addAgent
  68670. * @returns world space velocity
  68671. */
  68672. getAgentVelocity(index: number): Vector3;
  68673. /**
  68674. * Returns the agent velocity result in world space
  68675. * @param index agent index returned by addAgent
  68676. * @param result output world space velocity
  68677. */
  68678. getAgentVelocityToRef(index: number, result: Vector3): void;
  68679. /**
  68680. * Returns the agent next target point on the path
  68681. * @param index agent index returned by addAgent
  68682. * @returns world space position
  68683. */
  68684. getAgentNextTargetPath(index: number): Vector3;
  68685. /**
  68686. * Returns the agent next target point on the path
  68687. * @param index agent index returned by addAgent
  68688. * @param result output world space position
  68689. */
  68690. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68691. /**
  68692. * Gets the agent state
  68693. * @param index agent index returned by addAgent
  68694. * @returns agent state
  68695. */
  68696. getAgentState(index: number): number;
  68697. /**
  68698. * returns true if the agent in over an off mesh link connection
  68699. * @param index agent index returned by addAgent
  68700. * @returns true if over an off mesh link connection
  68701. */
  68702. overOffmeshConnection(index: number): boolean;
  68703. /**
  68704. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68705. * @param index agent index returned by addAgent
  68706. * @param destination targeted world position
  68707. */
  68708. agentGoto(index: number, destination: Vector3): void;
  68709. /**
  68710. * Teleport the agent to a new position
  68711. * @param index agent index returned by addAgent
  68712. * @param destination targeted world position
  68713. */
  68714. agentTeleport(index: number, destination: Vector3): void;
  68715. /**
  68716. * Update agent parameters
  68717. * @param index agent index returned by addAgent
  68718. * @param parameters agent parameters
  68719. */
  68720. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68721. /**
  68722. * remove a particular agent previously created
  68723. * @param index agent index returned by addAgent
  68724. */
  68725. removeAgent(index: number): void;
  68726. /**
  68727. * get the list of all agents attached to this crowd
  68728. * @returns list of agent indices
  68729. */
  68730. getAgents(): number[];
  68731. /**
  68732. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68733. * @param deltaTime in seconds
  68734. */
  68735. update(deltaTime: number): void;
  68736. /**
  68737. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68738. * The queries will try to find a solution within those bounds
  68739. * default is (1,1,1)
  68740. * @param extent x,y,z value that define the extent around the queries point of reference
  68741. */
  68742. setDefaultQueryExtent(extent: Vector3): void;
  68743. /**
  68744. * Get the Bounding box extent specified by setDefaultQueryExtent
  68745. * @returns the box extent values
  68746. */
  68747. getDefaultQueryExtent(): Vector3;
  68748. /**
  68749. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68750. * @param result output the box extent values
  68751. */
  68752. getDefaultQueryExtentToRef(result: Vector3): void;
  68753. /**
  68754. * Release all resources
  68755. */
  68756. dispose(): void;
  68757. }
  68758. }
  68759. declare module BABYLON {
  68760. /**
  68761. * Class used to enable access to IndexedDB
  68762. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68763. */
  68764. export class Database implements IOfflineProvider {
  68765. private _callbackManifestChecked;
  68766. private _currentSceneUrl;
  68767. private _db;
  68768. private _enableSceneOffline;
  68769. private _enableTexturesOffline;
  68770. private _manifestVersionFound;
  68771. private _mustUpdateRessources;
  68772. private _hasReachedQuota;
  68773. private _isSupported;
  68774. private _idbFactory;
  68775. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68776. private static IsUASupportingBlobStorage;
  68777. /**
  68778. * Gets a boolean indicating if Database storate is enabled (off by default)
  68779. */
  68780. static IDBStorageEnabled: boolean;
  68781. /**
  68782. * Gets a boolean indicating if scene must be saved in the database
  68783. */
  68784. get enableSceneOffline(): boolean;
  68785. /**
  68786. * Gets a boolean indicating if textures must be saved in the database
  68787. */
  68788. get enableTexturesOffline(): boolean;
  68789. /**
  68790. * Creates a new Database
  68791. * @param urlToScene defines the url to load the scene
  68792. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68793. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68794. */
  68795. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68796. private static _ParseURL;
  68797. private static _ReturnFullUrlLocation;
  68798. private _checkManifestFile;
  68799. /**
  68800. * Open the database and make it available
  68801. * @param successCallback defines the callback to call on success
  68802. * @param errorCallback defines the callback to call on error
  68803. */
  68804. open(successCallback: () => void, errorCallback: () => void): void;
  68805. /**
  68806. * Loads an image from the database
  68807. * @param url defines the url to load from
  68808. * @param image defines the target DOM image
  68809. */
  68810. loadImage(url: string, image: HTMLImageElement): void;
  68811. private _loadImageFromDBAsync;
  68812. private _saveImageIntoDBAsync;
  68813. private _checkVersionFromDB;
  68814. private _loadVersionFromDBAsync;
  68815. private _saveVersionIntoDBAsync;
  68816. /**
  68817. * Loads a file from database
  68818. * @param url defines the URL to load from
  68819. * @param sceneLoaded defines a callback to call on success
  68820. * @param progressCallBack defines a callback to call when progress changed
  68821. * @param errorCallback defines a callback to call on error
  68822. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68823. */
  68824. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68825. private _loadFileAsync;
  68826. private _saveFileAsync;
  68827. /**
  68828. * Validates if xhr data is correct
  68829. * @param xhr defines the request to validate
  68830. * @param dataType defines the expected data type
  68831. * @returns true if data is correct
  68832. */
  68833. private static _ValidateXHRData;
  68834. }
  68835. }
  68836. declare module BABYLON {
  68837. /** @hidden */
  68838. export var gpuUpdateParticlesPixelShader: {
  68839. name: string;
  68840. shader: string;
  68841. };
  68842. }
  68843. declare module BABYLON {
  68844. /** @hidden */
  68845. export var gpuUpdateParticlesVertexShader: {
  68846. name: string;
  68847. shader: string;
  68848. };
  68849. }
  68850. declare module BABYLON {
  68851. /** @hidden */
  68852. export var clipPlaneFragmentDeclaration2: {
  68853. name: string;
  68854. shader: string;
  68855. };
  68856. }
  68857. declare module BABYLON {
  68858. /** @hidden */
  68859. export var gpuRenderParticlesPixelShader: {
  68860. name: string;
  68861. shader: string;
  68862. };
  68863. }
  68864. declare module BABYLON {
  68865. /** @hidden */
  68866. export var clipPlaneVertexDeclaration2: {
  68867. name: string;
  68868. shader: string;
  68869. };
  68870. }
  68871. declare module BABYLON {
  68872. /** @hidden */
  68873. export var gpuRenderParticlesVertexShader: {
  68874. name: string;
  68875. shader: string;
  68876. };
  68877. }
  68878. declare module BABYLON {
  68879. /**
  68880. * This represents a GPU particle system in Babylon
  68881. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68882. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68883. */
  68884. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68885. /**
  68886. * The layer mask we are rendering the particles through.
  68887. */
  68888. layerMask: number;
  68889. private _capacity;
  68890. private _activeCount;
  68891. private _currentActiveCount;
  68892. private _accumulatedCount;
  68893. private _renderEffect;
  68894. private _updateEffect;
  68895. private _buffer0;
  68896. private _buffer1;
  68897. private _spriteBuffer;
  68898. private _updateVAO;
  68899. private _renderVAO;
  68900. private _targetIndex;
  68901. private _sourceBuffer;
  68902. private _targetBuffer;
  68903. private _currentRenderId;
  68904. private _started;
  68905. private _stopped;
  68906. private _timeDelta;
  68907. private _randomTexture;
  68908. private _randomTexture2;
  68909. private _attributesStrideSize;
  68910. private _updateEffectOptions;
  68911. private _randomTextureSize;
  68912. private _actualFrame;
  68913. private _customEffect;
  68914. private readonly _rawTextureWidth;
  68915. /**
  68916. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68917. */
  68918. static get IsSupported(): boolean;
  68919. /**
  68920. * An event triggered when the system is disposed.
  68921. */
  68922. onDisposeObservable: Observable<IParticleSystem>;
  68923. /**
  68924. * An event triggered when the system is stopped
  68925. */
  68926. onStoppedObservable: Observable<IParticleSystem>;
  68927. /**
  68928. * Gets the maximum number of particles active at the same time.
  68929. * @returns The max number of active particles.
  68930. */
  68931. getCapacity(): number;
  68932. /**
  68933. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68934. * to override the particles.
  68935. */
  68936. forceDepthWrite: boolean;
  68937. /**
  68938. * Gets or set the number of active particles
  68939. */
  68940. get activeParticleCount(): number;
  68941. set activeParticleCount(value: number);
  68942. private _preWarmDone;
  68943. /**
  68944. * Specifies if the particles are updated in emitter local space or world space.
  68945. */
  68946. isLocal: boolean;
  68947. /** Gets or sets a matrix to use to compute projection */
  68948. defaultProjectionMatrix: Matrix;
  68949. /**
  68950. * Is this system ready to be used/rendered
  68951. * @return true if the system is ready
  68952. */
  68953. isReady(): boolean;
  68954. /**
  68955. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68956. * @returns True if it has been started, otherwise false.
  68957. */
  68958. isStarted(): boolean;
  68959. /**
  68960. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68961. * @returns True if it has been stopped, otherwise false.
  68962. */
  68963. isStopped(): boolean;
  68964. /**
  68965. * Gets a boolean indicating that the system is stopping
  68966. * @returns true if the system is currently stopping
  68967. */
  68968. isStopping(): boolean;
  68969. /**
  68970. * Gets the number of particles active at the same time.
  68971. * @returns The number of active particles.
  68972. */
  68973. getActiveCount(): number;
  68974. /**
  68975. * Starts the particle system and begins to emit
  68976. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68977. */
  68978. start(delay?: number): void;
  68979. /**
  68980. * Stops the particle system.
  68981. */
  68982. stop(): void;
  68983. /**
  68984. * Remove all active particles
  68985. */
  68986. reset(): void;
  68987. /**
  68988. * Returns the string "GPUParticleSystem"
  68989. * @returns a string containing the class name
  68990. */
  68991. getClassName(): string;
  68992. /**
  68993. * Gets the custom effect used to render the particles
  68994. * @param blendMode Blend mode for which the effect should be retrieved
  68995. * @returns The effect
  68996. */
  68997. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68998. /**
  68999. * Sets the custom effect used to render the particles
  69000. * @param effect The effect to set
  69001. * @param blendMode Blend mode for which the effect should be set
  69002. */
  69003. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69004. /** @hidden */
  69005. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69006. /**
  69007. * Observable that will be called just before the particles are drawn
  69008. */
  69009. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69010. /**
  69011. * Gets the name of the particle vertex shader
  69012. */
  69013. get vertexShaderName(): string;
  69014. private _colorGradientsTexture;
  69015. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69016. /**
  69017. * Adds a new color gradient
  69018. * @param gradient defines the gradient to use (between 0 and 1)
  69019. * @param color1 defines the color to affect to the specified gradient
  69020. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69021. * @returns the current particle system
  69022. */
  69023. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69024. private _refreshColorGradient;
  69025. /** Force the system to rebuild all gradients that need to be resync */
  69026. forceRefreshGradients(): void;
  69027. /**
  69028. * Remove a specific color gradient
  69029. * @param gradient defines the gradient to remove
  69030. * @returns the current particle system
  69031. */
  69032. removeColorGradient(gradient: number): GPUParticleSystem;
  69033. private _angularSpeedGradientsTexture;
  69034. private _sizeGradientsTexture;
  69035. private _velocityGradientsTexture;
  69036. private _limitVelocityGradientsTexture;
  69037. private _dragGradientsTexture;
  69038. private _addFactorGradient;
  69039. /**
  69040. * Adds a new size gradient
  69041. * @param gradient defines the gradient to use (between 0 and 1)
  69042. * @param factor defines the size factor to affect to the specified gradient
  69043. * @returns the current particle system
  69044. */
  69045. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69046. /**
  69047. * Remove a specific size gradient
  69048. * @param gradient defines the gradient to remove
  69049. * @returns the current particle system
  69050. */
  69051. removeSizeGradient(gradient: number): GPUParticleSystem;
  69052. private _refreshFactorGradient;
  69053. /**
  69054. * Adds a new angular speed gradient
  69055. * @param gradient defines the gradient to use (between 0 and 1)
  69056. * @param factor defines the angular speed to affect to the specified gradient
  69057. * @returns the current particle system
  69058. */
  69059. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69060. /**
  69061. * Remove a specific angular speed gradient
  69062. * @param gradient defines the gradient to remove
  69063. * @returns the current particle system
  69064. */
  69065. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69066. /**
  69067. * Adds a new velocity gradient
  69068. * @param gradient defines the gradient to use (between 0 and 1)
  69069. * @param factor defines the velocity to affect to the specified gradient
  69070. * @returns the current particle system
  69071. */
  69072. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69073. /**
  69074. * Remove a specific velocity gradient
  69075. * @param gradient defines the gradient to remove
  69076. * @returns the current particle system
  69077. */
  69078. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69079. /**
  69080. * Adds a new limit velocity gradient
  69081. * @param gradient defines the gradient to use (between 0 and 1)
  69082. * @param factor defines the limit velocity value to affect to the specified gradient
  69083. * @returns the current particle system
  69084. */
  69085. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69086. /**
  69087. * Remove a specific limit velocity gradient
  69088. * @param gradient defines the gradient to remove
  69089. * @returns the current particle system
  69090. */
  69091. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69092. /**
  69093. * Adds a new drag gradient
  69094. * @param gradient defines the gradient to use (between 0 and 1)
  69095. * @param factor defines the drag value to affect to the specified gradient
  69096. * @returns the current particle system
  69097. */
  69098. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69099. /**
  69100. * Remove a specific drag gradient
  69101. * @param gradient defines the gradient to remove
  69102. * @returns the current particle system
  69103. */
  69104. removeDragGradient(gradient: number): GPUParticleSystem;
  69105. /**
  69106. * Not supported by GPUParticleSystem
  69107. * @param gradient defines the gradient to use (between 0 and 1)
  69108. * @param factor defines the emit rate value to affect to the specified gradient
  69109. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69110. * @returns the current particle system
  69111. */
  69112. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69113. /**
  69114. * Not supported by GPUParticleSystem
  69115. * @param gradient defines the gradient to remove
  69116. * @returns the current particle system
  69117. */
  69118. removeEmitRateGradient(gradient: number): IParticleSystem;
  69119. /**
  69120. * Not supported by GPUParticleSystem
  69121. * @param gradient defines the gradient to use (between 0 and 1)
  69122. * @param factor defines the start size value to affect to the specified gradient
  69123. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69124. * @returns the current particle system
  69125. */
  69126. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69127. /**
  69128. * Not supported by GPUParticleSystem
  69129. * @param gradient defines the gradient to remove
  69130. * @returns the current particle system
  69131. */
  69132. removeStartSizeGradient(gradient: number): IParticleSystem;
  69133. /**
  69134. * Not supported by GPUParticleSystem
  69135. * @param gradient defines the gradient to use (between 0 and 1)
  69136. * @param min defines the color remap minimal range
  69137. * @param max defines the color remap maximal range
  69138. * @returns the current particle system
  69139. */
  69140. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69141. /**
  69142. * Not supported by GPUParticleSystem
  69143. * @param gradient defines the gradient to remove
  69144. * @returns the current particle system
  69145. */
  69146. removeColorRemapGradient(): IParticleSystem;
  69147. /**
  69148. * Not supported by GPUParticleSystem
  69149. * @param gradient defines the gradient to use (between 0 and 1)
  69150. * @param min defines the alpha remap minimal range
  69151. * @param max defines the alpha remap maximal range
  69152. * @returns the current particle system
  69153. */
  69154. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69155. /**
  69156. * Not supported by GPUParticleSystem
  69157. * @param gradient defines the gradient to remove
  69158. * @returns the current particle system
  69159. */
  69160. removeAlphaRemapGradient(): IParticleSystem;
  69161. /**
  69162. * Not supported by GPUParticleSystem
  69163. * @param gradient defines the gradient to use (between 0 and 1)
  69164. * @param color defines the color to affect to the specified gradient
  69165. * @returns the current particle system
  69166. */
  69167. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69168. /**
  69169. * Not supported by GPUParticleSystem
  69170. * @param gradient defines the gradient to remove
  69171. * @returns the current particle system
  69172. */
  69173. removeRampGradient(): IParticleSystem;
  69174. /**
  69175. * Not supported by GPUParticleSystem
  69176. * @returns the list of ramp gradients
  69177. */
  69178. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69179. /**
  69180. * Not supported by GPUParticleSystem
  69181. * Gets or sets a boolean indicating that ramp gradients must be used
  69182. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69183. */
  69184. get useRampGradients(): boolean;
  69185. set useRampGradients(value: boolean);
  69186. /**
  69187. * Not supported by GPUParticleSystem
  69188. * @param gradient defines the gradient to use (between 0 and 1)
  69189. * @param factor defines the life time factor to affect to the specified gradient
  69190. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69191. * @returns the current particle system
  69192. */
  69193. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69194. /**
  69195. * Not supported by GPUParticleSystem
  69196. * @param gradient defines the gradient to remove
  69197. * @returns the current particle system
  69198. */
  69199. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69200. /**
  69201. * Instantiates a GPU particle system.
  69202. * 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.
  69203. * @param name The name of the particle system
  69204. * @param options The options used to create the system
  69205. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  69206. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69207. * @param customEffect a custom effect used to change the way particles are rendered by default
  69208. */
  69209. constructor(name: string, options: Partial<{
  69210. capacity: number;
  69211. randomTextureSize: number;
  69212. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  69213. protected _reset(): void;
  69214. private _createUpdateVAO;
  69215. private _createRenderVAO;
  69216. private _initialize;
  69217. /** @hidden */
  69218. _recreateUpdateEffect(): void;
  69219. private _getEffect;
  69220. /**
  69221. * Fill the defines array according to the current settings of the particle system
  69222. * @param defines Array to be updated
  69223. * @param blendMode blend mode to take into account when updating the array
  69224. */
  69225. fillDefines(defines: Array<string>, blendMode?: number): void;
  69226. /**
  69227. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  69228. * @param uniforms Uniforms array to fill
  69229. * @param attributes Attributes array to fill
  69230. * @param samplers Samplers array to fill
  69231. */
  69232. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  69233. /** @hidden */
  69234. _recreateRenderEffect(): Effect;
  69235. /**
  69236. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  69237. * @param preWarm defines if we are in the pre-warmimg phase
  69238. */
  69239. animate(preWarm?: boolean): void;
  69240. private _createFactorGradientTexture;
  69241. private _createSizeGradientTexture;
  69242. private _createAngularSpeedGradientTexture;
  69243. private _createVelocityGradientTexture;
  69244. private _createLimitVelocityGradientTexture;
  69245. private _createDragGradientTexture;
  69246. private _createColorGradientTexture;
  69247. /**
  69248. * Renders the particle system in its current state
  69249. * @param preWarm defines if the system should only update the particles but not render them
  69250. * @returns the current number of particles
  69251. */
  69252. render(preWarm?: boolean): number;
  69253. /**
  69254. * Rebuilds the particle system
  69255. */
  69256. rebuild(): void;
  69257. private _releaseBuffers;
  69258. private _releaseVAOs;
  69259. /**
  69260. * Disposes the particle system and free the associated resources
  69261. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  69262. */
  69263. dispose(disposeTexture?: boolean): void;
  69264. /**
  69265. * Clones the particle system.
  69266. * @param name The name of the cloned object
  69267. * @param newEmitter The new emitter to use
  69268. * @returns the cloned particle system
  69269. */
  69270. clone(name: string, newEmitter: any): GPUParticleSystem;
  69271. /**
  69272. * Serializes the particle system to a JSON object
  69273. * @param serializeTexture defines if the texture must be serialized as well
  69274. * @returns the JSON object
  69275. */
  69276. serialize(serializeTexture?: boolean): any;
  69277. /**
  69278. * Parses a JSON object to create a GPU particle system.
  69279. * @param parsedParticleSystem The JSON object to parse
  69280. * @param sceneOrEngine The scene or the engine to create the particle system in
  69281. * @param rootUrl The root url to use to load external dependencies like texture
  69282. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69283. * @returns the parsed GPU particle system
  69284. */
  69285. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69286. }
  69287. }
  69288. declare module BABYLON {
  69289. /**
  69290. * Represents a set of particle systems working together to create a specific effect
  69291. */
  69292. export class ParticleSystemSet implements IDisposable {
  69293. /**
  69294. * Gets or sets base Assets URL
  69295. */
  69296. static BaseAssetsUrl: string;
  69297. private _emitterCreationOptions;
  69298. private _emitterNode;
  69299. /**
  69300. * Gets the particle system list
  69301. */
  69302. systems: IParticleSystem[];
  69303. /**
  69304. * Gets the emitter node used with this set
  69305. */
  69306. get emitterNode(): Nullable<TransformNode>;
  69307. /**
  69308. * Creates a new emitter mesh as a sphere
  69309. * @param options defines the options used to create the sphere
  69310. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69311. * @param scene defines the hosting scene
  69312. */
  69313. setEmitterAsSphere(options: {
  69314. diameter: number;
  69315. segments: number;
  69316. color: Color3;
  69317. }, renderingGroupId: number, scene: Scene): void;
  69318. /**
  69319. * Starts all particle systems of the set
  69320. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69321. */
  69322. start(emitter?: AbstractMesh): void;
  69323. /**
  69324. * Release all associated resources
  69325. */
  69326. dispose(): void;
  69327. /**
  69328. * Serialize the set into a JSON compatible object
  69329. * @param serializeTexture defines if the texture must be serialized as well
  69330. * @returns a JSON compatible representation of the set
  69331. */
  69332. serialize(serializeTexture?: boolean): any;
  69333. /**
  69334. * Parse a new ParticleSystemSet from a serialized source
  69335. * @param data defines a JSON compatible representation of the set
  69336. * @param scene defines the hosting scene
  69337. * @param gpu defines if we want GPU particles or CPU particles
  69338. * @returns a new ParticleSystemSet
  69339. */
  69340. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69341. }
  69342. }
  69343. declare module BABYLON {
  69344. /**
  69345. * This class is made for on one-liner static method to help creating particle system set.
  69346. */
  69347. export class ParticleHelper {
  69348. /**
  69349. * Gets or sets base Assets URL
  69350. */
  69351. static BaseAssetsUrl: string;
  69352. /** Define the Url to load snippets */
  69353. static SnippetUrl: string;
  69354. /**
  69355. * Create a default particle system that you can tweak
  69356. * @param emitter defines the emitter to use
  69357. * @param capacity defines the system capacity (default is 500 particles)
  69358. * @param scene defines the hosting scene
  69359. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69360. * @returns the new Particle system
  69361. */
  69362. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69363. /**
  69364. * This is the main static method (one-liner) of this helper to create different particle systems
  69365. * @param type This string represents the type to the particle system to create
  69366. * @param scene The scene where the particle system should live
  69367. * @param gpu If the system will use gpu
  69368. * @returns the ParticleSystemSet created
  69369. */
  69370. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69371. /**
  69372. * Static function used to export a particle system to a ParticleSystemSet variable.
  69373. * Please note that the emitter shape is not exported
  69374. * @param systems defines the particle systems to export
  69375. * @returns the created particle system set
  69376. */
  69377. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69378. /**
  69379. * Creates a particle system from a snippet saved in a remote file
  69380. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69381. * @param url defines the url to load from
  69382. * @param scene defines the hosting scene
  69383. * @param gpu If the system will use gpu
  69384. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69385. * @returns a promise that will resolve to the new particle system
  69386. */
  69387. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69388. /**
  69389. * Creates a particle system from a snippet saved by the particle system editor
  69390. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  69391. * @param scene defines the hosting scene
  69392. * @param gpu If the system will use gpu
  69393. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69394. * @returns a promise that will resolve to the new particle system
  69395. */
  69396. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69397. }
  69398. }
  69399. declare module BABYLON {
  69400. interface Engine {
  69401. /**
  69402. * Create an effect to use with particle systems.
  69403. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69404. * the particle system for which you want to create a custom effect in the last parameter
  69405. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69406. * @param uniformsNames defines a list of attribute names
  69407. * @param samplers defines an array of string used to represent textures
  69408. * @param defines defines the string containing the defines to use to compile the shaders
  69409. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69410. * @param onCompiled defines a function to call when the effect creation is successful
  69411. * @param onError defines a function to call when the effect creation has failed
  69412. * @param particleSystem the particle system you want to create the effect for
  69413. * @returns the new Effect
  69414. */
  69415. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69416. }
  69417. interface Mesh {
  69418. /**
  69419. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69420. * @returns an array of IParticleSystem
  69421. */
  69422. getEmittedParticleSystems(): IParticleSystem[];
  69423. /**
  69424. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69425. * @returns an array of IParticleSystem
  69426. */
  69427. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69428. }
  69429. }
  69430. declare module BABYLON {
  69431. /** Defines the 4 color options */
  69432. export enum PointColor {
  69433. /** color value */
  69434. Color = 2,
  69435. /** uv value */
  69436. UV = 1,
  69437. /** random value */
  69438. Random = 0,
  69439. /** stated value */
  69440. Stated = 3
  69441. }
  69442. /**
  69443. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69444. * 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.
  69445. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69446. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69447. *
  69448. * Full documentation here : TO BE ENTERED
  69449. */
  69450. export class PointsCloudSystem implements IDisposable {
  69451. /**
  69452. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69453. * Example : var p = SPS.particles[i];
  69454. */
  69455. particles: CloudPoint[];
  69456. /**
  69457. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69458. */
  69459. nbParticles: number;
  69460. /**
  69461. * This a counter for your own usage. It's not set by any SPS functions.
  69462. */
  69463. counter: number;
  69464. /**
  69465. * The PCS name. This name is also given to the underlying mesh.
  69466. */
  69467. name: string;
  69468. /**
  69469. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69470. */
  69471. mesh: Mesh;
  69472. /**
  69473. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69474. * Please read :
  69475. */
  69476. vars: any;
  69477. /**
  69478. * @hidden
  69479. */
  69480. _size: number;
  69481. private _scene;
  69482. private _promises;
  69483. private _positions;
  69484. private _indices;
  69485. private _normals;
  69486. private _colors;
  69487. private _uvs;
  69488. private _indices32;
  69489. private _positions32;
  69490. private _colors32;
  69491. private _uvs32;
  69492. private _updatable;
  69493. private _isVisibilityBoxLocked;
  69494. private _alwaysVisible;
  69495. private _groups;
  69496. private _groupCounter;
  69497. private _computeParticleColor;
  69498. private _computeParticleTexture;
  69499. private _computeParticleRotation;
  69500. private _computeBoundingBox;
  69501. private _isReady;
  69502. /**
  69503. * Creates a PCS (Points Cloud System) object
  69504. * @param name (String) is the PCS name, this will be the underlying mesh name
  69505. * @param pointSize (number) is the size for each point
  69506. * @param scene (Scene) is the scene in which the PCS is added
  69507. * @param options defines the options of the PCS e.g.
  69508. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69509. */
  69510. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69511. updatable?: boolean;
  69512. });
  69513. /**
  69514. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69515. * If no points were added to the PCS, the returned mesh is just a single point.
  69516. * @returns a promise for the created mesh
  69517. */
  69518. buildMeshAsync(): Promise<Mesh>;
  69519. /**
  69520. * @hidden
  69521. */
  69522. private _buildMesh;
  69523. private _addParticle;
  69524. private _randomUnitVector;
  69525. private _getColorIndicesForCoord;
  69526. private _setPointsColorOrUV;
  69527. private _colorFromTexture;
  69528. private _calculateDensity;
  69529. /**
  69530. * Adds points to the PCS in random positions within a unit sphere
  69531. * @param nb (positive integer) the number of particles to be created from this model
  69532. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69533. * @returns the number of groups in the system
  69534. */
  69535. addPoints(nb: number, pointFunction?: any): number;
  69536. /**
  69537. * Adds points to the PCS from the surface of the model shape
  69538. * @param mesh is any Mesh object that will be used as a surface model for the points
  69539. * @param nb (positive integer) the number of particles to be created from this model
  69540. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69541. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69542. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69543. * @returns the number of groups in the system
  69544. */
  69545. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69546. /**
  69547. * Adds points to the PCS inside the model shape
  69548. * @param mesh is any Mesh object that will be used as a surface model for the points
  69549. * @param nb (positive integer) the number of particles to be created from this model
  69550. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69551. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69552. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69553. * @returns the number of groups in the system
  69554. */
  69555. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69556. /**
  69557. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69558. * This method calls `updateParticle()` for each particle of the SPS.
  69559. * For an animated SPS, it is usually called within the render loop.
  69560. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69561. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69562. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69563. * @returns the PCS.
  69564. */
  69565. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69566. /**
  69567. * Disposes the PCS.
  69568. */
  69569. dispose(): void;
  69570. /**
  69571. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69572. * doc :
  69573. * @returns the PCS.
  69574. */
  69575. refreshVisibleSize(): PointsCloudSystem;
  69576. /**
  69577. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69578. * @param size the size (float) of the visibility box
  69579. * note : this doesn't lock the PCS mesh bounding box.
  69580. * doc :
  69581. */
  69582. setVisibilityBox(size: number): void;
  69583. /**
  69584. * Gets whether the PCS is always visible or not
  69585. * doc :
  69586. */
  69587. get isAlwaysVisible(): boolean;
  69588. /**
  69589. * Sets the PCS as always visible or not
  69590. * doc :
  69591. */
  69592. set isAlwaysVisible(val: boolean);
  69593. /**
  69594. * Tells to `setParticles()` to compute the particle rotations or not
  69595. * Default value : false. The PCS is faster when it's set to false
  69596. * Note : particle rotations are only applied to parent particles
  69597. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69598. */
  69599. set computeParticleRotation(val: boolean);
  69600. /**
  69601. * Tells to `setParticles()` to compute the particle colors or not.
  69602. * Default value : true. The PCS is faster when it's set to false.
  69603. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69604. */
  69605. set computeParticleColor(val: boolean);
  69606. set computeParticleTexture(val: boolean);
  69607. /**
  69608. * Gets if `setParticles()` computes the particle colors or not.
  69609. * Default value : false. The PCS is faster when it's set to false.
  69610. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69611. */
  69612. get computeParticleColor(): boolean;
  69613. /**
  69614. * Gets if `setParticles()` computes the particle textures or not.
  69615. * Default value : false. The PCS is faster when it's set to false.
  69616. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69617. */
  69618. get computeParticleTexture(): boolean;
  69619. /**
  69620. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69621. */
  69622. set computeBoundingBox(val: boolean);
  69623. /**
  69624. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69625. */
  69626. get computeBoundingBox(): boolean;
  69627. /**
  69628. * This function does nothing. It may be overwritten to set all the particle first values.
  69629. * The PCS doesn't call this function, you may have to call it by your own.
  69630. * doc :
  69631. */
  69632. initParticles(): void;
  69633. /**
  69634. * This function does nothing. It may be overwritten to recycle a particle
  69635. * The PCS doesn't call this function, you can to call it
  69636. * doc :
  69637. * @param particle The particle to recycle
  69638. * @returns the recycled particle
  69639. */
  69640. recycleParticle(particle: CloudPoint): CloudPoint;
  69641. /**
  69642. * Updates a particle : this function should be overwritten by the user.
  69643. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69644. * doc :
  69645. * @example : just set a particle position or velocity and recycle conditions
  69646. * @param particle The particle to update
  69647. * @returns the updated particle
  69648. */
  69649. updateParticle(particle: CloudPoint): CloudPoint;
  69650. /**
  69651. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  69652. * This does nothing and may be overwritten by the user.
  69653. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69654. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69655. * @param update the boolean update value actually passed to setParticles()
  69656. */
  69657. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69658. /**
  69659. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69660. * This will be passed three parameters.
  69661. * This does nothing and may be overwritten by the user.
  69662. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69663. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69664. * @param update the boolean update value actually passed to setParticles()
  69665. */
  69666. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69667. }
  69668. }
  69669. declare module BABYLON {
  69670. /**
  69671. * Represents one particle of a points cloud system.
  69672. */
  69673. export class CloudPoint {
  69674. /**
  69675. * particle global index
  69676. */
  69677. idx: number;
  69678. /**
  69679. * The color of the particle
  69680. */
  69681. color: Nullable<Color4>;
  69682. /**
  69683. * The world space position of the particle.
  69684. */
  69685. position: Vector3;
  69686. /**
  69687. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69688. */
  69689. rotation: Vector3;
  69690. /**
  69691. * The world space rotation quaternion of the particle.
  69692. */
  69693. rotationQuaternion: Nullable<Quaternion>;
  69694. /**
  69695. * The uv of the particle.
  69696. */
  69697. uv: Nullable<Vector2>;
  69698. /**
  69699. * The current speed of the particle.
  69700. */
  69701. velocity: Vector3;
  69702. /**
  69703. * The pivot point in the particle local space.
  69704. */
  69705. pivot: Vector3;
  69706. /**
  69707. * Must the particle be translated from its pivot point in its local space ?
  69708. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69709. * Default : false
  69710. */
  69711. translateFromPivot: boolean;
  69712. /**
  69713. * Index of this particle in the global "positions" array (Internal use)
  69714. * @hidden
  69715. */
  69716. _pos: number;
  69717. /**
  69718. * @hidden Index of this particle in the global "indices" array (Internal use)
  69719. */
  69720. _ind: number;
  69721. /**
  69722. * Group this particle belongs to
  69723. */
  69724. _group: PointsGroup;
  69725. /**
  69726. * Group id of this particle
  69727. */
  69728. groupId: number;
  69729. /**
  69730. * Index of the particle in its group id (Internal use)
  69731. */
  69732. idxInGroup: number;
  69733. /**
  69734. * @hidden Particle BoundingInfo object (Internal use)
  69735. */
  69736. _boundingInfo: BoundingInfo;
  69737. /**
  69738. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69739. */
  69740. _pcs: PointsCloudSystem;
  69741. /**
  69742. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69743. */
  69744. _stillInvisible: boolean;
  69745. /**
  69746. * @hidden Last computed particle rotation matrix
  69747. */
  69748. _rotationMatrix: number[];
  69749. /**
  69750. * Parent particle Id, if any.
  69751. * Default null.
  69752. */
  69753. parentId: Nullable<number>;
  69754. /**
  69755. * @hidden Internal global position in the PCS.
  69756. */
  69757. _globalPosition: Vector3;
  69758. /**
  69759. * Creates a Point Cloud object.
  69760. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69761. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69762. * @param group (PointsGroup) is the group the particle belongs to
  69763. * @param groupId (integer) is the group identifier in the PCS.
  69764. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69765. * @param pcs defines the PCS it is associated to
  69766. */
  69767. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69768. /**
  69769. * get point size
  69770. */
  69771. get size(): Vector3;
  69772. /**
  69773. * Set point size
  69774. */
  69775. set size(scale: Vector3);
  69776. /**
  69777. * Legacy support, changed quaternion to rotationQuaternion
  69778. */
  69779. get quaternion(): Nullable<Quaternion>;
  69780. /**
  69781. * Legacy support, changed quaternion to rotationQuaternion
  69782. */
  69783. set quaternion(q: Nullable<Quaternion>);
  69784. /**
  69785. * Returns a boolean. True if the particle intersects a mesh, else false
  69786. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69787. * @param target is the object (point or mesh) what the intersection is computed against
  69788. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69789. * @returns true if it intersects
  69790. */
  69791. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69792. /**
  69793. * get the rotation matrix of the particle
  69794. * @hidden
  69795. */
  69796. getRotationMatrix(m: Matrix): void;
  69797. }
  69798. /**
  69799. * Represents a group of points in a points cloud system
  69800. * * PCS internal tool, don't use it manually.
  69801. */
  69802. export class PointsGroup {
  69803. /**
  69804. * The group id
  69805. * @hidden
  69806. */
  69807. groupID: number;
  69808. /**
  69809. * image data for group (internal use)
  69810. * @hidden
  69811. */
  69812. _groupImageData: Nullable<ArrayBufferView>;
  69813. /**
  69814. * Image Width (internal use)
  69815. * @hidden
  69816. */
  69817. _groupImgWidth: number;
  69818. /**
  69819. * Image Height (internal use)
  69820. * @hidden
  69821. */
  69822. _groupImgHeight: number;
  69823. /**
  69824. * Custom position function (internal use)
  69825. * @hidden
  69826. */
  69827. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69828. /**
  69829. * density per facet for surface points
  69830. * @hidden
  69831. */
  69832. _groupDensity: number[];
  69833. /**
  69834. * Only when points are colored by texture carries pointer to texture list array
  69835. * @hidden
  69836. */
  69837. _textureNb: number;
  69838. /**
  69839. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69840. * PCS internal tool, don't use it manually.
  69841. * @hidden
  69842. */
  69843. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69844. }
  69845. }
  69846. declare module BABYLON {
  69847. interface Scene {
  69848. /** @hidden (Backing field) */
  69849. _physicsEngine: Nullable<IPhysicsEngine>;
  69850. /** @hidden */
  69851. _physicsTimeAccumulator: number;
  69852. /**
  69853. * Gets the current physics engine
  69854. * @returns a IPhysicsEngine or null if none attached
  69855. */
  69856. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69857. /**
  69858. * Enables physics to the current scene
  69859. * @param gravity defines the scene's gravity for the physics engine
  69860. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69861. * @return a boolean indicating if the physics engine was initialized
  69862. */
  69863. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69864. /**
  69865. * Disables and disposes the physics engine associated with the scene
  69866. */
  69867. disablePhysicsEngine(): void;
  69868. /**
  69869. * Gets a boolean indicating if there is an active physics engine
  69870. * @returns a boolean indicating if there is an active physics engine
  69871. */
  69872. isPhysicsEnabled(): boolean;
  69873. /**
  69874. * Deletes a physics compound impostor
  69875. * @param compound defines the compound to delete
  69876. */
  69877. deleteCompoundImpostor(compound: any): void;
  69878. /**
  69879. * An event triggered when physic simulation is about to be run
  69880. */
  69881. onBeforePhysicsObservable: Observable<Scene>;
  69882. /**
  69883. * An event triggered when physic simulation has been done
  69884. */
  69885. onAfterPhysicsObservable: Observable<Scene>;
  69886. }
  69887. interface AbstractMesh {
  69888. /** @hidden */
  69889. _physicsImpostor: Nullable<PhysicsImpostor>;
  69890. /**
  69891. * Gets or sets impostor used for physic simulation
  69892. * @see https://doc.babylonjs.com/features/physics_engine
  69893. */
  69894. physicsImpostor: Nullable<PhysicsImpostor>;
  69895. /**
  69896. * Gets the current physics impostor
  69897. * @see https://doc.babylonjs.com/features/physics_engine
  69898. * @returns a physics impostor or null
  69899. */
  69900. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69901. /** Apply a physic impulse to the mesh
  69902. * @param force defines the force to apply
  69903. * @param contactPoint defines where to apply the force
  69904. * @returns the current mesh
  69905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69906. */
  69907. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69908. /**
  69909. * Creates a physic joint between two meshes
  69910. * @param otherMesh defines the other mesh to use
  69911. * @param pivot1 defines the pivot to use on this mesh
  69912. * @param pivot2 defines the pivot to use on the other mesh
  69913. * @param options defines additional options (can be plugin dependent)
  69914. * @returns the current mesh
  69915. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69916. */
  69917. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69918. /** @hidden */
  69919. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69920. }
  69921. /**
  69922. * Defines the physics engine scene component responsible to manage a physics engine
  69923. */
  69924. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69925. /**
  69926. * The component name helpful to identify the component in the list of scene components.
  69927. */
  69928. readonly name: string;
  69929. /**
  69930. * The scene the component belongs to.
  69931. */
  69932. scene: Scene;
  69933. /**
  69934. * Creates a new instance of the component for the given scene
  69935. * @param scene Defines the scene to register the component in
  69936. */
  69937. constructor(scene: Scene);
  69938. /**
  69939. * Registers the component in a given scene
  69940. */
  69941. register(): void;
  69942. /**
  69943. * Rebuilds the elements related to this component in case of
  69944. * context lost for instance.
  69945. */
  69946. rebuild(): void;
  69947. /**
  69948. * Disposes the component and the associated ressources
  69949. */
  69950. dispose(): void;
  69951. }
  69952. }
  69953. declare module BABYLON {
  69954. /**
  69955. * A helper for physics simulations
  69956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69957. */
  69958. export class PhysicsHelper {
  69959. private _scene;
  69960. private _physicsEngine;
  69961. /**
  69962. * Initializes the Physics helper
  69963. * @param scene Babylon.js scene
  69964. */
  69965. constructor(scene: Scene);
  69966. /**
  69967. * Applies a radial explosion impulse
  69968. * @param origin the origin of the explosion
  69969. * @param radiusOrEventOptions the radius or the options of radial explosion
  69970. * @param strength the explosion strength
  69971. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69972. * @returns A physics radial explosion event, or null
  69973. */
  69974. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69975. /**
  69976. * Applies a radial explosion force
  69977. * @param origin the origin of the explosion
  69978. * @param radiusOrEventOptions the radius or the options of radial explosion
  69979. * @param strength the explosion strength
  69980. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69981. * @returns A physics radial explosion event, or null
  69982. */
  69983. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69984. /**
  69985. * Creates a gravitational field
  69986. * @param origin the origin of the explosion
  69987. * @param radiusOrEventOptions the radius or the options of radial explosion
  69988. * @param strength the explosion strength
  69989. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69990. * @returns A physics gravitational field event, or null
  69991. */
  69992. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69993. /**
  69994. * Creates a physics updraft event
  69995. * @param origin the origin of the updraft
  69996. * @param radiusOrEventOptions the radius or the options of the updraft
  69997. * @param strength the strength of the updraft
  69998. * @param height the height of the updraft
  69999. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70000. * @returns A physics updraft event, or null
  70001. */
  70002. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70003. /**
  70004. * Creates a physics vortex event
  70005. * @param origin the of the vortex
  70006. * @param radiusOrEventOptions the radius or the options of the vortex
  70007. * @param strength the strength of the vortex
  70008. * @param height the height of the vortex
  70009. * @returns a Physics vortex event, or null
  70010. * A physics vortex event or null
  70011. */
  70012. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70013. }
  70014. /**
  70015. * Represents a physics radial explosion event
  70016. */
  70017. class PhysicsRadialExplosionEvent {
  70018. private _scene;
  70019. private _options;
  70020. private _sphere;
  70021. private _dataFetched;
  70022. /**
  70023. * Initializes a radial explosioin event
  70024. * @param _scene BabylonJS scene
  70025. * @param _options The options for the vortex event
  70026. */
  70027. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70028. /**
  70029. * Returns the data related to the radial explosion event (sphere).
  70030. * @returns The radial explosion event data
  70031. */
  70032. getData(): PhysicsRadialExplosionEventData;
  70033. /**
  70034. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70035. * @param impostor A physics imposter
  70036. * @param origin the origin of the explosion
  70037. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70038. */
  70039. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70040. /**
  70041. * Triggers affecterd impostors callbacks
  70042. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70043. */
  70044. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70045. /**
  70046. * Disposes the sphere.
  70047. * @param force Specifies if the sphere should be disposed by force
  70048. */
  70049. dispose(force?: boolean): void;
  70050. /*** Helpers ***/
  70051. private _prepareSphere;
  70052. private _intersectsWithSphere;
  70053. }
  70054. /**
  70055. * Represents a gravitational field event
  70056. */
  70057. class PhysicsGravitationalFieldEvent {
  70058. private _physicsHelper;
  70059. private _scene;
  70060. private _origin;
  70061. private _options;
  70062. private _tickCallback;
  70063. private _sphere;
  70064. private _dataFetched;
  70065. /**
  70066. * Initializes the physics gravitational field event
  70067. * @param _physicsHelper A physics helper
  70068. * @param _scene BabylonJS scene
  70069. * @param _origin The origin position of the gravitational field event
  70070. * @param _options The options for the vortex event
  70071. */
  70072. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70073. /**
  70074. * Returns the data related to the gravitational field event (sphere).
  70075. * @returns A gravitational field event
  70076. */
  70077. getData(): PhysicsGravitationalFieldEventData;
  70078. /**
  70079. * Enables the gravitational field.
  70080. */
  70081. enable(): void;
  70082. /**
  70083. * Disables the gravitational field.
  70084. */
  70085. disable(): void;
  70086. /**
  70087. * Disposes the sphere.
  70088. * @param force The force to dispose from the gravitational field event
  70089. */
  70090. dispose(force?: boolean): void;
  70091. private _tick;
  70092. }
  70093. /**
  70094. * Represents a physics updraft event
  70095. */
  70096. class PhysicsUpdraftEvent {
  70097. private _scene;
  70098. private _origin;
  70099. private _options;
  70100. private _physicsEngine;
  70101. private _originTop;
  70102. private _originDirection;
  70103. private _tickCallback;
  70104. private _cylinder;
  70105. private _cylinderPosition;
  70106. private _dataFetched;
  70107. /**
  70108. * Initializes the physics updraft event
  70109. * @param _scene BabylonJS scene
  70110. * @param _origin The origin position of the updraft
  70111. * @param _options The options for the updraft event
  70112. */
  70113. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70114. /**
  70115. * Returns the data related to the updraft event (cylinder).
  70116. * @returns A physics updraft event
  70117. */
  70118. getData(): PhysicsUpdraftEventData;
  70119. /**
  70120. * Enables the updraft.
  70121. */
  70122. enable(): void;
  70123. /**
  70124. * Disables the updraft.
  70125. */
  70126. disable(): void;
  70127. /**
  70128. * Disposes the cylinder.
  70129. * @param force Specifies if the updraft should be disposed by force
  70130. */
  70131. dispose(force?: boolean): void;
  70132. private getImpostorHitData;
  70133. private _tick;
  70134. /*** Helpers ***/
  70135. private _prepareCylinder;
  70136. private _intersectsWithCylinder;
  70137. }
  70138. /**
  70139. * Represents a physics vortex event
  70140. */
  70141. class PhysicsVortexEvent {
  70142. private _scene;
  70143. private _origin;
  70144. private _options;
  70145. private _physicsEngine;
  70146. private _originTop;
  70147. private _tickCallback;
  70148. private _cylinder;
  70149. private _cylinderPosition;
  70150. private _dataFetched;
  70151. /**
  70152. * Initializes the physics vortex event
  70153. * @param _scene The BabylonJS scene
  70154. * @param _origin The origin position of the vortex
  70155. * @param _options The options for the vortex event
  70156. */
  70157. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  70158. /**
  70159. * Returns the data related to the vortex event (cylinder).
  70160. * @returns The physics vortex event data
  70161. */
  70162. getData(): PhysicsVortexEventData;
  70163. /**
  70164. * Enables the vortex.
  70165. */
  70166. enable(): void;
  70167. /**
  70168. * Disables the cortex.
  70169. */
  70170. disable(): void;
  70171. /**
  70172. * Disposes the sphere.
  70173. * @param force
  70174. */
  70175. dispose(force?: boolean): void;
  70176. private getImpostorHitData;
  70177. private _tick;
  70178. /*** Helpers ***/
  70179. private _prepareCylinder;
  70180. private _intersectsWithCylinder;
  70181. }
  70182. /**
  70183. * Options fot the radial explosion event
  70184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70185. */
  70186. export class PhysicsRadialExplosionEventOptions {
  70187. /**
  70188. * The radius of the sphere for the radial explosion.
  70189. */
  70190. radius: number;
  70191. /**
  70192. * The strenth of the explosion.
  70193. */
  70194. strength: number;
  70195. /**
  70196. * The strenght of the force in correspondence to the distance of the affected object
  70197. */
  70198. falloff: PhysicsRadialImpulseFalloff;
  70199. /**
  70200. * Sphere options for the radial explosion.
  70201. */
  70202. sphere: {
  70203. segments: number;
  70204. diameter: number;
  70205. };
  70206. /**
  70207. * Sphere options for the radial explosion.
  70208. */
  70209. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  70210. }
  70211. /**
  70212. * Options fot the updraft event
  70213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70214. */
  70215. export class PhysicsUpdraftEventOptions {
  70216. /**
  70217. * The radius of the cylinder for the vortex
  70218. */
  70219. radius: number;
  70220. /**
  70221. * The strenth of the updraft.
  70222. */
  70223. strength: number;
  70224. /**
  70225. * The height of the cylinder for the updraft.
  70226. */
  70227. height: number;
  70228. /**
  70229. * The mode for the the updraft.
  70230. */
  70231. updraftMode: PhysicsUpdraftMode;
  70232. }
  70233. /**
  70234. * Options fot the vortex event
  70235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70236. */
  70237. export class PhysicsVortexEventOptions {
  70238. /**
  70239. * The radius of the cylinder for the vortex
  70240. */
  70241. radius: number;
  70242. /**
  70243. * The strenth of the vortex.
  70244. */
  70245. strength: number;
  70246. /**
  70247. * The height of the cylinder for the vortex.
  70248. */
  70249. height: number;
  70250. /**
  70251. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  70252. */
  70253. centripetalForceThreshold: number;
  70254. /**
  70255. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  70256. */
  70257. centripetalForceMultiplier: number;
  70258. /**
  70259. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  70260. */
  70261. centrifugalForceMultiplier: number;
  70262. /**
  70263. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  70264. */
  70265. updraftForceMultiplier: number;
  70266. }
  70267. /**
  70268. * The strenght of the force in correspondence to the distance of the affected object
  70269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70270. */
  70271. export enum PhysicsRadialImpulseFalloff {
  70272. /** Defines that impulse is constant in strength across it's whole radius */
  70273. Constant = 0,
  70274. /** Defines that impulse gets weaker if it's further from the origin */
  70275. Linear = 1
  70276. }
  70277. /**
  70278. * The strength of the force in correspondence to the distance of the affected object
  70279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70280. */
  70281. export enum PhysicsUpdraftMode {
  70282. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70283. Center = 0,
  70284. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70285. Perpendicular = 1
  70286. }
  70287. /**
  70288. * Interface for a physics hit data
  70289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70290. */
  70291. export interface PhysicsHitData {
  70292. /**
  70293. * The force applied at the contact point
  70294. */
  70295. force: Vector3;
  70296. /**
  70297. * The contact point
  70298. */
  70299. contactPoint: Vector3;
  70300. /**
  70301. * The distance from the origin to the contact point
  70302. */
  70303. distanceFromOrigin: number;
  70304. }
  70305. /**
  70306. * Interface for radial explosion event data
  70307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70308. */
  70309. export interface PhysicsRadialExplosionEventData {
  70310. /**
  70311. * A sphere used for the radial explosion event
  70312. */
  70313. sphere: Mesh;
  70314. }
  70315. /**
  70316. * Interface for gravitational field event data
  70317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70318. */
  70319. export interface PhysicsGravitationalFieldEventData {
  70320. /**
  70321. * A sphere mesh used for the gravitational field event
  70322. */
  70323. sphere: Mesh;
  70324. }
  70325. /**
  70326. * Interface for updraft event data
  70327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70328. */
  70329. export interface PhysicsUpdraftEventData {
  70330. /**
  70331. * A cylinder used for the updraft event
  70332. */
  70333. cylinder: Mesh;
  70334. }
  70335. /**
  70336. * Interface for vortex event data
  70337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70338. */
  70339. export interface PhysicsVortexEventData {
  70340. /**
  70341. * A cylinder used for the vortex event
  70342. */
  70343. cylinder: Mesh;
  70344. }
  70345. /**
  70346. * Interface for an affected physics impostor
  70347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70348. */
  70349. export interface PhysicsAffectedImpostorWithData {
  70350. /**
  70351. * The impostor affected by the effect
  70352. */
  70353. impostor: PhysicsImpostor;
  70354. /**
  70355. * The data about the hit/horce from the explosion
  70356. */
  70357. hitData: PhysicsHitData;
  70358. }
  70359. }
  70360. declare module BABYLON {
  70361. /** @hidden */
  70362. export var blackAndWhitePixelShader: {
  70363. name: string;
  70364. shader: string;
  70365. };
  70366. }
  70367. declare module BABYLON {
  70368. /**
  70369. * Post process used to render in black and white
  70370. */
  70371. export class BlackAndWhitePostProcess extends PostProcess {
  70372. /**
  70373. * Linear about to convert he result to black and white (default: 1)
  70374. */
  70375. degree: number;
  70376. /**
  70377. * Gets a string identifying the name of the class
  70378. * @returns "BlackAndWhitePostProcess" string
  70379. */
  70380. getClassName(): string;
  70381. /**
  70382. * Creates a black and white post process
  70383. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70384. * @param name The name of the effect.
  70385. * @param options The required width/height ratio to downsize to before computing the render pass.
  70386. * @param camera The camera to apply the render pass to.
  70387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70388. * @param engine The engine which the post process will be applied. (default: current engine)
  70389. * @param reusable If the post process can be reused on the same frame. (default: false)
  70390. */
  70391. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70392. /** @hidden */
  70393. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  70394. }
  70395. }
  70396. declare module BABYLON {
  70397. /**
  70398. * This represents a set of one or more post processes in Babylon.
  70399. * A post process can be used to apply a shader to a texture after it is rendered.
  70400. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70401. */
  70402. export class PostProcessRenderEffect {
  70403. private _postProcesses;
  70404. private _getPostProcesses;
  70405. private _singleInstance;
  70406. private _cameras;
  70407. private _indicesForCamera;
  70408. /**
  70409. * Name of the effect
  70410. * @hidden
  70411. */
  70412. _name: string;
  70413. /**
  70414. * Instantiates a post process render effect.
  70415. * A post process can be used to apply a shader to a texture after it is rendered.
  70416. * @param engine The engine the effect is tied to
  70417. * @param name The name of the effect
  70418. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70419. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70420. */
  70421. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70422. /**
  70423. * Checks if all the post processes in the effect are supported.
  70424. */
  70425. get isSupported(): boolean;
  70426. /**
  70427. * Updates the current state of the effect
  70428. * @hidden
  70429. */
  70430. _update(): void;
  70431. /**
  70432. * Attaches the effect on cameras
  70433. * @param cameras The camera to attach to.
  70434. * @hidden
  70435. */
  70436. _attachCameras(cameras: Camera): void;
  70437. /**
  70438. * Attaches the effect on cameras
  70439. * @param cameras The camera to attach to.
  70440. * @hidden
  70441. */
  70442. _attachCameras(cameras: Camera[]): void;
  70443. /**
  70444. * Detaches the effect on cameras
  70445. * @param cameras The camera to detatch from.
  70446. * @hidden
  70447. */
  70448. _detachCameras(cameras: Camera): void;
  70449. /**
  70450. * Detatches the effect on cameras
  70451. * @param cameras The camera to detatch from.
  70452. * @hidden
  70453. */
  70454. _detachCameras(cameras: Camera[]): void;
  70455. /**
  70456. * Enables the effect on given cameras
  70457. * @param cameras The camera to enable.
  70458. * @hidden
  70459. */
  70460. _enable(cameras: Camera): void;
  70461. /**
  70462. * Enables the effect on given cameras
  70463. * @param cameras The camera to enable.
  70464. * @hidden
  70465. */
  70466. _enable(cameras: Nullable<Camera[]>): void;
  70467. /**
  70468. * Disables the effect on the given cameras
  70469. * @param cameras The camera to disable.
  70470. * @hidden
  70471. */
  70472. _disable(cameras: Camera): void;
  70473. /**
  70474. * Disables the effect on the given cameras
  70475. * @param cameras The camera to disable.
  70476. * @hidden
  70477. */
  70478. _disable(cameras: Nullable<Camera[]>): void;
  70479. /**
  70480. * Gets a list of the post processes contained in the effect.
  70481. * @param camera The camera to get the post processes on.
  70482. * @returns The list of the post processes in the effect.
  70483. */
  70484. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70485. }
  70486. }
  70487. declare module BABYLON {
  70488. /** @hidden */
  70489. export var extractHighlightsPixelShader: {
  70490. name: string;
  70491. shader: string;
  70492. };
  70493. }
  70494. declare module BABYLON {
  70495. /**
  70496. * 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.
  70497. */
  70498. export class ExtractHighlightsPostProcess extends PostProcess {
  70499. /**
  70500. * The luminance threshold, pixels below this value will be set to black.
  70501. */
  70502. threshold: number;
  70503. /** @hidden */
  70504. _exposure: number;
  70505. /**
  70506. * Post process which has the input texture to be used when performing highlight extraction
  70507. * @hidden
  70508. */
  70509. _inputPostProcess: Nullable<PostProcess>;
  70510. /**
  70511. * Gets a string identifying the name of the class
  70512. * @returns "ExtractHighlightsPostProcess" string
  70513. */
  70514. getClassName(): string;
  70515. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70516. }
  70517. }
  70518. declare module BABYLON {
  70519. /** @hidden */
  70520. export var bloomMergePixelShader: {
  70521. name: string;
  70522. shader: string;
  70523. };
  70524. }
  70525. declare module BABYLON {
  70526. /**
  70527. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70528. */
  70529. export class BloomMergePostProcess extends PostProcess {
  70530. /** Weight of the bloom to be added to the original input. */
  70531. weight: number;
  70532. /**
  70533. * Gets a string identifying the name of the class
  70534. * @returns "BloomMergePostProcess" string
  70535. */
  70536. getClassName(): string;
  70537. /**
  70538. * Creates a new instance of @see BloomMergePostProcess
  70539. * @param name The name of the effect.
  70540. * @param originalFromInput Post process which's input will be used for the merge.
  70541. * @param blurred Blurred highlights post process which's output will be used.
  70542. * @param weight Weight of the bloom to be added to the original input.
  70543. * @param options The required width/height ratio to downsize to before computing the render pass.
  70544. * @param camera The camera to apply the render pass to.
  70545. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70546. * @param engine The engine which the post process will be applied. (default: current engine)
  70547. * @param reusable If the post process can be reused on the same frame. (default: false)
  70548. * @param textureType Type of textures used when performing the post process. (default: 0)
  70549. * @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)
  70550. */
  70551. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70552. /** Weight of the bloom to be added to the original input. */
  70553. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70554. }
  70555. }
  70556. declare module BABYLON {
  70557. /**
  70558. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70559. */
  70560. export class BloomEffect extends PostProcessRenderEffect {
  70561. private bloomScale;
  70562. /**
  70563. * @hidden Internal
  70564. */
  70565. _effects: Array<PostProcess>;
  70566. /**
  70567. * @hidden Internal
  70568. */
  70569. _downscale: ExtractHighlightsPostProcess;
  70570. private _blurX;
  70571. private _blurY;
  70572. private _merge;
  70573. /**
  70574. * The luminance threshold to find bright areas of the image to bloom.
  70575. */
  70576. get threshold(): number;
  70577. set threshold(value: number);
  70578. /**
  70579. * The strength of the bloom.
  70580. */
  70581. get weight(): number;
  70582. set weight(value: number);
  70583. /**
  70584. * Specifies the size of the bloom blur kernel, relative to the final output size
  70585. */
  70586. get kernel(): number;
  70587. set kernel(value: number);
  70588. /**
  70589. * Creates a new instance of @see BloomEffect
  70590. * @param scene The scene the effect belongs to.
  70591. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70592. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70593. * @param bloomWeight The the strength of bloom.
  70594. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70595. * @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)
  70596. */
  70597. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70598. /**
  70599. * Disposes each of the internal effects for a given camera.
  70600. * @param camera The camera to dispose the effect on.
  70601. */
  70602. disposeEffects(camera: Camera): void;
  70603. /**
  70604. * @hidden Internal
  70605. */
  70606. _updateEffects(): void;
  70607. /**
  70608. * Internal
  70609. * @returns if all the contained post processes are ready.
  70610. * @hidden
  70611. */
  70612. _isReady(): boolean;
  70613. }
  70614. }
  70615. declare module BABYLON {
  70616. /** @hidden */
  70617. export var chromaticAberrationPixelShader: {
  70618. name: string;
  70619. shader: string;
  70620. };
  70621. }
  70622. declare module BABYLON {
  70623. /**
  70624. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70625. */
  70626. export class ChromaticAberrationPostProcess extends PostProcess {
  70627. /**
  70628. * The amount of seperation of rgb channels (default: 30)
  70629. */
  70630. aberrationAmount: number;
  70631. /**
  70632. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70633. */
  70634. radialIntensity: number;
  70635. /**
  70636. * 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))
  70637. */
  70638. direction: Vector2;
  70639. /**
  70640. * 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))
  70641. */
  70642. centerPosition: Vector2;
  70643. /** The width of the screen to apply the effect on */
  70644. screenWidth: number;
  70645. /** The height of the screen to apply the effect on */
  70646. screenHeight: number;
  70647. /**
  70648. * Gets a string identifying the name of the class
  70649. * @returns "ChromaticAberrationPostProcess" string
  70650. */
  70651. getClassName(): string;
  70652. /**
  70653. * Creates a new instance ChromaticAberrationPostProcess
  70654. * @param name The name of the effect.
  70655. * @param screenWidth The width of the screen to apply the effect on.
  70656. * @param screenHeight The height of the screen to apply the effect on.
  70657. * @param options The required width/height ratio to downsize to before computing the render pass.
  70658. * @param camera The camera to apply the render pass to.
  70659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70660. * @param engine The engine which the post process will be applied. (default: current engine)
  70661. * @param reusable If the post process can be reused on the same frame. (default: false)
  70662. * @param textureType Type of textures used when performing the post process. (default: 0)
  70663. * @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)
  70664. */
  70665. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70666. /** @hidden */
  70667. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70668. }
  70669. }
  70670. declare module BABYLON {
  70671. /** @hidden */
  70672. export var circleOfConfusionPixelShader: {
  70673. name: string;
  70674. shader: string;
  70675. };
  70676. }
  70677. declare module BABYLON {
  70678. /**
  70679. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70680. */
  70681. export class CircleOfConfusionPostProcess extends PostProcess {
  70682. /**
  70683. * 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.
  70684. */
  70685. lensSize: number;
  70686. /**
  70687. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70688. */
  70689. fStop: number;
  70690. /**
  70691. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70692. */
  70693. focusDistance: number;
  70694. /**
  70695. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70696. */
  70697. focalLength: number;
  70698. /**
  70699. * Gets a string identifying the name of the class
  70700. * @returns "CircleOfConfusionPostProcess" string
  70701. */
  70702. getClassName(): string;
  70703. private _depthTexture;
  70704. /**
  70705. * Creates a new instance CircleOfConfusionPostProcess
  70706. * @param name The name of the effect.
  70707. * @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.
  70708. * @param options The required width/height ratio to downsize to before computing the render pass.
  70709. * @param camera The camera to apply the render pass to.
  70710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70711. * @param engine The engine which the post process will be applied. (default: current engine)
  70712. * @param reusable If the post process can be reused on the same frame. (default: false)
  70713. * @param textureType Type of textures used when performing the post process. (default: 0)
  70714. * @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)
  70715. */
  70716. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70717. /**
  70718. * 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.
  70719. */
  70720. set depthTexture(value: RenderTargetTexture);
  70721. }
  70722. }
  70723. declare module BABYLON {
  70724. /** @hidden */
  70725. export var colorCorrectionPixelShader: {
  70726. name: string;
  70727. shader: string;
  70728. };
  70729. }
  70730. declare module BABYLON {
  70731. /**
  70732. *
  70733. * This post-process allows the modification of rendered colors by using
  70734. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70735. *
  70736. * The object needs to be provided an url to a texture containing the color
  70737. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70738. * Use an image editing software to tweak the LUT to match your needs.
  70739. *
  70740. * For an example of a color LUT, see here:
  70741. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70742. * For explanations on color grading, see here:
  70743. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70744. *
  70745. */
  70746. export class ColorCorrectionPostProcess extends PostProcess {
  70747. private _colorTableTexture;
  70748. /**
  70749. * Gets the color table url used to create the LUT texture
  70750. */
  70751. colorTableUrl: string;
  70752. /**
  70753. * Gets a string identifying the name of the class
  70754. * @returns "ColorCorrectionPostProcess" string
  70755. */
  70756. getClassName(): string;
  70757. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70758. /** @hidden */
  70759. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70760. }
  70761. }
  70762. declare module BABYLON {
  70763. /** @hidden */
  70764. export var convolutionPixelShader: {
  70765. name: string;
  70766. shader: string;
  70767. };
  70768. }
  70769. declare module BABYLON {
  70770. /**
  70771. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70772. * input texture to perform effects such as edge detection or sharpening
  70773. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70774. */
  70775. export class ConvolutionPostProcess extends PostProcess {
  70776. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70777. kernel: number[];
  70778. /**
  70779. * Gets a string identifying the name of the class
  70780. * @returns "ConvolutionPostProcess" string
  70781. */
  70782. getClassName(): string;
  70783. /**
  70784. * Creates a new instance ConvolutionPostProcess
  70785. * @param name The name of the effect.
  70786. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70787. * @param options The required width/height ratio to downsize to before computing the render pass.
  70788. * @param camera The camera to apply the render pass to.
  70789. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70790. * @param engine The engine which the post process will be applied. (default: current engine)
  70791. * @param reusable If the post process can be reused on the same frame. (default: false)
  70792. * @param textureType Type of textures used when performing the post process. (default: 0)
  70793. */
  70794. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70795. /** @hidden */
  70796. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70797. /**
  70798. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70799. */
  70800. static EdgeDetect0Kernel: number[];
  70801. /**
  70802. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70803. */
  70804. static EdgeDetect1Kernel: number[];
  70805. /**
  70806. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70807. */
  70808. static EdgeDetect2Kernel: number[];
  70809. /**
  70810. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70811. */
  70812. static SharpenKernel: number[];
  70813. /**
  70814. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70815. */
  70816. static EmbossKernel: number[];
  70817. /**
  70818. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70819. */
  70820. static GaussianKernel: number[];
  70821. }
  70822. }
  70823. declare module BABYLON {
  70824. /**
  70825. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70826. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70827. * based on samples that have a large difference in distance than the center pixel.
  70828. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70829. */
  70830. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70831. /**
  70832. * The direction the blur should be applied
  70833. */
  70834. direction: Vector2;
  70835. /**
  70836. * Gets a string identifying the name of the class
  70837. * @returns "DepthOfFieldBlurPostProcess" string
  70838. */
  70839. getClassName(): string;
  70840. /**
  70841. * Creates a new instance CircleOfConfusionPostProcess
  70842. * @param name The name of the effect.
  70843. * @param scene The scene the effect belongs to.
  70844. * @param direction The direction the blur should be applied.
  70845. * @param kernel The size of the kernel used to blur.
  70846. * @param options The required width/height ratio to downsize to before computing the render pass.
  70847. * @param camera The camera to apply the render pass to.
  70848. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70849. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70850. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70851. * @param engine The engine which the post process will be applied. (default: current engine)
  70852. * @param reusable If the post process can be reused on the same frame. (default: false)
  70853. * @param textureType Type of textures used when performing the post process. (default: 0)
  70854. * @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)
  70855. */
  70856. 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);
  70857. }
  70858. }
  70859. declare module BABYLON {
  70860. /** @hidden */
  70861. export var depthOfFieldMergePixelShader: {
  70862. name: string;
  70863. shader: string;
  70864. };
  70865. }
  70866. declare module BABYLON {
  70867. /**
  70868. * Options to be set when merging outputs from the default pipeline.
  70869. */
  70870. export class DepthOfFieldMergePostProcessOptions {
  70871. /**
  70872. * The original image to merge on top of
  70873. */
  70874. originalFromInput: PostProcess;
  70875. /**
  70876. * Parameters to perform the merge of the depth of field effect
  70877. */
  70878. depthOfField?: {
  70879. circleOfConfusion: PostProcess;
  70880. blurSteps: Array<PostProcess>;
  70881. };
  70882. /**
  70883. * Parameters to perform the merge of bloom effect
  70884. */
  70885. bloom?: {
  70886. blurred: PostProcess;
  70887. weight: number;
  70888. };
  70889. }
  70890. /**
  70891. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70892. */
  70893. export class DepthOfFieldMergePostProcess extends PostProcess {
  70894. private blurSteps;
  70895. /**
  70896. * Gets a string identifying the name of the class
  70897. * @returns "DepthOfFieldMergePostProcess" string
  70898. */
  70899. getClassName(): string;
  70900. /**
  70901. * Creates a new instance of DepthOfFieldMergePostProcess
  70902. * @param name The name of the effect.
  70903. * @param originalFromInput Post process which's input will be used for the merge.
  70904. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70905. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70906. * @param options The required width/height ratio to downsize to before computing the render pass.
  70907. * @param camera The camera to apply the render pass to.
  70908. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70909. * @param engine The engine which the post process will be applied. (default: current engine)
  70910. * @param reusable If the post process can be reused on the same frame. (default: false)
  70911. * @param textureType Type of textures used when performing the post process. (default: 0)
  70912. * @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)
  70913. */
  70914. 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);
  70915. /**
  70916. * Updates the effect with the current post process compile time values and recompiles the shader.
  70917. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70918. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70919. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70920. * @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
  70921. * @param onCompiled Called when the shader has been compiled.
  70922. * @param onError Called if there is an error when compiling a shader.
  70923. */
  70924. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70925. }
  70926. }
  70927. declare module BABYLON {
  70928. /**
  70929. * Specifies the level of max blur that should be applied when using the depth of field effect
  70930. */
  70931. export enum DepthOfFieldEffectBlurLevel {
  70932. /**
  70933. * Subtle blur
  70934. */
  70935. Low = 0,
  70936. /**
  70937. * Medium blur
  70938. */
  70939. Medium = 1,
  70940. /**
  70941. * Large blur
  70942. */
  70943. High = 2
  70944. }
  70945. /**
  70946. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70947. */
  70948. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70949. private _circleOfConfusion;
  70950. /**
  70951. * @hidden Internal, blurs from high to low
  70952. */
  70953. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70954. private _depthOfFieldBlurY;
  70955. private _dofMerge;
  70956. /**
  70957. * @hidden Internal post processes in depth of field effect
  70958. */
  70959. _effects: Array<PostProcess>;
  70960. /**
  70961. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70962. */
  70963. set focalLength(value: number);
  70964. get focalLength(): number;
  70965. /**
  70966. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70967. */
  70968. set fStop(value: number);
  70969. get fStop(): number;
  70970. /**
  70971. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70972. */
  70973. set focusDistance(value: number);
  70974. get focusDistance(): number;
  70975. /**
  70976. * 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.
  70977. */
  70978. set lensSize(value: number);
  70979. get lensSize(): number;
  70980. /**
  70981. * Creates a new instance DepthOfFieldEffect
  70982. * @param scene The scene the effect belongs to.
  70983. * @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.
  70984. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70985. * @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)
  70986. */
  70987. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70988. /**
  70989. * Get the current class name of the current effet
  70990. * @returns "DepthOfFieldEffect"
  70991. */
  70992. getClassName(): string;
  70993. /**
  70994. * 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.
  70995. */
  70996. set depthTexture(value: RenderTargetTexture);
  70997. /**
  70998. * Disposes each of the internal effects for a given camera.
  70999. * @param camera The camera to dispose the effect on.
  71000. */
  71001. disposeEffects(camera: Camera): void;
  71002. /**
  71003. * @hidden Internal
  71004. */
  71005. _updateEffects(): void;
  71006. /**
  71007. * Internal
  71008. * @returns if all the contained post processes are ready.
  71009. * @hidden
  71010. */
  71011. _isReady(): boolean;
  71012. }
  71013. }
  71014. declare module BABYLON {
  71015. /** @hidden */
  71016. export var displayPassPixelShader: {
  71017. name: string;
  71018. shader: string;
  71019. };
  71020. }
  71021. declare module BABYLON {
  71022. /**
  71023. * DisplayPassPostProcess which produces an output the same as it's input
  71024. */
  71025. export class DisplayPassPostProcess extends PostProcess {
  71026. /**
  71027. * Gets a string identifying the name of the class
  71028. * @returns "DisplayPassPostProcess" string
  71029. */
  71030. getClassName(): string;
  71031. /**
  71032. * Creates the DisplayPassPostProcess
  71033. * @param name The name of the effect.
  71034. * @param options The required width/height ratio to downsize to before computing the render pass.
  71035. * @param camera The camera to apply the render pass to.
  71036. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71037. * @param engine The engine which the post process will be applied. (default: current engine)
  71038. * @param reusable If the post process can be reused on the same frame. (default: false)
  71039. */
  71040. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71041. /** @hidden */
  71042. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  71043. }
  71044. }
  71045. declare module BABYLON {
  71046. /** @hidden */
  71047. export var filterPixelShader: {
  71048. name: string;
  71049. shader: string;
  71050. };
  71051. }
  71052. declare module BABYLON {
  71053. /**
  71054. * Applies a kernel filter to the image
  71055. */
  71056. export class FilterPostProcess extends PostProcess {
  71057. /** The matrix to be applied to the image */
  71058. kernelMatrix: Matrix;
  71059. /**
  71060. * Gets a string identifying the name of the class
  71061. * @returns "FilterPostProcess" string
  71062. */
  71063. getClassName(): string;
  71064. /**
  71065. *
  71066. * @param name The name of the effect.
  71067. * @param kernelMatrix The matrix to be applied to the image
  71068. * @param options The required width/height ratio to downsize to before computing the render pass.
  71069. * @param camera The camera to apply the render pass to.
  71070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71071. * @param engine The engine which the post process will be applied. (default: current engine)
  71072. * @param reusable If the post process can be reused on the same frame. (default: false)
  71073. */
  71074. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71075. /** @hidden */
  71076. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  71077. }
  71078. }
  71079. declare module BABYLON {
  71080. /** @hidden */
  71081. export var fxaaPixelShader: {
  71082. name: string;
  71083. shader: string;
  71084. };
  71085. }
  71086. declare module BABYLON {
  71087. /** @hidden */
  71088. export var fxaaVertexShader: {
  71089. name: string;
  71090. shader: string;
  71091. };
  71092. }
  71093. declare module BABYLON {
  71094. /**
  71095. * Fxaa post process
  71096. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71097. */
  71098. export class FxaaPostProcess extends PostProcess {
  71099. /**
  71100. * Gets a string identifying the name of the class
  71101. * @returns "FxaaPostProcess" string
  71102. */
  71103. getClassName(): string;
  71104. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71105. private _getDefines;
  71106. /** @hidden */
  71107. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  71108. }
  71109. }
  71110. declare module BABYLON {
  71111. /** @hidden */
  71112. export var grainPixelShader: {
  71113. name: string;
  71114. shader: string;
  71115. };
  71116. }
  71117. declare module BABYLON {
  71118. /**
  71119. * The GrainPostProcess adds noise to the image at mid luminance levels
  71120. */
  71121. export class GrainPostProcess extends PostProcess {
  71122. /**
  71123. * The intensity of the grain added (default: 30)
  71124. */
  71125. intensity: number;
  71126. /**
  71127. * If the grain should be randomized on every frame
  71128. */
  71129. animated: boolean;
  71130. /**
  71131. * Gets a string identifying the name of the class
  71132. * @returns "GrainPostProcess" string
  71133. */
  71134. getClassName(): string;
  71135. /**
  71136. * Creates a new instance of @see GrainPostProcess
  71137. * @param name The name of the effect.
  71138. * @param options The required width/height ratio to downsize to before computing the render pass.
  71139. * @param camera The camera to apply the render pass to.
  71140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71141. * @param engine The engine which the post process will be applied. (default: current engine)
  71142. * @param reusable If the post process can be reused on the same frame. (default: false)
  71143. * @param textureType Type of textures used when performing the post process. (default: 0)
  71144. * @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)
  71145. */
  71146. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71147. /** @hidden */
  71148. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  71149. }
  71150. }
  71151. declare module BABYLON {
  71152. /** @hidden */
  71153. export var highlightsPixelShader: {
  71154. name: string;
  71155. shader: string;
  71156. };
  71157. }
  71158. declare module BABYLON {
  71159. /**
  71160. * Extracts highlights from the image
  71161. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71162. */
  71163. export class HighlightsPostProcess extends PostProcess {
  71164. /**
  71165. * Gets a string identifying the name of the class
  71166. * @returns "HighlightsPostProcess" string
  71167. */
  71168. getClassName(): string;
  71169. /**
  71170. * Extracts highlights from the image
  71171. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71172. * @param name The name of the effect.
  71173. * @param options The required width/height ratio to downsize to before computing the render pass.
  71174. * @param camera The camera to apply the render pass to.
  71175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71176. * @param engine The engine which the post process will be applied. (default: current engine)
  71177. * @param reusable If the post process can be reused on the same frame. (default: false)
  71178. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  71179. */
  71180. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71181. }
  71182. }
  71183. declare module BABYLON {
  71184. /**
  71185. * Contains all parameters needed for the prepass to perform
  71186. * motion blur
  71187. */
  71188. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  71189. /**
  71190. * Is motion blur enabled
  71191. */
  71192. enabled: boolean;
  71193. /**
  71194. * Name of the configuration
  71195. */
  71196. name: string;
  71197. /**
  71198. * Textures that should be present in the MRT for this effect to work
  71199. */
  71200. readonly texturesRequired: number[];
  71201. }
  71202. }
  71203. declare module BABYLON {
  71204. interface Scene {
  71205. /** @hidden (Backing field) */
  71206. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71207. /**
  71208. * Gets or Sets the current geometry buffer associated to the scene.
  71209. */
  71210. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71211. /**
  71212. * Enables a GeometryBufferRender and associates it with the scene
  71213. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  71214. * @returns the GeometryBufferRenderer
  71215. */
  71216. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  71217. /**
  71218. * Disables the GeometryBufferRender associated with the scene
  71219. */
  71220. disableGeometryBufferRenderer(): void;
  71221. }
  71222. /**
  71223. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71224. * in several rendering techniques.
  71225. */
  71226. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  71227. /**
  71228. * The component name helpful to identify the component in the list of scene components.
  71229. */
  71230. readonly name: string;
  71231. /**
  71232. * The scene the component belongs to.
  71233. */
  71234. scene: Scene;
  71235. /**
  71236. * Creates a new instance of the component for the given scene
  71237. * @param scene Defines the scene to register the component in
  71238. */
  71239. constructor(scene: Scene);
  71240. /**
  71241. * Registers the component in a given scene
  71242. */
  71243. register(): void;
  71244. /**
  71245. * Rebuilds the elements related to this component in case of
  71246. * context lost for instance.
  71247. */
  71248. rebuild(): void;
  71249. /**
  71250. * Disposes the component and the associated ressources
  71251. */
  71252. dispose(): void;
  71253. private _gatherRenderTargets;
  71254. }
  71255. }
  71256. declare module BABYLON {
  71257. /** @hidden */
  71258. export var motionBlurPixelShader: {
  71259. name: string;
  71260. shader: string;
  71261. };
  71262. }
  71263. declare module BABYLON {
  71264. /**
  71265. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  71266. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  71267. * As an example, all you have to do is to create the post-process:
  71268. * var mb = new BABYLON.MotionBlurPostProcess(
  71269. * 'mb', // The name of the effect.
  71270. * scene, // The scene containing the objects to blur according to their velocity.
  71271. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  71272. * camera // The camera to apply the render pass to.
  71273. * );
  71274. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71275. */
  71276. export class MotionBlurPostProcess extends PostProcess {
  71277. /**
  71278. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71279. */
  71280. motionStrength: number;
  71281. /**
  71282. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71283. */
  71284. get motionBlurSamples(): number;
  71285. /**
  71286. * Sets the number of iterations to be used for motion blur quality
  71287. */
  71288. set motionBlurSamples(samples: number);
  71289. private _motionBlurSamples;
  71290. private _forceGeometryBuffer;
  71291. private _geometryBufferRenderer;
  71292. private _prePassRenderer;
  71293. /**
  71294. * Gets a string identifying the name of the class
  71295. * @returns "MotionBlurPostProcess" string
  71296. */
  71297. getClassName(): string;
  71298. /**
  71299. * Creates a new instance MotionBlurPostProcess
  71300. * @param name The name of the effect.
  71301. * @param scene The scene containing the objects to blur according to their velocity.
  71302. * @param options The required width/height ratio to downsize to before computing the render pass.
  71303. * @param camera The camera to apply the render pass to.
  71304. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71305. * @param engine The engine which the post process will be applied. (default: current engine)
  71306. * @param reusable If the post process can be reused on the same frame. (default: false)
  71307. * @param textureType Type of textures used when performing the post process. (default: 0)
  71308. * @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)
  71309. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71310. */
  71311. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71312. /**
  71313. * Excludes the given skinned mesh from computing bones velocities.
  71314. * 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.
  71315. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71316. */
  71317. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71318. /**
  71319. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71320. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71321. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71322. */
  71323. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71324. /**
  71325. * Disposes the post process.
  71326. * @param camera The camera to dispose the post process on.
  71327. */
  71328. dispose(camera?: Camera): void;
  71329. /** @hidden */
  71330. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  71331. }
  71332. }
  71333. declare module BABYLON {
  71334. /** @hidden */
  71335. export var refractionPixelShader: {
  71336. name: string;
  71337. shader: string;
  71338. };
  71339. }
  71340. declare module BABYLON {
  71341. /**
  71342. * Post process which applies a refractin texture
  71343. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71344. */
  71345. export class RefractionPostProcess extends PostProcess {
  71346. private _refTexture;
  71347. private _ownRefractionTexture;
  71348. /** the base color of the refraction (used to taint the rendering) */
  71349. color: Color3;
  71350. /** simulated refraction depth */
  71351. depth: number;
  71352. /** the coefficient of the base color (0 to remove base color tainting) */
  71353. colorLevel: number;
  71354. /** Gets the url used to load the refraction texture */
  71355. refractionTextureUrl: string;
  71356. /**
  71357. * Gets or sets the refraction texture
  71358. * Please note that you are responsible for disposing the texture if you set it manually
  71359. */
  71360. get refractionTexture(): Texture;
  71361. set refractionTexture(value: Texture);
  71362. /**
  71363. * Gets a string identifying the name of the class
  71364. * @returns "RefractionPostProcess" string
  71365. */
  71366. getClassName(): string;
  71367. /**
  71368. * Initializes the RefractionPostProcess
  71369. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71370. * @param name The name of the effect.
  71371. * @param refractionTextureUrl Url of the refraction texture to use
  71372. * @param color the base color of the refraction (used to taint the rendering)
  71373. * @param depth simulated refraction depth
  71374. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71375. * @param camera The camera to apply the render pass to.
  71376. * @param options The required width/height ratio to downsize to before computing the render pass.
  71377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71378. * @param engine The engine which the post process will be applied. (default: current engine)
  71379. * @param reusable If the post process can be reused on the same frame. (default: false)
  71380. */
  71381. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71382. /**
  71383. * Disposes of the post process
  71384. * @param camera Camera to dispose post process on
  71385. */
  71386. dispose(camera: Camera): void;
  71387. /** @hidden */
  71388. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  71389. }
  71390. }
  71391. declare module BABYLON {
  71392. /** @hidden */
  71393. export var sharpenPixelShader: {
  71394. name: string;
  71395. shader: string;
  71396. };
  71397. }
  71398. declare module BABYLON {
  71399. /**
  71400. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71401. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71402. */
  71403. export class SharpenPostProcess extends PostProcess {
  71404. /**
  71405. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71406. */
  71407. colorAmount: number;
  71408. /**
  71409. * How much sharpness should be applied (default: 0.3)
  71410. */
  71411. edgeAmount: number;
  71412. /**
  71413. * Gets a string identifying the name of the class
  71414. * @returns "SharpenPostProcess" string
  71415. */
  71416. getClassName(): string;
  71417. /**
  71418. * Creates a new instance ConvolutionPostProcess
  71419. * @param name The name of the effect.
  71420. * @param options The required width/height ratio to downsize to before computing the render pass.
  71421. * @param camera The camera to apply the render pass to.
  71422. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71423. * @param engine The engine which the post process will be applied. (default: current engine)
  71424. * @param reusable If the post process can be reused on the same frame. (default: false)
  71425. * @param textureType Type of textures used when performing the post process. (default: 0)
  71426. * @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)
  71427. */
  71428. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71429. /** @hidden */
  71430. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  71431. }
  71432. }
  71433. declare module BABYLON {
  71434. /**
  71435. * PostProcessRenderPipeline
  71436. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71437. */
  71438. export class PostProcessRenderPipeline {
  71439. private engine;
  71440. private _renderEffects;
  71441. private _renderEffectsForIsolatedPass;
  71442. /**
  71443. * List of inspectable custom properties (used by the Inspector)
  71444. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71445. */
  71446. inspectableCustomProperties: IInspectable[];
  71447. /**
  71448. * @hidden
  71449. */
  71450. protected _cameras: Camera[];
  71451. /** @hidden */
  71452. _name: string;
  71453. /**
  71454. * Gets pipeline name
  71455. */
  71456. get name(): string;
  71457. /** Gets the list of attached cameras */
  71458. get cameras(): Camera[];
  71459. /**
  71460. * Initializes a PostProcessRenderPipeline
  71461. * @param engine engine to add the pipeline to
  71462. * @param name name of the pipeline
  71463. */
  71464. constructor(engine: Engine, name: string);
  71465. /**
  71466. * Gets the class name
  71467. * @returns "PostProcessRenderPipeline"
  71468. */
  71469. getClassName(): string;
  71470. /**
  71471. * If all the render effects in the pipeline are supported
  71472. */
  71473. get isSupported(): boolean;
  71474. /**
  71475. * Adds an effect to the pipeline
  71476. * @param renderEffect the effect to add
  71477. */
  71478. addEffect(renderEffect: PostProcessRenderEffect): void;
  71479. /** @hidden */
  71480. _rebuild(): void;
  71481. /** @hidden */
  71482. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71483. /** @hidden */
  71484. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71485. /** @hidden */
  71486. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71487. /** @hidden */
  71488. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71489. /** @hidden */
  71490. _attachCameras(cameras: Camera, unique: boolean): void;
  71491. /** @hidden */
  71492. _attachCameras(cameras: Camera[], unique: boolean): void;
  71493. /** @hidden */
  71494. _detachCameras(cameras: Camera): void;
  71495. /** @hidden */
  71496. _detachCameras(cameras: Nullable<Camera[]>): void;
  71497. /** @hidden */
  71498. _update(): void;
  71499. /** @hidden */
  71500. _reset(): void;
  71501. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71502. /**
  71503. * Sets the required values to the prepass renderer.
  71504. * @param prePassRenderer defines the prepass renderer to setup.
  71505. * @returns true if the pre pass is needed.
  71506. */
  71507. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71508. /**
  71509. * Disposes of the pipeline
  71510. */
  71511. dispose(): void;
  71512. }
  71513. }
  71514. declare module BABYLON {
  71515. /**
  71516. * PostProcessRenderPipelineManager class
  71517. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71518. */
  71519. export class PostProcessRenderPipelineManager {
  71520. private _renderPipelines;
  71521. /**
  71522. * Initializes a PostProcessRenderPipelineManager
  71523. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71524. */
  71525. constructor();
  71526. /**
  71527. * Gets the list of supported render pipelines
  71528. */
  71529. get supportedPipelines(): PostProcessRenderPipeline[];
  71530. /**
  71531. * Adds a pipeline to the manager
  71532. * @param renderPipeline The pipeline to add
  71533. */
  71534. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71535. /**
  71536. * Attaches a camera to the pipeline
  71537. * @param renderPipelineName The name of the pipeline to attach to
  71538. * @param cameras the camera to attach
  71539. * @param unique if the camera can be attached multiple times to the pipeline
  71540. */
  71541. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71542. /**
  71543. * Detaches a camera from the pipeline
  71544. * @param renderPipelineName The name of the pipeline to detach from
  71545. * @param cameras the camera to detach
  71546. */
  71547. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71548. /**
  71549. * Enables an effect by name on a pipeline
  71550. * @param renderPipelineName the name of the pipeline to enable the effect in
  71551. * @param renderEffectName the name of the effect to enable
  71552. * @param cameras the cameras that the effect should be enabled on
  71553. */
  71554. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71555. /**
  71556. * Disables an effect by name on a pipeline
  71557. * @param renderPipelineName the name of the pipeline to disable the effect in
  71558. * @param renderEffectName the name of the effect to disable
  71559. * @param cameras the cameras that the effect should be disabled on
  71560. */
  71561. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71562. /**
  71563. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71564. */
  71565. update(): void;
  71566. /** @hidden */
  71567. _rebuild(): void;
  71568. /**
  71569. * Disposes of the manager and pipelines
  71570. */
  71571. dispose(): void;
  71572. }
  71573. }
  71574. declare module BABYLON {
  71575. interface Scene {
  71576. /** @hidden (Backing field) */
  71577. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71578. /**
  71579. * Gets the postprocess render pipeline manager
  71580. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71581. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71582. */
  71583. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71584. }
  71585. /**
  71586. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71587. */
  71588. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71589. /**
  71590. * The component name helpfull to identify the component in the list of scene components.
  71591. */
  71592. readonly name: string;
  71593. /**
  71594. * The scene the component belongs to.
  71595. */
  71596. scene: Scene;
  71597. /**
  71598. * Creates a new instance of the component for the given scene
  71599. * @param scene Defines the scene to register the component in
  71600. */
  71601. constructor(scene: Scene);
  71602. /**
  71603. * Registers the component in a given scene
  71604. */
  71605. register(): void;
  71606. /**
  71607. * Rebuilds the elements related to this component in case of
  71608. * context lost for instance.
  71609. */
  71610. rebuild(): void;
  71611. /**
  71612. * Disposes the component and the associated ressources
  71613. */
  71614. dispose(): void;
  71615. private _gatherRenderTargets;
  71616. }
  71617. }
  71618. declare module BABYLON {
  71619. /**
  71620. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71621. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71622. */
  71623. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71624. private _scene;
  71625. private _camerasToBeAttached;
  71626. /**
  71627. * ID of the sharpen post process,
  71628. */
  71629. private readonly SharpenPostProcessId;
  71630. /**
  71631. * @ignore
  71632. * ID of the image processing post process;
  71633. */
  71634. readonly ImageProcessingPostProcessId: string;
  71635. /**
  71636. * @ignore
  71637. * ID of the Fast Approximate Anti-Aliasing post process;
  71638. */
  71639. readonly FxaaPostProcessId: string;
  71640. /**
  71641. * ID of the chromatic aberration post process,
  71642. */
  71643. private readonly ChromaticAberrationPostProcessId;
  71644. /**
  71645. * ID of the grain post process
  71646. */
  71647. private readonly GrainPostProcessId;
  71648. /**
  71649. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71650. */
  71651. sharpen: SharpenPostProcess;
  71652. private _sharpenEffect;
  71653. private bloom;
  71654. /**
  71655. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71656. */
  71657. depthOfField: DepthOfFieldEffect;
  71658. /**
  71659. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71660. */
  71661. fxaa: FxaaPostProcess;
  71662. /**
  71663. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71664. */
  71665. imageProcessing: ImageProcessingPostProcess;
  71666. /**
  71667. * Chromatic aberration post process which will shift rgb colors in the image
  71668. */
  71669. chromaticAberration: ChromaticAberrationPostProcess;
  71670. private _chromaticAberrationEffect;
  71671. /**
  71672. * Grain post process which add noise to the image
  71673. */
  71674. grain: GrainPostProcess;
  71675. private _grainEffect;
  71676. /**
  71677. * Glow post process which adds a glow to emissive areas of the image
  71678. */
  71679. private _glowLayer;
  71680. /**
  71681. * Animations which can be used to tweak settings over a period of time
  71682. */
  71683. animations: Animation[];
  71684. private _imageProcessingConfigurationObserver;
  71685. private _sharpenEnabled;
  71686. private _bloomEnabled;
  71687. private _depthOfFieldEnabled;
  71688. private _depthOfFieldBlurLevel;
  71689. private _fxaaEnabled;
  71690. private _imageProcessingEnabled;
  71691. private _defaultPipelineTextureType;
  71692. private _bloomScale;
  71693. private _chromaticAberrationEnabled;
  71694. private _grainEnabled;
  71695. private _buildAllowed;
  71696. /**
  71697. * This is triggered each time the pipeline has been built.
  71698. */
  71699. onBuildObservable: Observable<DefaultRenderingPipeline>;
  71700. /**
  71701. * Gets active scene
  71702. */
  71703. get scene(): Scene;
  71704. /**
  71705. * Enable or disable the sharpen process from the pipeline
  71706. */
  71707. set sharpenEnabled(enabled: boolean);
  71708. get sharpenEnabled(): boolean;
  71709. private _resizeObserver;
  71710. private _hardwareScaleLevel;
  71711. private _bloomKernel;
  71712. /**
  71713. * Specifies the size of the bloom blur kernel, relative to the final output size
  71714. */
  71715. get bloomKernel(): number;
  71716. set bloomKernel(value: number);
  71717. /**
  71718. * Specifies the weight of the bloom in the final rendering
  71719. */
  71720. private _bloomWeight;
  71721. /**
  71722. * Specifies the luma threshold for the area that will be blurred by the bloom
  71723. */
  71724. private _bloomThreshold;
  71725. private _hdr;
  71726. /**
  71727. * The strength of the bloom.
  71728. */
  71729. set bloomWeight(value: number);
  71730. get bloomWeight(): number;
  71731. /**
  71732. * The strength of the bloom.
  71733. */
  71734. set bloomThreshold(value: number);
  71735. get bloomThreshold(): number;
  71736. /**
  71737. * The scale of the bloom, lower value will provide better performance.
  71738. */
  71739. set bloomScale(value: number);
  71740. get bloomScale(): number;
  71741. /**
  71742. * Enable or disable the bloom from the pipeline
  71743. */
  71744. set bloomEnabled(enabled: boolean);
  71745. get bloomEnabled(): boolean;
  71746. private _rebuildBloom;
  71747. /**
  71748. * If the depth of field is enabled.
  71749. */
  71750. get depthOfFieldEnabled(): boolean;
  71751. set depthOfFieldEnabled(enabled: boolean);
  71752. /**
  71753. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71754. */
  71755. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71756. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71757. /**
  71758. * If the anti aliasing is enabled.
  71759. */
  71760. set fxaaEnabled(enabled: boolean);
  71761. get fxaaEnabled(): boolean;
  71762. private _samples;
  71763. /**
  71764. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71765. */
  71766. set samples(sampleCount: number);
  71767. get samples(): number;
  71768. /**
  71769. * If image processing is enabled.
  71770. */
  71771. set imageProcessingEnabled(enabled: boolean);
  71772. get imageProcessingEnabled(): boolean;
  71773. /**
  71774. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71775. */
  71776. set glowLayerEnabled(enabled: boolean);
  71777. get glowLayerEnabled(): boolean;
  71778. /**
  71779. * Gets the glow layer (or null if not defined)
  71780. */
  71781. get glowLayer(): Nullable<GlowLayer>;
  71782. /**
  71783. * Enable or disable the chromaticAberration process from the pipeline
  71784. */
  71785. set chromaticAberrationEnabled(enabled: boolean);
  71786. get chromaticAberrationEnabled(): boolean;
  71787. /**
  71788. * Enable or disable the grain process from the pipeline
  71789. */
  71790. set grainEnabled(enabled: boolean);
  71791. get grainEnabled(): boolean;
  71792. /**
  71793. * @constructor
  71794. * @param name - The rendering pipeline name (default: "")
  71795. * @param hdr - If high dynamic range textures should be used (default: true)
  71796. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71797. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71798. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71799. */
  71800. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71801. /**
  71802. * Get the class name
  71803. * @returns "DefaultRenderingPipeline"
  71804. */
  71805. getClassName(): string;
  71806. /**
  71807. * Force the compilation of the entire pipeline.
  71808. */
  71809. prepare(): void;
  71810. private _hasCleared;
  71811. private _prevPostProcess;
  71812. private _prevPrevPostProcess;
  71813. private _setAutoClearAndTextureSharing;
  71814. private _depthOfFieldSceneObserver;
  71815. private _buildPipeline;
  71816. private _disposePostProcesses;
  71817. /**
  71818. * Adds a camera to the pipeline
  71819. * @param camera the camera to be added
  71820. */
  71821. addCamera(camera: Camera): void;
  71822. /**
  71823. * Removes a camera from the pipeline
  71824. * @param camera the camera to remove
  71825. */
  71826. removeCamera(camera: Camera): void;
  71827. /**
  71828. * Dispose of the pipeline and stop all post processes
  71829. */
  71830. dispose(): void;
  71831. /**
  71832. * Serialize the rendering pipeline (Used when exporting)
  71833. * @returns the serialized object
  71834. */
  71835. serialize(): any;
  71836. /**
  71837. * Parse the serialized pipeline
  71838. * @param source Source pipeline.
  71839. * @param scene The scene to load the pipeline to.
  71840. * @param rootUrl The URL of the serialized pipeline.
  71841. * @returns An instantiated pipeline from the serialized object.
  71842. */
  71843. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71844. }
  71845. }
  71846. declare module BABYLON {
  71847. /** @hidden */
  71848. export var lensHighlightsPixelShader: {
  71849. name: string;
  71850. shader: string;
  71851. };
  71852. }
  71853. declare module BABYLON {
  71854. /** @hidden */
  71855. export var depthOfFieldPixelShader: {
  71856. name: string;
  71857. shader: string;
  71858. };
  71859. }
  71860. declare module BABYLON {
  71861. /**
  71862. * BABYLON.JS Chromatic Aberration GLSL Shader
  71863. * Author: Olivier Guyot
  71864. * Separates very slightly R, G and B colors on the edges of the screen
  71865. * Inspired by Francois Tarlier & Martins Upitis
  71866. */
  71867. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71868. /**
  71869. * @ignore
  71870. * The chromatic aberration PostProcess id in the pipeline
  71871. */
  71872. LensChromaticAberrationEffect: string;
  71873. /**
  71874. * @ignore
  71875. * The highlights enhancing PostProcess id in the pipeline
  71876. */
  71877. HighlightsEnhancingEffect: string;
  71878. /**
  71879. * @ignore
  71880. * The depth-of-field PostProcess id in the pipeline
  71881. */
  71882. LensDepthOfFieldEffect: string;
  71883. private _scene;
  71884. private _depthTexture;
  71885. private _grainTexture;
  71886. private _chromaticAberrationPostProcess;
  71887. private _highlightsPostProcess;
  71888. private _depthOfFieldPostProcess;
  71889. private _edgeBlur;
  71890. private _grainAmount;
  71891. private _chromaticAberration;
  71892. private _distortion;
  71893. private _highlightsGain;
  71894. private _highlightsThreshold;
  71895. private _dofDistance;
  71896. private _dofAperture;
  71897. private _dofDarken;
  71898. private _dofPentagon;
  71899. private _blurNoise;
  71900. /**
  71901. * @constructor
  71902. *
  71903. * Effect parameters are as follow:
  71904. * {
  71905. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71906. * edge_blur: number; // from 0 to x (1 for realism)
  71907. * distortion: number; // from 0 to x (1 for realism)
  71908. * grain_amount: number; // from 0 to 1
  71909. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71910. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71911. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71912. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71913. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71914. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71915. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71916. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71917. * }
  71918. * Note: if an effect parameter is unset, effect is disabled
  71919. *
  71920. * @param name The rendering pipeline name
  71921. * @param parameters - An object containing all parameters (see above)
  71922. * @param scene The scene linked to this pipeline
  71923. * @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)
  71924. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71925. */
  71926. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71927. /**
  71928. * Get the class name
  71929. * @returns "LensRenderingPipeline"
  71930. */
  71931. getClassName(): string;
  71932. /**
  71933. * Gets associated scene
  71934. */
  71935. get scene(): Scene;
  71936. /**
  71937. * Gets or sets the edge blur
  71938. */
  71939. get edgeBlur(): number;
  71940. set edgeBlur(value: number);
  71941. /**
  71942. * Gets or sets the grain amount
  71943. */
  71944. get grainAmount(): number;
  71945. set grainAmount(value: number);
  71946. /**
  71947. * Gets or sets the chromatic aberration amount
  71948. */
  71949. get chromaticAberration(): number;
  71950. set chromaticAberration(value: number);
  71951. /**
  71952. * Gets or sets the depth of field aperture
  71953. */
  71954. get dofAperture(): number;
  71955. set dofAperture(value: number);
  71956. /**
  71957. * Gets or sets the edge distortion
  71958. */
  71959. get edgeDistortion(): number;
  71960. set edgeDistortion(value: number);
  71961. /**
  71962. * Gets or sets the depth of field distortion
  71963. */
  71964. get dofDistortion(): number;
  71965. set dofDistortion(value: number);
  71966. /**
  71967. * Gets or sets the darken out of focus amount
  71968. */
  71969. get darkenOutOfFocus(): number;
  71970. set darkenOutOfFocus(value: number);
  71971. /**
  71972. * Gets or sets a boolean indicating if blur noise is enabled
  71973. */
  71974. get blurNoise(): boolean;
  71975. set blurNoise(value: boolean);
  71976. /**
  71977. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71978. */
  71979. get pentagonBokeh(): boolean;
  71980. set pentagonBokeh(value: boolean);
  71981. /**
  71982. * Gets or sets the highlight grain amount
  71983. */
  71984. get highlightsGain(): number;
  71985. set highlightsGain(value: number);
  71986. /**
  71987. * Gets or sets the highlight threshold
  71988. */
  71989. get highlightsThreshold(): number;
  71990. set highlightsThreshold(value: number);
  71991. /**
  71992. * Sets the amount of blur at the edges
  71993. * @param amount blur amount
  71994. */
  71995. setEdgeBlur(amount: number): void;
  71996. /**
  71997. * Sets edge blur to 0
  71998. */
  71999. disableEdgeBlur(): void;
  72000. /**
  72001. * Sets the amout of grain
  72002. * @param amount Amount of grain
  72003. */
  72004. setGrainAmount(amount: number): void;
  72005. /**
  72006. * Set grain amount to 0
  72007. */
  72008. disableGrain(): void;
  72009. /**
  72010. * Sets the chromatic aberration amount
  72011. * @param amount amount of chromatic aberration
  72012. */
  72013. setChromaticAberration(amount: number): void;
  72014. /**
  72015. * Sets chromatic aberration amount to 0
  72016. */
  72017. disableChromaticAberration(): void;
  72018. /**
  72019. * Sets the EdgeDistortion amount
  72020. * @param amount amount of EdgeDistortion
  72021. */
  72022. setEdgeDistortion(amount: number): void;
  72023. /**
  72024. * Sets edge distortion to 0
  72025. */
  72026. disableEdgeDistortion(): void;
  72027. /**
  72028. * Sets the FocusDistance amount
  72029. * @param amount amount of FocusDistance
  72030. */
  72031. setFocusDistance(amount: number): void;
  72032. /**
  72033. * Disables depth of field
  72034. */
  72035. disableDepthOfField(): void;
  72036. /**
  72037. * Sets the Aperture amount
  72038. * @param amount amount of Aperture
  72039. */
  72040. setAperture(amount: number): void;
  72041. /**
  72042. * Sets the DarkenOutOfFocus amount
  72043. * @param amount amount of DarkenOutOfFocus
  72044. */
  72045. setDarkenOutOfFocus(amount: number): void;
  72046. private _pentagonBokehIsEnabled;
  72047. /**
  72048. * Creates a pentagon bokeh effect
  72049. */
  72050. enablePentagonBokeh(): void;
  72051. /**
  72052. * Disables the pentagon bokeh effect
  72053. */
  72054. disablePentagonBokeh(): void;
  72055. /**
  72056. * Enables noise blur
  72057. */
  72058. enableNoiseBlur(): void;
  72059. /**
  72060. * Disables noise blur
  72061. */
  72062. disableNoiseBlur(): void;
  72063. /**
  72064. * Sets the HighlightsGain amount
  72065. * @param amount amount of HighlightsGain
  72066. */
  72067. setHighlightsGain(amount: number): void;
  72068. /**
  72069. * Sets the HighlightsThreshold amount
  72070. * @param amount amount of HighlightsThreshold
  72071. */
  72072. setHighlightsThreshold(amount: number): void;
  72073. /**
  72074. * Disables highlights
  72075. */
  72076. disableHighlights(): void;
  72077. /**
  72078. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  72079. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  72080. */
  72081. dispose(disableDepthRender?: boolean): void;
  72082. private _createChromaticAberrationPostProcess;
  72083. private _createHighlightsPostProcess;
  72084. private _createDepthOfFieldPostProcess;
  72085. private _createGrainTexture;
  72086. }
  72087. }
  72088. declare module BABYLON {
  72089. /**
  72090. * Contains all parameters needed for the prepass to perform
  72091. * screen space subsurface scattering
  72092. */
  72093. export class SSAO2Configuration implements PrePassEffectConfiguration {
  72094. /**
  72095. * Is subsurface enabled
  72096. */
  72097. enabled: boolean;
  72098. /**
  72099. * Name of the configuration
  72100. */
  72101. name: string;
  72102. /**
  72103. * Textures that should be present in the MRT for this effect to work
  72104. */
  72105. readonly texturesRequired: number[];
  72106. }
  72107. }
  72108. declare module BABYLON {
  72109. /** @hidden */
  72110. export var ssao2PixelShader: {
  72111. name: string;
  72112. shader: string;
  72113. };
  72114. }
  72115. declare module BABYLON {
  72116. /** @hidden */
  72117. export var ssaoCombinePixelShader: {
  72118. name: string;
  72119. shader: string;
  72120. };
  72121. }
  72122. declare module BABYLON {
  72123. /**
  72124. * Render pipeline to produce ssao effect
  72125. */
  72126. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  72127. /**
  72128. * @ignore
  72129. * The PassPostProcess id in the pipeline that contains the original scene color
  72130. */
  72131. SSAOOriginalSceneColorEffect: string;
  72132. /**
  72133. * @ignore
  72134. * The SSAO PostProcess id in the pipeline
  72135. */
  72136. SSAORenderEffect: string;
  72137. /**
  72138. * @ignore
  72139. * The horizontal blur PostProcess id in the pipeline
  72140. */
  72141. SSAOBlurHRenderEffect: string;
  72142. /**
  72143. * @ignore
  72144. * The vertical blur PostProcess id in the pipeline
  72145. */
  72146. SSAOBlurVRenderEffect: string;
  72147. /**
  72148. * @ignore
  72149. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72150. */
  72151. SSAOCombineRenderEffect: string;
  72152. /**
  72153. * The output strength of the SSAO post-process. Default value is 1.0.
  72154. */
  72155. totalStrength: number;
  72156. /**
  72157. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  72158. */
  72159. maxZ: number;
  72160. /**
  72161. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  72162. */
  72163. minZAspect: number;
  72164. private _samples;
  72165. /**
  72166. * Number of samples used for the SSAO calculations. Default value is 8
  72167. */
  72168. set samples(n: number);
  72169. get samples(): number;
  72170. private _textureSamples;
  72171. /**
  72172. * Number of samples to use for antialiasing
  72173. */
  72174. set textureSamples(n: number);
  72175. get textureSamples(): number;
  72176. /**
  72177. * Force rendering the geometry through geometry buffer
  72178. */
  72179. private _forceGeometryBuffer;
  72180. /**
  72181. * Ratio object used for SSAO ratio and blur ratio
  72182. */
  72183. private _ratio;
  72184. /**
  72185. * Dynamically generated sphere sampler.
  72186. */
  72187. private _sampleSphere;
  72188. /**
  72189. * Blur filter offsets
  72190. */
  72191. private _samplerOffsets;
  72192. private _expensiveBlur;
  72193. /**
  72194. * If bilateral blur should be used
  72195. */
  72196. set expensiveBlur(b: boolean);
  72197. get expensiveBlur(): boolean;
  72198. /**
  72199. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  72200. */
  72201. radius: number;
  72202. /**
  72203. * The base color of the SSAO post-process
  72204. * The final result is "base + ssao" between [0, 1]
  72205. */
  72206. base: number;
  72207. /**
  72208. * Support test.
  72209. */
  72210. static get IsSupported(): boolean;
  72211. private _scene;
  72212. private _randomTexture;
  72213. private _originalColorPostProcess;
  72214. private _ssaoPostProcess;
  72215. private _blurHPostProcess;
  72216. private _blurVPostProcess;
  72217. private _ssaoCombinePostProcess;
  72218. private _prePassRenderer;
  72219. /**
  72220. * Gets active scene
  72221. */
  72222. get scene(): Scene;
  72223. /**
  72224. * @constructor
  72225. * @param name The rendering pipeline name
  72226. * @param scene The scene linked to this pipeline
  72227. * @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 }
  72228. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72229. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  72230. */
  72231. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  72232. /**
  72233. * Get the class name
  72234. * @returns "SSAO2RenderingPipeline"
  72235. */
  72236. getClassName(): string;
  72237. /**
  72238. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72239. */
  72240. dispose(disableGeometryBufferRenderer?: boolean): void;
  72241. private _createBlurPostProcess;
  72242. /** @hidden */
  72243. _rebuild(): void;
  72244. private _bits;
  72245. private _radicalInverse_VdC;
  72246. private _hammersley;
  72247. private _hemisphereSample_uniform;
  72248. private _generateHemisphere;
  72249. private _getDefinesForSSAO;
  72250. private _createSSAOPostProcess;
  72251. private _createSSAOCombinePostProcess;
  72252. private _createRandomTexture;
  72253. /**
  72254. * Serialize the rendering pipeline (Used when exporting)
  72255. * @returns the serialized object
  72256. */
  72257. serialize(): any;
  72258. /**
  72259. * Parse the serialized pipeline
  72260. * @param source Source pipeline.
  72261. * @param scene The scene to load the pipeline to.
  72262. * @param rootUrl The URL of the serialized pipeline.
  72263. * @returns An instantiated pipeline from the serialized object.
  72264. */
  72265. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  72266. }
  72267. }
  72268. declare module BABYLON {
  72269. /** @hidden */
  72270. export var ssaoPixelShader: {
  72271. name: string;
  72272. shader: string;
  72273. };
  72274. }
  72275. declare module BABYLON {
  72276. /**
  72277. * Render pipeline to produce ssao effect
  72278. */
  72279. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72280. /**
  72281. * @ignore
  72282. * The PassPostProcess id in the pipeline that contains the original scene color
  72283. */
  72284. SSAOOriginalSceneColorEffect: string;
  72285. /**
  72286. * @ignore
  72287. * The SSAO PostProcess id in the pipeline
  72288. */
  72289. SSAORenderEffect: string;
  72290. /**
  72291. * @ignore
  72292. * The horizontal blur PostProcess id in the pipeline
  72293. */
  72294. SSAOBlurHRenderEffect: string;
  72295. /**
  72296. * @ignore
  72297. * The vertical blur PostProcess id in the pipeline
  72298. */
  72299. SSAOBlurVRenderEffect: string;
  72300. /**
  72301. * @ignore
  72302. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72303. */
  72304. SSAOCombineRenderEffect: string;
  72305. /**
  72306. * The output strength of the SSAO post-process. Default value is 1.0.
  72307. */
  72308. totalStrength: number;
  72309. /**
  72310. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72311. */
  72312. radius: number;
  72313. /**
  72314. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72315. * Must not be equal to fallOff and superior to fallOff.
  72316. * Default value is 0.0075
  72317. */
  72318. area: number;
  72319. /**
  72320. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72321. * Must not be equal to area and inferior to area.
  72322. * Default value is 0.000001
  72323. */
  72324. fallOff: number;
  72325. /**
  72326. * The base color of the SSAO post-process
  72327. * The final result is "base + ssao" between [0, 1]
  72328. */
  72329. base: number;
  72330. private _scene;
  72331. private _depthTexture;
  72332. private _randomTexture;
  72333. private _originalColorPostProcess;
  72334. private _ssaoPostProcess;
  72335. private _blurHPostProcess;
  72336. private _blurVPostProcess;
  72337. private _ssaoCombinePostProcess;
  72338. private _firstUpdate;
  72339. /**
  72340. * Gets active scene
  72341. */
  72342. get scene(): Scene;
  72343. /**
  72344. * @constructor
  72345. * @param name - The rendering pipeline name
  72346. * @param scene - The scene linked to this pipeline
  72347. * @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 }
  72348. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72349. */
  72350. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72351. /**
  72352. * Get the class name
  72353. * @returns "SSAORenderingPipeline"
  72354. */
  72355. getClassName(): string;
  72356. /**
  72357. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72358. */
  72359. dispose(disableDepthRender?: boolean): void;
  72360. private _createBlurPostProcess;
  72361. /** @hidden */
  72362. _rebuild(): void;
  72363. private _createSSAOPostProcess;
  72364. private _createSSAOCombinePostProcess;
  72365. private _createRandomTexture;
  72366. }
  72367. }
  72368. declare module BABYLON {
  72369. /**
  72370. * Contains all parameters needed for the prepass to perform
  72371. * screen space reflections
  72372. */
  72373. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  72374. /**
  72375. * Is ssr enabled
  72376. */
  72377. enabled: boolean;
  72378. /**
  72379. * Name of the configuration
  72380. */
  72381. name: string;
  72382. /**
  72383. * Textures that should be present in the MRT for this effect to work
  72384. */
  72385. readonly texturesRequired: number[];
  72386. }
  72387. }
  72388. declare module BABYLON {
  72389. /** @hidden */
  72390. export var screenSpaceReflectionPixelShader: {
  72391. name: string;
  72392. shader: string;
  72393. };
  72394. }
  72395. declare module BABYLON {
  72396. /**
  72397. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72398. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72399. */
  72400. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72401. /**
  72402. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72403. */
  72404. threshold: number;
  72405. /**
  72406. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72407. */
  72408. strength: number;
  72409. /**
  72410. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72411. */
  72412. reflectionSpecularFalloffExponent: number;
  72413. /**
  72414. * 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]
  72415. */
  72416. step: number;
  72417. /**
  72418. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72419. */
  72420. roughnessFactor: number;
  72421. private _forceGeometryBuffer;
  72422. private _geometryBufferRenderer;
  72423. private _prePassRenderer;
  72424. private _enableSmoothReflections;
  72425. private _reflectionSamples;
  72426. private _smoothSteps;
  72427. /**
  72428. * Gets a string identifying the name of the class
  72429. * @returns "ScreenSpaceReflectionPostProcess" string
  72430. */
  72431. getClassName(): string;
  72432. /**
  72433. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72434. * @param name The name of the effect.
  72435. * @param scene The scene containing the objects to calculate reflections.
  72436. * @param options The required width/height ratio to downsize to before computing the render pass.
  72437. * @param camera The camera to apply the render pass to.
  72438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72439. * @param engine The engine which the post process will be applied. (default: current engine)
  72440. * @param reusable If the post process can be reused on the same frame. (default: false)
  72441. * @param textureType Type of textures used when performing the post process. (default: 0)
  72442. * @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)
  72443. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  72444. */
  72445. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  72446. /**
  72447. * Gets wether or not smoothing reflections is enabled.
  72448. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72449. */
  72450. get enableSmoothReflections(): boolean;
  72451. /**
  72452. * Sets wether or not smoothing reflections is enabled.
  72453. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72454. */
  72455. set enableSmoothReflections(enabled: boolean);
  72456. /**
  72457. * Gets the number of samples taken while computing reflections. More samples count is high,
  72458. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72459. */
  72460. get reflectionSamples(): number;
  72461. /**
  72462. * Sets the number of samples taken while computing reflections. More samples count is high,
  72463. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72464. */
  72465. set reflectionSamples(samples: number);
  72466. /**
  72467. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72468. * more the post-process will require GPU power and can generate a drop in FPS.
  72469. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72470. */
  72471. get smoothSteps(): number;
  72472. set smoothSteps(steps: number);
  72473. private _updateEffectDefines;
  72474. /** @hidden */
  72475. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  72476. }
  72477. }
  72478. declare module BABYLON {
  72479. /** @hidden */
  72480. export var standardPixelShader: {
  72481. name: string;
  72482. shader: string;
  72483. };
  72484. }
  72485. declare module BABYLON {
  72486. /**
  72487. * Standard rendering pipeline
  72488. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72489. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72490. */
  72491. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72492. /**
  72493. * Public members
  72494. */
  72495. /**
  72496. * Post-process which contains the original scene color before the pipeline applies all the effects
  72497. */
  72498. originalPostProcess: Nullable<PostProcess>;
  72499. /**
  72500. * Post-process used to down scale an image x4
  72501. */
  72502. downSampleX4PostProcess: Nullable<PostProcess>;
  72503. /**
  72504. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72505. */
  72506. brightPassPostProcess: Nullable<PostProcess>;
  72507. /**
  72508. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72509. */
  72510. blurHPostProcesses: PostProcess[];
  72511. /**
  72512. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72513. */
  72514. blurVPostProcesses: PostProcess[];
  72515. /**
  72516. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72517. */
  72518. textureAdderPostProcess: Nullable<PostProcess>;
  72519. /**
  72520. * Post-process used to create volumetric lighting effect
  72521. */
  72522. volumetricLightPostProcess: Nullable<PostProcess>;
  72523. /**
  72524. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72525. */
  72526. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72527. /**
  72528. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72529. */
  72530. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72531. /**
  72532. * Post-process used to merge the volumetric light effect and the real scene color
  72533. */
  72534. volumetricLightMergePostProces: Nullable<PostProcess>;
  72535. /**
  72536. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72537. */
  72538. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72539. /**
  72540. * Base post-process used to calculate the average luminance of the final image for HDR
  72541. */
  72542. luminancePostProcess: Nullable<PostProcess>;
  72543. /**
  72544. * Post-processes used to create down sample post-processes in order to get
  72545. * the average luminance of the final image for HDR
  72546. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72547. */
  72548. luminanceDownSamplePostProcesses: PostProcess[];
  72549. /**
  72550. * Post-process used to create a HDR effect (light adaptation)
  72551. */
  72552. hdrPostProcess: Nullable<PostProcess>;
  72553. /**
  72554. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72555. */
  72556. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72557. /**
  72558. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72559. */
  72560. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72561. /**
  72562. * Post-process used to merge the final HDR post-process and the real scene color
  72563. */
  72564. hdrFinalPostProcess: Nullable<PostProcess>;
  72565. /**
  72566. * Post-process used to create a lens flare effect
  72567. */
  72568. lensFlarePostProcess: Nullable<PostProcess>;
  72569. /**
  72570. * Post-process that merges the result of the lens flare post-process and the real scene color
  72571. */
  72572. lensFlareComposePostProcess: Nullable<PostProcess>;
  72573. /**
  72574. * Post-process used to create a motion blur effect
  72575. */
  72576. motionBlurPostProcess: Nullable<PostProcess>;
  72577. /**
  72578. * Post-process used to create a depth of field effect
  72579. */
  72580. depthOfFieldPostProcess: Nullable<PostProcess>;
  72581. /**
  72582. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72583. */
  72584. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72585. /**
  72586. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72587. */
  72588. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72589. /**
  72590. * Represents the brightness threshold in order to configure the illuminated surfaces
  72591. */
  72592. brightThreshold: number;
  72593. /**
  72594. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72595. */
  72596. blurWidth: number;
  72597. /**
  72598. * Sets if the blur for highlighted surfaces must be only horizontal
  72599. */
  72600. horizontalBlur: boolean;
  72601. /**
  72602. * Gets the overall exposure used by the pipeline
  72603. */
  72604. get exposure(): number;
  72605. /**
  72606. * Sets the overall exposure used by the pipeline
  72607. */
  72608. set exposure(value: number);
  72609. /**
  72610. * Texture used typically to simulate "dirty" on camera lens
  72611. */
  72612. lensTexture: Nullable<Texture>;
  72613. /**
  72614. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72615. */
  72616. volumetricLightCoefficient: number;
  72617. /**
  72618. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72619. */
  72620. volumetricLightPower: number;
  72621. /**
  72622. * Used the set the blur intensity to smooth the volumetric lights
  72623. */
  72624. volumetricLightBlurScale: number;
  72625. /**
  72626. * Light (spot or directional) used to generate the volumetric lights rays
  72627. * The source light must have a shadow generate so the pipeline can get its
  72628. * depth map
  72629. */
  72630. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72631. /**
  72632. * For eye adaptation, represents the minimum luminance the eye can see
  72633. */
  72634. hdrMinimumLuminance: number;
  72635. /**
  72636. * For eye adaptation, represents the decrease luminance speed
  72637. */
  72638. hdrDecreaseRate: number;
  72639. /**
  72640. * For eye adaptation, represents the increase luminance speed
  72641. */
  72642. hdrIncreaseRate: number;
  72643. /**
  72644. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72645. */
  72646. get hdrAutoExposure(): boolean;
  72647. /**
  72648. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72649. */
  72650. set hdrAutoExposure(value: boolean);
  72651. /**
  72652. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72653. */
  72654. lensColorTexture: Nullable<Texture>;
  72655. /**
  72656. * The overall strengh for the lens flare effect
  72657. */
  72658. lensFlareStrength: number;
  72659. /**
  72660. * Dispersion coefficient for lens flare ghosts
  72661. */
  72662. lensFlareGhostDispersal: number;
  72663. /**
  72664. * Main lens flare halo width
  72665. */
  72666. lensFlareHaloWidth: number;
  72667. /**
  72668. * Based on the lens distortion effect, defines how much the lens flare result
  72669. * is distorted
  72670. */
  72671. lensFlareDistortionStrength: number;
  72672. /**
  72673. * Configures the blur intensity used for for lens flare (halo)
  72674. */
  72675. lensFlareBlurWidth: number;
  72676. /**
  72677. * Lens star texture must be used to simulate rays on the flares and is available
  72678. * in the documentation
  72679. */
  72680. lensStarTexture: Nullable<Texture>;
  72681. /**
  72682. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72683. * flare effect by taking account of the dirt texture
  72684. */
  72685. lensFlareDirtTexture: Nullable<Texture>;
  72686. /**
  72687. * Represents the focal length for the depth of field effect
  72688. */
  72689. depthOfFieldDistance: number;
  72690. /**
  72691. * Represents the blur intensity for the blurred part of the depth of field effect
  72692. */
  72693. depthOfFieldBlurWidth: number;
  72694. /**
  72695. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72696. */
  72697. get motionStrength(): number;
  72698. /**
  72699. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72700. */
  72701. set motionStrength(strength: number);
  72702. /**
  72703. * Gets wether or not the motion blur post-process is object based or screen based.
  72704. */
  72705. get objectBasedMotionBlur(): boolean;
  72706. /**
  72707. * Sets wether or not the motion blur post-process should be object based or screen based
  72708. */
  72709. set objectBasedMotionBlur(value: boolean);
  72710. /**
  72711. * List of animations for the pipeline (IAnimatable implementation)
  72712. */
  72713. animations: Animation[];
  72714. /**
  72715. * Private members
  72716. */
  72717. private _scene;
  72718. private _currentDepthOfFieldSource;
  72719. private _basePostProcess;
  72720. private _fixedExposure;
  72721. private _currentExposure;
  72722. private _hdrAutoExposure;
  72723. private _hdrCurrentLuminance;
  72724. private _motionStrength;
  72725. private _isObjectBasedMotionBlur;
  72726. private _floatTextureType;
  72727. private _camerasToBeAttached;
  72728. private _ratio;
  72729. private _bloomEnabled;
  72730. private _depthOfFieldEnabled;
  72731. private _vlsEnabled;
  72732. private _lensFlareEnabled;
  72733. private _hdrEnabled;
  72734. private _motionBlurEnabled;
  72735. private _fxaaEnabled;
  72736. private _screenSpaceReflectionsEnabled;
  72737. private _motionBlurSamples;
  72738. private _volumetricLightStepsCount;
  72739. private _samples;
  72740. /**
  72741. * @ignore
  72742. * Specifies if the bloom pipeline is enabled
  72743. */
  72744. get BloomEnabled(): boolean;
  72745. set BloomEnabled(enabled: boolean);
  72746. /**
  72747. * @ignore
  72748. * Specifies if the depth of field pipeline is enabed
  72749. */
  72750. get DepthOfFieldEnabled(): boolean;
  72751. set DepthOfFieldEnabled(enabled: boolean);
  72752. /**
  72753. * @ignore
  72754. * Specifies if the lens flare pipeline is enabed
  72755. */
  72756. get LensFlareEnabled(): boolean;
  72757. set LensFlareEnabled(enabled: boolean);
  72758. /**
  72759. * @ignore
  72760. * Specifies if the HDR pipeline is enabled
  72761. */
  72762. get HDREnabled(): boolean;
  72763. set HDREnabled(enabled: boolean);
  72764. /**
  72765. * @ignore
  72766. * Specifies if the volumetric lights scattering effect is enabled
  72767. */
  72768. get VLSEnabled(): boolean;
  72769. set VLSEnabled(enabled: boolean);
  72770. /**
  72771. * @ignore
  72772. * Specifies if the motion blur effect is enabled
  72773. */
  72774. get MotionBlurEnabled(): boolean;
  72775. set MotionBlurEnabled(enabled: boolean);
  72776. /**
  72777. * Specifies if anti-aliasing is enabled
  72778. */
  72779. get fxaaEnabled(): boolean;
  72780. set fxaaEnabled(enabled: boolean);
  72781. /**
  72782. * Specifies if screen space reflections are enabled.
  72783. */
  72784. get screenSpaceReflectionsEnabled(): boolean;
  72785. set screenSpaceReflectionsEnabled(enabled: boolean);
  72786. /**
  72787. * Specifies the number of steps used to calculate the volumetric lights
  72788. * Typically in interval [50, 200]
  72789. */
  72790. get volumetricLightStepsCount(): number;
  72791. set volumetricLightStepsCount(count: number);
  72792. /**
  72793. * Specifies the number of samples used for the motion blur effect
  72794. * Typically in interval [16, 64]
  72795. */
  72796. get motionBlurSamples(): number;
  72797. set motionBlurSamples(samples: number);
  72798. /**
  72799. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72800. */
  72801. get samples(): number;
  72802. set samples(sampleCount: number);
  72803. /**
  72804. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72805. * @constructor
  72806. * @param name The rendering pipeline name
  72807. * @param scene The scene linked to this pipeline
  72808. * @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)
  72809. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72810. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72811. */
  72812. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72813. private _buildPipeline;
  72814. private _createDownSampleX4PostProcess;
  72815. private _createBrightPassPostProcess;
  72816. private _createBlurPostProcesses;
  72817. private _createTextureAdderPostProcess;
  72818. private _createVolumetricLightPostProcess;
  72819. private _createLuminancePostProcesses;
  72820. private _createHdrPostProcess;
  72821. private _createLensFlarePostProcess;
  72822. private _createDepthOfFieldPostProcess;
  72823. private _createMotionBlurPostProcess;
  72824. private _getDepthTexture;
  72825. private _disposePostProcesses;
  72826. /**
  72827. * Dispose of the pipeline and stop all post processes
  72828. */
  72829. dispose(): void;
  72830. /**
  72831. * Serialize the rendering pipeline (Used when exporting)
  72832. * @returns the serialized object
  72833. */
  72834. serialize(): any;
  72835. /**
  72836. * Parse the serialized pipeline
  72837. * @param source Source pipeline.
  72838. * @param scene The scene to load the pipeline to.
  72839. * @param rootUrl The URL of the serialized pipeline.
  72840. * @returns An instantiated pipeline from the serialized object.
  72841. */
  72842. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72843. /**
  72844. * Luminance steps
  72845. */
  72846. static LuminanceSteps: number;
  72847. }
  72848. }
  72849. declare module BABYLON {
  72850. /** @hidden */
  72851. export var stereoscopicInterlacePixelShader: {
  72852. name: string;
  72853. shader: string;
  72854. };
  72855. }
  72856. declare module BABYLON {
  72857. /**
  72858. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72859. */
  72860. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72861. private _stepSize;
  72862. private _passedProcess;
  72863. /**
  72864. * Gets a string identifying the name of the class
  72865. * @returns "StereoscopicInterlacePostProcessI" string
  72866. */
  72867. getClassName(): string;
  72868. /**
  72869. * Initializes a StereoscopicInterlacePostProcessI
  72870. * @param name The name of the effect.
  72871. * @param rigCameras The rig cameras to be appled to the post process
  72872. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72873. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72874. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72875. * @param engine The engine which the post process will be applied. (default: current engine)
  72876. * @param reusable If the post process can be reused on the same frame. (default: false)
  72877. */
  72878. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72879. }
  72880. /**
  72881. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72882. */
  72883. export class StereoscopicInterlacePostProcess extends PostProcess {
  72884. private _stepSize;
  72885. private _passedProcess;
  72886. /**
  72887. * Gets a string identifying the name of the class
  72888. * @returns "StereoscopicInterlacePostProcess" string
  72889. */
  72890. getClassName(): string;
  72891. /**
  72892. * Initializes a StereoscopicInterlacePostProcess
  72893. * @param name The name of the effect.
  72894. * @param rigCameras The rig cameras to be appled to the post process
  72895. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72897. * @param engine The engine which the post process will be applied. (default: current engine)
  72898. * @param reusable If the post process can be reused on the same frame. (default: false)
  72899. */
  72900. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72901. }
  72902. }
  72903. declare module BABYLON {
  72904. /** @hidden */
  72905. export var tonemapPixelShader: {
  72906. name: string;
  72907. shader: string;
  72908. };
  72909. }
  72910. declare module BABYLON {
  72911. /** Defines operator used for tonemapping */
  72912. export enum TonemappingOperator {
  72913. /** Hable */
  72914. Hable = 0,
  72915. /** Reinhard */
  72916. Reinhard = 1,
  72917. /** HejiDawson */
  72918. HejiDawson = 2,
  72919. /** Photographic */
  72920. Photographic = 3
  72921. }
  72922. /**
  72923. * Defines a post process to apply tone mapping
  72924. */
  72925. export class TonemapPostProcess extends PostProcess {
  72926. private _operator;
  72927. /** Defines the required exposure adjustement */
  72928. exposureAdjustment: number;
  72929. /**
  72930. * Gets a string identifying the name of the class
  72931. * @returns "TonemapPostProcess" string
  72932. */
  72933. getClassName(): string;
  72934. /**
  72935. * Creates a new TonemapPostProcess
  72936. * @param name defines the name of the postprocess
  72937. * @param _operator defines the operator to use
  72938. * @param exposureAdjustment defines the required exposure adjustement
  72939. * @param camera defines the camera to use (can be null)
  72940. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72941. * @param engine defines the hosting engine (can be ignore if camera is set)
  72942. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72943. */
  72944. constructor(name: string, _operator: TonemappingOperator,
  72945. /** Defines the required exposure adjustement */
  72946. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72947. }
  72948. }
  72949. declare module BABYLON {
  72950. /** @hidden */
  72951. export var volumetricLightScatteringPixelShader: {
  72952. name: string;
  72953. shader: string;
  72954. };
  72955. }
  72956. declare module BABYLON {
  72957. /** @hidden */
  72958. export var volumetricLightScatteringPassVertexShader: {
  72959. name: string;
  72960. shader: string;
  72961. };
  72962. }
  72963. declare module BABYLON {
  72964. /** @hidden */
  72965. export var volumetricLightScatteringPassPixelShader: {
  72966. name: string;
  72967. shader: string;
  72968. };
  72969. }
  72970. declare module BABYLON {
  72971. /**
  72972. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72973. */
  72974. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72975. private _volumetricLightScatteringPass;
  72976. private _volumetricLightScatteringRTT;
  72977. private _viewPort;
  72978. private _screenCoordinates;
  72979. private _cachedDefines;
  72980. /**
  72981. * If not undefined, the mesh position is computed from the attached node position
  72982. */
  72983. attachedNode: {
  72984. position: Vector3;
  72985. };
  72986. /**
  72987. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72988. */
  72989. customMeshPosition: Vector3;
  72990. /**
  72991. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72992. */
  72993. useCustomMeshPosition: boolean;
  72994. /**
  72995. * If the post-process should inverse the light scattering direction
  72996. */
  72997. invert: boolean;
  72998. /**
  72999. * The internal mesh used by the post-process
  73000. */
  73001. mesh: Mesh;
  73002. /**
  73003. * @hidden
  73004. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  73005. */
  73006. get useDiffuseColor(): boolean;
  73007. set useDiffuseColor(useDiffuseColor: boolean);
  73008. /**
  73009. * Array containing the excluded meshes not rendered in the internal pass
  73010. */
  73011. excludedMeshes: AbstractMesh[];
  73012. /**
  73013. * Controls the overall intensity of the post-process
  73014. */
  73015. exposure: number;
  73016. /**
  73017. * Dissipates each sample's contribution in range [0, 1]
  73018. */
  73019. decay: number;
  73020. /**
  73021. * Controls the overall intensity of each sample
  73022. */
  73023. weight: number;
  73024. /**
  73025. * Controls the density of each sample
  73026. */
  73027. density: number;
  73028. /**
  73029. * @constructor
  73030. * @param name The post-process name
  73031. * @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)
  73032. * @param camera The camera that the post-process will be attached to
  73033. * @param mesh The mesh used to create the light scattering
  73034. * @param samples The post-process quality, default 100
  73035. * @param samplingModeThe post-process filtering mode
  73036. * @param engine The babylon engine
  73037. * @param reusable If the post-process is reusable
  73038. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  73039. */
  73040. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  73041. /**
  73042. * Returns the string "VolumetricLightScatteringPostProcess"
  73043. * @returns "VolumetricLightScatteringPostProcess"
  73044. */
  73045. getClassName(): string;
  73046. private _isReady;
  73047. /**
  73048. * Sets the new light position for light scattering effect
  73049. * @param position The new custom light position
  73050. */
  73051. setCustomMeshPosition(position: Vector3): void;
  73052. /**
  73053. * Returns the light position for light scattering effect
  73054. * @return Vector3 The custom light position
  73055. */
  73056. getCustomMeshPosition(): Vector3;
  73057. /**
  73058. * Disposes the internal assets and detaches the post-process from the camera
  73059. */
  73060. dispose(camera: Camera): void;
  73061. /**
  73062. * Returns the render target texture used by the post-process
  73063. * @return the render target texture used by the post-process
  73064. */
  73065. getPass(): RenderTargetTexture;
  73066. private _meshExcluded;
  73067. private _createPass;
  73068. private _updateMeshScreenCoordinates;
  73069. /**
  73070. * Creates a default mesh for the Volumeric Light Scattering post-process
  73071. * @param name The mesh name
  73072. * @param scene The scene where to create the mesh
  73073. * @return the default mesh
  73074. */
  73075. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  73076. }
  73077. }
  73078. declare module BABYLON {
  73079. /** @hidden */
  73080. export var screenSpaceCurvaturePixelShader: {
  73081. name: string;
  73082. shader: string;
  73083. };
  73084. }
  73085. declare module BABYLON {
  73086. /**
  73087. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  73088. */
  73089. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  73090. /**
  73091. * Defines how much ridge the curvature effect displays.
  73092. */
  73093. ridge: number;
  73094. /**
  73095. * Defines how much valley the curvature effect displays.
  73096. */
  73097. valley: number;
  73098. private _geometryBufferRenderer;
  73099. /**
  73100. * Gets a string identifying the name of the class
  73101. * @returns "ScreenSpaceCurvaturePostProcess" string
  73102. */
  73103. getClassName(): string;
  73104. /**
  73105. * Creates a new instance ScreenSpaceCurvaturePostProcess
  73106. * @param name The name of the effect.
  73107. * @param scene The scene containing the objects to blur according to their velocity.
  73108. * @param options The required width/height ratio to downsize to before computing the render pass.
  73109. * @param camera The camera to apply the render pass to.
  73110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73111. * @param engine The engine which the post process will be applied. (default: current engine)
  73112. * @param reusable If the post process can be reused on the same frame. (default: false)
  73113. * @param textureType Type of textures used when performing the post process. (default: 0)
  73114. * @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)
  73115. */
  73116. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73117. /**
  73118. * Support test.
  73119. */
  73120. static get IsSupported(): boolean;
  73121. /** @hidden */
  73122. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  73123. }
  73124. }
  73125. declare module BABYLON {
  73126. interface Scene {
  73127. /** @hidden (Backing field) */
  73128. _boundingBoxRenderer: BoundingBoxRenderer;
  73129. /** @hidden (Backing field) */
  73130. _forceShowBoundingBoxes: boolean;
  73131. /**
  73132. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  73133. */
  73134. forceShowBoundingBoxes: boolean;
  73135. /**
  73136. * Gets the bounding box renderer associated with the scene
  73137. * @returns a BoundingBoxRenderer
  73138. */
  73139. getBoundingBoxRenderer(): BoundingBoxRenderer;
  73140. }
  73141. interface AbstractMesh {
  73142. /** @hidden (Backing field) */
  73143. _showBoundingBox: boolean;
  73144. /**
  73145. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  73146. */
  73147. showBoundingBox: boolean;
  73148. }
  73149. /**
  73150. * Component responsible of rendering the bounding box of the meshes in a scene.
  73151. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  73152. */
  73153. export class BoundingBoxRenderer implements ISceneComponent {
  73154. /**
  73155. * The component name helpfull to identify the component in the list of scene components.
  73156. */
  73157. readonly name: string;
  73158. /**
  73159. * The scene the component belongs to.
  73160. */
  73161. scene: Scene;
  73162. /**
  73163. * Color of the bounding box lines placed in front of an object
  73164. */
  73165. frontColor: Color3;
  73166. /**
  73167. * Color of the bounding box lines placed behind an object
  73168. */
  73169. backColor: Color3;
  73170. /**
  73171. * Defines if the renderer should show the back lines or not
  73172. */
  73173. showBackLines: boolean;
  73174. /**
  73175. * Observable raised before rendering a bounding box
  73176. */
  73177. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  73178. /**
  73179. * Observable raised after rendering a bounding box
  73180. */
  73181. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  73182. /**
  73183. * Observable raised after resources are created
  73184. */
  73185. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  73186. /**
  73187. * When false, no bounding boxes will be rendered
  73188. */
  73189. enabled: boolean;
  73190. /**
  73191. * @hidden
  73192. */
  73193. renderList: SmartArray<BoundingBox>;
  73194. private _colorShader;
  73195. private _vertexBuffers;
  73196. private _indexBuffer;
  73197. private _fillIndexBuffer;
  73198. private _fillIndexData;
  73199. /**
  73200. * Instantiates a new bounding box renderer in a scene.
  73201. * @param scene the scene the renderer renders in
  73202. */
  73203. constructor(scene: Scene);
  73204. /**
  73205. * Registers the component in a given scene
  73206. */
  73207. register(): void;
  73208. private _evaluateSubMesh;
  73209. private _preActiveMesh;
  73210. private _prepareResources;
  73211. private _createIndexBuffer;
  73212. /**
  73213. * Rebuilds the elements related to this component in case of
  73214. * context lost for instance.
  73215. */
  73216. rebuild(): void;
  73217. /**
  73218. * @hidden
  73219. */
  73220. reset(): void;
  73221. /**
  73222. * Render the bounding boxes of a specific rendering group
  73223. * @param renderingGroupId defines the rendering group to render
  73224. */
  73225. render(renderingGroupId: number): void;
  73226. /**
  73227. * In case of occlusion queries, we can render the occlusion bounding box through this method
  73228. * @param mesh Define the mesh to render the occlusion bounding box for
  73229. */
  73230. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  73231. /**
  73232. * Dispose and release the resources attached to this renderer.
  73233. */
  73234. dispose(): void;
  73235. }
  73236. }
  73237. declare module BABYLON {
  73238. interface Scene {
  73239. /** @hidden (Backing field) */
  73240. _depthRenderer: {
  73241. [id: string]: DepthRenderer;
  73242. };
  73243. /**
  73244. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  73245. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  73246. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  73247. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  73248. * @returns the created depth renderer
  73249. */
  73250. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  73251. /**
  73252. * Disables a depth renderer for a given camera
  73253. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  73254. */
  73255. disableDepthRenderer(camera?: Nullable<Camera>): void;
  73256. }
  73257. /**
  73258. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  73259. * in several rendering techniques.
  73260. */
  73261. export class DepthRendererSceneComponent implements ISceneComponent {
  73262. /**
  73263. * The component name helpfull to identify the component in the list of scene components.
  73264. */
  73265. readonly name: string;
  73266. /**
  73267. * The scene the component belongs to.
  73268. */
  73269. scene: Scene;
  73270. /**
  73271. * Creates a new instance of the component for the given scene
  73272. * @param scene Defines the scene to register the component in
  73273. */
  73274. constructor(scene: Scene);
  73275. /**
  73276. * Registers the component in a given scene
  73277. */
  73278. register(): void;
  73279. /**
  73280. * Rebuilds the elements related to this component in case of
  73281. * context lost for instance.
  73282. */
  73283. rebuild(): void;
  73284. /**
  73285. * Disposes the component and the associated ressources
  73286. */
  73287. dispose(): void;
  73288. private _gatherRenderTargets;
  73289. private _gatherActiveCameraRenderTargets;
  73290. }
  73291. }
  73292. declare module BABYLON {
  73293. interface AbstractScene {
  73294. /** @hidden (Backing field) */
  73295. _prePassRenderer: Nullable<PrePassRenderer>;
  73296. /**
  73297. * Gets or Sets the current prepass renderer associated to the scene.
  73298. */
  73299. prePassRenderer: Nullable<PrePassRenderer>;
  73300. /**
  73301. * Enables the prepass and associates it with the scene
  73302. * @returns the PrePassRenderer
  73303. */
  73304. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  73305. /**
  73306. * Disables the prepass associated with the scene
  73307. */
  73308. disablePrePassRenderer(): void;
  73309. }
  73310. /**
  73311. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73312. * in several rendering techniques.
  73313. */
  73314. export class PrePassRendererSceneComponent implements ISceneComponent {
  73315. /**
  73316. * The component name helpful to identify the component in the list of scene components.
  73317. */
  73318. readonly name: string;
  73319. /**
  73320. * The scene the component belongs to.
  73321. */
  73322. scene: Scene;
  73323. /**
  73324. * Creates a new instance of the component for the given scene
  73325. * @param scene Defines the scene to register the component in
  73326. */
  73327. constructor(scene: Scene);
  73328. /**
  73329. * Registers the component in a given scene
  73330. */
  73331. register(): void;
  73332. private _beforeCameraDraw;
  73333. private _afterCameraDraw;
  73334. private _beforeClearStage;
  73335. /**
  73336. * Rebuilds the elements related to this component in case of
  73337. * context lost for instance.
  73338. */
  73339. rebuild(): void;
  73340. /**
  73341. * Disposes the component and the associated ressources
  73342. */
  73343. dispose(): void;
  73344. }
  73345. }
  73346. declare module BABYLON {
  73347. /** @hidden */
  73348. export var fibonacci: {
  73349. name: string;
  73350. shader: string;
  73351. };
  73352. }
  73353. declare module BABYLON {
  73354. /** @hidden */
  73355. export var diffusionProfile: {
  73356. name: string;
  73357. shader: string;
  73358. };
  73359. }
  73360. declare module BABYLON {
  73361. /** @hidden */
  73362. export var subSurfaceScatteringPixelShader: {
  73363. name: string;
  73364. shader: string;
  73365. };
  73366. }
  73367. declare module BABYLON {
  73368. /**
  73369. * Sub surface scattering post process
  73370. */
  73371. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73372. /**
  73373. * Gets a string identifying the name of the class
  73374. * @returns "SubSurfaceScatteringPostProcess" string
  73375. */
  73376. getClassName(): string;
  73377. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73378. }
  73379. }
  73380. declare module BABYLON {
  73381. /**
  73382. * Contains all parameters needed for the prepass to perform
  73383. * screen space subsurface scattering
  73384. */
  73385. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73386. /** @hidden */
  73387. static _SceneComponentInitialization: (scene: Scene) => void;
  73388. private _ssDiffusionS;
  73389. private _ssFilterRadii;
  73390. private _ssDiffusionD;
  73391. /**
  73392. * Post process to attach for screen space subsurface scattering
  73393. */
  73394. postProcess: SubSurfaceScatteringPostProcess;
  73395. /**
  73396. * Diffusion profile color for subsurface scattering
  73397. */
  73398. get ssDiffusionS(): number[];
  73399. /**
  73400. * Diffusion profile max color channel value for subsurface scattering
  73401. */
  73402. get ssDiffusionD(): number[];
  73403. /**
  73404. * Diffusion profile filter radius for subsurface scattering
  73405. */
  73406. get ssFilterRadii(): number[];
  73407. /**
  73408. * Is subsurface enabled
  73409. */
  73410. enabled: boolean;
  73411. /**
  73412. * Name of the configuration
  73413. */
  73414. name: string;
  73415. /**
  73416. * Diffusion profile colors for subsurface scattering
  73417. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73418. * See ...
  73419. * Note that you can only store up to 5 of them
  73420. */
  73421. ssDiffusionProfileColors: Color3[];
  73422. /**
  73423. * Defines the ratio real world => scene units.
  73424. * Used for subsurface scattering
  73425. */
  73426. metersPerUnit: number;
  73427. /**
  73428. * Textures that should be present in the MRT for this effect to work
  73429. */
  73430. readonly texturesRequired: number[];
  73431. private _scene;
  73432. /**
  73433. * Builds a subsurface configuration object
  73434. * @param scene The scene
  73435. */
  73436. constructor(scene: Scene);
  73437. /**
  73438. * Adds a new diffusion profile.
  73439. * Useful for more realistic subsurface scattering on diverse materials.
  73440. * @param color The color of the diffusion profile. Should be the average color of the material.
  73441. * @return The index of the diffusion profile for the material subsurface configuration
  73442. */
  73443. addDiffusionProfile(color: Color3): number;
  73444. /**
  73445. * Creates the sss post process
  73446. * @return The created post process
  73447. */
  73448. createPostProcess(): SubSurfaceScatteringPostProcess;
  73449. /**
  73450. * Deletes all diffusion profiles.
  73451. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73452. */
  73453. clearAllDiffusionProfiles(): void;
  73454. /**
  73455. * Disposes this object
  73456. */
  73457. dispose(): void;
  73458. /**
  73459. * @hidden
  73460. * https://zero-radiance.github.io/post/sampling-diffusion/
  73461. *
  73462. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73463. * ------------------------------------------------------------------------------------
  73464. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73465. * PDF[r, phi, s] = r * R[r, phi, s]
  73466. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73467. * ------------------------------------------------------------------------------------
  73468. * We importance sample the color channel with the widest scattering distance.
  73469. */
  73470. getDiffusionProfileParameters(color: Color3): number;
  73471. /**
  73472. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73473. * 'u' is the random number (the value of the CDF): [0, 1).
  73474. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73475. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73476. */
  73477. private _sampleBurleyDiffusionProfile;
  73478. }
  73479. }
  73480. declare module BABYLON {
  73481. interface AbstractScene {
  73482. /** @hidden (Backing field) */
  73483. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73484. /**
  73485. * Gets or Sets the current prepass renderer associated to the scene.
  73486. */
  73487. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73488. /**
  73489. * Enables the subsurface effect for prepass
  73490. * @returns the SubSurfaceConfiguration
  73491. */
  73492. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  73493. /**
  73494. * Disables the subsurface effect for prepass
  73495. */
  73496. disableSubSurfaceForPrePass(): void;
  73497. }
  73498. /**
  73499. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73500. * in several rendering techniques.
  73501. */
  73502. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  73503. /**
  73504. * The component name helpful to identify the component in the list of scene components.
  73505. */
  73506. readonly name: string;
  73507. /**
  73508. * The scene the component belongs to.
  73509. */
  73510. scene: Scene;
  73511. /**
  73512. * Creates a new instance of the component for the given scene
  73513. * @param scene Defines the scene to register the component in
  73514. */
  73515. constructor(scene: Scene);
  73516. /**
  73517. * Registers the component in a given scene
  73518. */
  73519. register(): void;
  73520. /**
  73521. * Serializes the component data to the specified json object
  73522. * @param serializationObject The object to serialize to
  73523. */
  73524. serialize(serializationObject: any): void;
  73525. /**
  73526. * Adds all the elements from the container to the scene
  73527. * @param container the container holding the elements
  73528. */
  73529. addFromContainer(container: AbstractScene): void;
  73530. /**
  73531. * Removes all the elements in the container from the scene
  73532. * @param container contains the elements to remove
  73533. * @param dispose if the removed element should be disposed (default: false)
  73534. */
  73535. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73536. /**
  73537. * Rebuilds the elements related to this component in case of
  73538. * context lost for instance.
  73539. */
  73540. rebuild(): void;
  73541. /**
  73542. * Disposes the component and the associated ressources
  73543. */
  73544. dispose(): void;
  73545. }
  73546. }
  73547. declare module BABYLON {
  73548. /** @hidden */
  73549. export var outlinePixelShader: {
  73550. name: string;
  73551. shader: string;
  73552. };
  73553. }
  73554. declare module BABYLON {
  73555. /** @hidden */
  73556. export var outlineVertexShader: {
  73557. name: string;
  73558. shader: string;
  73559. };
  73560. }
  73561. declare module BABYLON {
  73562. interface Scene {
  73563. /** @hidden */
  73564. _outlineRenderer: OutlineRenderer;
  73565. /**
  73566. * Gets the outline renderer associated with the scene
  73567. * @returns a OutlineRenderer
  73568. */
  73569. getOutlineRenderer(): OutlineRenderer;
  73570. }
  73571. interface AbstractMesh {
  73572. /** @hidden (Backing field) */
  73573. _renderOutline: boolean;
  73574. /**
  73575. * Gets or sets a boolean indicating if the outline must be rendered as well
  73576. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73577. */
  73578. renderOutline: boolean;
  73579. /** @hidden (Backing field) */
  73580. _renderOverlay: boolean;
  73581. /**
  73582. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73583. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73584. */
  73585. renderOverlay: boolean;
  73586. }
  73587. /**
  73588. * This class is responsible to draw bothe outline/overlay of meshes.
  73589. * It should not be used directly but through the available method on mesh.
  73590. */
  73591. export class OutlineRenderer implements ISceneComponent {
  73592. /**
  73593. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73594. */
  73595. private static _StencilReference;
  73596. /**
  73597. * The name of the component. Each component must have a unique name.
  73598. */
  73599. name: string;
  73600. /**
  73601. * The scene the component belongs to.
  73602. */
  73603. scene: Scene;
  73604. /**
  73605. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73606. */
  73607. zOffset: number;
  73608. private _engine;
  73609. private _effect;
  73610. private _cachedDefines;
  73611. private _savedDepthWrite;
  73612. /**
  73613. * Instantiates a new outline renderer. (There could be only one per scene).
  73614. * @param scene Defines the scene it belongs to
  73615. */
  73616. constructor(scene: Scene);
  73617. /**
  73618. * Register the component to one instance of a scene.
  73619. */
  73620. register(): void;
  73621. /**
  73622. * Rebuilds the elements related to this component in case of
  73623. * context lost for instance.
  73624. */
  73625. rebuild(): void;
  73626. /**
  73627. * Disposes the component and the associated ressources.
  73628. */
  73629. dispose(): void;
  73630. /**
  73631. * Renders the outline in the canvas.
  73632. * @param subMesh Defines the sumesh to render
  73633. * @param batch Defines the batch of meshes in case of instances
  73634. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73635. */
  73636. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73637. /**
  73638. * Returns whether or not the outline renderer is ready for a given submesh.
  73639. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73640. * @param subMesh Defines the submesh to check readyness for
  73641. * @param useInstances Defines wheter wee are trying to render instances or not
  73642. * @returns true if ready otherwise false
  73643. */
  73644. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73645. private _beforeRenderingMesh;
  73646. private _afterRenderingMesh;
  73647. }
  73648. }
  73649. declare module BABYLON {
  73650. /**
  73651. * Defines the basic options interface of a Sprite Frame Source Size.
  73652. */
  73653. export interface ISpriteJSONSpriteSourceSize {
  73654. /**
  73655. * number of the original width of the Frame
  73656. */
  73657. w: number;
  73658. /**
  73659. * number of the original height of the Frame
  73660. */
  73661. h: number;
  73662. }
  73663. /**
  73664. * Defines the basic options interface of a Sprite Frame Data.
  73665. */
  73666. export interface ISpriteJSONSpriteFrameData {
  73667. /**
  73668. * number of the x offset of the Frame
  73669. */
  73670. x: number;
  73671. /**
  73672. * number of the y offset of the Frame
  73673. */
  73674. y: number;
  73675. /**
  73676. * number of the width of the Frame
  73677. */
  73678. w: number;
  73679. /**
  73680. * number of the height of the Frame
  73681. */
  73682. h: number;
  73683. }
  73684. /**
  73685. * Defines the basic options interface of a JSON Sprite.
  73686. */
  73687. export interface ISpriteJSONSprite {
  73688. /**
  73689. * string name of the Frame
  73690. */
  73691. filename: string;
  73692. /**
  73693. * ISpriteJSONSpriteFrame basic object of the frame data
  73694. */
  73695. frame: ISpriteJSONSpriteFrameData;
  73696. /**
  73697. * boolean to flag is the frame was rotated.
  73698. */
  73699. rotated: boolean;
  73700. /**
  73701. * boolean to flag is the frame was trimmed.
  73702. */
  73703. trimmed: boolean;
  73704. /**
  73705. * ISpriteJSONSpriteFrame basic object of the source data
  73706. */
  73707. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73708. /**
  73709. * ISpriteJSONSpriteFrame basic object of the source data
  73710. */
  73711. sourceSize: ISpriteJSONSpriteSourceSize;
  73712. }
  73713. /**
  73714. * Defines the basic options interface of a JSON atlas.
  73715. */
  73716. export interface ISpriteJSONAtlas {
  73717. /**
  73718. * Array of objects that contain the frame data.
  73719. */
  73720. frames: Array<ISpriteJSONSprite>;
  73721. /**
  73722. * object basic object containing the sprite meta data.
  73723. */
  73724. meta?: object;
  73725. }
  73726. }
  73727. declare module BABYLON {
  73728. /** @hidden */
  73729. export var spriteMapPixelShader: {
  73730. name: string;
  73731. shader: string;
  73732. };
  73733. }
  73734. declare module BABYLON {
  73735. /** @hidden */
  73736. export var spriteMapVertexShader: {
  73737. name: string;
  73738. shader: string;
  73739. };
  73740. }
  73741. declare module BABYLON {
  73742. /**
  73743. * Defines the basic options interface of a SpriteMap
  73744. */
  73745. export interface ISpriteMapOptions {
  73746. /**
  73747. * Vector2 of the number of cells in the grid.
  73748. */
  73749. stageSize?: Vector2;
  73750. /**
  73751. * Vector2 of the size of the output plane in World Units.
  73752. */
  73753. outputSize?: Vector2;
  73754. /**
  73755. * Vector3 of the position of the output plane in World Units.
  73756. */
  73757. outputPosition?: Vector3;
  73758. /**
  73759. * Vector3 of the rotation of the output plane.
  73760. */
  73761. outputRotation?: Vector3;
  73762. /**
  73763. * number of layers that the system will reserve in resources.
  73764. */
  73765. layerCount?: number;
  73766. /**
  73767. * number of max animation frames a single cell will reserve in resources.
  73768. */
  73769. maxAnimationFrames?: number;
  73770. /**
  73771. * number cell index of the base tile when the system compiles.
  73772. */
  73773. baseTile?: number;
  73774. /**
  73775. * boolean flip the sprite after its been repositioned by the framing data.
  73776. */
  73777. flipU?: boolean;
  73778. /**
  73779. * Vector3 scalar of the global RGB values of the SpriteMap.
  73780. */
  73781. colorMultiply?: Vector3;
  73782. }
  73783. /**
  73784. * Defines the IDisposable interface in order to be cleanable from resources.
  73785. */
  73786. export interface ISpriteMap extends IDisposable {
  73787. /**
  73788. * String name of the SpriteMap.
  73789. */
  73790. name: string;
  73791. /**
  73792. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73793. */
  73794. atlasJSON: ISpriteJSONAtlas;
  73795. /**
  73796. * Texture of the SpriteMap.
  73797. */
  73798. spriteSheet: Texture;
  73799. /**
  73800. * The parameters to initialize the SpriteMap with.
  73801. */
  73802. options: ISpriteMapOptions;
  73803. }
  73804. /**
  73805. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73806. */
  73807. export class SpriteMap implements ISpriteMap {
  73808. /** The Name of the spriteMap */
  73809. name: string;
  73810. /** The JSON file with the frame and meta data */
  73811. atlasJSON: ISpriteJSONAtlas;
  73812. /** The systems Sprite Sheet Texture */
  73813. spriteSheet: Texture;
  73814. /** Arguments passed with the Constructor */
  73815. options: ISpriteMapOptions;
  73816. /** Public Sprite Storage array, parsed from atlasJSON */
  73817. sprites: Array<ISpriteJSONSprite>;
  73818. /** Returns the Number of Sprites in the System */
  73819. get spriteCount(): number;
  73820. /** Returns the Position of Output Plane*/
  73821. get position(): Vector3;
  73822. /** Returns the Position of Output Plane*/
  73823. set position(v: Vector3);
  73824. /** Returns the Rotation of Output Plane*/
  73825. get rotation(): Vector3;
  73826. /** Returns the Rotation of Output Plane*/
  73827. set rotation(v: Vector3);
  73828. /** Sets the AnimationMap*/
  73829. get animationMap(): RawTexture;
  73830. /** Sets the AnimationMap*/
  73831. set animationMap(v: RawTexture);
  73832. /** Scene that the SpriteMap was created in */
  73833. private _scene;
  73834. /** Texture Buffer of Float32 that holds tile frame data*/
  73835. private _frameMap;
  73836. /** Texture Buffers of Float32 that holds tileMap data*/
  73837. private _tileMaps;
  73838. /** Texture Buffer of Float32 that holds Animation Data*/
  73839. private _animationMap;
  73840. /** Custom ShaderMaterial Central to the System*/
  73841. private _material;
  73842. /** Custom ShaderMaterial Central to the System*/
  73843. private _output;
  73844. /** Systems Time Ticker*/
  73845. private _time;
  73846. /**
  73847. * Creates a new SpriteMap
  73848. * @param name defines the SpriteMaps Name
  73849. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73850. * @param spriteSheet is the Texture that the Sprites are on.
  73851. * @param options a basic deployment configuration
  73852. * @param scene The Scene that the map is deployed on
  73853. */
  73854. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73855. /**
  73856. * Returns tileID location
  73857. * @returns Vector2 the cell position ID
  73858. */
  73859. getTileID(): Vector2;
  73860. /**
  73861. * Gets the UV location of the mouse over the SpriteMap.
  73862. * @returns Vector2 the UV position of the mouse interaction
  73863. */
  73864. getMousePosition(): Vector2;
  73865. /**
  73866. * Creates the "frame" texture Buffer
  73867. * -------------------------------------
  73868. * Structure of frames
  73869. * "filename": "Falling-Water-2.png",
  73870. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73871. * "rotated": true,
  73872. * "trimmed": true,
  73873. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73874. * "sourceSize": {"w":32,"h":32}
  73875. * @returns RawTexture of the frameMap
  73876. */
  73877. private _createFrameBuffer;
  73878. /**
  73879. * Creates the tileMap texture Buffer
  73880. * @param buffer normally and array of numbers, or a false to generate from scratch
  73881. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73882. * @returns RawTexture of the tileMap
  73883. */
  73884. private _createTileBuffer;
  73885. /**
  73886. * Modifies the data of the tileMaps
  73887. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73888. * @param pos is the iVector2 Coordinates of the Tile
  73889. * @param tile The SpriteIndex of the new Tile
  73890. */
  73891. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73892. /**
  73893. * Creates the animationMap texture Buffer
  73894. * @param buffer normally and array of numbers, or a false to generate from scratch
  73895. * @returns RawTexture of the animationMap
  73896. */
  73897. private _createTileAnimationBuffer;
  73898. /**
  73899. * Modifies the data of the animationMap
  73900. * @param cellID is the Index of the Sprite
  73901. * @param _frame is the target Animation frame
  73902. * @param toCell is the Target Index of the next frame of the animation
  73903. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73904. * @param speed is a global scalar of the time variable on the map.
  73905. */
  73906. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73907. /**
  73908. * Exports the .tilemaps file
  73909. */
  73910. saveTileMaps(): void;
  73911. /**
  73912. * Imports the .tilemaps file
  73913. * @param url of the .tilemaps file
  73914. */
  73915. loadTileMaps(url: string): void;
  73916. /**
  73917. * Release associated resources
  73918. */
  73919. dispose(): void;
  73920. }
  73921. }
  73922. declare module BABYLON {
  73923. /**
  73924. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73925. * @see https://doc.babylonjs.com/babylon101/sprites
  73926. */
  73927. export class SpritePackedManager extends SpriteManager {
  73928. /** defines the packed manager's name */
  73929. name: string;
  73930. /**
  73931. * Creates a new sprite manager from a packed sprite sheet
  73932. * @param name defines the manager's name
  73933. * @param imgUrl defines the sprite sheet url
  73934. * @param capacity defines the maximum allowed number of sprites
  73935. * @param scene defines the hosting scene
  73936. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73937. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73938. * @param samplingMode defines the smapling mode to use with spritesheet
  73939. * @param fromPacked set to true; do not alter
  73940. */
  73941. constructor(
  73942. /** defines the packed manager's name */
  73943. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73944. }
  73945. }
  73946. declare module BABYLON {
  73947. /**
  73948. * Defines the list of states available for a task inside a AssetsManager
  73949. */
  73950. export enum AssetTaskState {
  73951. /**
  73952. * Initialization
  73953. */
  73954. INIT = 0,
  73955. /**
  73956. * Running
  73957. */
  73958. RUNNING = 1,
  73959. /**
  73960. * Done
  73961. */
  73962. DONE = 2,
  73963. /**
  73964. * Error
  73965. */
  73966. ERROR = 3
  73967. }
  73968. /**
  73969. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73970. */
  73971. export abstract class AbstractAssetTask {
  73972. /**
  73973. * Task name
  73974. */ name: string;
  73975. /**
  73976. * Callback called when the task is successful
  73977. */
  73978. onSuccess: (task: any) => void;
  73979. /**
  73980. * Callback called when the task is not successful
  73981. */
  73982. onError: (task: any, message?: string, exception?: any) => void;
  73983. /**
  73984. * Creates a new AssetsManager
  73985. * @param name defines the name of the task
  73986. */
  73987. constructor(
  73988. /**
  73989. * Task name
  73990. */ name: string);
  73991. private _isCompleted;
  73992. private _taskState;
  73993. private _errorObject;
  73994. /**
  73995. * Get if the task is completed
  73996. */
  73997. get isCompleted(): boolean;
  73998. /**
  73999. * Gets the current state of the task
  74000. */
  74001. get taskState(): AssetTaskState;
  74002. /**
  74003. * Gets the current error object (if task is in error)
  74004. */
  74005. get errorObject(): {
  74006. message?: string;
  74007. exception?: any;
  74008. };
  74009. /**
  74010. * Internal only
  74011. * @hidden
  74012. */
  74013. _setErrorObject(message?: string, exception?: any): void;
  74014. /**
  74015. * Execute the current task
  74016. * @param scene defines the scene where you want your assets to be loaded
  74017. * @param onSuccess is a callback called when the task is successfully executed
  74018. * @param onError is a callback called if an error occurs
  74019. */
  74020. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74021. /**
  74022. * Execute the current task
  74023. * @param scene defines the scene where you want your assets to be loaded
  74024. * @param onSuccess is a callback called when the task is successfully executed
  74025. * @param onError is a callback called if an error occurs
  74026. */
  74027. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74028. /**
  74029. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74030. * This can be used with failed tasks that have the reason for failure fixed.
  74031. */
  74032. reset(): void;
  74033. private onErrorCallback;
  74034. private onDoneCallback;
  74035. }
  74036. /**
  74037. * Define the interface used by progress events raised during assets loading
  74038. */
  74039. export interface IAssetsProgressEvent {
  74040. /**
  74041. * Defines the number of remaining tasks to process
  74042. */
  74043. remainingCount: number;
  74044. /**
  74045. * Defines the total number of tasks
  74046. */
  74047. totalCount: number;
  74048. /**
  74049. * Defines the task that was just processed
  74050. */
  74051. task: AbstractAssetTask;
  74052. }
  74053. /**
  74054. * Class used to share progress information about assets loading
  74055. */
  74056. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74057. /**
  74058. * Defines the number of remaining tasks to process
  74059. */
  74060. remainingCount: number;
  74061. /**
  74062. * Defines the total number of tasks
  74063. */
  74064. totalCount: number;
  74065. /**
  74066. * Defines the task that was just processed
  74067. */
  74068. task: AbstractAssetTask;
  74069. /**
  74070. * Creates a AssetsProgressEvent
  74071. * @param remainingCount defines the number of remaining tasks to process
  74072. * @param totalCount defines the total number of tasks
  74073. * @param task defines the task that was just processed
  74074. */
  74075. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74076. }
  74077. /**
  74078. * Define a task used by AssetsManager to load assets into a container
  74079. */
  74080. export class ContainerAssetTask extends AbstractAssetTask {
  74081. /**
  74082. * Defines the name of the task
  74083. */
  74084. name: string;
  74085. /**
  74086. * Defines the list of mesh's names you want to load
  74087. */
  74088. meshesNames: any;
  74089. /**
  74090. * Defines the root url to use as a base to load your meshes and associated resources
  74091. */
  74092. rootUrl: string;
  74093. /**
  74094. * Defines the filename or File of the scene to load from
  74095. */
  74096. sceneFilename: string | File;
  74097. /**
  74098. * Get the loaded asset container
  74099. */
  74100. loadedContainer: AssetContainer;
  74101. /**
  74102. * Gets the list of loaded meshes
  74103. */
  74104. loadedMeshes: Array<AbstractMesh>;
  74105. /**
  74106. * Gets the list of loaded particle systems
  74107. */
  74108. loadedParticleSystems: Array<IParticleSystem>;
  74109. /**
  74110. * Gets the list of loaded skeletons
  74111. */
  74112. loadedSkeletons: Array<Skeleton>;
  74113. /**
  74114. * Gets the list of loaded animation groups
  74115. */
  74116. loadedAnimationGroups: Array<AnimationGroup>;
  74117. /**
  74118. * Callback called when the task is successful
  74119. */
  74120. onSuccess: (task: ContainerAssetTask) => void;
  74121. /**
  74122. * Callback called when the task is successful
  74123. */
  74124. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  74125. /**
  74126. * Creates a new ContainerAssetTask
  74127. * @param name defines the name of the task
  74128. * @param meshesNames defines the list of mesh's names you want to load
  74129. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74130. * @param sceneFilename defines the filename or File of the scene to load from
  74131. */
  74132. constructor(
  74133. /**
  74134. * Defines the name of the task
  74135. */
  74136. name: string,
  74137. /**
  74138. * Defines the list of mesh's names you want to load
  74139. */
  74140. meshesNames: any,
  74141. /**
  74142. * Defines the root url to use as a base to load your meshes and associated resources
  74143. */
  74144. rootUrl: string,
  74145. /**
  74146. * Defines the filename or File of the scene to load from
  74147. */
  74148. sceneFilename: string | File);
  74149. /**
  74150. * Execute the current task
  74151. * @param scene defines the scene where you want your assets to be loaded
  74152. * @param onSuccess is a callback called when the task is successfully executed
  74153. * @param onError is a callback called if an error occurs
  74154. */
  74155. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74156. }
  74157. /**
  74158. * Define a task used by AssetsManager to load meshes
  74159. */
  74160. export class MeshAssetTask extends AbstractAssetTask {
  74161. /**
  74162. * Defines the name of the task
  74163. */
  74164. name: string;
  74165. /**
  74166. * Defines the list of mesh's names you want to load
  74167. */
  74168. meshesNames: any;
  74169. /**
  74170. * Defines the root url to use as a base to load your meshes and associated resources
  74171. */
  74172. rootUrl: string;
  74173. /**
  74174. * Defines the filename or File of the scene to load from
  74175. */
  74176. sceneFilename: string | File;
  74177. /**
  74178. * Gets the list of loaded meshes
  74179. */
  74180. loadedMeshes: Array<AbstractMesh>;
  74181. /**
  74182. * Gets the list of loaded particle systems
  74183. */
  74184. loadedParticleSystems: Array<IParticleSystem>;
  74185. /**
  74186. * Gets the list of loaded skeletons
  74187. */
  74188. loadedSkeletons: Array<Skeleton>;
  74189. /**
  74190. * Gets the list of loaded animation groups
  74191. */
  74192. loadedAnimationGroups: Array<AnimationGroup>;
  74193. /**
  74194. * Callback called when the task is successful
  74195. */
  74196. onSuccess: (task: MeshAssetTask) => void;
  74197. /**
  74198. * Callback called when the task is successful
  74199. */
  74200. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  74201. /**
  74202. * Creates a new MeshAssetTask
  74203. * @param name defines the name of the task
  74204. * @param meshesNames defines the list of mesh's names you want to load
  74205. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74206. * @param sceneFilename defines the filename or File of the scene to load from
  74207. */
  74208. constructor(
  74209. /**
  74210. * Defines the name of the task
  74211. */
  74212. name: string,
  74213. /**
  74214. * Defines the list of mesh's names you want to load
  74215. */
  74216. meshesNames: any,
  74217. /**
  74218. * Defines the root url to use as a base to load your meshes and associated resources
  74219. */
  74220. rootUrl: string,
  74221. /**
  74222. * Defines the filename or File of the scene to load from
  74223. */
  74224. sceneFilename: string | File);
  74225. /**
  74226. * Execute the current task
  74227. * @param scene defines the scene where you want your assets to be loaded
  74228. * @param onSuccess is a callback called when the task is successfully executed
  74229. * @param onError is a callback called if an error occurs
  74230. */
  74231. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74232. }
  74233. /**
  74234. * Define a task used by AssetsManager to load text content
  74235. */
  74236. export class TextFileAssetTask extends AbstractAssetTask {
  74237. /**
  74238. * Defines the name of the task
  74239. */
  74240. name: string;
  74241. /**
  74242. * Defines the location of the file to load
  74243. */
  74244. url: string;
  74245. /**
  74246. * Gets the loaded text string
  74247. */
  74248. text: string;
  74249. /**
  74250. * Callback called when the task is successful
  74251. */
  74252. onSuccess: (task: TextFileAssetTask) => void;
  74253. /**
  74254. * Callback called when the task is successful
  74255. */
  74256. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  74257. /**
  74258. * Creates a new TextFileAssetTask object
  74259. * @param name defines the name of the task
  74260. * @param url defines the location of the file to load
  74261. */
  74262. constructor(
  74263. /**
  74264. * Defines the name of the task
  74265. */
  74266. name: string,
  74267. /**
  74268. * Defines the location of the file to load
  74269. */
  74270. url: string);
  74271. /**
  74272. * Execute the current task
  74273. * @param scene defines the scene where you want your assets to be loaded
  74274. * @param onSuccess is a callback called when the task is successfully executed
  74275. * @param onError is a callback called if an error occurs
  74276. */
  74277. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74278. }
  74279. /**
  74280. * Define a task used by AssetsManager to load binary data
  74281. */
  74282. export class BinaryFileAssetTask extends AbstractAssetTask {
  74283. /**
  74284. * Defines the name of the task
  74285. */
  74286. name: string;
  74287. /**
  74288. * Defines the location of the file to load
  74289. */
  74290. url: string;
  74291. /**
  74292. * Gets the lodaded data (as an array buffer)
  74293. */
  74294. data: ArrayBuffer;
  74295. /**
  74296. * Callback called when the task is successful
  74297. */
  74298. onSuccess: (task: BinaryFileAssetTask) => void;
  74299. /**
  74300. * Callback called when the task is successful
  74301. */
  74302. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74303. /**
  74304. * Creates a new BinaryFileAssetTask object
  74305. * @param name defines the name of the new task
  74306. * @param url defines the location of the file to load
  74307. */
  74308. constructor(
  74309. /**
  74310. * Defines the name of the task
  74311. */
  74312. name: string,
  74313. /**
  74314. * Defines the location of the file to load
  74315. */
  74316. url: string);
  74317. /**
  74318. * Execute the current task
  74319. * @param scene defines the scene where you want your assets to be loaded
  74320. * @param onSuccess is a callback called when the task is successfully executed
  74321. * @param onError is a callback called if an error occurs
  74322. */
  74323. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74324. }
  74325. /**
  74326. * Define a task used by AssetsManager to load images
  74327. */
  74328. export class ImageAssetTask extends AbstractAssetTask {
  74329. /**
  74330. * Defines the name of the task
  74331. */
  74332. name: string;
  74333. /**
  74334. * Defines the location of the image to load
  74335. */
  74336. url: string;
  74337. /**
  74338. * Gets the loaded images
  74339. */
  74340. image: HTMLImageElement;
  74341. /**
  74342. * Callback called when the task is successful
  74343. */
  74344. onSuccess: (task: ImageAssetTask) => void;
  74345. /**
  74346. * Callback called when the task is successful
  74347. */
  74348. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74349. /**
  74350. * Creates a new ImageAssetTask
  74351. * @param name defines the name of the task
  74352. * @param url defines the location of the image to load
  74353. */
  74354. constructor(
  74355. /**
  74356. * Defines the name of the task
  74357. */
  74358. name: string,
  74359. /**
  74360. * Defines the location of the image to load
  74361. */
  74362. url: string);
  74363. /**
  74364. * Execute the current task
  74365. * @param scene defines the scene where you want your assets to be loaded
  74366. * @param onSuccess is a callback called when the task is successfully executed
  74367. * @param onError is a callback called if an error occurs
  74368. */
  74369. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74370. }
  74371. /**
  74372. * Defines the interface used by texture loading tasks
  74373. */
  74374. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74375. /**
  74376. * Gets the loaded texture
  74377. */
  74378. texture: TEX;
  74379. }
  74380. /**
  74381. * Define a task used by AssetsManager to load 2D textures
  74382. */
  74383. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74384. /**
  74385. * Defines the name of the task
  74386. */
  74387. name: string;
  74388. /**
  74389. * Defines the location of the file to load
  74390. */
  74391. url: string;
  74392. /**
  74393. * Defines if mipmap should not be generated (default is false)
  74394. */
  74395. noMipmap?: boolean | undefined;
  74396. /**
  74397. * Defines if texture must be inverted on Y axis (default is true)
  74398. */
  74399. invertY: boolean;
  74400. /**
  74401. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74402. */
  74403. samplingMode: number;
  74404. /**
  74405. * Gets the loaded texture
  74406. */
  74407. texture: Texture;
  74408. /**
  74409. * Callback called when the task is successful
  74410. */
  74411. onSuccess: (task: TextureAssetTask) => void;
  74412. /**
  74413. * Callback called when the task is successful
  74414. */
  74415. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74416. /**
  74417. * Creates a new TextureAssetTask object
  74418. * @param name defines the name of the task
  74419. * @param url defines the location of the file to load
  74420. * @param noMipmap defines if mipmap should not be generated (default is false)
  74421. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74422. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74423. */
  74424. constructor(
  74425. /**
  74426. * Defines the name of the task
  74427. */
  74428. name: string,
  74429. /**
  74430. * Defines the location of the file to load
  74431. */
  74432. url: string,
  74433. /**
  74434. * Defines if mipmap should not be generated (default is false)
  74435. */
  74436. noMipmap?: boolean | undefined,
  74437. /**
  74438. * Defines if texture must be inverted on Y axis (default is true)
  74439. */
  74440. invertY?: boolean,
  74441. /**
  74442. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74443. */
  74444. samplingMode?: number);
  74445. /**
  74446. * Execute the current task
  74447. * @param scene defines the scene where you want your assets to be loaded
  74448. * @param onSuccess is a callback called when the task is successfully executed
  74449. * @param onError is a callback called if an error occurs
  74450. */
  74451. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74452. }
  74453. /**
  74454. * Define a task used by AssetsManager to load cube textures
  74455. */
  74456. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74457. /**
  74458. * Defines the name of the task
  74459. */
  74460. name: string;
  74461. /**
  74462. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74463. */
  74464. url: string;
  74465. /**
  74466. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74467. */
  74468. extensions?: string[] | undefined;
  74469. /**
  74470. * Defines if mipmaps should not be generated (default is false)
  74471. */
  74472. noMipmap?: boolean | undefined;
  74473. /**
  74474. * Defines the explicit list of files (undefined by default)
  74475. */
  74476. files?: string[] | undefined;
  74477. /**
  74478. * Gets the loaded texture
  74479. */
  74480. texture: CubeTexture;
  74481. /**
  74482. * Callback called when the task is successful
  74483. */
  74484. onSuccess: (task: CubeTextureAssetTask) => void;
  74485. /**
  74486. * Callback called when the task is successful
  74487. */
  74488. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74489. /**
  74490. * Creates a new CubeTextureAssetTask
  74491. * @param name defines the name of the task
  74492. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74493. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74494. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74495. * @param files defines the explicit list of files (undefined by default)
  74496. */
  74497. constructor(
  74498. /**
  74499. * Defines the name of the task
  74500. */
  74501. name: string,
  74502. /**
  74503. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74504. */
  74505. url: string,
  74506. /**
  74507. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74508. */
  74509. extensions?: string[] | undefined,
  74510. /**
  74511. * Defines if mipmaps should not be generated (default is false)
  74512. */
  74513. noMipmap?: boolean | undefined,
  74514. /**
  74515. * Defines the explicit list of files (undefined by default)
  74516. */
  74517. files?: string[] | undefined);
  74518. /**
  74519. * Execute the current task
  74520. * @param scene defines the scene where you want your assets to be loaded
  74521. * @param onSuccess is a callback called when the task is successfully executed
  74522. * @param onError is a callback called if an error occurs
  74523. */
  74524. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74525. }
  74526. /**
  74527. * Define a task used by AssetsManager to load HDR cube textures
  74528. */
  74529. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74530. /**
  74531. * Defines the name of the task
  74532. */
  74533. name: string;
  74534. /**
  74535. * Defines the location of the file to load
  74536. */
  74537. url: string;
  74538. /**
  74539. * Defines the desired size (the more it increases the longer the generation will be)
  74540. */
  74541. size: number;
  74542. /**
  74543. * Defines if mipmaps should not be generated (default is false)
  74544. */
  74545. noMipmap: boolean;
  74546. /**
  74547. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74548. */
  74549. generateHarmonics: boolean;
  74550. /**
  74551. * 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)
  74552. */
  74553. gammaSpace: boolean;
  74554. /**
  74555. * Internal Use Only
  74556. */
  74557. reserved: boolean;
  74558. /**
  74559. * Gets the loaded texture
  74560. */
  74561. texture: HDRCubeTexture;
  74562. /**
  74563. * Callback called when the task is successful
  74564. */
  74565. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74566. /**
  74567. * Callback called when the task is successful
  74568. */
  74569. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74570. /**
  74571. * Creates a new HDRCubeTextureAssetTask object
  74572. * @param name defines the name of the task
  74573. * @param url defines the location of the file to load
  74574. * @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.
  74575. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74576. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74577. * @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)
  74578. * @param reserved Internal use only
  74579. */
  74580. constructor(
  74581. /**
  74582. * Defines the name of the task
  74583. */
  74584. name: string,
  74585. /**
  74586. * Defines the location of the file to load
  74587. */
  74588. url: string,
  74589. /**
  74590. * Defines the desired size (the more it increases the longer the generation will be)
  74591. */
  74592. size: number,
  74593. /**
  74594. * Defines if mipmaps should not be generated (default is false)
  74595. */
  74596. noMipmap?: boolean,
  74597. /**
  74598. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74599. */
  74600. generateHarmonics?: boolean,
  74601. /**
  74602. * 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)
  74603. */
  74604. gammaSpace?: boolean,
  74605. /**
  74606. * Internal Use Only
  74607. */
  74608. reserved?: boolean);
  74609. /**
  74610. * Execute the current task
  74611. * @param scene defines the scene where you want your assets to be loaded
  74612. * @param onSuccess is a callback called when the task is successfully executed
  74613. * @param onError is a callback called if an error occurs
  74614. */
  74615. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74616. }
  74617. /**
  74618. * Define a task used by AssetsManager to load Equirectangular cube textures
  74619. */
  74620. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74621. /**
  74622. * Defines the name of the task
  74623. */
  74624. name: string;
  74625. /**
  74626. * Defines the location of the file to load
  74627. */
  74628. url: string;
  74629. /**
  74630. * Defines the desired size (the more it increases the longer the generation will be)
  74631. */
  74632. size: number;
  74633. /**
  74634. * Defines if mipmaps should not be generated (default is false)
  74635. */
  74636. noMipmap: boolean;
  74637. /**
  74638. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74639. * but the standard material would require them in Gamma space) (default is true)
  74640. */
  74641. gammaSpace: boolean;
  74642. /**
  74643. * Gets the loaded texture
  74644. */
  74645. texture: EquiRectangularCubeTexture;
  74646. /**
  74647. * Callback called when the task is successful
  74648. */
  74649. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74650. /**
  74651. * Callback called when the task is successful
  74652. */
  74653. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74654. /**
  74655. * Creates a new EquiRectangularCubeTextureAssetTask object
  74656. * @param name defines the name of the task
  74657. * @param url defines the location of the file to load
  74658. * @param size defines the desired size (the more it increases the longer the generation will be)
  74659. * If the size is omitted this implies you are using a preprocessed cubemap.
  74660. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74661. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74662. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74663. * (default is true)
  74664. */
  74665. constructor(
  74666. /**
  74667. * Defines the name of the task
  74668. */
  74669. name: string,
  74670. /**
  74671. * Defines the location of the file to load
  74672. */
  74673. url: string,
  74674. /**
  74675. * Defines the desired size (the more it increases the longer the generation will be)
  74676. */
  74677. size: number,
  74678. /**
  74679. * Defines if mipmaps should not be generated (default is false)
  74680. */
  74681. noMipmap?: boolean,
  74682. /**
  74683. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74684. * but the standard material would require them in Gamma space) (default is true)
  74685. */
  74686. gammaSpace?: boolean);
  74687. /**
  74688. * Execute the current task
  74689. * @param scene defines the scene where you want your assets to be loaded
  74690. * @param onSuccess is a callback called when the task is successfully executed
  74691. * @param onError is a callback called if an error occurs
  74692. */
  74693. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74694. }
  74695. /**
  74696. * This class can be used to easily import assets into a scene
  74697. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74698. */
  74699. export class AssetsManager {
  74700. private _scene;
  74701. private _isLoading;
  74702. protected _tasks: AbstractAssetTask[];
  74703. protected _waitingTasksCount: number;
  74704. protected _totalTasksCount: number;
  74705. /**
  74706. * Callback called when all tasks are processed
  74707. */
  74708. onFinish: (tasks: AbstractAssetTask[]) => void;
  74709. /**
  74710. * Callback called when a task is successful
  74711. */
  74712. onTaskSuccess: (task: AbstractAssetTask) => void;
  74713. /**
  74714. * Callback called when a task had an error
  74715. */
  74716. onTaskError: (task: AbstractAssetTask) => void;
  74717. /**
  74718. * Callback called when a task is done (whatever the result is)
  74719. */
  74720. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74721. /**
  74722. * Observable called when all tasks are processed
  74723. */
  74724. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74725. /**
  74726. * Observable called when a task had an error
  74727. */
  74728. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74729. /**
  74730. * Observable called when all tasks were executed
  74731. */
  74732. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74733. /**
  74734. * Observable called when a task is done (whatever the result is)
  74735. */
  74736. onProgressObservable: Observable<IAssetsProgressEvent>;
  74737. /**
  74738. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74739. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74740. */
  74741. useDefaultLoadingScreen: boolean;
  74742. /**
  74743. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74744. * when all assets have been downloaded.
  74745. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74746. */
  74747. autoHideLoadingUI: boolean;
  74748. /**
  74749. * Creates a new AssetsManager
  74750. * @param scene defines the scene to work on
  74751. */
  74752. constructor(scene: Scene);
  74753. /**
  74754. * Add a ContainerAssetTask to the list of active tasks
  74755. * @param taskName defines the name of the new task
  74756. * @param meshesNames defines the name of meshes to load
  74757. * @param rootUrl defines the root url to use to locate files
  74758. * @param sceneFilename defines the filename of the scene file
  74759. * @returns a new ContainerAssetTask object
  74760. */
  74761. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74762. /**
  74763. * Add a MeshAssetTask to the list of active tasks
  74764. * @param taskName defines the name of the new task
  74765. * @param meshesNames defines the name of meshes to load
  74766. * @param rootUrl defines the root url to use to locate files
  74767. * @param sceneFilename defines the filename of the scene file
  74768. * @returns a new MeshAssetTask object
  74769. */
  74770. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74771. /**
  74772. * Add a TextFileAssetTask to the list of active tasks
  74773. * @param taskName defines the name of the new task
  74774. * @param url defines the url of the file to load
  74775. * @returns a new TextFileAssetTask object
  74776. */
  74777. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74778. /**
  74779. * Add a BinaryFileAssetTask to the list of active tasks
  74780. * @param taskName defines the name of the new task
  74781. * @param url defines the url of the file to load
  74782. * @returns a new BinaryFileAssetTask object
  74783. */
  74784. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74785. /**
  74786. * Add a ImageAssetTask to the list of active tasks
  74787. * @param taskName defines the name of the new task
  74788. * @param url defines the url of the file to load
  74789. * @returns a new ImageAssetTask object
  74790. */
  74791. addImageTask(taskName: string, url: string): ImageAssetTask;
  74792. /**
  74793. * Add a TextureAssetTask to the list of active tasks
  74794. * @param taskName defines the name of the new task
  74795. * @param url defines the url of the file to load
  74796. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74797. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74798. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74799. * @returns a new TextureAssetTask object
  74800. */
  74801. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74802. /**
  74803. * Add a CubeTextureAssetTask to the list of active tasks
  74804. * @param taskName defines the name of the new task
  74805. * @param url defines the url of the file to load
  74806. * @param extensions defines the extension to use to load the cube map (can be null)
  74807. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74808. * @param files defines the list of files to load (can be null)
  74809. * @returns a new CubeTextureAssetTask object
  74810. */
  74811. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74812. /**
  74813. *
  74814. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74815. * @param taskName defines the name of the new task
  74816. * @param url defines the url of the file to load
  74817. * @param size defines the size you want for the cubemap (can be null)
  74818. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74819. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74820. * @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)
  74821. * @param reserved Internal use only
  74822. * @returns a new HDRCubeTextureAssetTask object
  74823. */
  74824. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74825. /**
  74826. *
  74827. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74828. * @param taskName defines the name of the new task
  74829. * @param url defines the url of the file to load
  74830. * @param size defines the size you want for the cubemap (can be null)
  74831. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74832. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74833. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74834. * @returns a new EquiRectangularCubeTextureAssetTask object
  74835. */
  74836. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74837. /**
  74838. * Remove a task from the assets manager.
  74839. * @param task the task to remove
  74840. */
  74841. removeTask(task: AbstractAssetTask): void;
  74842. private _decreaseWaitingTasksCount;
  74843. private _runTask;
  74844. /**
  74845. * Reset the AssetsManager and remove all tasks
  74846. * @return the current instance of the AssetsManager
  74847. */
  74848. reset(): AssetsManager;
  74849. /**
  74850. * Start the loading process
  74851. * @return the current instance of the AssetsManager
  74852. */
  74853. load(): AssetsManager;
  74854. /**
  74855. * Start the loading process as an async operation
  74856. * @return a promise returning the list of failed tasks
  74857. */
  74858. loadAsync(): Promise<void>;
  74859. }
  74860. }
  74861. declare module BABYLON {
  74862. /**
  74863. * Wrapper class for promise with external resolve and reject.
  74864. */
  74865. export class Deferred<T> {
  74866. /**
  74867. * The promise associated with this deferred object.
  74868. */
  74869. readonly promise: Promise<T>;
  74870. private _resolve;
  74871. private _reject;
  74872. /**
  74873. * The resolve method of the promise associated with this deferred object.
  74874. */
  74875. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74876. /**
  74877. * The reject method of the promise associated with this deferred object.
  74878. */
  74879. get reject(): (reason?: any) => void;
  74880. /**
  74881. * Constructor for this deferred object.
  74882. */
  74883. constructor();
  74884. }
  74885. }
  74886. declare module BABYLON {
  74887. /**
  74888. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74889. */
  74890. export class MeshExploder {
  74891. private _centerMesh;
  74892. private _meshes;
  74893. private _meshesOrigins;
  74894. private _toCenterVectors;
  74895. private _scaledDirection;
  74896. private _newPosition;
  74897. private _centerPosition;
  74898. /**
  74899. * Explodes meshes from a center mesh.
  74900. * @param meshes The meshes to explode.
  74901. * @param centerMesh The mesh to be center of explosion.
  74902. */
  74903. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74904. private _setCenterMesh;
  74905. /**
  74906. * Get class name
  74907. * @returns "MeshExploder"
  74908. */
  74909. getClassName(): string;
  74910. /**
  74911. * "Exploded meshes"
  74912. * @returns Array of meshes with the centerMesh at index 0.
  74913. */
  74914. getMeshes(): Array<Mesh>;
  74915. /**
  74916. * Explodes meshes giving a specific direction
  74917. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74918. */
  74919. explode(direction?: number): void;
  74920. }
  74921. }
  74922. declare module BABYLON {
  74923. /**
  74924. * Class used to help managing file picking and drag'n'drop
  74925. */
  74926. export class FilesInput {
  74927. /**
  74928. * List of files ready to be loaded
  74929. */
  74930. static get FilesToLoad(): {
  74931. [key: string]: File;
  74932. };
  74933. /**
  74934. * Callback called when a file is processed
  74935. */
  74936. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74937. private _engine;
  74938. private _currentScene;
  74939. private _sceneLoadedCallback;
  74940. private _progressCallback;
  74941. private _additionalRenderLoopLogicCallback;
  74942. private _textureLoadingCallback;
  74943. private _startingProcessingFilesCallback;
  74944. private _onReloadCallback;
  74945. private _errorCallback;
  74946. private _elementToMonitor;
  74947. private _sceneFileToLoad;
  74948. private _filesToLoad;
  74949. /**
  74950. * Creates a new FilesInput
  74951. * @param engine defines the rendering engine
  74952. * @param scene defines the hosting scene
  74953. * @param sceneLoadedCallback callback called when scene is loaded
  74954. * @param progressCallback callback called to track progress
  74955. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74956. * @param textureLoadingCallback callback called when a texture is loading
  74957. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74958. * @param onReloadCallback callback called when a reload is requested
  74959. * @param errorCallback callback call if an error occurs
  74960. */
  74961. 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>);
  74962. private _dragEnterHandler;
  74963. private _dragOverHandler;
  74964. private _dropHandler;
  74965. /**
  74966. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74967. * @param elementToMonitor defines the DOM element to track
  74968. */
  74969. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74970. /** Gets the current list of files to load */
  74971. get filesToLoad(): File[];
  74972. /**
  74973. * Release all associated resources
  74974. */
  74975. dispose(): void;
  74976. private renderFunction;
  74977. private drag;
  74978. private drop;
  74979. private _traverseFolder;
  74980. private _processFiles;
  74981. /**
  74982. * Load files from a drop event
  74983. * @param event defines the drop event to use as source
  74984. */
  74985. loadFiles(event: any): void;
  74986. private _processReload;
  74987. /**
  74988. * Reload the current scene from the loaded files
  74989. */
  74990. reload(): void;
  74991. }
  74992. }
  74993. declare module BABYLON {
  74994. /**
  74995. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74996. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74997. */
  74998. export class SceneOptimization {
  74999. /**
  75000. * Defines the priority of this optimization (0 by default which means first in the list)
  75001. */
  75002. priority: number;
  75003. /**
  75004. * Gets a string describing the action executed by the current optimization
  75005. * @returns description string
  75006. */
  75007. getDescription(): string;
  75008. /**
  75009. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75010. * @param scene defines the current scene where to apply this optimization
  75011. * @param optimizer defines the current optimizer
  75012. * @returns true if everything that can be done was applied
  75013. */
  75014. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75015. /**
  75016. * Creates the SceneOptimization object
  75017. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75018. * @param desc defines the description associated with the optimization
  75019. */
  75020. constructor(
  75021. /**
  75022. * Defines the priority of this optimization (0 by default which means first in the list)
  75023. */
  75024. priority?: number);
  75025. }
  75026. /**
  75027. * Defines an optimization used to reduce the size of render target textures
  75028. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75029. */
  75030. export class TextureOptimization extends SceneOptimization {
  75031. /**
  75032. * Defines the priority of this optimization (0 by default which means first in the list)
  75033. */
  75034. priority: number;
  75035. /**
  75036. * 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
  75037. */
  75038. maximumSize: number;
  75039. /**
  75040. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75041. */
  75042. step: number;
  75043. /**
  75044. * Gets a string describing the action executed by the current optimization
  75045. * @returns description string
  75046. */
  75047. getDescription(): string;
  75048. /**
  75049. * Creates the TextureOptimization object
  75050. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75051. * @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
  75052. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75053. */
  75054. constructor(
  75055. /**
  75056. * Defines the priority of this optimization (0 by default which means first in the list)
  75057. */
  75058. priority?: number,
  75059. /**
  75060. * 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
  75061. */
  75062. maximumSize?: number,
  75063. /**
  75064. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75065. */
  75066. step?: number);
  75067. /**
  75068. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75069. * @param scene defines the current scene where to apply this optimization
  75070. * @param optimizer defines the current optimizer
  75071. * @returns true if everything that can be done was applied
  75072. */
  75073. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75074. }
  75075. /**
  75076. * Defines an optimization used to increase or decrease the rendering resolution
  75077. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75078. */
  75079. export class HardwareScalingOptimization extends SceneOptimization {
  75080. /**
  75081. * Defines the priority of this optimization (0 by default which means first in the list)
  75082. */
  75083. priority: number;
  75084. /**
  75085. * Defines the maximum scale to use (2 by default)
  75086. */
  75087. maximumScale: number;
  75088. /**
  75089. * Defines the step to use between two passes (0.5 by default)
  75090. */
  75091. step: number;
  75092. private _currentScale;
  75093. private _directionOffset;
  75094. /**
  75095. * Gets a string describing the action executed by the current optimization
  75096. * @return description string
  75097. */
  75098. getDescription(): string;
  75099. /**
  75100. * Creates the HardwareScalingOptimization object
  75101. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75102. * @param maximumScale defines the maximum scale to use (2 by default)
  75103. * @param step defines the step to use between two passes (0.5 by default)
  75104. */
  75105. constructor(
  75106. /**
  75107. * Defines the priority of this optimization (0 by default which means first in the list)
  75108. */
  75109. priority?: number,
  75110. /**
  75111. * Defines the maximum scale to use (2 by default)
  75112. */
  75113. maximumScale?: number,
  75114. /**
  75115. * Defines the step to use between two passes (0.5 by default)
  75116. */
  75117. step?: number);
  75118. /**
  75119. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75120. * @param scene defines the current scene where to apply this optimization
  75121. * @param optimizer defines the current optimizer
  75122. * @returns true if everything that can be done was applied
  75123. */
  75124. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75125. }
  75126. /**
  75127. * Defines an optimization used to remove shadows
  75128. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75129. */
  75130. export class ShadowsOptimization extends SceneOptimization {
  75131. /**
  75132. * Gets a string describing the action executed by the current optimization
  75133. * @return description string
  75134. */
  75135. getDescription(): string;
  75136. /**
  75137. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75138. * @param scene defines the current scene where to apply this optimization
  75139. * @param optimizer defines the current optimizer
  75140. * @returns true if everything that can be done was applied
  75141. */
  75142. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75143. }
  75144. /**
  75145. * Defines an optimization used to turn post-processes off
  75146. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75147. */
  75148. export class PostProcessesOptimization extends SceneOptimization {
  75149. /**
  75150. * Gets a string describing the action executed by the current optimization
  75151. * @return description string
  75152. */
  75153. getDescription(): string;
  75154. /**
  75155. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75156. * @param scene defines the current scene where to apply this optimization
  75157. * @param optimizer defines the current optimizer
  75158. * @returns true if everything that can be done was applied
  75159. */
  75160. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75161. }
  75162. /**
  75163. * Defines an optimization used to turn lens flares off
  75164. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75165. */
  75166. export class LensFlaresOptimization extends SceneOptimization {
  75167. /**
  75168. * Gets a string describing the action executed by the current optimization
  75169. * @return description string
  75170. */
  75171. getDescription(): string;
  75172. /**
  75173. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75174. * @param scene defines the current scene where to apply this optimization
  75175. * @param optimizer defines the current optimizer
  75176. * @returns true if everything that can be done was applied
  75177. */
  75178. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75179. }
  75180. /**
  75181. * Defines an optimization based on user defined callback.
  75182. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75183. */
  75184. export class CustomOptimization extends SceneOptimization {
  75185. /**
  75186. * Callback called to apply the custom optimization.
  75187. */
  75188. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  75189. /**
  75190. * Callback called to get custom description
  75191. */
  75192. onGetDescription: () => string;
  75193. /**
  75194. * Gets a string describing the action executed by the current optimization
  75195. * @returns description string
  75196. */
  75197. getDescription(): string;
  75198. /**
  75199. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75200. * @param scene defines the current scene where to apply this optimization
  75201. * @param optimizer defines the current optimizer
  75202. * @returns true if everything that can be done was applied
  75203. */
  75204. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75205. }
  75206. /**
  75207. * Defines an optimization used to turn particles off
  75208. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75209. */
  75210. export class ParticlesOptimization extends SceneOptimization {
  75211. /**
  75212. * Gets a string describing the action executed by the current optimization
  75213. * @return description string
  75214. */
  75215. getDescription(): string;
  75216. /**
  75217. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75218. * @param scene defines the current scene where to apply this optimization
  75219. * @param optimizer defines the current optimizer
  75220. * @returns true if everything that can be done was applied
  75221. */
  75222. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75223. }
  75224. /**
  75225. * Defines an optimization used to turn render targets off
  75226. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75227. */
  75228. export class RenderTargetsOptimization extends SceneOptimization {
  75229. /**
  75230. * Gets a string describing the action executed by the current optimization
  75231. * @return description string
  75232. */
  75233. getDescription(): string;
  75234. /**
  75235. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75236. * @param scene defines the current scene where to apply this optimization
  75237. * @param optimizer defines the current optimizer
  75238. * @returns true if everything that can be done was applied
  75239. */
  75240. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75241. }
  75242. /**
  75243. * Defines an optimization used to merge meshes with compatible materials
  75244. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75245. */
  75246. export class MergeMeshesOptimization extends SceneOptimization {
  75247. private static _UpdateSelectionTree;
  75248. /**
  75249. * Gets or sets a boolean which defines if optimization octree has to be updated
  75250. */
  75251. static get UpdateSelectionTree(): boolean;
  75252. /**
  75253. * Gets or sets a boolean which defines if optimization octree has to be updated
  75254. */
  75255. static set UpdateSelectionTree(value: boolean);
  75256. /**
  75257. * Gets a string describing the action executed by the current optimization
  75258. * @return description string
  75259. */
  75260. getDescription(): string;
  75261. private _canBeMerged;
  75262. /**
  75263. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75264. * @param scene defines the current scene where to apply this optimization
  75265. * @param optimizer defines the current optimizer
  75266. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  75267. * @returns true if everything that can be done was applied
  75268. */
  75269. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75270. }
  75271. /**
  75272. * Defines a list of options used by SceneOptimizer
  75273. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75274. */
  75275. export class SceneOptimizerOptions {
  75276. /**
  75277. * Defines the target frame rate to reach (60 by default)
  75278. */
  75279. targetFrameRate: number;
  75280. /**
  75281. * Defines the interval between two checkes (2000ms by default)
  75282. */
  75283. trackerDuration: number;
  75284. /**
  75285. * Gets the list of optimizations to apply
  75286. */
  75287. optimizations: SceneOptimization[];
  75288. /**
  75289. * Creates a new list of options used by SceneOptimizer
  75290. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75291. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75292. */
  75293. constructor(
  75294. /**
  75295. * Defines the target frame rate to reach (60 by default)
  75296. */
  75297. targetFrameRate?: number,
  75298. /**
  75299. * Defines the interval between two checkes (2000ms by default)
  75300. */
  75301. trackerDuration?: number);
  75302. /**
  75303. * Add a new optimization
  75304. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75305. * @returns the current SceneOptimizerOptions
  75306. */
  75307. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75308. /**
  75309. * Add a new custom optimization
  75310. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75311. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75312. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75313. * @returns the current SceneOptimizerOptions
  75314. */
  75315. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75316. /**
  75317. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75318. * @param targetFrameRate defines the target frame rate (60 by default)
  75319. * @returns a SceneOptimizerOptions object
  75320. */
  75321. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75322. /**
  75323. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75324. * @param targetFrameRate defines the target frame rate (60 by default)
  75325. * @returns a SceneOptimizerOptions object
  75326. */
  75327. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75328. /**
  75329. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75330. * @param targetFrameRate defines the target frame rate (60 by default)
  75331. * @returns a SceneOptimizerOptions object
  75332. */
  75333. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75334. }
  75335. /**
  75336. * Class used to run optimizations in order to reach a target frame rate
  75337. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75338. */
  75339. export class SceneOptimizer implements IDisposable {
  75340. private _isRunning;
  75341. private _options;
  75342. private _scene;
  75343. private _currentPriorityLevel;
  75344. private _targetFrameRate;
  75345. private _trackerDuration;
  75346. private _currentFrameRate;
  75347. private _sceneDisposeObserver;
  75348. private _improvementMode;
  75349. /**
  75350. * Defines an observable called when the optimizer reaches the target frame rate
  75351. */
  75352. onSuccessObservable: Observable<SceneOptimizer>;
  75353. /**
  75354. * Defines an observable called when the optimizer enables an optimization
  75355. */
  75356. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75357. /**
  75358. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75359. */
  75360. onFailureObservable: Observable<SceneOptimizer>;
  75361. /**
  75362. * Gets a boolean indicating if the optimizer is in improvement mode
  75363. */
  75364. get isInImprovementMode(): boolean;
  75365. /**
  75366. * Gets the current priority level (0 at start)
  75367. */
  75368. get currentPriorityLevel(): number;
  75369. /**
  75370. * Gets the current frame rate checked by the SceneOptimizer
  75371. */
  75372. get currentFrameRate(): number;
  75373. /**
  75374. * Gets or sets the current target frame rate (60 by default)
  75375. */
  75376. get targetFrameRate(): number;
  75377. /**
  75378. * Gets or sets the current target frame rate (60 by default)
  75379. */
  75380. set targetFrameRate(value: number);
  75381. /**
  75382. * Gets or sets the current interval between two checks (every 2000ms by default)
  75383. */
  75384. get trackerDuration(): number;
  75385. /**
  75386. * Gets or sets the current interval between two checks (every 2000ms by default)
  75387. */
  75388. set trackerDuration(value: number);
  75389. /**
  75390. * Gets the list of active optimizations
  75391. */
  75392. get optimizations(): SceneOptimization[];
  75393. /**
  75394. * Creates a new SceneOptimizer
  75395. * @param scene defines the scene to work on
  75396. * @param options defines the options to use with the SceneOptimizer
  75397. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75398. * @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)
  75399. */
  75400. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75401. /**
  75402. * Stops the current optimizer
  75403. */
  75404. stop(): void;
  75405. /**
  75406. * Reset the optimizer to initial step (current priority level = 0)
  75407. */
  75408. reset(): void;
  75409. /**
  75410. * Start the optimizer. By default it will try to reach a specific framerate
  75411. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75412. */
  75413. start(): void;
  75414. private _checkCurrentState;
  75415. /**
  75416. * Release all resources
  75417. */
  75418. dispose(): void;
  75419. /**
  75420. * Helper function to create a SceneOptimizer with one single line of code
  75421. * @param scene defines the scene to work on
  75422. * @param options defines the options to use with the SceneOptimizer
  75423. * @param onSuccess defines a callback to call on success
  75424. * @param onFailure defines a callback to call on failure
  75425. * @returns the new SceneOptimizer object
  75426. */
  75427. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75428. }
  75429. }
  75430. declare module BABYLON {
  75431. /**
  75432. * Class used to serialize a scene into a string
  75433. */
  75434. export class SceneSerializer {
  75435. /**
  75436. * Clear cache used by a previous serialization
  75437. */
  75438. static ClearCache(): void;
  75439. /**
  75440. * Serialize a scene into a JSON compatible object
  75441. * @param scene defines the scene to serialize
  75442. * @returns a JSON compatible object
  75443. */
  75444. static Serialize(scene: Scene): any;
  75445. /**
  75446. * Serialize a mesh into a JSON compatible object
  75447. * @param toSerialize defines the mesh to serialize
  75448. * @param withParents defines if parents must be serialized as well
  75449. * @param withChildren defines if children must be serialized as well
  75450. * @returns a JSON compatible object
  75451. */
  75452. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75453. }
  75454. }
  75455. declare module BABYLON {
  75456. /**
  75457. * Class used to host texture specific utilities
  75458. */
  75459. export class TextureTools {
  75460. /**
  75461. * Uses the GPU to create a copy texture rescaled at a given size
  75462. * @param texture Texture to copy from
  75463. * @param width defines the desired width
  75464. * @param height defines the desired height
  75465. * @param useBilinearMode defines if bilinear mode has to be used
  75466. * @return the generated texture
  75467. */
  75468. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75469. }
  75470. }
  75471. declare module BABYLON {
  75472. /**
  75473. * This represents the different options available for the video capture.
  75474. */
  75475. export interface VideoRecorderOptions {
  75476. /** Defines the mime type of the video. */
  75477. mimeType: string;
  75478. /** Defines the FPS the video should be recorded at. */
  75479. fps: number;
  75480. /** Defines the chunk size for the recording data. */
  75481. recordChunckSize: number;
  75482. /** The audio tracks to attach to the recording. */
  75483. audioTracks?: MediaStreamTrack[];
  75484. }
  75485. /**
  75486. * This can help with recording videos from BabylonJS.
  75487. * This is based on the available WebRTC functionalities of the browser.
  75488. *
  75489. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  75490. */
  75491. export class VideoRecorder {
  75492. private static readonly _defaultOptions;
  75493. /**
  75494. * Returns whether or not the VideoRecorder is available in your browser.
  75495. * @param engine Defines the Babylon Engine.
  75496. * @returns true if supported otherwise false.
  75497. */
  75498. static IsSupported(engine: Engine): boolean;
  75499. private readonly _options;
  75500. private _canvas;
  75501. private _mediaRecorder;
  75502. private _recordedChunks;
  75503. private _fileName;
  75504. private _resolve;
  75505. private _reject;
  75506. /**
  75507. * True when a recording is already in progress.
  75508. */
  75509. get isRecording(): boolean;
  75510. /**
  75511. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75512. * @param engine Defines the BabylonJS Engine you wish to record.
  75513. * @param options Defines options that can be used to customize the capture.
  75514. */
  75515. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75516. /**
  75517. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75518. */
  75519. stopRecording(): void;
  75520. /**
  75521. * Starts recording the canvas for a max duration specified in parameters.
  75522. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75523. * If null no automatic download will start and you can rely on the promise to get the data back.
  75524. * @param maxDuration Defines the maximum recording time in seconds.
  75525. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75526. * @return A promise callback at the end of the recording with the video data in Blob.
  75527. */
  75528. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75529. /**
  75530. * Releases internal resources used during the recording.
  75531. */
  75532. dispose(): void;
  75533. private _handleDataAvailable;
  75534. private _handleError;
  75535. private _handleStop;
  75536. }
  75537. }
  75538. declare module BABYLON {
  75539. /**
  75540. * Class containing a set of static utilities functions for screenshots
  75541. */
  75542. export class ScreenshotTools {
  75543. /**
  75544. * Captures a screenshot of the current rendering
  75545. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75546. * @param engine defines the rendering engine
  75547. * @param camera defines the source camera
  75548. * @param size This parameter can be set to a single number or to an object with the
  75549. * following (optional) properties: precision, width, height. If a single number is passed,
  75550. * it will be used for both width and height. If an object is passed, the screenshot size
  75551. * will be derived from the parameters. The precision property is a multiplier allowing
  75552. * rendering at a higher or lower resolution
  75553. * @param successCallback defines the callback receives a single parameter which contains the
  75554. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75555. * src parameter of an <img> to display it
  75556. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75557. * Check your browser for supported MIME types
  75558. */
  75559. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75560. /**
  75561. * Captures a screenshot of the current rendering
  75562. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75563. * @param engine defines the rendering engine
  75564. * @param camera defines the source camera
  75565. * @param size This parameter can be set to a single number or to an object with the
  75566. * following (optional) properties: precision, width, height. If a single number is passed,
  75567. * it will be used for both width and height. If an object is passed, the screenshot size
  75568. * will be derived from the parameters. The precision property is a multiplier allowing
  75569. * rendering at a higher or lower resolution
  75570. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75571. * Check your browser for supported MIME types
  75572. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75573. * to the src parameter of an <img> to display it
  75574. */
  75575. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75576. /**
  75577. * Generates an image screenshot from the specified camera.
  75578. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75579. * @param engine The engine to use for rendering
  75580. * @param camera The camera to use for rendering
  75581. * @param size This parameter can be set to a single number or to an object with the
  75582. * following (optional) properties: precision, width, height. If a single number is passed,
  75583. * it will be used for both width and height. If an object is passed, the screenshot size
  75584. * will be derived from the parameters. The precision property is a multiplier allowing
  75585. * rendering at a higher or lower resolution
  75586. * @param successCallback The callback receives a single parameter which contains the
  75587. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75588. * src parameter of an <img> to display it
  75589. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75590. * Check your browser for supported MIME types
  75591. * @param samples Texture samples (default: 1)
  75592. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75593. * @param fileName A name for for the downloaded file.
  75594. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75595. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  75596. */
  75597. 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;
  75598. /**
  75599. * Generates an image screenshot from the specified camera.
  75600. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75601. * @param engine The engine to use for rendering
  75602. * @param camera The camera to use for rendering
  75603. * @param size This parameter can be set to a single number or to an object with the
  75604. * following (optional) properties: precision, width, height. If a single number is passed,
  75605. * it will be used for both width and height. If an object is passed, the screenshot size
  75606. * will be derived from the parameters. The precision property is a multiplier allowing
  75607. * rendering at a higher or lower resolution
  75608. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75609. * Check your browser for supported MIME types
  75610. * @param samples Texture samples (default: 1)
  75611. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75612. * @param fileName A name for for the downloaded file.
  75613. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75614. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75615. * to the src parameter of an <img> to display it
  75616. */
  75617. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75618. /**
  75619. * Gets height and width for screenshot size
  75620. * @private
  75621. */
  75622. private static _getScreenshotSize;
  75623. }
  75624. }
  75625. declare module BABYLON {
  75626. /**
  75627. * Interface for a data buffer
  75628. */
  75629. export interface IDataBuffer {
  75630. /**
  75631. * Reads bytes from the data buffer.
  75632. * @param byteOffset The byte offset to read
  75633. * @param byteLength The byte length to read
  75634. * @returns A promise that resolves when the bytes are read
  75635. */
  75636. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75637. /**
  75638. * The byte length of the buffer.
  75639. */
  75640. readonly byteLength: number;
  75641. }
  75642. /**
  75643. * Utility class for reading from a data buffer
  75644. */
  75645. export class DataReader {
  75646. /**
  75647. * The data buffer associated with this data reader.
  75648. */
  75649. readonly buffer: IDataBuffer;
  75650. /**
  75651. * The current byte offset from the beginning of the data buffer.
  75652. */
  75653. byteOffset: number;
  75654. private _dataView;
  75655. private _dataByteOffset;
  75656. /**
  75657. * Constructor
  75658. * @param buffer The buffer to read
  75659. */
  75660. constructor(buffer: IDataBuffer);
  75661. /**
  75662. * Loads the given byte length.
  75663. * @param byteLength The byte length to load
  75664. * @returns A promise that resolves when the load is complete
  75665. */
  75666. loadAsync(byteLength: number): Promise<void>;
  75667. /**
  75668. * Read a unsigned 32-bit integer from the currently loaded data range.
  75669. * @returns The 32-bit integer read
  75670. */
  75671. readUint32(): number;
  75672. /**
  75673. * Read a byte array from the currently loaded data range.
  75674. * @param byteLength The byte length to read
  75675. * @returns The byte array read
  75676. */
  75677. readUint8Array(byteLength: number): Uint8Array;
  75678. /**
  75679. * Read a string from the currently loaded data range.
  75680. * @param byteLength The byte length to read
  75681. * @returns The string read
  75682. */
  75683. readString(byteLength: number): string;
  75684. /**
  75685. * Skips the given byte length the currently loaded data range.
  75686. * @param byteLength The byte length to skip
  75687. */
  75688. skipBytes(byteLength: number): void;
  75689. }
  75690. }
  75691. declare module BABYLON {
  75692. /**
  75693. * Class for storing data to local storage if available or in-memory storage otherwise
  75694. */
  75695. export class DataStorage {
  75696. private static _Storage;
  75697. private static _GetStorage;
  75698. /**
  75699. * Reads a string from the data storage
  75700. * @param key The key to read
  75701. * @param defaultValue The value if the key doesn't exist
  75702. * @returns The string value
  75703. */
  75704. static ReadString(key: string, defaultValue: string): string;
  75705. /**
  75706. * Writes a string to the data storage
  75707. * @param key The key to write
  75708. * @param value The value to write
  75709. */
  75710. static WriteString(key: string, value: string): void;
  75711. /**
  75712. * Reads a boolean from the data storage
  75713. * @param key The key to read
  75714. * @param defaultValue The value if the key doesn't exist
  75715. * @returns The boolean value
  75716. */
  75717. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75718. /**
  75719. * Writes a boolean to the data storage
  75720. * @param key The key to write
  75721. * @param value The value to write
  75722. */
  75723. static WriteBoolean(key: string, value: boolean): void;
  75724. /**
  75725. * Reads a number from the data storage
  75726. * @param key The key to read
  75727. * @param defaultValue The value if the key doesn't exist
  75728. * @returns The number value
  75729. */
  75730. static ReadNumber(key: string, defaultValue: number): number;
  75731. /**
  75732. * Writes a number to the data storage
  75733. * @param key The key to write
  75734. * @param value The value to write
  75735. */
  75736. static WriteNumber(key: string, value: number): void;
  75737. }
  75738. }
  75739. declare module BABYLON {
  75740. /**
  75741. * Class used to record delta files between 2 scene states
  75742. */
  75743. export class SceneRecorder {
  75744. private _trackedScene;
  75745. private _savedJSON;
  75746. /**
  75747. * Track a given scene. This means the current scene state will be considered the original state
  75748. * @param scene defines the scene to track
  75749. */
  75750. track(scene: Scene): void;
  75751. /**
  75752. * Get the delta between current state and original state
  75753. * @returns a string containing the delta
  75754. */
  75755. getDelta(): any;
  75756. private _compareArray;
  75757. private _compareObjects;
  75758. private _compareCollections;
  75759. private static GetShadowGeneratorById;
  75760. /**
  75761. * Apply a given delta to a given scene
  75762. * @param deltaJSON defines the JSON containing the delta
  75763. * @param scene defines the scene to apply the delta to
  75764. */
  75765. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75766. private static _ApplyPropertiesToEntity;
  75767. private static _ApplyDeltaForEntity;
  75768. }
  75769. }
  75770. declare module BABYLON {
  75771. /**
  75772. * A 3D trajectory consisting of an order list of vectors describing a
  75773. * path of motion through 3D space.
  75774. */
  75775. export class Trajectory {
  75776. private _points;
  75777. private readonly _segmentLength;
  75778. /**
  75779. * Serialize to JSON.
  75780. * @returns serialized JSON string
  75781. */
  75782. serialize(): string;
  75783. /**
  75784. * Deserialize from JSON.
  75785. * @param json serialized JSON string
  75786. * @returns deserialized Trajectory
  75787. */
  75788. static Deserialize(json: string): Trajectory;
  75789. /**
  75790. * Create a new empty Trajectory.
  75791. * @param segmentLength radius of discretization for Trajectory points
  75792. */
  75793. constructor(segmentLength?: number);
  75794. /**
  75795. * Get the length of the Trajectory.
  75796. * @returns length of the Trajectory
  75797. */
  75798. getLength(): number;
  75799. /**
  75800. * Append a new point to the Trajectory.
  75801. * NOTE: This implementation has many allocations.
  75802. * @param point point to append to the Trajectory
  75803. */
  75804. add(point: DeepImmutable<Vector3>): void;
  75805. /**
  75806. * Create a new Trajectory with a segment length chosen to make it
  75807. * probable that the new Trajectory will have a specified number of
  75808. * segments. This operation is imprecise.
  75809. * @param targetResolution number of segments desired
  75810. * @returns new Trajectory with approximately the requested number of segments
  75811. */
  75812. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75813. /**
  75814. * Convert Trajectory segments into tokenized representation. This
  75815. * representation is an array of numbers where each nth number is the
  75816. * index of the token which is most similar to the nth segment of the
  75817. * Trajectory.
  75818. * @param tokens list of vectors which serve as discrete tokens
  75819. * @returns list of indices of most similar token per segment
  75820. */
  75821. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75822. private static _forwardDir;
  75823. private static _inverseFromVec;
  75824. private static _upDir;
  75825. private static _fromToVec;
  75826. private static _lookMatrix;
  75827. /**
  75828. * Transform the rotation (i.e., direction) of a segment to isolate
  75829. * the relative transformation represented by the segment. This operation
  75830. * may or may not succeed due to singularities in the equations that define
  75831. * motion relativity in this context.
  75832. * @param priorVec the origin of the prior segment
  75833. * @param fromVec the origin of the current segment
  75834. * @param toVec the destination of the current segment
  75835. * @param result reference to output variable
  75836. * @returns whether or not transformation was successful
  75837. */
  75838. private static _transformSegmentDirToRef;
  75839. private static _bestMatch;
  75840. private static _score;
  75841. private static _bestScore;
  75842. /**
  75843. * Determine which token vector is most similar to the
  75844. * segment vector.
  75845. * @param segment segment vector
  75846. * @param tokens token vector list
  75847. * @returns index of the most similar token to the segment
  75848. */
  75849. private static _tokenizeSegment;
  75850. }
  75851. /**
  75852. * Class representing a set of known, named trajectories to which Trajectories can be
  75853. * added and using which Trajectories can be recognized.
  75854. */
  75855. export class TrajectoryClassifier {
  75856. private _maximumAllowableMatchCost;
  75857. private _vector3Alphabet;
  75858. private _levenshteinAlphabet;
  75859. private _nameToDescribedTrajectory;
  75860. /**
  75861. * Serialize to JSON.
  75862. * @returns JSON serialization
  75863. */
  75864. serialize(): string;
  75865. /**
  75866. * Deserialize from JSON.
  75867. * @param json JSON serialization
  75868. * @returns deserialized TrajectorySet
  75869. */
  75870. static Deserialize(json: string): TrajectoryClassifier;
  75871. /**
  75872. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75873. * VERY naive, need to be generating these things from known
  75874. * sets. Better version later, probably eliminating this one.
  75875. * @returns auto-generated TrajectorySet
  75876. */
  75877. static Generate(): TrajectoryClassifier;
  75878. private constructor();
  75879. /**
  75880. * Add a new Trajectory to the set with a given name.
  75881. * @param trajectory new Trajectory to be added
  75882. * @param classification name to which to add the Trajectory
  75883. */
  75884. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75885. /**
  75886. * Remove a known named trajectory and all Trajectories associated with it.
  75887. * @param classification name to remove
  75888. * @returns whether anything was removed
  75889. */
  75890. deleteClassification(classification: string): boolean;
  75891. /**
  75892. * Attempt to recognize a Trajectory from among all the classifications
  75893. * already known to the classifier.
  75894. * @param trajectory Trajectory to be recognized
  75895. * @returns classification of Trajectory if recognized, null otherwise
  75896. */
  75897. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75898. }
  75899. }
  75900. declare module BABYLON {
  75901. /**
  75902. * An interface for all Hit test features
  75903. */
  75904. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75905. /**
  75906. * Triggered when new babylon (transformed) hit test results are available
  75907. */
  75908. onHitTestResultObservable: Observable<T[]>;
  75909. }
  75910. /**
  75911. * Options used for hit testing
  75912. */
  75913. export interface IWebXRLegacyHitTestOptions {
  75914. /**
  75915. * Only test when user interacted with the scene. Default - hit test every frame
  75916. */
  75917. testOnPointerDownOnly?: boolean;
  75918. /**
  75919. * The node to use to transform the local results to world coordinates
  75920. */
  75921. worldParentNode?: TransformNode;
  75922. }
  75923. /**
  75924. * Interface defining the babylon result of raycasting/hit-test
  75925. */
  75926. export interface IWebXRLegacyHitResult {
  75927. /**
  75928. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75929. */
  75930. transformationMatrix: Matrix;
  75931. /**
  75932. * The native hit test result
  75933. */
  75934. xrHitResult: XRHitResult | XRHitTestResult;
  75935. }
  75936. /**
  75937. * The currently-working hit-test module.
  75938. * Hit test (or Ray-casting) is used to interact with the real world.
  75939. * For further information read here - https://github.com/immersive-web/hit-test
  75940. */
  75941. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75942. /**
  75943. * options to use when constructing this feature
  75944. */
  75945. readonly options: IWebXRLegacyHitTestOptions;
  75946. private _direction;
  75947. private _mat;
  75948. private _onSelectEnabled;
  75949. private _origin;
  75950. /**
  75951. * The module's name
  75952. */
  75953. static readonly Name: string;
  75954. /**
  75955. * The (Babylon) version of this module.
  75956. * This is an integer representing the implementation version.
  75957. * This number does not correspond to the WebXR specs version
  75958. */
  75959. static readonly Version: number;
  75960. /**
  75961. * Populated with the last native XR Hit Results
  75962. */
  75963. lastNativeXRHitResults: XRHitResult[];
  75964. /**
  75965. * Triggered when new babylon (transformed) hit test results are available
  75966. */
  75967. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75968. /**
  75969. * Creates a new instance of the (legacy version) hit test feature
  75970. * @param _xrSessionManager an instance of WebXRSessionManager
  75971. * @param options options to use when constructing this feature
  75972. */
  75973. constructor(_xrSessionManager: WebXRSessionManager,
  75974. /**
  75975. * options to use when constructing this feature
  75976. */
  75977. options?: IWebXRLegacyHitTestOptions);
  75978. /**
  75979. * execute a hit test with an XR Ray
  75980. *
  75981. * @param xrSession a native xrSession that will execute this hit test
  75982. * @param xrRay the ray (position and direction) to use for ray-casting
  75983. * @param referenceSpace native XR reference space to use for the hit-test
  75984. * @param filter filter function that will filter the results
  75985. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75986. */
  75987. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75988. /**
  75989. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75990. * @param event the (select) event to use to select with
  75991. * @param referenceSpace the reference space to use for this hit test
  75992. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75993. */
  75994. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75995. /**
  75996. * attach this feature
  75997. * Will usually be called by the features manager
  75998. *
  75999. * @returns true if successful.
  76000. */
  76001. attach(): boolean;
  76002. /**
  76003. * detach this feature.
  76004. * Will usually be called by the features manager
  76005. *
  76006. * @returns true if successful.
  76007. */
  76008. detach(): boolean;
  76009. /**
  76010. * Dispose this feature and all of the resources attached
  76011. */
  76012. dispose(): void;
  76013. protected _onXRFrame(frame: XRFrame): void;
  76014. private _onHitTestResults;
  76015. private _onSelect;
  76016. }
  76017. }
  76018. declare module BABYLON {
  76019. /**
  76020. * Options used for hit testing (version 2)
  76021. */
  76022. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76023. /**
  76024. * Do not create a permanent hit test. Will usually be used when only
  76025. * transient inputs are needed.
  76026. */
  76027. disablePermanentHitTest?: boolean;
  76028. /**
  76029. * Enable transient (for example touch-based) hit test inspections
  76030. */
  76031. enableTransientHitTest?: boolean;
  76032. /**
  76033. * Offset ray for the permanent hit test
  76034. */
  76035. offsetRay?: Vector3;
  76036. /**
  76037. * Offset ray for the transient hit test
  76038. */
  76039. transientOffsetRay?: Vector3;
  76040. /**
  76041. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76042. */
  76043. useReferenceSpace?: boolean;
  76044. /**
  76045. * Override the default entity type(s) of the hit-test result
  76046. */
  76047. entityTypes?: XRHitTestTrackableType[];
  76048. }
  76049. /**
  76050. * Interface defining the babylon result of hit-test
  76051. */
  76052. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76053. /**
  76054. * The input source that generated this hit test (if transient)
  76055. */
  76056. inputSource?: XRInputSource;
  76057. /**
  76058. * Is this a transient hit test
  76059. */
  76060. isTransient?: boolean;
  76061. /**
  76062. * Position of the hit test result
  76063. */
  76064. position: Vector3;
  76065. /**
  76066. * Rotation of the hit test result
  76067. */
  76068. rotationQuaternion: Quaternion;
  76069. /**
  76070. * The native hit test result
  76071. */
  76072. xrHitResult: XRHitTestResult;
  76073. }
  76074. /**
  76075. * The currently-working hit-test module.
  76076. * Hit test (or Ray-casting) is used to interact with the real world.
  76077. * For further information read here - https://github.com/immersive-web/hit-test
  76078. *
  76079. * Tested on chrome (mobile) 80.
  76080. */
  76081. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  76082. /**
  76083. * options to use when constructing this feature
  76084. */
  76085. readonly options: IWebXRHitTestOptions;
  76086. private _tmpMat;
  76087. private _tmpPos;
  76088. private _tmpQuat;
  76089. private _transientXrHitTestSource;
  76090. private _xrHitTestSource;
  76091. private initHitTestSource;
  76092. /**
  76093. * The module's name
  76094. */
  76095. static readonly Name: string;
  76096. /**
  76097. * The (Babylon) version of this module.
  76098. * This is an integer representing the implementation version.
  76099. * This number does not correspond to the WebXR specs version
  76100. */
  76101. static readonly Version: number;
  76102. /**
  76103. * When set to true, each hit test will have its own position/rotation objects
  76104. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76105. * the developers will clone them or copy them as they see fit.
  76106. */
  76107. autoCloneTransformation: boolean;
  76108. /**
  76109. * Triggered when new babylon (transformed) hit test results are available
  76110. * Note - this will be called when results come back from the device. It can be an empty array!!
  76111. */
  76112. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76113. /**
  76114. * Use this to temporarily pause hit test checks.
  76115. */
  76116. paused: boolean;
  76117. /**
  76118. * Creates a new instance of the hit test feature
  76119. * @param _xrSessionManager an instance of WebXRSessionManager
  76120. * @param options options to use when constructing this feature
  76121. */
  76122. constructor(_xrSessionManager: WebXRSessionManager,
  76123. /**
  76124. * options to use when constructing this feature
  76125. */
  76126. options?: IWebXRHitTestOptions);
  76127. /**
  76128. * attach this feature
  76129. * Will usually be called by the features manager
  76130. *
  76131. * @returns true if successful.
  76132. */
  76133. attach(): boolean;
  76134. /**
  76135. * detach this feature.
  76136. * Will usually be called by the features manager
  76137. *
  76138. * @returns true if successful.
  76139. */
  76140. detach(): boolean;
  76141. /**
  76142. * Dispose this feature and all of the resources attached
  76143. */
  76144. dispose(): void;
  76145. protected _onXRFrame(frame: XRFrame): void;
  76146. private _processWebXRHitTestResult;
  76147. }
  76148. }
  76149. declare module BABYLON {
  76150. /**
  76151. * Configuration options of the anchor system
  76152. */
  76153. export interface IWebXRAnchorSystemOptions {
  76154. /**
  76155. * a node that will be used to convert local to world coordinates
  76156. */
  76157. worldParentNode?: TransformNode;
  76158. /**
  76159. * If set to true a reference of the created anchors will be kept until the next session starts
  76160. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76161. */
  76162. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76163. }
  76164. /**
  76165. * A babylon container for an XR Anchor
  76166. */
  76167. export interface IWebXRAnchor {
  76168. /**
  76169. * A babylon-assigned ID for this anchor
  76170. */
  76171. id: number;
  76172. /**
  76173. * Transformation matrix to apply to an object attached to this anchor
  76174. */
  76175. transformationMatrix: Matrix;
  76176. /**
  76177. * The native anchor object
  76178. */
  76179. xrAnchor: XRAnchor;
  76180. /**
  76181. * if defined, this object will be constantly updated by the anchor's position and rotation
  76182. */
  76183. attachedNode?: TransformNode;
  76184. /**
  76185. * Remove this anchor from the scene
  76186. */
  76187. remove(): void;
  76188. }
  76189. /**
  76190. * An implementation of the anchor system for WebXR.
  76191. * For further information see https://github.com/immersive-web/anchors/
  76192. */
  76193. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76194. private _options;
  76195. private _lastFrameDetected;
  76196. private _trackedAnchors;
  76197. private _referenceSpaceForFrameAnchors;
  76198. private _futureAnchors;
  76199. /**
  76200. * The module's name
  76201. */
  76202. static readonly Name: string;
  76203. /**
  76204. * The (Babylon) version of this module.
  76205. * This is an integer representing the implementation version.
  76206. * This number does not correspond to the WebXR specs version
  76207. */
  76208. static readonly Version: number;
  76209. /**
  76210. * Observers registered here will be executed when a new anchor was added to the session
  76211. */
  76212. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76213. /**
  76214. * Observers registered here will be executed when an anchor was removed from the session
  76215. */
  76216. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76217. /**
  76218. * Observers registered here will be executed when an existing anchor updates
  76219. * This can execute N times every frame
  76220. */
  76221. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76222. /**
  76223. * Set the reference space to use for anchor creation, when not using a hit test.
  76224. * Will default to the session's reference space if not defined
  76225. */
  76226. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76227. /**
  76228. * constructs a new anchor system
  76229. * @param _xrSessionManager an instance of WebXRSessionManager
  76230. * @param _options configuration object for this feature
  76231. */
  76232. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76233. private _tmpVector;
  76234. private _tmpQuaternion;
  76235. private _populateTmpTransformation;
  76236. /**
  76237. * Create a new anchor point using a hit test result at a specific point in the scene
  76238. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76239. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76240. *
  76241. * @param hitTestResult The hit test result to use for this anchor creation
  76242. * @param position an optional position offset for this anchor
  76243. * @param rotationQuaternion an optional rotation offset for this anchor
  76244. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  76245. */
  76246. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  76247. /**
  76248. * Add a new anchor at a specific position and rotation
  76249. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76250. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76251. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76252. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76253. *
  76254. * @param position the position in which to add an anchor
  76255. * @param rotationQuaternion an optional rotation for the anchor transformation
  76256. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76257. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  76258. */
  76259. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  76260. /**
  76261. * Get the list of anchors currently being tracked by the system
  76262. */
  76263. get anchors(): IWebXRAnchor[];
  76264. /**
  76265. * detach this feature.
  76266. * Will usually be called by the features manager
  76267. *
  76268. * @returns true if successful.
  76269. */
  76270. detach(): boolean;
  76271. /**
  76272. * Dispose this feature and all of the resources attached
  76273. */
  76274. dispose(): void;
  76275. protected _onXRFrame(frame: XRFrame): void;
  76276. /**
  76277. * avoiding using Array.find for global support.
  76278. * @param xrAnchor the plane to find in the array
  76279. */
  76280. private _findIndexInAnchorArray;
  76281. private _updateAnchorWithXRFrame;
  76282. private _createAnchorAtTransformation;
  76283. }
  76284. }
  76285. declare module BABYLON {
  76286. /**
  76287. * Options used in the plane detector module
  76288. */
  76289. export interface IWebXRPlaneDetectorOptions {
  76290. /**
  76291. * The node to use to transform the local results to world coordinates
  76292. */
  76293. worldParentNode?: TransformNode;
  76294. /**
  76295. * If set to true a reference of the created planes will be kept until the next session starts
  76296. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76297. */
  76298. doNotRemovePlanesOnSessionEnded?: boolean;
  76299. }
  76300. /**
  76301. * A babylon interface for a WebXR plane.
  76302. * A Plane is actually a polygon, built from N points in space
  76303. *
  76304. * Supported in chrome 79, not supported in canary 81 ATM
  76305. */
  76306. export interface IWebXRPlane {
  76307. /**
  76308. * a babylon-assigned ID for this polygon
  76309. */
  76310. id: number;
  76311. /**
  76312. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76313. */
  76314. polygonDefinition: Array<Vector3>;
  76315. /**
  76316. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76317. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76318. */
  76319. transformationMatrix: Matrix;
  76320. /**
  76321. * the native xr-plane object
  76322. */
  76323. xrPlane: XRPlane;
  76324. }
  76325. /**
  76326. * The plane detector is used to detect planes in the real world when in AR
  76327. * For more information see https://github.com/immersive-web/real-world-geometry/
  76328. */
  76329. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76330. private _options;
  76331. private _detectedPlanes;
  76332. private _enabled;
  76333. private _lastFrameDetected;
  76334. /**
  76335. * The module's name
  76336. */
  76337. static readonly Name: string;
  76338. /**
  76339. * The (Babylon) version of this module.
  76340. * This is an integer representing the implementation version.
  76341. * This number does not correspond to the WebXR specs version
  76342. */
  76343. static readonly Version: number;
  76344. /**
  76345. * Observers registered here will be executed when a new plane was added to the session
  76346. */
  76347. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76348. /**
  76349. * Observers registered here will be executed when a plane is no longer detected in the session
  76350. */
  76351. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76352. /**
  76353. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76354. * This can execute N times every frame
  76355. */
  76356. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76357. /**
  76358. * construct a new Plane Detector
  76359. * @param _xrSessionManager an instance of xr Session manager
  76360. * @param _options configuration to use when constructing this feature
  76361. */
  76362. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76363. /**
  76364. * detach this feature.
  76365. * Will usually be called by the features manager
  76366. *
  76367. * @returns true if successful.
  76368. */
  76369. detach(): boolean;
  76370. /**
  76371. * Dispose this feature and all of the resources attached
  76372. */
  76373. dispose(): void;
  76374. /**
  76375. * Check if the needed objects are defined.
  76376. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76377. */
  76378. isCompatible(): boolean;
  76379. protected _onXRFrame(frame: XRFrame): void;
  76380. private _init;
  76381. private _updatePlaneWithXRPlane;
  76382. /**
  76383. * avoiding using Array.find for global support.
  76384. * @param xrPlane the plane to find in the array
  76385. */
  76386. private findIndexInPlaneArray;
  76387. }
  76388. }
  76389. declare module BABYLON {
  76390. /**
  76391. * Options interface for the background remover plugin
  76392. */
  76393. export interface IWebXRBackgroundRemoverOptions {
  76394. /**
  76395. * Further background meshes to disable when entering AR
  76396. */
  76397. backgroundMeshes?: AbstractMesh[];
  76398. /**
  76399. * flags to configure the removal of the environment helper.
  76400. * If not set, the entire background will be removed. If set, flags should be set as well.
  76401. */
  76402. environmentHelperRemovalFlags?: {
  76403. /**
  76404. * Should the skybox be removed (default false)
  76405. */
  76406. skyBox?: boolean;
  76407. /**
  76408. * Should the ground be removed (default false)
  76409. */
  76410. ground?: boolean;
  76411. };
  76412. /**
  76413. * don't disable the environment helper
  76414. */
  76415. ignoreEnvironmentHelper?: boolean;
  76416. }
  76417. /**
  76418. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76419. */
  76420. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76421. /**
  76422. * read-only options to be used in this module
  76423. */
  76424. readonly options: IWebXRBackgroundRemoverOptions;
  76425. /**
  76426. * The module's name
  76427. */
  76428. static readonly Name: string;
  76429. /**
  76430. * The (Babylon) version of this module.
  76431. * This is an integer representing the implementation version.
  76432. * This number does not correspond to the WebXR specs version
  76433. */
  76434. static readonly Version: number;
  76435. /**
  76436. * registered observers will be triggered when the background state changes
  76437. */
  76438. onBackgroundStateChangedObservable: Observable<boolean>;
  76439. /**
  76440. * constructs a new background remover module
  76441. * @param _xrSessionManager the session manager for this module
  76442. * @param options read-only options to be used in this module
  76443. */
  76444. constructor(_xrSessionManager: WebXRSessionManager,
  76445. /**
  76446. * read-only options to be used in this module
  76447. */
  76448. options?: IWebXRBackgroundRemoverOptions);
  76449. /**
  76450. * attach this feature
  76451. * Will usually be called by the features manager
  76452. *
  76453. * @returns true if successful.
  76454. */
  76455. attach(): boolean;
  76456. /**
  76457. * detach this feature.
  76458. * Will usually be called by the features manager
  76459. *
  76460. * @returns true if successful.
  76461. */
  76462. detach(): boolean;
  76463. /**
  76464. * Dispose this feature and all of the resources attached
  76465. */
  76466. dispose(): void;
  76467. protected _onXRFrame(_xrFrame: XRFrame): void;
  76468. private _setBackgroundState;
  76469. }
  76470. }
  76471. declare module BABYLON {
  76472. /**
  76473. * Options for the controller physics feature
  76474. */
  76475. export class IWebXRControllerPhysicsOptions {
  76476. /**
  76477. * Should the headset get its own impostor
  76478. */
  76479. enableHeadsetImpostor?: boolean;
  76480. /**
  76481. * Optional parameters for the headset impostor
  76482. */
  76483. headsetImpostorParams?: {
  76484. /**
  76485. * The type of impostor to create. Default is sphere
  76486. */
  76487. impostorType: number;
  76488. /**
  76489. * the size of the impostor. Defaults to 10cm
  76490. */
  76491. impostorSize?: number | {
  76492. width: number;
  76493. height: number;
  76494. depth: number;
  76495. };
  76496. /**
  76497. * Friction definitions
  76498. */
  76499. friction?: number;
  76500. /**
  76501. * Restitution
  76502. */
  76503. restitution?: number;
  76504. };
  76505. /**
  76506. * The physics properties of the future impostors
  76507. */
  76508. physicsProperties?: {
  76509. /**
  76510. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76511. * Note that this requires a physics engine that supports mesh impostors!
  76512. */
  76513. useControllerMesh?: boolean;
  76514. /**
  76515. * The type of impostor to create. Default is sphere
  76516. */
  76517. impostorType?: number;
  76518. /**
  76519. * the size of the impostor. Defaults to 10cm
  76520. */
  76521. impostorSize?: number | {
  76522. width: number;
  76523. height: number;
  76524. depth: number;
  76525. };
  76526. /**
  76527. * Friction definitions
  76528. */
  76529. friction?: number;
  76530. /**
  76531. * Restitution
  76532. */
  76533. restitution?: number;
  76534. };
  76535. /**
  76536. * the xr input to use with this pointer selection
  76537. */
  76538. xrInput: WebXRInput;
  76539. }
  76540. /**
  76541. * Add physics impostor to your webxr controllers,
  76542. * including naive calculation of their linear and angular velocity
  76543. */
  76544. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76545. private readonly _options;
  76546. private _attachController;
  76547. private _controllers;
  76548. private _debugMode;
  76549. private _delta;
  76550. private _headsetImpostor?;
  76551. private _headsetMesh?;
  76552. private _lastTimestamp;
  76553. private _tmpQuaternion;
  76554. private _tmpVector;
  76555. /**
  76556. * The module's name
  76557. */
  76558. static readonly Name: string;
  76559. /**
  76560. * The (Babylon) version of this module.
  76561. * This is an integer representing the implementation version.
  76562. * This number does not correspond to the webxr specs version
  76563. */
  76564. static readonly Version: number;
  76565. /**
  76566. * Construct a new Controller Physics Feature
  76567. * @param _xrSessionManager the corresponding xr session manager
  76568. * @param _options options to create this feature with
  76569. */
  76570. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76571. /**
  76572. * @hidden
  76573. * enable debugging - will show console outputs and the impostor mesh
  76574. */
  76575. _enablePhysicsDebug(): void;
  76576. /**
  76577. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76578. * @param xrController the controller to add
  76579. */
  76580. addController(xrController: WebXRInputSource): void;
  76581. /**
  76582. * attach this feature
  76583. * Will usually be called by the features manager
  76584. *
  76585. * @returns true if successful.
  76586. */
  76587. attach(): boolean;
  76588. /**
  76589. * detach this feature.
  76590. * Will usually be called by the features manager
  76591. *
  76592. * @returns true if successful.
  76593. */
  76594. detach(): boolean;
  76595. /**
  76596. * Get the headset impostor, if enabled
  76597. * @returns the impostor
  76598. */
  76599. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76600. /**
  76601. * Get the physics impostor of a specific controller.
  76602. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76603. * @param controller the controller or the controller id of which to get the impostor
  76604. * @returns the impostor or null
  76605. */
  76606. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76607. /**
  76608. * Update the physics properties provided in the constructor
  76609. * @param newProperties the new properties object
  76610. */
  76611. setPhysicsProperties(newProperties: {
  76612. impostorType?: number;
  76613. impostorSize?: number | {
  76614. width: number;
  76615. height: number;
  76616. depth: number;
  76617. };
  76618. friction?: number;
  76619. restitution?: number;
  76620. }): void;
  76621. protected _onXRFrame(_xrFrame: any): void;
  76622. private _detachController;
  76623. }
  76624. }
  76625. declare module BABYLON {
  76626. /**
  76627. * A babylon interface for a "WebXR" feature point.
  76628. * Represents the position and confidence value of a given feature point.
  76629. */
  76630. export interface IWebXRFeaturePoint {
  76631. /**
  76632. * Represents the position of the feature point in world space.
  76633. */
  76634. position: Vector3;
  76635. /**
  76636. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  76637. */
  76638. confidenceValue: number;
  76639. }
  76640. /**
  76641. * The feature point system is used to detect feature points from real world geometry.
  76642. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  76643. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  76644. */
  76645. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  76646. private _enabled;
  76647. private _featurePointCloud;
  76648. /**
  76649. * The module's name
  76650. */
  76651. static readonly Name: string;
  76652. /**
  76653. * The (Babylon) version of this module.
  76654. * This is an integer representing the implementation version.
  76655. * This number does not correspond to the WebXR specs version
  76656. */
  76657. static readonly Version: number;
  76658. /**
  76659. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76660. * Will notify the observers about which feature points have been added.
  76661. */
  76662. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76663. /**
  76664. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76665. * Will notify the observers about which feature points have been updated.
  76666. */
  76667. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76668. /**
  76669. * The current feature point cloud maintained across frames.
  76670. */
  76671. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76672. /**
  76673. * construct the feature point system
  76674. * @param _xrSessionManager an instance of xr Session manager
  76675. */
  76676. constructor(_xrSessionManager: WebXRSessionManager);
  76677. /**
  76678. * Detach this feature.
  76679. * Will usually be called by the features manager
  76680. *
  76681. * @returns true if successful.
  76682. */
  76683. detach(): boolean;
  76684. /**
  76685. * Dispose this feature and all of the resources attached
  76686. */
  76687. dispose(): void;
  76688. /**
  76689. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76690. */
  76691. protected _onXRFrame(frame: XRFrame): void;
  76692. /**
  76693. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76694. */
  76695. private _init;
  76696. }
  76697. }
  76698. declare module BABYLON {
  76699. /**
  76700. * Configuration interface for the hand tracking feature
  76701. */
  76702. export interface IWebXRHandTrackingOptions {
  76703. /**
  76704. * The xrInput that will be used as source for new hands
  76705. */
  76706. xrInput: WebXRInput;
  76707. /**
  76708. * Configuration object for the joint meshes
  76709. */
  76710. jointMeshes?: {
  76711. /**
  76712. * Should the meshes created be invisible (defaults to false)
  76713. */
  76714. invisible?: boolean;
  76715. /**
  76716. * A source mesh to be used to create instances. Defaults to a sphere.
  76717. * This mesh will be the source for all other (25) meshes.
  76718. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76719. */
  76720. sourceMesh?: Mesh;
  76721. /**
  76722. * This function will be called after a mesh was created for a specific joint.
  76723. * Using this function you can either manipulate the instance or return a new mesh.
  76724. * When returning a new mesh the instance created before will be disposed
  76725. */
  76726. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76727. /**
  76728. * Should the source mesh stay visible. Defaults to false
  76729. */
  76730. keepOriginalVisible?: boolean;
  76731. /**
  76732. * Scale factor for all instances (defaults to 2)
  76733. */
  76734. scaleFactor?: number;
  76735. /**
  76736. * Should each instance have its own physics impostor
  76737. */
  76738. enablePhysics?: boolean;
  76739. /**
  76740. * If enabled, override default physics properties
  76741. */
  76742. physicsProps?: {
  76743. friction?: number;
  76744. restitution?: number;
  76745. impostorType?: number;
  76746. };
  76747. /**
  76748. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  76749. */
  76750. handMesh?: AbstractMesh;
  76751. };
  76752. }
  76753. /**
  76754. * Parts of the hands divided to writs and finger names
  76755. */
  76756. export const enum HandPart {
  76757. /**
  76758. * HandPart - Wrist
  76759. */
  76760. WRIST = "wrist",
  76761. /**
  76762. * HandPart - The THumb
  76763. */
  76764. THUMB = "thumb",
  76765. /**
  76766. * HandPart - Index finger
  76767. */
  76768. INDEX = "index",
  76769. /**
  76770. * HandPart - Middle finger
  76771. */
  76772. MIDDLE = "middle",
  76773. /**
  76774. * HandPart - Ring finger
  76775. */
  76776. RING = "ring",
  76777. /**
  76778. * HandPart - Little finger
  76779. */
  76780. LITTLE = "little"
  76781. }
  76782. /**
  76783. * Representing a single hand (with its corresponding native XRHand object)
  76784. */
  76785. export class WebXRHand implements IDisposable {
  76786. /** the controller to which the hand correlates */
  76787. readonly xrController: WebXRInputSource;
  76788. /** the meshes to be used to track the hand joints */
  76789. readonly trackedMeshes: AbstractMesh[];
  76790. /**
  76791. * Hand-parts definition (key is HandPart)
  76792. */
  76793. handPartsDefinition: {
  76794. [key: string]: number[];
  76795. };
  76796. /**
  76797. * Populate the HandPartsDefinition object.
  76798. * This is called as a side effect since certain browsers don't have XRHand defined.
  76799. */
  76800. private generateHandPartsDefinition;
  76801. /**
  76802. * Construct a new hand object
  76803. * @param xrController the controller to which the hand correlates
  76804. * @param trackedMeshes the meshes to be used to track the hand joints
  76805. */
  76806. constructor(
  76807. /** the controller to which the hand correlates */
  76808. xrController: WebXRInputSource,
  76809. /** the meshes to be used to track the hand joints */
  76810. trackedMeshes: AbstractMesh[]);
  76811. /**
  76812. * Update this hand from the latest xr frame
  76813. * @param xrFrame xrFrame to update from
  76814. * @param referenceSpace The current viewer reference space
  76815. * @param scaleFactor optional scale factor for the meshes
  76816. */
  76817. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  76818. /**
  76819. * Get meshes of part of the hand
  76820. * @param part the part of hand to get
  76821. * @returns An array of meshes that correlate to the hand part requested
  76822. */
  76823. getHandPartMeshes(part: HandPart): AbstractMesh[];
  76824. /**
  76825. * Dispose this Hand object
  76826. */
  76827. dispose(): void;
  76828. }
  76829. /**
  76830. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  76831. */
  76832. export class WebXRHandTracking extends WebXRAbstractFeature {
  76833. /**
  76834. * options to use when constructing this feature
  76835. */
  76836. readonly options: IWebXRHandTrackingOptions;
  76837. private static _idCounter;
  76838. /**
  76839. * The module's name
  76840. */
  76841. static readonly Name: string;
  76842. /**
  76843. * The (Babylon) version of this module.
  76844. * This is an integer representing the implementation version.
  76845. * This number does not correspond to the WebXR specs version
  76846. */
  76847. static readonly Version: number;
  76848. /**
  76849. * This observable will notify registered observers when a new hand object was added and initialized
  76850. */
  76851. onHandAddedObservable: Observable<WebXRHand>;
  76852. /**
  76853. * This observable will notify its observers right before the hand object is disposed
  76854. */
  76855. onHandRemovedObservable: Observable<WebXRHand>;
  76856. private _hands;
  76857. /**
  76858. * Creates a new instance of the hit test feature
  76859. * @param _xrSessionManager an instance of WebXRSessionManager
  76860. * @param options options to use when constructing this feature
  76861. */
  76862. constructor(_xrSessionManager: WebXRSessionManager,
  76863. /**
  76864. * options to use when constructing this feature
  76865. */
  76866. options: IWebXRHandTrackingOptions);
  76867. /**
  76868. * Check if the needed objects are defined.
  76869. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76870. */
  76871. isCompatible(): boolean;
  76872. /**
  76873. * attach this feature
  76874. * Will usually be called by the features manager
  76875. *
  76876. * @returns true if successful.
  76877. */
  76878. attach(): boolean;
  76879. /**
  76880. * detach this feature.
  76881. * Will usually be called by the features manager
  76882. *
  76883. * @returns true if successful.
  76884. */
  76885. detach(): boolean;
  76886. /**
  76887. * Dispose this feature and all of the resources attached
  76888. */
  76889. dispose(): void;
  76890. /**
  76891. * Get the hand object according to the controller id
  76892. * @param controllerId the controller id to which we want to get the hand
  76893. * @returns null if not found or the WebXRHand object if found
  76894. */
  76895. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76896. /**
  76897. * Get a hand object according to the requested handedness
  76898. * @param handedness the handedness to request
  76899. * @returns null if not found or the WebXRHand object if found
  76900. */
  76901. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76902. protected _onXRFrame(_xrFrame: XRFrame): void;
  76903. private _attachHand;
  76904. private _detachHand;
  76905. }
  76906. }
  76907. declare module BABYLON {
  76908. /**
  76909. * The motion controller class for all microsoft mixed reality controllers
  76910. */
  76911. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76912. protected readonly _mapping: {
  76913. defaultButton: {
  76914. valueNodeName: string;
  76915. unpressedNodeName: string;
  76916. pressedNodeName: string;
  76917. };
  76918. defaultAxis: {
  76919. valueNodeName: string;
  76920. minNodeName: string;
  76921. maxNodeName: string;
  76922. };
  76923. buttons: {
  76924. "xr-standard-trigger": {
  76925. rootNodeName: string;
  76926. componentProperty: string;
  76927. states: string[];
  76928. };
  76929. "xr-standard-squeeze": {
  76930. rootNodeName: string;
  76931. componentProperty: string;
  76932. states: string[];
  76933. };
  76934. "xr-standard-touchpad": {
  76935. rootNodeName: string;
  76936. labelAnchorNodeName: string;
  76937. touchPointNodeName: string;
  76938. };
  76939. "xr-standard-thumbstick": {
  76940. rootNodeName: string;
  76941. componentProperty: string;
  76942. states: string[];
  76943. };
  76944. };
  76945. axes: {
  76946. "xr-standard-touchpad": {
  76947. "x-axis": {
  76948. rootNodeName: string;
  76949. };
  76950. "y-axis": {
  76951. rootNodeName: string;
  76952. };
  76953. };
  76954. "xr-standard-thumbstick": {
  76955. "x-axis": {
  76956. rootNodeName: string;
  76957. };
  76958. "y-axis": {
  76959. rootNodeName: string;
  76960. };
  76961. };
  76962. };
  76963. };
  76964. /**
  76965. * The base url used to load the left and right controller models
  76966. */
  76967. static MODEL_BASE_URL: string;
  76968. /**
  76969. * The name of the left controller model file
  76970. */
  76971. static MODEL_LEFT_FILENAME: string;
  76972. /**
  76973. * The name of the right controller model file
  76974. */
  76975. static MODEL_RIGHT_FILENAME: string;
  76976. profileId: string;
  76977. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76978. protected _getFilenameAndPath(): {
  76979. filename: string;
  76980. path: string;
  76981. };
  76982. protected _getModelLoadingConstraints(): boolean;
  76983. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76984. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76985. protected _updateModel(): void;
  76986. }
  76987. }
  76988. declare module BABYLON {
  76989. /**
  76990. * The motion controller class for oculus touch (quest, rift).
  76991. * This class supports legacy mapping as well the standard xr mapping
  76992. */
  76993. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76994. private _forceLegacyControllers;
  76995. private _modelRootNode;
  76996. /**
  76997. * The base url used to load the left and right controller models
  76998. */
  76999. static MODEL_BASE_URL: string;
  77000. /**
  77001. * The name of the left controller model file
  77002. */
  77003. static MODEL_LEFT_FILENAME: string;
  77004. /**
  77005. * The name of the right controller model file
  77006. */
  77007. static MODEL_RIGHT_FILENAME: string;
  77008. /**
  77009. * Base Url for the Quest controller model.
  77010. */
  77011. static QUEST_MODEL_BASE_URL: string;
  77012. profileId: string;
  77013. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  77014. protected _getFilenameAndPath(): {
  77015. filename: string;
  77016. path: string;
  77017. };
  77018. protected _getModelLoadingConstraints(): boolean;
  77019. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77020. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77021. protected _updateModel(): void;
  77022. /**
  77023. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  77024. * between the touch and touch 2.
  77025. */
  77026. private _isQuest;
  77027. }
  77028. }
  77029. declare module BABYLON {
  77030. /**
  77031. * The motion controller class for the standard HTC-Vive controllers
  77032. */
  77033. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  77034. private _modelRootNode;
  77035. /**
  77036. * The base url used to load the left and right controller models
  77037. */
  77038. static MODEL_BASE_URL: string;
  77039. /**
  77040. * File name for the controller model.
  77041. */
  77042. static MODEL_FILENAME: string;
  77043. profileId: string;
  77044. /**
  77045. * Create a new Vive motion controller object
  77046. * @param scene the scene to use to create this controller
  77047. * @param gamepadObject the corresponding gamepad object
  77048. * @param handedness the handedness of the controller
  77049. */
  77050. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77051. protected _getFilenameAndPath(): {
  77052. filename: string;
  77053. path: string;
  77054. };
  77055. protected _getModelLoadingConstraints(): boolean;
  77056. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77057. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77058. protected _updateModel(): void;
  77059. }
  77060. }
  77061. declare module BABYLON {
  77062. /**
  77063. * A cursor which tracks a point on a path
  77064. */
  77065. export class PathCursor {
  77066. private path;
  77067. /**
  77068. * Stores path cursor callbacks for when an onchange event is triggered
  77069. */
  77070. private _onchange;
  77071. /**
  77072. * The value of the path cursor
  77073. */
  77074. value: number;
  77075. /**
  77076. * The animation array of the path cursor
  77077. */
  77078. animations: Animation[];
  77079. /**
  77080. * Initializes the path cursor
  77081. * @param path The path to track
  77082. */
  77083. constructor(path: Path2);
  77084. /**
  77085. * Gets the cursor point on the path
  77086. * @returns A point on the path cursor at the cursor location
  77087. */
  77088. getPoint(): Vector3;
  77089. /**
  77090. * Moves the cursor ahead by the step amount
  77091. * @param step The amount to move the cursor forward
  77092. * @returns This path cursor
  77093. */
  77094. moveAhead(step?: number): PathCursor;
  77095. /**
  77096. * Moves the cursor behind by the step amount
  77097. * @param step The amount to move the cursor back
  77098. * @returns This path cursor
  77099. */
  77100. moveBack(step?: number): PathCursor;
  77101. /**
  77102. * Moves the cursor by the step amount
  77103. * If the step amount is greater than one, an exception is thrown
  77104. * @param step The amount to move the cursor
  77105. * @returns This path cursor
  77106. */
  77107. move(step: number): PathCursor;
  77108. /**
  77109. * Ensures that the value is limited between zero and one
  77110. * @returns This path cursor
  77111. */
  77112. private ensureLimits;
  77113. /**
  77114. * Runs onchange callbacks on change (used by the animation engine)
  77115. * @returns This path cursor
  77116. */
  77117. private raiseOnChange;
  77118. /**
  77119. * Executes a function on change
  77120. * @param f A path cursor onchange callback
  77121. * @returns This path cursor
  77122. */
  77123. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77124. }
  77125. }
  77126. declare module BABYLON {
  77127. /** @hidden */
  77128. export var blurPixelShader: {
  77129. name: string;
  77130. shader: string;
  77131. };
  77132. }
  77133. declare module BABYLON {
  77134. /** @hidden */
  77135. export var pointCloudVertexDeclaration: {
  77136. name: string;
  77137. shader: string;
  77138. };
  77139. }
  77140. // Mixins
  77141. interface Window {
  77142. mozIndexedDB: IDBFactory;
  77143. webkitIndexedDB: IDBFactory;
  77144. msIndexedDB: IDBFactory;
  77145. webkitURL: typeof URL;
  77146. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  77147. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  77148. WebGLRenderingContext: WebGLRenderingContext;
  77149. MSGesture: MSGesture;
  77150. CANNON: any;
  77151. AudioContext: AudioContext;
  77152. webkitAudioContext: AudioContext;
  77153. PointerEvent: any;
  77154. Math: Math;
  77155. Uint8Array: Uint8ArrayConstructor;
  77156. Float32Array: Float32ArrayConstructor;
  77157. mozURL: typeof URL;
  77158. msURL: typeof URL;
  77159. VRFrameData: any; // WebVR, from specs 1.1
  77160. DracoDecoderModule: any;
  77161. setImmediate(handler: (...args: any[]) => void): number;
  77162. }
  77163. interface HTMLCanvasElement {
  77164. requestPointerLock(): void;
  77165. msRequestPointerLock?(): void;
  77166. mozRequestPointerLock?(): void;
  77167. webkitRequestPointerLock?(): void;
  77168. /** Track wether a record is in progress */
  77169. isRecording: boolean;
  77170. /** Capture Stream method defined by some browsers */
  77171. captureStream(fps?: number): MediaStream;
  77172. }
  77173. interface CanvasRenderingContext2D {
  77174. msImageSmoothingEnabled: boolean;
  77175. }
  77176. interface MouseEvent {
  77177. mozMovementX: number;
  77178. mozMovementY: number;
  77179. webkitMovementX: number;
  77180. webkitMovementY: number;
  77181. msMovementX: number;
  77182. msMovementY: number;
  77183. }
  77184. interface Navigator {
  77185. mozGetVRDevices: (any: any) => any;
  77186. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77187. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77188. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77189. webkitGetGamepads(): Gamepad[];
  77190. msGetGamepads(): Gamepad[];
  77191. webkitGamepads(): Gamepad[];
  77192. }
  77193. interface HTMLVideoElement {
  77194. mozSrcObject: any;
  77195. }
  77196. interface Math {
  77197. fround(x: number): number;
  77198. imul(a: number, b: number): number;
  77199. }
  77200. interface WebGLRenderingContext {
  77201. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  77202. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  77203. vertexAttribDivisor(index: number, divisor: number): void;
  77204. createVertexArray(): any;
  77205. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  77206. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  77207. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  77208. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  77209. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  77210. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  77211. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  77212. // Queries
  77213. createQuery(): WebGLQuery;
  77214. deleteQuery(query: WebGLQuery): void;
  77215. beginQuery(target: number, query: WebGLQuery): void;
  77216. endQuery(target: number): void;
  77217. getQueryParameter(query: WebGLQuery, pname: number): any;
  77218. getQuery(target: number, pname: number): any;
  77219. MAX_SAMPLES: number;
  77220. RGBA8: number;
  77221. READ_FRAMEBUFFER: number;
  77222. DRAW_FRAMEBUFFER: number;
  77223. UNIFORM_BUFFER: number;
  77224. HALF_FLOAT_OES: number;
  77225. RGBA16F: number;
  77226. RGBA32F: number;
  77227. R32F: number;
  77228. RG32F: number;
  77229. RGB32F: number;
  77230. R16F: number;
  77231. RG16F: number;
  77232. RGB16F: number;
  77233. RED: number;
  77234. RG: number;
  77235. R8: number;
  77236. RG8: number;
  77237. UNSIGNED_INT_24_8: number;
  77238. DEPTH24_STENCIL8: number;
  77239. MIN: number;
  77240. MAX: number;
  77241. /* Multiple Render Targets */
  77242. drawBuffers(buffers: number[]): void;
  77243. readBuffer(src: number): void;
  77244. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  77245. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  77246. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  77247. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  77248. // Occlusion Query
  77249. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  77250. ANY_SAMPLES_PASSED: number;
  77251. QUERY_RESULT_AVAILABLE: number;
  77252. QUERY_RESULT: number;
  77253. }
  77254. interface WebGLProgram {
  77255. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  77256. }
  77257. interface EXT_disjoint_timer_query {
  77258. QUERY_COUNTER_BITS_EXT: number;
  77259. TIME_ELAPSED_EXT: number;
  77260. TIMESTAMP_EXT: number;
  77261. GPU_DISJOINT_EXT: number;
  77262. QUERY_RESULT_EXT: number;
  77263. QUERY_RESULT_AVAILABLE_EXT: number;
  77264. queryCounterEXT(query: WebGLQuery, target: number): void;
  77265. createQueryEXT(): WebGLQuery;
  77266. beginQueryEXT(target: number, query: WebGLQuery): void;
  77267. endQueryEXT(target: number): void;
  77268. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  77269. deleteQueryEXT(query: WebGLQuery): void;
  77270. }
  77271. interface WebGLUniformLocation {
  77272. _currentState: any;
  77273. }
  77274. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  77275. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  77276. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  77277. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77278. interface WebGLRenderingContext {
  77279. readonly RASTERIZER_DISCARD: number;
  77280. readonly DEPTH_COMPONENT24: number;
  77281. readonly TEXTURE_3D: number;
  77282. readonly TEXTURE_2D_ARRAY: number;
  77283. readonly TEXTURE_COMPARE_FUNC: number;
  77284. readonly TEXTURE_COMPARE_MODE: number;
  77285. readonly COMPARE_REF_TO_TEXTURE: number;
  77286. readonly TEXTURE_WRAP_R: number;
  77287. readonly HALF_FLOAT: number;
  77288. readonly RGB8: number;
  77289. readonly RED_INTEGER: number;
  77290. readonly RG_INTEGER: number;
  77291. readonly RGB_INTEGER: number;
  77292. readonly RGBA_INTEGER: number;
  77293. readonly R8_SNORM: number;
  77294. readonly RG8_SNORM: number;
  77295. readonly RGB8_SNORM: number;
  77296. readonly RGBA8_SNORM: number;
  77297. readonly R8I: number;
  77298. readonly RG8I: number;
  77299. readonly RGB8I: number;
  77300. readonly RGBA8I: number;
  77301. readonly R8UI: number;
  77302. readonly RG8UI: number;
  77303. readonly RGB8UI: number;
  77304. readonly RGBA8UI: number;
  77305. readonly R16I: number;
  77306. readonly RG16I: number;
  77307. readonly RGB16I: number;
  77308. readonly RGBA16I: number;
  77309. readonly R16UI: number;
  77310. readonly RG16UI: number;
  77311. readonly RGB16UI: number;
  77312. readonly RGBA16UI: number;
  77313. readonly R32I: number;
  77314. readonly RG32I: number;
  77315. readonly RGB32I: number;
  77316. readonly RGBA32I: number;
  77317. readonly R32UI: number;
  77318. readonly RG32UI: number;
  77319. readonly RGB32UI: number;
  77320. readonly RGBA32UI: number;
  77321. readonly RGB10_A2UI: number;
  77322. readonly R11F_G11F_B10F: number;
  77323. readonly RGB9_E5: number;
  77324. readonly RGB10_A2: number;
  77325. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  77326. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  77327. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  77328. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77329. readonly DEPTH_COMPONENT32F: number;
  77330. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  77331. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  77332. 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;
  77333. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  77334. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  77335. readonly TRANSFORM_FEEDBACK: number;
  77336. readonly INTERLEAVED_ATTRIBS: number;
  77337. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  77338. createTransformFeedback(): WebGLTransformFeedback;
  77339. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  77340. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  77341. beginTransformFeedback(primitiveMode: number): void;
  77342. endTransformFeedback(): void;
  77343. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  77344. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77345. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77346. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77347. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  77348. }
  77349. interface ImageBitmap {
  77350. readonly width: number;
  77351. readonly height: number;
  77352. close(): void;
  77353. }
  77354. interface WebGLQuery extends WebGLObject {
  77355. }
  77356. declare var WebGLQuery: {
  77357. prototype: WebGLQuery;
  77358. new(): WebGLQuery;
  77359. };
  77360. interface WebGLSampler extends WebGLObject {
  77361. }
  77362. declare var WebGLSampler: {
  77363. prototype: WebGLSampler;
  77364. new(): WebGLSampler;
  77365. };
  77366. interface WebGLSync extends WebGLObject {
  77367. }
  77368. declare var WebGLSync: {
  77369. prototype: WebGLSync;
  77370. new(): WebGLSync;
  77371. };
  77372. interface WebGLTransformFeedback extends WebGLObject {
  77373. }
  77374. declare var WebGLTransformFeedback: {
  77375. prototype: WebGLTransformFeedback;
  77376. new(): WebGLTransformFeedback;
  77377. };
  77378. interface WebGLVertexArrayObject extends WebGLObject {
  77379. }
  77380. declare var WebGLVertexArrayObject: {
  77381. prototype: WebGLVertexArrayObject;
  77382. new(): WebGLVertexArrayObject;
  77383. };
  77384. // Type definitions for WebVR API
  77385. // Project: https://w3c.github.io/webvr/
  77386. // Definitions by: six a <https://github.com/lostfictions>
  77387. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77388. interface VRDisplay extends EventTarget {
  77389. /**
  77390. * Dictionary of capabilities describing the VRDisplay.
  77391. */
  77392. readonly capabilities: VRDisplayCapabilities;
  77393. /**
  77394. * z-depth defining the far plane of the eye view frustum
  77395. * enables mapping of values in the render target depth
  77396. * attachment to scene coordinates. Initially set to 10000.0.
  77397. */
  77398. depthFar: number;
  77399. /**
  77400. * z-depth defining the near plane of the eye view frustum
  77401. * enables mapping of values in the render target depth
  77402. * attachment to scene coordinates. Initially set to 0.01.
  77403. */
  77404. depthNear: number;
  77405. /**
  77406. * An identifier for this distinct VRDisplay. Used as an
  77407. * association point in the Gamepad API.
  77408. */
  77409. readonly displayId: number;
  77410. /**
  77411. * A display name, a user-readable name identifying it.
  77412. */
  77413. readonly displayName: string;
  77414. readonly isConnected: boolean;
  77415. readonly isPresenting: boolean;
  77416. /**
  77417. * If this VRDisplay supports room-scale experiences, the optional
  77418. * stage attribute contains details on the room-scale parameters.
  77419. */
  77420. readonly stageParameters: VRStageParameters | null;
  77421. /**
  77422. * Passing the value returned by `requestAnimationFrame` to
  77423. * `cancelAnimationFrame` will unregister the callback.
  77424. * @param handle Define the hanle of the request to cancel
  77425. */
  77426. cancelAnimationFrame(handle: number): void;
  77427. /**
  77428. * Stops presenting to the VRDisplay.
  77429. * @returns a promise to know when it stopped
  77430. */
  77431. exitPresent(): Promise<void>;
  77432. /**
  77433. * Return the current VREyeParameters for the given eye.
  77434. * @param whichEye Define the eye we want the parameter for
  77435. * @returns the eye parameters
  77436. */
  77437. getEyeParameters(whichEye: string): VREyeParameters;
  77438. /**
  77439. * Populates the passed VRFrameData with the information required to render
  77440. * the current frame.
  77441. * @param frameData Define the data structure to populate
  77442. * @returns true if ok otherwise false
  77443. */
  77444. getFrameData(frameData: VRFrameData): boolean;
  77445. /**
  77446. * Get the layers currently being presented.
  77447. * @returns the list of VR layers
  77448. */
  77449. getLayers(): VRLayer[];
  77450. /**
  77451. * Return a VRPose containing the future predicted pose of the VRDisplay
  77452. * when the current frame will be presented. The value returned will not
  77453. * change until JavaScript has returned control to the browser.
  77454. *
  77455. * The VRPose will contain the position, orientation, velocity,
  77456. * and acceleration of each of these properties.
  77457. * @returns the pose object
  77458. */
  77459. getPose(): VRPose;
  77460. /**
  77461. * Return the current instantaneous pose of the VRDisplay, with no
  77462. * prediction applied.
  77463. * @returns the current instantaneous pose
  77464. */
  77465. getImmediatePose(): VRPose;
  77466. /**
  77467. * The callback passed to `requestAnimationFrame` will be called
  77468. * any time a new frame should be rendered. When the VRDisplay is
  77469. * presenting the callback will be called at the native refresh
  77470. * rate of the HMD. When not presenting this function acts
  77471. * identically to how window.requestAnimationFrame acts. Content should
  77472. * make no assumptions of frame rate or vsync behavior as the HMD runs
  77473. * asynchronously from other displays and at differing refresh rates.
  77474. * @param callback Define the eaction to run next frame
  77475. * @returns the request handle it
  77476. */
  77477. requestAnimationFrame(callback: FrameRequestCallback): number;
  77478. /**
  77479. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  77480. * Repeat calls while already presenting will update the VRLayers being displayed.
  77481. * @param layers Define the list of layer to present
  77482. * @returns a promise to know when the request has been fulfilled
  77483. */
  77484. requestPresent(layers: VRLayer[]): Promise<void>;
  77485. /**
  77486. * Reset the pose for this display, treating its current position and
  77487. * orientation as the "origin/zero" values. VRPose.position,
  77488. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  77489. * updated when calling resetPose(). This should be called in only
  77490. * sitting-space experiences.
  77491. */
  77492. resetPose(): void;
  77493. /**
  77494. * The VRLayer provided to the VRDisplay will be captured and presented
  77495. * in the HMD. Calling this function has the same effect on the source
  77496. * canvas as any other operation that uses its source image, and canvases
  77497. * created without preserveDrawingBuffer set to true will be cleared.
  77498. * @param pose Define the pose to submit
  77499. */
  77500. submitFrame(pose?: VRPose): void;
  77501. }
  77502. declare var VRDisplay: {
  77503. prototype: VRDisplay;
  77504. new(): VRDisplay;
  77505. };
  77506. interface VRLayer {
  77507. leftBounds?: number[] | Float32Array | null;
  77508. rightBounds?: number[] | Float32Array | null;
  77509. source?: HTMLCanvasElement | null;
  77510. }
  77511. interface VRDisplayCapabilities {
  77512. readonly canPresent: boolean;
  77513. readonly hasExternalDisplay: boolean;
  77514. readonly hasOrientation: boolean;
  77515. readonly hasPosition: boolean;
  77516. readonly maxLayers: number;
  77517. }
  77518. interface VREyeParameters {
  77519. /** @deprecated */
  77520. readonly fieldOfView: VRFieldOfView;
  77521. readonly offset: Float32Array;
  77522. readonly renderHeight: number;
  77523. readonly renderWidth: number;
  77524. }
  77525. interface VRFieldOfView {
  77526. readonly downDegrees: number;
  77527. readonly leftDegrees: number;
  77528. readonly rightDegrees: number;
  77529. readonly upDegrees: number;
  77530. }
  77531. interface VRFrameData {
  77532. readonly leftProjectionMatrix: Float32Array;
  77533. readonly leftViewMatrix: Float32Array;
  77534. readonly pose: VRPose;
  77535. readonly rightProjectionMatrix: Float32Array;
  77536. readonly rightViewMatrix: Float32Array;
  77537. readonly timestamp: number;
  77538. }
  77539. interface VRPose {
  77540. readonly angularAcceleration: Float32Array | null;
  77541. readonly angularVelocity: Float32Array | null;
  77542. readonly linearAcceleration: Float32Array | null;
  77543. readonly linearVelocity: Float32Array | null;
  77544. readonly orientation: Float32Array | null;
  77545. readonly position: Float32Array | null;
  77546. readonly timestamp: number;
  77547. }
  77548. interface VRStageParameters {
  77549. sittingToStandingTransform?: Float32Array;
  77550. sizeX?: number;
  77551. sizeY?: number;
  77552. }
  77553. interface Navigator {
  77554. getVRDisplays(): Promise<VRDisplay[]>;
  77555. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  77556. }
  77557. interface Window {
  77558. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  77559. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  77560. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  77561. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77562. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77563. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  77564. }
  77565. interface Gamepad {
  77566. readonly displayId: number;
  77567. }
  77568. /**
  77569. * Available session modes
  77570. */
  77571. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  77572. /**
  77573. * Reference space types
  77574. */
  77575. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  77576. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  77577. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  77578. /**
  77579. * Handedness types
  77580. */
  77581. type XRHandedness = "none" | "left" | "right";
  77582. /**
  77583. * InputSource target ray modes
  77584. */
  77585. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  77586. /**
  77587. * Eye types
  77588. */
  77589. type XREye = "none" | "left" | "right";
  77590. /**
  77591. * Type of XR events available
  77592. */
  77593. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  77594. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  77595. type XRPlaneSet = Set<XRPlane>;
  77596. type XRAnchorSet = Set<XRAnchor>;
  77597. type XREventHandler = (callback: any) => void;
  77598. interface XRLayer extends EventTarget {}
  77599. interface XRSessionInit {
  77600. optionalFeatures?: string[];
  77601. requiredFeatures?: string[];
  77602. }
  77603. interface XRSessionEvent extends Event {
  77604. readonly session: XRSession;
  77605. }
  77606. interface XRSystem {
  77607. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  77608. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  77609. }
  77610. interface XRViewport {
  77611. readonly x: number;
  77612. readonly y: number;
  77613. readonly width: number;
  77614. readonly height: number;
  77615. }
  77616. interface XRWebGLLayerInit {
  77617. antialias?: boolean;
  77618. depth?: boolean;
  77619. stencil?: boolean;
  77620. alpha?: boolean;
  77621. multiview?: boolean;
  77622. framebufferScaleFactor?: number;
  77623. }
  77624. declare class XRWebGLLayer {
  77625. static getNativeFramebufferScaleFactor(session: XRSession): number;
  77626. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  77627. readonly antialias: boolean;
  77628. readonly framebuffer: WebGLFramebuffer;
  77629. readonly framebufferWidth: number;
  77630. readonly framebufferHeight: number;
  77631. readonly ignoreDepthValues: boolean;
  77632. getViewport: (view: XRView) => XRViewport;
  77633. }
  77634. // tslint:disable-next-line no-empty-interface
  77635. interface XRSpace extends EventTarget {}
  77636. interface XRRenderState {
  77637. readonly baseLayer?: XRWebGLLayer;
  77638. readonly depthFar: number;
  77639. readonly depthNear: number;
  77640. readonly inlineVerticalFieldOfView?: number;
  77641. }
  77642. interface XRRenderStateInit extends XRRenderState {
  77643. baseLayer: XRWebGLLayer;
  77644. depthFar: number;
  77645. depthNear: number;
  77646. inlineVerticalFieldOfView?: number;
  77647. layers?: XRLayer[];
  77648. }
  77649. interface XRReferenceSpace extends XRSpace {
  77650. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  77651. onreset: XREventHandler;
  77652. }
  77653. interface XRBoundedReferenceSpace extends XRSpace {
  77654. readonly boundsGeometry: DOMPointReadOnly[];
  77655. }
  77656. interface XRInputSource {
  77657. readonly handedness: XRHandedness;
  77658. readonly targetRayMode: XRTargetRayMode;
  77659. readonly targetRaySpace: XRSpace;
  77660. readonly gripSpace?: XRSpace;
  77661. readonly gamepad?: Gamepad;
  77662. readonly profiles: Array<string>;
  77663. readonly hand?: XRHand;
  77664. }
  77665. interface XRPose {
  77666. readonly transform: XRRigidTransform;
  77667. readonly emulatedPosition: boolean;
  77668. }
  77669. interface XRFrame {
  77670. readonly session: XRSession;
  77671. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  77672. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  77673. // AR
  77674. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  77675. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  77676. // Anchors
  77677. trackedAnchors?: XRAnchorSet;
  77678. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  77679. // Planes
  77680. worldInformation?: {
  77681. detectedPlanes?: XRPlaneSet;
  77682. };
  77683. // Hand tracking
  77684. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  77685. }
  77686. interface XRInputSourceEvent extends Event {
  77687. readonly frame: XRFrame;
  77688. readonly inputSource: XRInputSource;
  77689. }
  77690. type XRInputSourceArray = XRInputSource[];
  77691. interface XRSession {
  77692. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  77693. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  77694. /**
  77695. * Returns a list of this session's XRInputSources, each representing an input device
  77696. * used to control the camera and/or scene.
  77697. */
  77698. readonly inputSources: Array<XRInputSource>;
  77699. /**
  77700. * object which contains options affecting how the imagery is rendered.
  77701. * This includes things such as the near and far clipping planes
  77702. */
  77703. readonly renderState: XRRenderState;
  77704. readonly visibilityState: XRVisibilityState;
  77705. /**
  77706. * Removes a callback from the animation frame painting callback from
  77707. * XRSession's set of animation frame rendering callbacks, given the
  77708. * identifying handle returned by a previous call to requestAnimationFrame().
  77709. */
  77710. cancelAnimationFrame: (handle: number) => void;
  77711. /**
  77712. * Ends the WebXR session. Returns a promise which resolves when the
  77713. * session has been shut down.
  77714. */
  77715. end(): Promise<void>;
  77716. /**
  77717. * Schedules the specified method to be called the next time the user agent
  77718. * is working on rendering an animation frame for the WebXR device. Returns an
  77719. * integer value which can be used to identify the request for the purposes of
  77720. * canceling the callback using cancelAnimationFrame(). This method is comparable
  77721. * to the Window.requestAnimationFrame() method.
  77722. */
  77723. requestAnimationFrame: XRFrameRequestCallback;
  77724. /**
  77725. * Requests that a new XRReferenceSpace of the specified type be created.
  77726. * Returns a promise which resolves with the XRReferenceSpace or
  77727. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  77728. * the requested space type isn't supported by the device.
  77729. */
  77730. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  77731. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  77732. onend: XREventHandler;
  77733. oninputsourceschange: XREventHandler;
  77734. onselect: XREventHandler;
  77735. onselectstart: XREventHandler;
  77736. onselectend: XREventHandler;
  77737. onsqueeze: XREventHandler;
  77738. onsqueezestart: XREventHandler;
  77739. onsqueezeend: XREventHandler;
  77740. onvisibilitychange: XREventHandler;
  77741. // hit test
  77742. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  77743. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  77744. // legacy AR hit test
  77745. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77746. // legacy plane detection
  77747. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  77748. }
  77749. interface XRViewerPose extends XRPose {
  77750. readonly views: Array<XRView>;
  77751. }
  77752. declare class XRRigidTransform {
  77753. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  77754. position: DOMPointReadOnly;
  77755. orientation: DOMPointReadOnly;
  77756. matrix: Float32Array;
  77757. inverse: XRRigidTransform;
  77758. }
  77759. interface XRView {
  77760. readonly eye: XREye;
  77761. readonly projectionMatrix: Float32Array;
  77762. readonly transform: XRRigidTransform;
  77763. readonly recommendedViewportScale?: number;
  77764. requestViewportScale(scale: number): void;
  77765. }
  77766. interface XRInputSourceChangeEvent extends Event {
  77767. session: XRSession;
  77768. removed: Array<XRInputSource>;
  77769. added: Array<XRInputSource>;
  77770. }
  77771. // Experimental/Draft features
  77772. declare class XRRay {
  77773. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77774. origin: DOMPointReadOnly;
  77775. direction: DOMPointReadOnly;
  77776. matrix: Float32Array;
  77777. }
  77778. declare enum XRHitTestTrackableType {
  77779. "point",
  77780. "plane",
  77781. "mesh",
  77782. }
  77783. interface XRHitResult {
  77784. hitMatrix: Float32Array;
  77785. }
  77786. interface XRTransientInputHitTestResult {
  77787. readonly inputSource: XRInputSource;
  77788. readonly results: Array<XRHitTestResult>;
  77789. }
  77790. interface XRHitTestResult {
  77791. getPose(baseSpace: XRSpace): XRPose | undefined;
  77792. // When anchor system is enabled
  77793. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77794. }
  77795. interface XRHitTestSource {
  77796. cancel(): void;
  77797. }
  77798. interface XRTransientInputHitTestSource {
  77799. cancel(): void;
  77800. }
  77801. interface XRHitTestOptionsInit {
  77802. space: XRSpace;
  77803. entityTypes?: Array<XRHitTestTrackableType>;
  77804. offsetRay?: XRRay;
  77805. }
  77806. interface XRTransientInputHitTestOptionsInit {
  77807. profile: string;
  77808. entityTypes?: Array<XRHitTestTrackableType>;
  77809. offsetRay?: XRRay;
  77810. }
  77811. interface XRAnchor {
  77812. anchorSpace: XRSpace;
  77813. delete(): void;
  77814. }
  77815. interface XRPlane {
  77816. orientation: "Horizontal" | "Vertical";
  77817. planeSpace: XRSpace;
  77818. polygon: Array<DOMPointReadOnly>;
  77819. lastChangedTime: number;
  77820. }
  77821. interface XRJointSpace extends XRSpace {}
  77822. interface XRJointPose extends XRPose {
  77823. radius: number | undefined;
  77824. }
  77825. interface XRHand extends Iterable<XRJointSpace> {
  77826. readonly length: number;
  77827. [index: number]: XRJointSpace;
  77828. readonly WRIST: number;
  77829. readonly THUMB_METACARPAL: number;
  77830. readonly THUMB_PHALANX_PROXIMAL: number;
  77831. readonly THUMB_PHALANX_DISTAL: number;
  77832. readonly THUMB_PHALANX_TIP: number;
  77833. readonly INDEX_METACARPAL: number;
  77834. readonly INDEX_PHALANX_PROXIMAL: number;
  77835. readonly INDEX_PHALANX_INTERMEDIATE: number;
  77836. readonly INDEX_PHALANX_DISTAL: number;
  77837. readonly INDEX_PHALANX_TIP: number;
  77838. readonly MIDDLE_METACARPAL: number;
  77839. readonly MIDDLE_PHALANX_PROXIMAL: number;
  77840. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  77841. readonly MIDDLE_PHALANX_DISTAL: number;
  77842. readonly MIDDLE_PHALANX_TIP: number;
  77843. readonly RING_METACARPAL: number;
  77844. readonly RING_PHALANX_PROXIMAL: number;
  77845. readonly RING_PHALANX_INTERMEDIATE: number;
  77846. readonly RING_PHALANX_DISTAL: number;
  77847. readonly RING_PHALANX_TIP: number;
  77848. readonly LITTLE_METACARPAL: number;
  77849. readonly LITTLE_PHALANX_PROXIMAL: number;
  77850. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  77851. readonly LITTLE_PHALANX_DISTAL: number;
  77852. readonly LITTLE_PHALANX_TIP: number;
  77853. }
  77854. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  77855. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  77856. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  77857. interface XRSession {
  77858. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  77859. }
  77860. interface XRFrame {
  77861. featurePointCloud? : Array<number>;
  77862. }
  77863. /**
  77864. * @ignore
  77865. */
  77866. declare module BABYLON.GLTF2.Exporter {
  77867. }
  77868. /**
  77869. * @ignore
  77870. */
  77871. declare module BABYLON.GLTF1 {
  77872. }
  77873. declare module BABYLON.GUI {
  77874. /**
  77875. * Class used to specific a value and its associated unit
  77876. */
  77877. export class ValueAndUnit {
  77878. /** defines the unit to store */
  77879. unit: number;
  77880. /** defines a boolean indicating if the value can be negative */
  77881. negativeValueAllowed: boolean;
  77882. private _value;
  77883. private _originalUnit;
  77884. /**
  77885. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  77886. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77887. */
  77888. ignoreAdaptiveScaling: boolean;
  77889. /**
  77890. * Creates a new ValueAndUnit
  77891. * @param value defines the value to store
  77892. * @param unit defines the unit to store
  77893. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  77894. */
  77895. constructor(value: number,
  77896. /** defines the unit to store */
  77897. unit?: number,
  77898. /** defines a boolean indicating if the value can be negative */
  77899. negativeValueAllowed?: boolean);
  77900. /** Gets a boolean indicating if the value is a percentage */
  77901. get isPercentage(): boolean;
  77902. /** Gets a boolean indicating if the value is store as pixel */
  77903. get isPixel(): boolean;
  77904. /** Gets direct internal value */
  77905. get internalValue(): number;
  77906. /**
  77907. * Gets value as pixel
  77908. * @param host defines the root host
  77909. * @param refValue defines the reference value for percentages
  77910. * @returns the value as pixel
  77911. */
  77912. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  77913. /**
  77914. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  77915. * @param value defines the value to store
  77916. * @param unit defines the unit to store
  77917. * @returns the current ValueAndUnit
  77918. */
  77919. updateInPlace(value: number, unit?: number): ValueAndUnit;
  77920. /**
  77921. * Gets the value accordingly to its unit
  77922. * @param host defines the root host
  77923. * @returns the value
  77924. */
  77925. getValue(host: AdvancedDynamicTexture): number;
  77926. /**
  77927. * Gets a string representation of the value
  77928. * @param host defines the root host
  77929. * @param decimals defines an optional number of decimals to display
  77930. * @returns a string
  77931. */
  77932. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77933. /**
  77934. * Store a value parsed from a string
  77935. * @param source defines the source string
  77936. * @returns true if the value was successfully parsed
  77937. */
  77938. fromString(source: string | number): boolean;
  77939. private static _Regex;
  77940. private static _UNITMODE_PERCENTAGE;
  77941. private static _UNITMODE_PIXEL;
  77942. /** UNITMODE_PERCENTAGE */
  77943. static get UNITMODE_PERCENTAGE(): number;
  77944. /** UNITMODE_PIXEL */
  77945. static get UNITMODE_PIXEL(): number;
  77946. }
  77947. }
  77948. declare module BABYLON.GUI {
  77949. /**
  77950. * Define a style used by control to automatically setup properties based on a template.
  77951. * Only support font related properties so far
  77952. */
  77953. export class Style implements BABYLON.IDisposable {
  77954. private _fontFamily;
  77955. private _fontStyle;
  77956. private _fontWeight;
  77957. /** @hidden */
  77958. _host: AdvancedDynamicTexture;
  77959. /** @hidden */
  77960. _fontSize: ValueAndUnit;
  77961. /**
  77962. * BABYLON.Observable raised when the style values are changed
  77963. */
  77964. onChangedObservable: BABYLON.Observable<Style>;
  77965. /**
  77966. * Creates a new style object
  77967. * @param host defines the AdvancedDynamicTexture which hosts this style
  77968. */
  77969. constructor(host: AdvancedDynamicTexture);
  77970. /**
  77971. * Gets or sets the font size
  77972. */
  77973. get fontSize(): string | number;
  77974. set fontSize(value: string | number);
  77975. /**
  77976. * Gets or sets the font family
  77977. */
  77978. get fontFamily(): string;
  77979. set fontFamily(value: string);
  77980. /**
  77981. * Gets or sets the font style
  77982. */
  77983. get fontStyle(): string;
  77984. set fontStyle(value: string);
  77985. /** Gets or sets font weight */
  77986. get fontWeight(): string;
  77987. set fontWeight(value: string);
  77988. /** Dispose all associated resources */
  77989. dispose(): void;
  77990. }
  77991. }
  77992. declare module BABYLON.GUI {
  77993. /**
  77994. * Class used to transport BABYLON.Vector2 information for pointer events
  77995. */
  77996. export class Vector2WithInfo extends BABYLON.Vector2 {
  77997. /** defines the current mouse button index */
  77998. buttonIndex: number;
  77999. /**
  78000. * Creates a new Vector2WithInfo
  78001. * @param source defines the vector2 data to transport
  78002. * @param buttonIndex defines the current mouse button index
  78003. */
  78004. constructor(source: BABYLON.Vector2,
  78005. /** defines the current mouse button index */
  78006. buttonIndex?: number);
  78007. }
  78008. /** Class used to provide 2D matrix features */
  78009. export class Matrix2D {
  78010. /** Gets the internal array of 6 floats used to store matrix data */
  78011. m: Float32Array;
  78012. /**
  78013. * Creates a new matrix
  78014. * @param m00 defines value for (0, 0)
  78015. * @param m01 defines value for (0, 1)
  78016. * @param m10 defines value for (1, 0)
  78017. * @param m11 defines value for (1, 1)
  78018. * @param m20 defines value for (2, 0)
  78019. * @param m21 defines value for (2, 1)
  78020. */
  78021. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  78022. /**
  78023. * Fills the matrix from direct values
  78024. * @param m00 defines value for (0, 0)
  78025. * @param m01 defines value for (0, 1)
  78026. * @param m10 defines value for (1, 0)
  78027. * @param m11 defines value for (1, 1)
  78028. * @param m20 defines value for (2, 0)
  78029. * @param m21 defines value for (2, 1)
  78030. * @returns the current modified matrix
  78031. */
  78032. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  78033. /**
  78034. * Gets matrix determinant
  78035. * @returns the determinant
  78036. */
  78037. determinant(): number;
  78038. /**
  78039. * Inverses the matrix and stores it in a target matrix
  78040. * @param result defines the target matrix
  78041. * @returns the current matrix
  78042. */
  78043. invertToRef(result: Matrix2D): Matrix2D;
  78044. /**
  78045. * Multiplies the current matrix with another one
  78046. * @param other defines the second operand
  78047. * @param result defines the target matrix
  78048. * @returns the current matrix
  78049. */
  78050. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  78051. /**
  78052. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  78053. * @param x defines the x coordinate to transform
  78054. * @param y defines the x coordinate to transform
  78055. * @param result defines the target vector2
  78056. * @returns the current matrix
  78057. */
  78058. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  78059. /**
  78060. * Creates an identity matrix
  78061. * @returns a new matrix
  78062. */
  78063. static Identity(): Matrix2D;
  78064. /**
  78065. * Creates a translation matrix and stores it in a target matrix
  78066. * @param x defines the x coordinate of the translation
  78067. * @param y defines the y coordinate of the translation
  78068. * @param result defines the target matrix
  78069. */
  78070. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  78071. /**
  78072. * Creates a scaling matrix and stores it in a target matrix
  78073. * @param x defines the x coordinate of the scaling
  78074. * @param y defines the y coordinate of the scaling
  78075. * @param result defines the target matrix
  78076. */
  78077. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  78078. /**
  78079. * Creates a rotation matrix and stores it in a target matrix
  78080. * @param angle defines the rotation angle
  78081. * @param result defines the target matrix
  78082. */
  78083. static RotationToRef(angle: number, result: Matrix2D): void;
  78084. private static _TempPreTranslationMatrix;
  78085. private static _TempPostTranslationMatrix;
  78086. private static _TempRotationMatrix;
  78087. private static _TempScalingMatrix;
  78088. private static _TempCompose0;
  78089. private static _TempCompose1;
  78090. private static _TempCompose2;
  78091. /**
  78092. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  78093. * @param tx defines the x coordinate of the translation
  78094. * @param ty defines the y coordinate of the translation
  78095. * @param angle defines the rotation angle
  78096. * @param scaleX defines the x coordinate of the scaling
  78097. * @param scaleY defines the y coordinate of the scaling
  78098. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  78099. * @param result defines the target matrix
  78100. */
  78101. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  78102. }
  78103. }
  78104. declare module BABYLON.GUI {
  78105. /**
  78106. * Class used to store 2D control sizes
  78107. */
  78108. export class Measure {
  78109. /** defines left coordinate */
  78110. left: number;
  78111. /** defines top coordinate */
  78112. top: number;
  78113. /** defines width dimension */
  78114. width: number;
  78115. /** defines height dimension */
  78116. height: number;
  78117. /**
  78118. * Creates a new measure
  78119. * @param left defines left coordinate
  78120. * @param top defines top coordinate
  78121. * @param width defines width dimension
  78122. * @param height defines height dimension
  78123. */
  78124. constructor(
  78125. /** defines left coordinate */
  78126. left: number,
  78127. /** defines top coordinate */
  78128. top: number,
  78129. /** defines width dimension */
  78130. width: number,
  78131. /** defines height dimension */
  78132. height: number);
  78133. /**
  78134. * Copy from another measure
  78135. * @param other defines the other measure to copy from
  78136. */
  78137. copyFrom(other: Measure): void;
  78138. /**
  78139. * Copy from a group of 4 floats
  78140. * @param left defines left coordinate
  78141. * @param top defines top coordinate
  78142. * @param width defines width dimension
  78143. * @param height defines height dimension
  78144. */
  78145. copyFromFloats(left: number, top: number, width: number, height: number): void;
  78146. /**
  78147. * Computes the axis aligned bounding box measure for two given measures
  78148. * @param a Input measure
  78149. * @param b Input measure
  78150. * @param result the resulting bounding measure
  78151. */
  78152. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  78153. /**
  78154. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78155. * @param transform the matrix to transform the measure before computing the AABB
  78156. * @param addX number to add to left
  78157. * @param addY number to add to top
  78158. * @param addWidth number to add to width
  78159. * @param addHeight number to add to height
  78160. * @param result the resulting AABB
  78161. */
  78162. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  78163. /**
  78164. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78165. * @param transform the matrix to transform the measure before computing the AABB
  78166. * @param result the resulting AABB
  78167. */
  78168. transformToRef(transform: Matrix2D, result: Measure): void;
  78169. /**
  78170. * Check equality between this measure and another one
  78171. * @param other defines the other measures
  78172. * @returns true if both measures are equals
  78173. */
  78174. isEqualsTo(other: Measure): boolean;
  78175. /**
  78176. * Creates an empty measure
  78177. * @returns a new measure
  78178. */
  78179. static Empty(): Measure;
  78180. }
  78181. }
  78182. declare module BABYLON.GUI {
  78183. /**
  78184. * Interface used to define a control that can receive focus
  78185. */
  78186. export interface IFocusableControl {
  78187. /**
  78188. * Function called when the control receives the focus
  78189. */
  78190. onFocus(): void;
  78191. /**
  78192. * Function called when the control loses the focus
  78193. */
  78194. onBlur(): void;
  78195. /**
  78196. * Function called to let the control handle keyboard events
  78197. * @param evt defines the current keyboard event
  78198. */
  78199. processKeyboard(evt: KeyboardEvent): void;
  78200. /**
  78201. * Function called to get the list of controls that should not steal the focus from this control
  78202. * @returns an array of controls
  78203. */
  78204. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78205. }
  78206. /**
  78207. * Class used to create texture to support 2D GUI elements
  78208. * @see https://doc.babylonjs.com/how_to/gui
  78209. */
  78210. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  78211. private _isDirty;
  78212. private _renderObserver;
  78213. private _resizeObserver;
  78214. private _preKeyboardObserver;
  78215. private _pointerMoveObserver;
  78216. private _pointerObserver;
  78217. private _canvasPointerOutObserver;
  78218. private _canvasBlurObserver;
  78219. private _background;
  78220. /** @hidden */
  78221. _rootContainer: Container;
  78222. /** @hidden */
  78223. _lastPickedControl: Control;
  78224. /** @hidden */
  78225. _lastControlOver: {
  78226. [pointerId: number]: Control;
  78227. };
  78228. /** @hidden */
  78229. _lastControlDown: {
  78230. [pointerId: number]: Control;
  78231. };
  78232. /** @hidden */
  78233. _capturingControl: {
  78234. [pointerId: number]: Control;
  78235. };
  78236. /** @hidden */
  78237. _shouldBlockPointer: boolean;
  78238. /** @hidden */
  78239. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  78240. /** @hidden */
  78241. _linkedControls: Control[];
  78242. private _isFullscreen;
  78243. private _fullscreenViewport;
  78244. private _idealWidth;
  78245. private _idealHeight;
  78246. private _useSmallestIdeal;
  78247. private _renderAtIdealSize;
  78248. private _focusedControl;
  78249. private _blockNextFocusCheck;
  78250. private _renderScale;
  78251. private _rootElement;
  78252. private _cursorChanged;
  78253. private _defaultMousePointerId;
  78254. /** @hidden */
  78255. _numLayoutCalls: number;
  78256. /** Gets the number of layout calls made the last time the ADT has been rendered */
  78257. get numLayoutCalls(): number;
  78258. /** @hidden */
  78259. _numRenderCalls: number;
  78260. /** Gets the number of render calls made the last time the ADT has been rendered */
  78261. get numRenderCalls(): number;
  78262. /**
  78263. * Define type to string to ensure compatibility across browsers
  78264. * Safari doesn't support DataTransfer constructor
  78265. */
  78266. private _clipboardData;
  78267. /**
  78268. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  78269. */
  78270. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  78271. /**
  78272. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  78273. */
  78274. onControlPickedObservable: BABYLON.Observable<Control>;
  78275. /**
  78276. * BABYLON.Observable event triggered before layout is evaluated
  78277. */
  78278. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78279. /**
  78280. * BABYLON.Observable event triggered after the layout was evaluated
  78281. */
  78282. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78283. /**
  78284. * BABYLON.Observable event triggered before the texture is rendered
  78285. */
  78286. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78287. /**
  78288. * BABYLON.Observable event triggered after the texture was rendered
  78289. */
  78290. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78291. /**
  78292. * Gets or sets a boolean defining if alpha is stored as premultiplied
  78293. */
  78294. premulAlpha: boolean;
  78295. /**
  78296. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  78297. */
  78298. applyYInversionOnUpdate: boolean;
  78299. /**
  78300. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  78301. * Useful when you want more antialiasing
  78302. */
  78303. get renderScale(): number;
  78304. set renderScale(value: number);
  78305. /** Gets or sets the background color */
  78306. get background(): string;
  78307. set background(value: string);
  78308. /**
  78309. * Gets or sets the ideal width used to design controls.
  78310. * The GUI will then rescale everything accordingly
  78311. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78312. */
  78313. get idealWidth(): number;
  78314. set idealWidth(value: number);
  78315. /**
  78316. * Gets or sets the ideal height used to design controls.
  78317. * The GUI will then rescale everything accordingly
  78318. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78319. */
  78320. get idealHeight(): number;
  78321. set idealHeight(value: number);
  78322. /**
  78323. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  78324. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78325. */
  78326. get useSmallestIdeal(): boolean;
  78327. set useSmallestIdeal(value: boolean);
  78328. /**
  78329. * Gets or sets a boolean indicating if adaptive scaling must be used
  78330. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78331. */
  78332. get renderAtIdealSize(): boolean;
  78333. set renderAtIdealSize(value: boolean);
  78334. /**
  78335. * Gets the ratio used when in "ideal mode"
  78336. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78337. * */
  78338. get idealRatio(): number;
  78339. /**
  78340. * Gets the underlying layer used to render the texture when in fullscreen mode
  78341. */
  78342. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  78343. /**
  78344. * Gets the root container control
  78345. */
  78346. get rootContainer(): Container;
  78347. /**
  78348. * Returns an array containing the root container.
  78349. * This is mostly used to let the Inspector introspects the ADT
  78350. * @returns an array containing the rootContainer
  78351. */
  78352. getChildren(): Array<Container>;
  78353. /**
  78354. * Will return all controls that are inside this texture
  78355. * @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
  78356. * @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
  78357. * @return all child controls
  78358. */
  78359. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78360. /**
  78361. * Gets or sets the current focused control
  78362. */
  78363. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  78364. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  78365. /**
  78366. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  78367. */
  78368. get isForeground(): boolean;
  78369. set isForeground(value: boolean);
  78370. /**
  78371. * Gets or set information about clipboardData
  78372. */
  78373. get clipboardData(): string;
  78374. set clipboardData(value: string);
  78375. /**
  78376. * Creates a new AdvancedDynamicTexture
  78377. * @param name defines the name of the texture
  78378. * @param width defines the width of the texture
  78379. * @param height defines the height of the texture
  78380. * @param scene defines the hosting scene
  78381. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  78382. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78383. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78384. */
  78385. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  78386. /**
  78387. * Get the current class name of the texture useful for serialization or dynamic coding.
  78388. * @returns "AdvancedDynamicTexture"
  78389. */
  78390. getClassName(): string;
  78391. /**
  78392. * Function used to execute a function on all controls
  78393. * @param func defines the function to execute
  78394. * @param container defines the container where controls belong. If null the root container will be used
  78395. */
  78396. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  78397. private _useInvalidateRectOptimization;
  78398. /**
  78399. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  78400. */
  78401. get useInvalidateRectOptimization(): boolean;
  78402. set useInvalidateRectOptimization(value: boolean);
  78403. private _invalidatedRectangle;
  78404. /**
  78405. * Invalidates a rectangle area on the gui texture
  78406. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  78407. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  78408. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  78409. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  78410. */
  78411. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  78412. /**
  78413. * Marks the texture as dirty forcing a complete update
  78414. */
  78415. markAsDirty(): void;
  78416. /**
  78417. * Helper function used to create a new style
  78418. * @returns a new style
  78419. * @see https://doc.babylonjs.com/how_to/gui#styles
  78420. */
  78421. createStyle(): Style;
  78422. /**
  78423. * Adds a new control to the root container
  78424. * @param control defines the control to add
  78425. * @returns the current texture
  78426. */
  78427. addControl(control: Control): AdvancedDynamicTexture;
  78428. /**
  78429. * Removes a control from the root container
  78430. * @param control defines the control to remove
  78431. * @returns the current texture
  78432. */
  78433. removeControl(control: Control): AdvancedDynamicTexture;
  78434. /**
  78435. * Release all resources
  78436. */
  78437. dispose(): void;
  78438. private _onResize;
  78439. /** @hidden */
  78440. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  78441. /**
  78442. * Get screen coordinates for a vector3
  78443. * @param position defines the position to project
  78444. * @param worldMatrix defines the world matrix to use
  78445. * @returns the projected position
  78446. */
  78447. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  78448. /**
  78449. * Get screen coordinates for a vector3
  78450. * @param position defines the position to project
  78451. * @param worldMatrix defines the world matrix to use
  78452. * @returns the projected position with Z
  78453. */
  78454. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  78455. private _checkUpdate;
  78456. private _clearMeasure;
  78457. private _render;
  78458. /** @hidden */
  78459. _changeCursor(cursor: string): void;
  78460. /** @hidden */
  78461. _registerLastControlDown(control: Control, pointerId: number): void;
  78462. private _doPicking;
  78463. /** @hidden */
  78464. _cleanControlAfterRemovalFromList(list: {
  78465. [pointerId: number]: Control;
  78466. }, control: Control): void;
  78467. /** @hidden */
  78468. _cleanControlAfterRemoval(control: Control): void;
  78469. /** Attach to all scene events required to support pointer events */
  78470. attach(): void;
  78471. /** @hidden */
  78472. private onClipboardCopy;
  78473. /** @hidden */
  78474. private onClipboardCut;
  78475. /** @hidden */
  78476. private onClipboardPaste;
  78477. /**
  78478. * Register the clipboard Events onto the canvas
  78479. */
  78480. registerClipboardEvents(): void;
  78481. /**
  78482. * Unregister the clipboard Events from the canvas
  78483. */
  78484. unRegisterClipboardEvents(): void;
  78485. /**
  78486. * Connect the texture to a hosting mesh to enable interactions
  78487. * @param mesh defines the mesh to attach to
  78488. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  78489. */
  78490. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  78491. /**
  78492. * Move the focus to a specific control
  78493. * @param control defines the control which will receive the focus
  78494. */
  78495. moveFocusToControl(control: IFocusableControl): void;
  78496. private _manageFocus;
  78497. private _attachToOnPointerOut;
  78498. private _attachToOnBlur;
  78499. /**
  78500. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  78501. * @param mesh defines the mesh which will receive the texture
  78502. * @param width defines the texture width (1024 by default)
  78503. * @param height defines the texture height (1024 by default)
  78504. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78505. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  78506. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78507. * @returns a new AdvancedDynamicTexture
  78508. */
  78509. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78510. /**
  78511. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh) BUT do not create a new material for the mesh. You will be responsible for connecting the texture
  78512. * @param mesh defines the mesh which will receive the texture
  78513. * @param width defines the texture width (1024 by default)
  78514. * @param height defines the texture height (1024 by default)
  78515. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78516. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78517. * @returns a new AdvancedDynamicTexture
  78518. */
  78519. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78520. /**
  78521. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  78522. * In this mode the texture will rely on a layer for its rendering.
  78523. * This allows it to be treated like any other layer.
  78524. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  78525. * LayerMask is set through advancedTexture.layer.layerMask
  78526. * @param name defines name for the texture
  78527. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  78528. * @param scene defines the hsoting scene
  78529. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  78530. * @returns a new AdvancedDynamicTexture
  78531. */
  78532. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  78533. }
  78534. }
  78535. declare module BABYLON.GUI {
  78536. /**
  78537. * Root class used for all 2D controls
  78538. * @see https://doc.babylonjs.com/how_to/gui#controls
  78539. */
  78540. export class Control {
  78541. /** defines the name of the control */
  78542. name?: string | undefined;
  78543. /**
  78544. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  78545. */
  78546. static AllowAlphaInheritance: boolean;
  78547. private _alpha;
  78548. private _alphaSet;
  78549. private _zIndex;
  78550. /** @hidden */
  78551. _host: AdvancedDynamicTexture;
  78552. /** Gets or sets the control parent */
  78553. parent: BABYLON.Nullable<Container>;
  78554. /** @hidden */
  78555. _currentMeasure: Measure;
  78556. private _fontFamily;
  78557. private _fontStyle;
  78558. private _fontWeight;
  78559. private _fontSize;
  78560. private _font;
  78561. /** @hidden */
  78562. _width: ValueAndUnit;
  78563. /** @hidden */
  78564. _height: ValueAndUnit;
  78565. /** @hidden */
  78566. protected _fontOffset: {
  78567. ascent: number;
  78568. height: number;
  78569. descent: number;
  78570. };
  78571. private _color;
  78572. private _style;
  78573. private _styleObserver;
  78574. /** @hidden */
  78575. protected _horizontalAlignment: number;
  78576. /** @hidden */
  78577. protected _verticalAlignment: number;
  78578. /** @hidden */
  78579. protected _isDirty: boolean;
  78580. /** @hidden */
  78581. protected _wasDirty: boolean;
  78582. /** @hidden */
  78583. _tempParentMeasure: Measure;
  78584. /** @hidden */
  78585. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  78586. /** @hidden */
  78587. protected _cachedParentMeasure: Measure;
  78588. private _paddingLeft;
  78589. private _paddingRight;
  78590. private _paddingTop;
  78591. private _paddingBottom;
  78592. /** @hidden */
  78593. _left: ValueAndUnit;
  78594. /** @hidden */
  78595. _top: ValueAndUnit;
  78596. private _scaleX;
  78597. private _scaleY;
  78598. private _rotation;
  78599. private _transformCenterX;
  78600. private _transformCenterY;
  78601. /** @hidden */
  78602. _transformMatrix: Matrix2D;
  78603. /** @hidden */
  78604. protected _invertTransformMatrix: Matrix2D;
  78605. /** @hidden */
  78606. protected _transformedPosition: BABYLON.Vector2;
  78607. private _isMatrixDirty;
  78608. private _cachedOffsetX;
  78609. private _cachedOffsetY;
  78610. private _isVisible;
  78611. private _isHighlighted;
  78612. /** @hidden */
  78613. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  78614. private _fontSet;
  78615. private _dummyVector2;
  78616. private _downCount;
  78617. private _enterCount;
  78618. private _doNotRender;
  78619. private _downPointerIds;
  78620. protected _isEnabled: boolean;
  78621. protected _disabledColor: string;
  78622. protected _disabledColorItem: string;
  78623. /** @hidden */
  78624. protected _rebuildLayout: boolean;
  78625. /** @hidden */
  78626. _customData: any;
  78627. /** @hidden */
  78628. _isClipped: boolean;
  78629. /** @hidden */
  78630. _automaticSize: boolean;
  78631. /** @hidden */
  78632. _tag: any;
  78633. /**
  78634. * 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
  78635. */
  78636. uniqueId: number;
  78637. /**
  78638. * Gets or sets an object used to store user defined information for the node
  78639. */
  78640. metadata: any;
  78641. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  78642. isHitTestVisible: boolean;
  78643. /** Gets or sets a boolean indicating if the control can block pointer events */
  78644. isPointerBlocker: boolean;
  78645. /** Gets or sets a boolean indicating if the control can be focusable */
  78646. isFocusInvisible: boolean;
  78647. /**
  78648. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  78649. * 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
  78650. */
  78651. clipChildren: boolean;
  78652. /**
  78653. * Gets or sets a boolean indicating that control content must be clipped
  78654. * 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
  78655. */
  78656. clipContent: boolean;
  78657. /**
  78658. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  78659. */
  78660. useBitmapCache: boolean;
  78661. private _cacheData;
  78662. private _shadowOffsetX;
  78663. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  78664. get shadowOffsetX(): number;
  78665. set shadowOffsetX(value: number);
  78666. private _shadowOffsetY;
  78667. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  78668. get shadowOffsetY(): number;
  78669. set shadowOffsetY(value: number);
  78670. private _shadowBlur;
  78671. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  78672. get shadowBlur(): number;
  78673. set shadowBlur(value: number);
  78674. private _shadowColor;
  78675. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  78676. get shadowColor(): string;
  78677. set shadowColor(value: string);
  78678. /** Gets or sets the cursor to use when the control is hovered */
  78679. hoverCursor: string;
  78680. /** @hidden */
  78681. protected _linkOffsetX: ValueAndUnit;
  78682. /** @hidden */
  78683. protected _linkOffsetY: ValueAndUnit;
  78684. /** Gets the control type name */
  78685. get typeName(): string;
  78686. /**
  78687. * Get the current class name of the control.
  78688. * @returns current class name
  78689. */
  78690. getClassName(): string;
  78691. /**
  78692. * An event triggered when pointer wheel is scrolled
  78693. */
  78694. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  78695. /**
  78696. * An event triggered when the pointer move over the control.
  78697. */
  78698. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  78699. /**
  78700. * An event triggered when the pointer move out of the control.
  78701. */
  78702. onPointerOutObservable: BABYLON.Observable<Control>;
  78703. /**
  78704. * An event triggered when the pointer taps the control
  78705. */
  78706. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  78707. /**
  78708. * An event triggered when pointer up
  78709. */
  78710. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  78711. /**
  78712. * An event triggered when a control is clicked on
  78713. */
  78714. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  78715. /**
  78716. * An event triggered when pointer enters the control
  78717. */
  78718. onPointerEnterObservable: BABYLON.Observable<Control>;
  78719. /**
  78720. * An event triggered when the control is marked as dirty
  78721. */
  78722. onDirtyObservable: BABYLON.Observable<Control>;
  78723. /**
  78724. * An event triggered before drawing the control
  78725. */
  78726. onBeforeDrawObservable: BABYLON.Observable<Control>;
  78727. /**
  78728. * An event triggered after the control was drawn
  78729. */
  78730. onAfterDrawObservable: BABYLON.Observable<Control>;
  78731. /**
  78732. * An event triggered when the control has been disposed
  78733. */
  78734. onDisposeObservable: BABYLON.Observable<Control>;
  78735. /**
  78736. * Get the hosting AdvancedDynamicTexture
  78737. */
  78738. get host(): AdvancedDynamicTexture;
  78739. /** Gets or set information about font offsets (used to render and align text) */
  78740. get fontOffset(): {
  78741. ascent: number;
  78742. height: number;
  78743. descent: number;
  78744. };
  78745. set fontOffset(offset: {
  78746. ascent: number;
  78747. height: number;
  78748. descent: number;
  78749. });
  78750. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  78751. get alpha(): number;
  78752. set alpha(value: number);
  78753. /**
  78754. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  78755. */
  78756. get isHighlighted(): boolean;
  78757. set isHighlighted(value: boolean);
  78758. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  78759. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78760. */
  78761. get scaleX(): number;
  78762. set scaleX(value: number);
  78763. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  78764. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78765. */
  78766. get scaleY(): number;
  78767. set scaleY(value: number);
  78768. /** Gets or sets the rotation angle (0 by default)
  78769. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78770. */
  78771. get rotation(): number;
  78772. set rotation(value: number);
  78773. /** Gets or sets the transformation center on Y axis (0 by default)
  78774. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78775. */
  78776. get transformCenterY(): number;
  78777. set transformCenterY(value: number);
  78778. /** Gets or sets the transformation center on X axis (0 by default)
  78779. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78780. */
  78781. get transformCenterX(): number;
  78782. set transformCenterX(value: number);
  78783. /**
  78784. * Gets or sets the horizontal alignment
  78785. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78786. */
  78787. get horizontalAlignment(): number;
  78788. set horizontalAlignment(value: number);
  78789. /**
  78790. * Gets or sets the vertical alignment
  78791. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78792. */
  78793. get verticalAlignment(): number;
  78794. set verticalAlignment(value: number);
  78795. /**
  78796. * Gets or sets a fixed ratio for this control.
  78797. * When different from 0, the ratio is used to compute the "second" dimension.
  78798. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78799. * second dimension is computed as first dimension * fixedRatio
  78800. */
  78801. fixedRatio: number;
  78802. private _fixedRatioMasterIsWidth;
  78803. /**
  78804. * Gets or sets control width
  78805. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78806. */
  78807. get width(): string | number;
  78808. set width(value: string | number);
  78809. /**
  78810. * Gets or sets the control width in pixel
  78811. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78812. */
  78813. get widthInPixels(): number;
  78814. set widthInPixels(value: number);
  78815. /**
  78816. * Gets or sets control height
  78817. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78818. */
  78819. get height(): string | number;
  78820. set height(value: string | number);
  78821. /**
  78822. * Gets or sets control height in pixel
  78823. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78824. */
  78825. get heightInPixels(): number;
  78826. set heightInPixels(value: number);
  78827. /** Gets or set font family */
  78828. get fontFamily(): string;
  78829. set fontFamily(value: string);
  78830. /** Gets or sets font style */
  78831. get fontStyle(): string;
  78832. set fontStyle(value: string);
  78833. /** Gets or sets font weight */
  78834. get fontWeight(): string;
  78835. set fontWeight(value: string);
  78836. /**
  78837. * Gets or sets style
  78838. * @see https://doc.babylonjs.com/how_to/gui#styles
  78839. */
  78840. get style(): BABYLON.Nullable<Style>;
  78841. set style(value: BABYLON.Nullable<Style>);
  78842. /** @hidden */
  78843. get _isFontSizeInPercentage(): boolean;
  78844. /** Gets or sets font size in pixels */
  78845. get fontSizeInPixels(): number;
  78846. set fontSizeInPixels(value: number);
  78847. /** Gets or sets font size */
  78848. get fontSize(): string | number;
  78849. set fontSize(value: string | number);
  78850. /** Gets or sets foreground color */
  78851. get color(): string;
  78852. set color(value: string);
  78853. /** Gets or sets z index which is used to reorder controls on the z axis */
  78854. get zIndex(): number;
  78855. set zIndex(value: number);
  78856. /** Gets or sets a boolean indicating if the control can be rendered */
  78857. get notRenderable(): boolean;
  78858. set notRenderable(value: boolean);
  78859. /** Gets or sets a boolean indicating if the control is visible */
  78860. get isVisible(): boolean;
  78861. set isVisible(value: boolean);
  78862. /** Gets a boolean indicating that the control needs to update its rendering */
  78863. get isDirty(): boolean;
  78864. /**
  78865. * Gets the current linked mesh (or null if none)
  78866. */
  78867. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  78868. /**
  78869. * Gets or sets a value indicating the padding to use on the left of the control
  78870. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78871. */
  78872. get paddingLeft(): string | number;
  78873. set paddingLeft(value: string | number);
  78874. /**
  78875. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  78876. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78877. */
  78878. get paddingLeftInPixels(): number;
  78879. set paddingLeftInPixels(value: number);
  78880. /**
  78881. * Gets or sets a value indicating the padding to use on the right of the control
  78882. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78883. */
  78884. get paddingRight(): string | number;
  78885. set paddingRight(value: string | number);
  78886. /**
  78887. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  78888. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78889. */
  78890. get paddingRightInPixels(): number;
  78891. set paddingRightInPixels(value: number);
  78892. /**
  78893. * Gets or sets a value indicating the padding to use on the top of the control
  78894. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78895. */
  78896. get paddingTop(): string | number;
  78897. set paddingTop(value: string | number);
  78898. /**
  78899. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  78900. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78901. */
  78902. get paddingTopInPixels(): number;
  78903. set paddingTopInPixels(value: number);
  78904. /**
  78905. * Gets or sets a value indicating the padding to use on the bottom of the control
  78906. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78907. */
  78908. get paddingBottom(): string | number;
  78909. set paddingBottom(value: string | number);
  78910. /**
  78911. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  78912. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78913. */
  78914. get paddingBottomInPixels(): number;
  78915. set paddingBottomInPixels(value: number);
  78916. /**
  78917. * Gets or sets a value indicating the left coordinate of the control
  78918. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78919. */
  78920. get left(): string | number;
  78921. set left(value: string | number);
  78922. /**
  78923. * Gets or sets a value indicating the left coordinate in pixels of the control
  78924. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78925. */
  78926. get leftInPixels(): number;
  78927. set leftInPixels(value: number);
  78928. /**
  78929. * Gets or sets a value indicating the top coordinate of the control
  78930. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78931. */
  78932. get top(): string | number;
  78933. set top(value: string | number);
  78934. /**
  78935. * Gets or sets a value indicating the top coordinate in pixels of the control
  78936. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78937. */
  78938. get topInPixels(): number;
  78939. set topInPixels(value: number);
  78940. /**
  78941. * Gets or sets a value indicating the offset on X axis to the linked mesh
  78942. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78943. */
  78944. get linkOffsetX(): string | number;
  78945. set linkOffsetX(value: string | number);
  78946. /**
  78947. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  78948. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78949. */
  78950. get linkOffsetXInPixels(): number;
  78951. set linkOffsetXInPixels(value: number);
  78952. /**
  78953. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  78954. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78955. */
  78956. get linkOffsetY(): string | number;
  78957. set linkOffsetY(value: string | number);
  78958. /**
  78959. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  78960. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78961. */
  78962. get linkOffsetYInPixels(): number;
  78963. set linkOffsetYInPixels(value: number);
  78964. /** Gets the center coordinate on X axis */
  78965. get centerX(): number;
  78966. /** Gets the center coordinate on Y axis */
  78967. get centerY(): number;
  78968. /** Gets or sets if control is Enabled*/
  78969. get isEnabled(): boolean;
  78970. set isEnabled(value: boolean);
  78971. /** Gets or sets background color of control if it's disabled*/
  78972. get disabledColor(): string;
  78973. set disabledColor(value: string);
  78974. /** Gets or sets front color of control if it's disabled*/
  78975. get disabledColorItem(): string;
  78976. set disabledColorItem(value: string);
  78977. /**
  78978. * Creates a new control
  78979. * @param name defines the name of the control
  78980. */
  78981. constructor(
  78982. /** defines the name of the control */
  78983. name?: string | undefined);
  78984. /** @hidden */
  78985. protected _getTypeName(): string;
  78986. /**
  78987. * Gets the first ascendant in the hierarchy of the given type
  78988. * @param className defines the required type
  78989. * @returns the ascendant or null if not found
  78990. */
  78991. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78992. /** @hidden */
  78993. _resetFontCache(): void;
  78994. /**
  78995. * Determines if a container is an ascendant of the current control
  78996. * @param container defines the container to look for
  78997. * @returns true if the container is one of the ascendant of the control
  78998. */
  78999. isAscendant(container: Control): boolean;
  79000. /**
  79001. * Gets coordinates in local control space
  79002. * @param globalCoordinates defines the coordinates to transform
  79003. * @returns the new coordinates in local space
  79004. */
  79005. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  79006. /**
  79007. * Gets coordinates in local control space
  79008. * @param globalCoordinates defines the coordinates to transform
  79009. * @param result defines the target vector2 where to store the result
  79010. * @returns the current control
  79011. */
  79012. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  79013. /**
  79014. * Gets coordinates in parent local control space
  79015. * @param globalCoordinates defines the coordinates to transform
  79016. * @returns the new coordinates in parent local space
  79017. */
  79018. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  79019. /**
  79020. * Move the current control to a vector3 position projected onto the screen.
  79021. * @param position defines the target position
  79022. * @param scene defines the hosting scene
  79023. */
  79024. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  79025. /**
  79026. * Will store all controls that have this control as ascendant in a given array
  79027. * @param results defines the array where to store the descendants
  79028. * @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
  79029. * @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
  79030. */
  79031. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79032. /**
  79033. * Will return all controls that have this control as ascendant
  79034. * @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
  79035. * @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
  79036. * @return all child controls
  79037. */
  79038. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  79039. /**
  79040. * Link current control with a target mesh
  79041. * @param mesh defines the mesh to link with
  79042. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79043. */
  79044. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  79045. /** @hidden */
  79046. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  79047. /** @hidden */
  79048. _offsetLeft(offset: number): void;
  79049. /** @hidden */
  79050. _offsetTop(offset: number): void;
  79051. /** @hidden */
  79052. _markMatrixAsDirty(): void;
  79053. /** @hidden */
  79054. _flagDescendantsAsMatrixDirty(): void;
  79055. /** @hidden */
  79056. _intersectsRect(rect: Measure): boolean;
  79057. /** @hidden */
  79058. protected invalidateRect(): void;
  79059. /** @hidden */
  79060. _markAsDirty(force?: boolean): void;
  79061. /** @hidden */
  79062. _markAllAsDirty(): void;
  79063. /** @hidden */
  79064. _link(host: AdvancedDynamicTexture): void;
  79065. /** @hidden */
  79066. protected _transform(context?: CanvasRenderingContext2D): void;
  79067. /** @hidden */
  79068. _renderHighlight(context: CanvasRenderingContext2D): void;
  79069. /** @hidden */
  79070. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79071. /** @hidden */
  79072. protected _applyStates(context: CanvasRenderingContext2D): void;
  79073. /** @hidden */
  79074. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79075. /** @hidden */
  79076. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79077. protected _evaluateClippingState(parentMeasure: Measure): void;
  79078. /** @hidden */
  79079. _measure(): void;
  79080. /** @hidden */
  79081. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79082. /** @hidden */
  79083. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79084. /** @hidden */
  79085. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79086. /** @hidden */
  79087. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79088. private static _ClipMeasure;
  79089. private _tmpMeasureA;
  79090. private _clip;
  79091. /** @hidden */
  79092. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  79093. /** @hidden */
  79094. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79095. /**
  79096. * Tests if a given coordinates belong to the current control
  79097. * @param x defines x coordinate to test
  79098. * @param y defines y coordinate to test
  79099. * @returns true if the coordinates are inside the control
  79100. */
  79101. contains(x: number, y: number): boolean;
  79102. /** @hidden */
  79103. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79104. /** @hidden */
  79105. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79106. /** @hidden */
  79107. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79108. /** @hidden */
  79109. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  79110. /** @hidden */
  79111. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79112. /** @hidden */
  79113. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  79114. /** @hidden */
  79115. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79116. /** @hidden */
  79117. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  79118. /** @hidden */
  79119. _onCanvasBlur(): void;
  79120. /** @hidden */
  79121. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79122. private _prepareFont;
  79123. /** Releases associated resources */
  79124. dispose(): void;
  79125. private static _HORIZONTAL_ALIGNMENT_LEFT;
  79126. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  79127. private static _HORIZONTAL_ALIGNMENT_CENTER;
  79128. private static _VERTICAL_ALIGNMENT_TOP;
  79129. private static _VERTICAL_ALIGNMENT_BOTTOM;
  79130. private static _VERTICAL_ALIGNMENT_CENTER;
  79131. /** HORIZONTAL_ALIGNMENT_LEFT */
  79132. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  79133. /** HORIZONTAL_ALIGNMENT_RIGHT */
  79134. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  79135. /** HORIZONTAL_ALIGNMENT_CENTER */
  79136. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  79137. /** VERTICAL_ALIGNMENT_TOP */
  79138. static get VERTICAL_ALIGNMENT_TOP(): number;
  79139. /** VERTICAL_ALIGNMENT_BOTTOM */
  79140. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  79141. /** VERTICAL_ALIGNMENT_CENTER */
  79142. static get VERTICAL_ALIGNMENT_CENTER(): number;
  79143. private static _FontHeightSizes;
  79144. /** @hidden */
  79145. static _GetFontOffset(font: string): {
  79146. ascent: number;
  79147. height: number;
  79148. descent: number;
  79149. };
  79150. /**
  79151. * Creates a stack panel that can be used to render headers
  79152. * @param control defines the control to associate with the header
  79153. * @param text defines the text of the header
  79154. * @param size defines the size of the header
  79155. * @param options defines options used to configure the header
  79156. * @returns a new StackPanel
  79157. * @ignore
  79158. * @hidden
  79159. */
  79160. static AddHeader: (control: Control, text: string, size: string | number, options: {
  79161. isHorizontal: boolean;
  79162. controlFirst: boolean;
  79163. }) => any;
  79164. /** @hidden */
  79165. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  79166. }
  79167. }
  79168. declare module BABYLON.GUI {
  79169. /**
  79170. * Root class for 2D containers
  79171. * @see https://doc.babylonjs.com/how_to/gui#containers
  79172. */
  79173. export class Container extends Control {
  79174. name?: string | undefined;
  79175. /** @hidden */
  79176. _children: Control[];
  79177. /** @hidden */
  79178. protected _measureForChildren: Measure;
  79179. /** @hidden */
  79180. protected _background: string;
  79181. /** @hidden */
  79182. protected _adaptWidthToChildren: boolean;
  79183. /** @hidden */
  79184. protected _adaptHeightToChildren: boolean;
  79185. /**
  79186. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  79187. */
  79188. logLayoutCycleErrors: boolean;
  79189. /**
  79190. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  79191. */
  79192. maxLayoutCycle: number;
  79193. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  79194. get adaptHeightToChildren(): boolean;
  79195. set adaptHeightToChildren(value: boolean);
  79196. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  79197. get adaptWidthToChildren(): boolean;
  79198. set adaptWidthToChildren(value: boolean);
  79199. /** Gets or sets background color */
  79200. get background(): string;
  79201. set background(value: string);
  79202. /** Gets the list of children */
  79203. get children(): Control[];
  79204. /**
  79205. * Creates a new Container
  79206. * @param name defines the name of the container
  79207. */
  79208. constructor(name?: string | undefined);
  79209. protected _getTypeName(): string;
  79210. _flagDescendantsAsMatrixDirty(): void;
  79211. /**
  79212. * Gets a child using its name
  79213. * @param name defines the child name to look for
  79214. * @returns the child control if found
  79215. */
  79216. getChildByName(name: string): BABYLON.Nullable<Control>;
  79217. /**
  79218. * Gets a child using its type and its name
  79219. * @param name defines the child name to look for
  79220. * @param type defines the child type to look for
  79221. * @returns the child control if found
  79222. */
  79223. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  79224. /**
  79225. * Search for a specific control in children
  79226. * @param control defines the control to look for
  79227. * @returns true if the control is in child list
  79228. */
  79229. containsControl(control: Control): boolean;
  79230. /**
  79231. * Adds a new control to the current container
  79232. * @param control defines the control to add
  79233. * @returns the current container
  79234. */
  79235. addControl(control: BABYLON.Nullable<Control>): Container;
  79236. /**
  79237. * Removes all controls from the current container
  79238. * @returns the current container
  79239. */
  79240. clearControls(): Container;
  79241. /**
  79242. * Removes a control from the current container
  79243. * @param control defines the control to remove
  79244. * @returns the current container
  79245. */
  79246. removeControl(control: Control): Container;
  79247. /** @hidden */
  79248. _reOrderControl(control: Control): void;
  79249. /** @hidden */
  79250. _offsetLeft(offset: number): void;
  79251. /** @hidden */
  79252. _offsetTop(offset: number): void;
  79253. /** @hidden */
  79254. _markAllAsDirty(): void;
  79255. /** @hidden */
  79256. protected _localDraw(context: CanvasRenderingContext2D): void;
  79257. /** @hidden */
  79258. _link(host: AdvancedDynamicTexture): void;
  79259. /** @hidden */
  79260. protected _beforeLayout(): void;
  79261. /** @hidden */
  79262. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79263. /** @hidden */
  79264. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79265. protected _postMeasure(): void;
  79266. /** @hidden */
  79267. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79268. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79269. /** @hidden */
  79270. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79271. /** @hidden */
  79272. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79273. /** Releases associated resources */
  79274. dispose(): void;
  79275. }
  79276. }
  79277. declare module BABYLON.GUI {
  79278. /** Class used to create rectangle container */
  79279. export class Rectangle extends Container {
  79280. name?: string | undefined;
  79281. private _thickness;
  79282. private _cornerRadius;
  79283. /** Gets or sets border thickness */
  79284. get thickness(): number;
  79285. set thickness(value: number);
  79286. /** Gets or sets the corner radius angle */
  79287. get cornerRadius(): number;
  79288. set cornerRadius(value: number);
  79289. /**
  79290. * Creates a new Rectangle
  79291. * @param name defines the control name
  79292. */
  79293. constructor(name?: string | undefined);
  79294. protected _getTypeName(): string;
  79295. protected _localDraw(context: CanvasRenderingContext2D): void;
  79296. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79297. private _drawRoundedRect;
  79298. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79299. }
  79300. }
  79301. declare module BABYLON.GUI {
  79302. /**
  79303. * Enum that determines the text-wrapping mode to use.
  79304. */
  79305. export enum TextWrapping {
  79306. /**
  79307. * Clip the text when it's larger than Control.width; this is the default mode.
  79308. */
  79309. Clip = 0,
  79310. /**
  79311. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  79312. */
  79313. WordWrap = 1,
  79314. /**
  79315. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  79316. */
  79317. Ellipsis = 2
  79318. }
  79319. /**
  79320. * Class used to create text block control
  79321. */
  79322. export class TextBlock extends Control {
  79323. /**
  79324. * Defines the name of the control
  79325. */
  79326. name?: string | undefined;
  79327. private _text;
  79328. private _textWrapping;
  79329. private _textHorizontalAlignment;
  79330. private _textVerticalAlignment;
  79331. private _lines;
  79332. private _resizeToFit;
  79333. private _lineSpacing;
  79334. private _outlineWidth;
  79335. private _outlineColor;
  79336. private _underline;
  79337. private _lineThrough;
  79338. /**
  79339. * An event triggered after the text is changed
  79340. */
  79341. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  79342. /**
  79343. * An event triggered after the text was broken up into lines
  79344. */
  79345. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  79346. /**
  79347. * Function used to split a string into words. By default, a string is split at each space character found
  79348. */
  79349. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  79350. /**
  79351. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  79352. */
  79353. get lines(): any[];
  79354. /**
  79355. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79356. */
  79357. get resizeToFit(): boolean;
  79358. /**
  79359. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79360. */
  79361. set resizeToFit(value: boolean);
  79362. /**
  79363. * Gets or sets a boolean indicating if text must be wrapped
  79364. */
  79365. get textWrapping(): TextWrapping | boolean;
  79366. /**
  79367. * Gets or sets a boolean indicating if text must be wrapped
  79368. */
  79369. set textWrapping(value: TextWrapping | boolean);
  79370. /**
  79371. * Gets or sets text to display
  79372. */
  79373. get text(): string;
  79374. /**
  79375. * Gets or sets text to display
  79376. */
  79377. set text(value: string);
  79378. /**
  79379. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79380. */
  79381. get textHorizontalAlignment(): number;
  79382. /**
  79383. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79384. */
  79385. set textHorizontalAlignment(value: number);
  79386. /**
  79387. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79388. */
  79389. get textVerticalAlignment(): number;
  79390. /**
  79391. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79392. */
  79393. set textVerticalAlignment(value: number);
  79394. /**
  79395. * Gets or sets line spacing value
  79396. */
  79397. set lineSpacing(value: string | number);
  79398. /**
  79399. * Gets or sets line spacing value
  79400. */
  79401. get lineSpacing(): string | number;
  79402. /**
  79403. * Gets or sets outlineWidth of the text to display
  79404. */
  79405. get outlineWidth(): number;
  79406. /**
  79407. * Gets or sets outlineWidth of the text to display
  79408. */
  79409. set outlineWidth(value: number);
  79410. /**
  79411. * Gets or sets a boolean indicating that text must have underline
  79412. */
  79413. get underline(): boolean;
  79414. /**
  79415. * Gets or sets a boolean indicating that text must have underline
  79416. */
  79417. set underline(value: boolean);
  79418. /**
  79419. * Gets or sets an boolean indicating that text must be crossed out
  79420. */
  79421. get lineThrough(): boolean;
  79422. /**
  79423. * Gets or sets an boolean indicating that text must be crossed out
  79424. */
  79425. set lineThrough(value: boolean);
  79426. /**
  79427. * Gets or sets outlineColor of the text to display
  79428. */
  79429. get outlineColor(): string;
  79430. /**
  79431. * Gets or sets outlineColor of the text to display
  79432. */
  79433. set outlineColor(value: string);
  79434. /**
  79435. * Creates a new TextBlock object
  79436. * @param name defines the name of the control
  79437. * @param text defines the text to display (emptry string by default)
  79438. */
  79439. constructor(
  79440. /**
  79441. * Defines the name of the control
  79442. */
  79443. name?: string | undefined, text?: string);
  79444. protected _getTypeName(): string;
  79445. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79446. private _drawText;
  79447. /** @hidden */
  79448. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79449. protected _applyStates(context: CanvasRenderingContext2D): void;
  79450. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  79451. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  79452. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  79453. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  79454. protected _renderLines(context: CanvasRenderingContext2D): void;
  79455. /**
  79456. * Given a width constraint applied on the text block, find the expected height
  79457. * @returns expected height
  79458. */
  79459. computeExpectedHeight(): number;
  79460. dispose(): void;
  79461. }
  79462. }
  79463. declare module BABYLON.GUI {
  79464. /**
  79465. * Class used to create 2D images
  79466. */
  79467. export class Image extends Control {
  79468. name?: string | undefined;
  79469. private _workingCanvas;
  79470. private _domImage;
  79471. private _imageWidth;
  79472. private _imageHeight;
  79473. private _loaded;
  79474. private _stretch;
  79475. private _source;
  79476. private _autoScale;
  79477. private _sourceLeft;
  79478. private _sourceTop;
  79479. private _sourceWidth;
  79480. private _sourceHeight;
  79481. private _svgAttributesComputationCompleted;
  79482. private _isSVG;
  79483. private _cellWidth;
  79484. private _cellHeight;
  79485. private _cellId;
  79486. private _populateNinePatchSlicesFromImage;
  79487. private _sliceLeft;
  79488. private _sliceRight;
  79489. private _sliceTop;
  79490. private _sliceBottom;
  79491. private _detectPointerOnOpaqueOnly;
  79492. private _imageDataCache;
  79493. /**
  79494. * BABYLON.Observable notified when the content is loaded
  79495. */
  79496. onImageLoadedObservable: BABYLON.Observable<Image>;
  79497. /**
  79498. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  79499. */
  79500. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  79501. /**
  79502. * Gets a boolean indicating that the content is loaded
  79503. */
  79504. get isLoaded(): boolean;
  79505. /**
  79506. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  79507. */
  79508. get populateNinePatchSlicesFromImage(): boolean;
  79509. set populateNinePatchSlicesFromImage(value: boolean);
  79510. /**
  79511. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  79512. * Beware using this as this will comsume more memory as the image has to be stored twice
  79513. */
  79514. get detectPointerOnOpaqueOnly(): boolean;
  79515. set detectPointerOnOpaqueOnly(value: boolean);
  79516. /**
  79517. * Gets or sets the left value for slicing (9-patch)
  79518. */
  79519. get sliceLeft(): number;
  79520. set sliceLeft(value: number);
  79521. /**
  79522. * Gets or sets the right value for slicing (9-patch)
  79523. */
  79524. get sliceRight(): number;
  79525. set sliceRight(value: number);
  79526. /**
  79527. * Gets or sets the top value for slicing (9-patch)
  79528. */
  79529. get sliceTop(): number;
  79530. set sliceTop(value: number);
  79531. /**
  79532. * Gets or sets the bottom value for slicing (9-patch)
  79533. */
  79534. get sliceBottom(): number;
  79535. set sliceBottom(value: number);
  79536. /**
  79537. * Gets or sets the left coordinate in the source image
  79538. */
  79539. get sourceLeft(): number;
  79540. set sourceLeft(value: number);
  79541. /**
  79542. * Gets or sets the top coordinate in the source image
  79543. */
  79544. get sourceTop(): number;
  79545. set sourceTop(value: number);
  79546. /**
  79547. * Gets or sets the width to capture in the source image
  79548. */
  79549. get sourceWidth(): number;
  79550. set sourceWidth(value: number);
  79551. /**
  79552. * Gets or sets the height to capture in the source image
  79553. */
  79554. get sourceHeight(): number;
  79555. set sourceHeight(value: number);
  79556. /** Indicates if the format of the image is SVG */
  79557. get isSVG(): boolean;
  79558. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  79559. get svgAttributesComputationCompleted(): boolean;
  79560. /**
  79561. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  79562. * @see https://doc.babylonjs.com/how_to/gui#image
  79563. */
  79564. get autoScale(): boolean;
  79565. set autoScale(value: boolean);
  79566. /** Gets or sets the streching mode used by the image */
  79567. get stretch(): number;
  79568. set stretch(value: number);
  79569. /** @hidden */
  79570. _rotate90(n: number, preserveProperties?: boolean): Image;
  79571. private _handleRotationForSVGImage;
  79572. private _rotate90SourceProperties;
  79573. /**
  79574. * Gets or sets the internal DOM image used to render the control
  79575. */
  79576. set domImage(value: HTMLImageElement);
  79577. get domImage(): HTMLImageElement;
  79578. private _onImageLoaded;
  79579. private _extractNinePatchSliceDataFromImage;
  79580. /**
  79581. * Gets or sets image source url
  79582. */
  79583. set source(value: BABYLON.Nullable<string>);
  79584. /**
  79585. * Checks for svg document with icon id present
  79586. */
  79587. private _svgCheck;
  79588. /**
  79589. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  79590. * given external svg file and icon id
  79591. */
  79592. private _getSVGAttribs;
  79593. /**
  79594. * Gets or sets the cell width to use when animation sheet is enabled
  79595. * @see https://doc.babylonjs.com/how_to/gui#image
  79596. */
  79597. get cellWidth(): number;
  79598. set cellWidth(value: number);
  79599. /**
  79600. * Gets or sets the cell height to use when animation sheet is enabled
  79601. * @see https://doc.babylonjs.com/how_to/gui#image
  79602. */
  79603. get cellHeight(): number;
  79604. set cellHeight(value: number);
  79605. /**
  79606. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  79607. * @see https://doc.babylonjs.com/how_to/gui#image
  79608. */
  79609. get cellId(): number;
  79610. set cellId(value: number);
  79611. /**
  79612. * Creates a new Image
  79613. * @param name defines the control name
  79614. * @param url defines the image url
  79615. */
  79616. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  79617. /**
  79618. * Tests if a given coordinates belong to the current control
  79619. * @param x defines x coordinate to test
  79620. * @param y defines y coordinate to test
  79621. * @returns true if the coordinates are inside the control
  79622. */
  79623. contains(x: number, y: number): boolean;
  79624. protected _getTypeName(): string;
  79625. /** Force the control to synchronize with its content */
  79626. synchronizeSizeWithContent(): void;
  79627. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79628. private _prepareWorkingCanvasForOpaqueDetection;
  79629. private _drawImage;
  79630. _draw(context: CanvasRenderingContext2D): void;
  79631. private _renderCornerPatch;
  79632. private _renderNinePatch;
  79633. dispose(): void;
  79634. /** STRETCH_NONE */
  79635. static readonly STRETCH_NONE: number;
  79636. /** STRETCH_FILL */
  79637. static readonly STRETCH_FILL: number;
  79638. /** STRETCH_UNIFORM */
  79639. static readonly STRETCH_UNIFORM: number;
  79640. /** STRETCH_EXTEND */
  79641. static readonly STRETCH_EXTEND: number;
  79642. /** NINE_PATCH */
  79643. static readonly STRETCH_NINE_PATCH: number;
  79644. }
  79645. }
  79646. declare module BABYLON.GUI {
  79647. /**
  79648. * Class used to create 2D buttons
  79649. */
  79650. export class Button extends Rectangle {
  79651. name?: string | undefined;
  79652. /**
  79653. * Function called to generate a pointer enter animation
  79654. */
  79655. pointerEnterAnimation: () => void;
  79656. /**
  79657. * Function called to generate a pointer out animation
  79658. */
  79659. pointerOutAnimation: () => void;
  79660. /**
  79661. * Function called to generate a pointer down animation
  79662. */
  79663. pointerDownAnimation: () => void;
  79664. /**
  79665. * Function called to generate a pointer up animation
  79666. */
  79667. pointerUpAnimation: () => void;
  79668. /**
  79669. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  79670. */
  79671. delegatePickingToChildren: boolean;
  79672. private _image;
  79673. /**
  79674. * Returns the image part of the button (if any)
  79675. */
  79676. get image(): BABYLON.Nullable<Image>;
  79677. private _textBlock;
  79678. /**
  79679. * Returns the image part of the button (if any)
  79680. */
  79681. get textBlock(): BABYLON.Nullable<TextBlock>;
  79682. /**
  79683. * Creates a new Button
  79684. * @param name defines the name of the button
  79685. */
  79686. constructor(name?: string | undefined);
  79687. protected _getTypeName(): string;
  79688. /** @hidden */
  79689. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79690. /** @hidden */
  79691. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79692. /** @hidden */
  79693. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  79694. /** @hidden */
  79695. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79696. /** @hidden */
  79697. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79698. /**
  79699. * Creates a new button made with an image and a text
  79700. * @param name defines the name of the button
  79701. * @param text defines the text of the button
  79702. * @param imageUrl defines the url of the image
  79703. * @returns a new Button
  79704. */
  79705. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  79706. /**
  79707. * Creates a new button made with an image
  79708. * @param name defines the name of the button
  79709. * @param imageUrl defines the url of the image
  79710. * @returns a new Button
  79711. */
  79712. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  79713. /**
  79714. * Creates a new button made with a text
  79715. * @param name defines the name of the button
  79716. * @param text defines the text of the button
  79717. * @returns a new Button
  79718. */
  79719. static CreateSimpleButton(name: string, text: string): Button;
  79720. /**
  79721. * Creates a new button made with an image and a centered text
  79722. * @param name defines the name of the button
  79723. * @param text defines the text of the button
  79724. * @param imageUrl defines the url of the image
  79725. * @returns a new Button
  79726. */
  79727. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  79728. }
  79729. }
  79730. declare module BABYLON.GUI {
  79731. /**
  79732. * Class used to create a 2D stack panel container
  79733. */
  79734. export class StackPanel extends Container {
  79735. name?: string | undefined;
  79736. private _isVertical;
  79737. private _manualWidth;
  79738. private _manualHeight;
  79739. private _doNotTrackManualChanges;
  79740. /**
  79741. * Gets or sets a boolean indicating that layou warnings should be ignored
  79742. */
  79743. ignoreLayoutWarnings: boolean;
  79744. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  79745. get isVertical(): boolean;
  79746. set isVertical(value: boolean);
  79747. /**
  79748. * Gets or sets panel width.
  79749. * This value should not be set when in horizontal mode as it will be computed automatically
  79750. */
  79751. set width(value: string | number);
  79752. get width(): string | number;
  79753. /**
  79754. * Gets or sets panel height.
  79755. * This value should not be set when in vertical mode as it will be computed automatically
  79756. */
  79757. set height(value: string | number);
  79758. get height(): string | number;
  79759. /**
  79760. * Creates a new StackPanel
  79761. * @param name defines control name
  79762. */
  79763. constructor(name?: string | undefined);
  79764. protected _getTypeName(): string;
  79765. /** @hidden */
  79766. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79767. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79768. protected _postMeasure(): void;
  79769. }
  79770. }
  79771. declare module BABYLON.GUI {
  79772. /**
  79773. * Class used to represent a 2D checkbox
  79774. */
  79775. export class Checkbox extends Control {
  79776. name?: string | undefined;
  79777. private _isChecked;
  79778. private _background;
  79779. private _checkSizeRatio;
  79780. private _thickness;
  79781. /** Gets or sets border thickness */
  79782. get thickness(): number;
  79783. set thickness(value: number);
  79784. /**
  79785. * BABYLON.Observable raised when isChecked property changes
  79786. */
  79787. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79788. /** Gets or sets a value indicating the ratio between overall size and check size */
  79789. get checkSizeRatio(): number;
  79790. set checkSizeRatio(value: number);
  79791. /** Gets or sets background color */
  79792. get background(): string;
  79793. set background(value: string);
  79794. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79795. get isChecked(): boolean;
  79796. set isChecked(value: boolean);
  79797. /**
  79798. * Creates a new CheckBox
  79799. * @param name defines the control name
  79800. */
  79801. constructor(name?: string | undefined);
  79802. protected _getTypeName(): string;
  79803. /** @hidden */
  79804. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79805. /** @hidden */
  79806. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79807. /**
  79808. * Utility function to easily create a checkbox with a header
  79809. * @param title defines the label to use for the header
  79810. * @param onValueChanged defines the callback to call when value changes
  79811. * @returns a StackPanel containing the checkbox and a textBlock
  79812. */
  79813. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  79814. }
  79815. }
  79816. declare module BABYLON.GUI {
  79817. /**
  79818. * Class used to store key control properties
  79819. */
  79820. export class KeyPropertySet {
  79821. /** Width */
  79822. width?: string;
  79823. /** Height */
  79824. height?: string;
  79825. /** Left padding */
  79826. paddingLeft?: string;
  79827. /** Right padding */
  79828. paddingRight?: string;
  79829. /** Top padding */
  79830. paddingTop?: string;
  79831. /** Bottom padding */
  79832. paddingBottom?: string;
  79833. /** Foreground color */
  79834. color?: string;
  79835. /** Background color */
  79836. background?: string;
  79837. }
  79838. /**
  79839. * Class used to create virtual keyboard
  79840. */
  79841. export class VirtualKeyboard extends StackPanel {
  79842. /** BABYLON.Observable raised when a key is pressed */
  79843. onKeyPressObservable: BABYLON.Observable<string>;
  79844. /** Gets or sets default key button width */
  79845. defaultButtonWidth: string;
  79846. /** Gets or sets default key button height */
  79847. defaultButtonHeight: string;
  79848. /** Gets or sets default key button left padding */
  79849. defaultButtonPaddingLeft: string;
  79850. /** Gets or sets default key button right padding */
  79851. defaultButtonPaddingRight: string;
  79852. /** Gets or sets default key button top padding */
  79853. defaultButtonPaddingTop: string;
  79854. /** Gets or sets default key button bottom padding */
  79855. defaultButtonPaddingBottom: string;
  79856. /** Gets or sets default key button foreground color */
  79857. defaultButtonColor: string;
  79858. /** Gets or sets default key button background color */
  79859. defaultButtonBackground: string;
  79860. /** Gets or sets shift button foreground color */
  79861. shiftButtonColor: string;
  79862. /** Gets or sets shift button thickness*/
  79863. selectedShiftThickness: number;
  79864. /** Gets shift key state */
  79865. shiftState: number;
  79866. protected _getTypeName(): string;
  79867. private _createKey;
  79868. /**
  79869. * Adds a new row of keys
  79870. * @param keys defines the list of keys to add
  79871. * @param propertySets defines the associated property sets
  79872. */
  79873. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  79874. /**
  79875. * Set the shift key to a specific state
  79876. * @param shiftState defines the new shift state
  79877. */
  79878. applyShiftState(shiftState: number): void;
  79879. private _currentlyConnectedInputText;
  79880. private _connectedInputTexts;
  79881. private _onKeyPressObserver;
  79882. /** Gets the input text control currently attached to the keyboard */
  79883. get connectedInputText(): BABYLON.Nullable<InputText>;
  79884. /**
  79885. * Connects the keyboard with an input text control
  79886. *
  79887. * @param input defines the target control
  79888. */
  79889. connect(input: InputText): void;
  79890. /**
  79891. * Disconnects the keyboard from connected InputText controls
  79892. *
  79893. * @param input optionally defines a target control, otherwise all are disconnected
  79894. */
  79895. disconnect(input?: InputText): void;
  79896. private _removeConnectedInputObservables;
  79897. /**
  79898. * Release all resources
  79899. */
  79900. dispose(): void;
  79901. /**
  79902. * Creates a new keyboard using a default layout
  79903. *
  79904. * @param name defines control name
  79905. * @returns a new VirtualKeyboard
  79906. */
  79907. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  79908. }
  79909. }
  79910. declare module BABYLON.GUI {
  79911. /** @hidden */
  79912. export class TextWrapper {
  79913. private _text;
  79914. private _characters;
  79915. get text(): string;
  79916. set text(txt: string);
  79917. get length(): number;
  79918. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  79919. charAt(idx: number): string;
  79920. substr(from: number, length?: number): string;
  79921. substring(from: number, to?: number): string;
  79922. isWord(index: number): boolean;
  79923. }
  79924. }
  79925. declare module BABYLON.GUI {
  79926. /**
  79927. * Class used to create input text control
  79928. */
  79929. export class InputText extends Control implements IFocusableControl {
  79930. name?: string | undefined;
  79931. private _textWrapper;
  79932. private _placeholderText;
  79933. private _background;
  79934. private _focusedBackground;
  79935. private _focusedColor;
  79936. private _placeholderColor;
  79937. private _thickness;
  79938. private _margin;
  79939. private _autoStretchWidth;
  79940. private _maxWidth;
  79941. private _isFocused;
  79942. private _blinkTimeout;
  79943. private _blinkIsEven;
  79944. private _cursorOffset;
  79945. private _scrollLeft;
  79946. private _textWidth;
  79947. private _clickedCoordinate;
  79948. private _deadKey;
  79949. private _addKey;
  79950. private _currentKey;
  79951. private _isTextHighlightOn;
  79952. private _textHighlightColor;
  79953. private _highligherOpacity;
  79954. private _highlightedText;
  79955. private _startHighlightIndex;
  79956. private _endHighlightIndex;
  79957. private _cursorIndex;
  79958. private _onFocusSelectAll;
  79959. private _isPointerDown;
  79960. private _onClipboardObserver;
  79961. private _onPointerDblTapObserver;
  79962. /** @hidden */
  79963. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  79964. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  79965. promptMessage: string;
  79966. /** Force disable prompt on mobile device */
  79967. disableMobilePrompt: boolean;
  79968. /** BABYLON.Observable raised when the text changes */
  79969. onTextChangedObservable: BABYLON.Observable<InputText>;
  79970. /** BABYLON.Observable raised just before an entered character is to be added */
  79971. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  79972. /** BABYLON.Observable raised when the control gets the focus */
  79973. onFocusObservable: BABYLON.Observable<InputText>;
  79974. /** BABYLON.Observable raised when the control loses the focus */
  79975. onBlurObservable: BABYLON.Observable<InputText>;
  79976. /**Observable raised when the text is highlighted */
  79977. onTextHighlightObservable: BABYLON.Observable<InputText>;
  79978. /**Observable raised when copy event is triggered */
  79979. onTextCopyObservable: BABYLON.Observable<InputText>;
  79980. /** BABYLON.Observable raised when cut event is triggered */
  79981. onTextCutObservable: BABYLON.Observable<InputText>;
  79982. /** BABYLON.Observable raised when paste event is triggered */
  79983. onTextPasteObservable: BABYLON.Observable<InputText>;
  79984. /** BABYLON.Observable raised when a key event was processed */
  79985. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  79986. /** Gets or sets the maximum width allowed by the control */
  79987. get maxWidth(): string | number;
  79988. /** Gets the maximum width allowed by the control in pixels */
  79989. get maxWidthInPixels(): number;
  79990. set maxWidth(value: string | number);
  79991. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79992. get highligherOpacity(): number;
  79993. set highligherOpacity(value: number);
  79994. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79995. get onFocusSelectAll(): boolean;
  79996. set onFocusSelectAll(value: boolean);
  79997. /** Gets or sets the text hightlight color */
  79998. get textHighlightColor(): string;
  79999. set textHighlightColor(value: string);
  80000. /** Gets or sets control margin */
  80001. get margin(): string;
  80002. /** Gets control margin in pixels */
  80003. get marginInPixels(): number;
  80004. set margin(value: string);
  80005. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  80006. get autoStretchWidth(): boolean;
  80007. set autoStretchWidth(value: boolean);
  80008. /** Gets or sets border thickness */
  80009. get thickness(): number;
  80010. set thickness(value: number);
  80011. /** Gets or sets the background color when focused */
  80012. get focusedBackground(): string;
  80013. set focusedBackground(value: string);
  80014. /** Gets or sets the background color when focused */
  80015. get focusedColor(): string;
  80016. set focusedColor(value: string);
  80017. /** Gets or sets the background color */
  80018. get background(): string;
  80019. set background(value: string);
  80020. /** Gets or sets the placeholder color */
  80021. get placeholderColor(): string;
  80022. set placeholderColor(value: string);
  80023. /** Gets or sets the text displayed when the control is empty */
  80024. get placeholderText(): string;
  80025. set placeholderText(value: string);
  80026. /** Gets or sets the dead key flag */
  80027. get deadKey(): boolean;
  80028. set deadKey(flag: boolean);
  80029. /** Gets or sets the highlight text */
  80030. get highlightedText(): string;
  80031. set highlightedText(text: string);
  80032. /** Gets or sets if the current key should be added */
  80033. get addKey(): boolean;
  80034. set addKey(flag: boolean);
  80035. /** Gets or sets the value of the current key being entered */
  80036. get currentKey(): string;
  80037. set currentKey(key: string);
  80038. /** Gets or sets the text displayed in the control */
  80039. get text(): string;
  80040. set text(value: string);
  80041. private _textHasChanged;
  80042. /** Gets or sets control width */
  80043. get width(): string | number;
  80044. set width(value: string | number);
  80045. /**
  80046. * Creates a new InputText
  80047. * @param name defines the control name
  80048. * @param text defines the text of the control
  80049. */
  80050. constructor(name?: string | undefined, text?: string);
  80051. /** @hidden */
  80052. onBlur(): void;
  80053. /** @hidden */
  80054. onFocus(): void;
  80055. protected _getTypeName(): string;
  80056. /**
  80057. * Function called to get the list of controls that should not steal the focus from this control
  80058. * @returns an array of controls
  80059. */
  80060. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  80061. /** @hidden */
  80062. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  80063. /** @hidden */
  80064. private _updateValueFromCursorIndex;
  80065. /** @hidden */
  80066. private _processDblClick;
  80067. /** @hidden */
  80068. private _selectAllText;
  80069. /**
  80070. * Handles the keyboard event
  80071. * @param evt Defines the KeyboardEvent
  80072. */
  80073. processKeyboard(evt: KeyboardEvent): void;
  80074. /** @hidden */
  80075. private _onCopyText;
  80076. /** @hidden */
  80077. private _onCutText;
  80078. /** @hidden */
  80079. private _onPasteText;
  80080. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80081. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80082. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80083. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80084. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  80085. dispose(): void;
  80086. }
  80087. }
  80088. declare module BABYLON.GUI {
  80089. /**
  80090. * Class used to create a 2D grid container
  80091. */
  80092. export class Grid extends Container {
  80093. name?: string | undefined;
  80094. private _rowDefinitions;
  80095. private _columnDefinitions;
  80096. private _cells;
  80097. private _childControls;
  80098. /**
  80099. * Gets the number of columns
  80100. */
  80101. get columnCount(): number;
  80102. /**
  80103. * Gets the number of rows
  80104. */
  80105. get rowCount(): number;
  80106. /** Gets the list of children */
  80107. get children(): Control[];
  80108. /** Gets the list of cells (e.g. the containers) */
  80109. get cells(): {
  80110. [key: string]: Container;
  80111. };
  80112. /**
  80113. * Gets the definition of a specific row
  80114. * @param index defines the index of the row
  80115. * @returns the row definition
  80116. */
  80117. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  80118. /**
  80119. * Gets the definition of a specific column
  80120. * @param index defines the index of the column
  80121. * @returns the column definition
  80122. */
  80123. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  80124. /**
  80125. * Adds a new row to the grid
  80126. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80127. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  80128. * @returns the current grid
  80129. */
  80130. addRowDefinition(height: number, isPixel?: boolean): Grid;
  80131. /**
  80132. * Adds a new column to the grid
  80133. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80134. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80135. * @returns the current grid
  80136. */
  80137. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  80138. /**
  80139. * Update a row definition
  80140. * @param index defines the index of the row to update
  80141. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80142. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  80143. * @returns the current grid
  80144. */
  80145. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  80146. /**
  80147. * Update a column definition
  80148. * @param index defines the index of the column to update
  80149. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80150. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80151. * @returns the current grid
  80152. */
  80153. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  80154. /**
  80155. * Gets the list of children stored in a specific cell
  80156. * @param row defines the row to check
  80157. * @param column defines the column to check
  80158. * @returns the list of controls
  80159. */
  80160. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  80161. /**
  80162. * Gets a string representing the child cell info (row x column)
  80163. * @param child defines the control to get info from
  80164. * @returns a string containing the child cell info (row x column)
  80165. */
  80166. getChildCellInfo(child: Control): string;
  80167. private _removeCell;
  80168. private _offsetCell;
  80169. /**
  80170. * Remove a column definition at specified index
  80171. * @param index defines the index of the column to remove
  80172. * @returns the current grid
  80173. */
  80174. removeColumnDefinition(index: number): Grid;
  80175. /**
  80176. * Remove a row definition at specified index
  80177. * @param index defines the index of the row to remove
  80178. * @returns the current grid
  80179. */
  80180. removeRowDefinition(index: number): Grid;
  80181. /**
  80182. * Adds a new control to the current grid
  80183. * @param control defines the control to add
  80184. * @param row defines the row where to add the control (0 by default)
  80185. * @param column defines the column where to add the control (0 by default)
  80186. * @returns the current grid
  80187. */
  80188. addControl(control: Control, row?: number, column?: number): Grid;
  80189. /**
  80190. * Removes a control from the current container
  80191. * @param control defines the control to remove
  80192. * @returns the current container
  80193. */
  80194. removeControl(control: Control): Container;
  80195. /**
  80196. * Creates a new Grid
  80197. * @param name defines control name
  80198. */
  80199. constructor(name?: string | undefined);
  80200. protected _getTypeName(): string;
  80201. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  80202. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80203. _flagDescendantsAsMatrixDirty(): void;
  80204. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80205. /** Releases associated resources */
  80206. dispose(): void;
  80207. }
  80208. }
  80209. declare module BABYLON.GUI {
  80210. /** Class used to create color pickers */
  80211. export class ColorPicker extends Control {
  80212. name?: string | undefined;
  80213. private static _Epsilon;
  80214. private _colorWheelCanvas;
  80215. private _value;
  80216. private _tmpColor;
  80217. private _pointerStartedOnSquare;
  80218. private _pointerStartedOnWheel;
  80219. private _squareLeft;
  80220. private _squareTop;
  80221. private _squareSize;
  80222. private _h;
  80223. private _s;
  80224. private _v;
  80225. private _lastPointerDownID;
  80226. /**
  80227. * BABYLON.Observable raised when the value changes
  80228. */
  80229. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  80230. /** Gets or sets the color of the color picker */
  80231. get value(): BABYLON.Color3;
  80232. set value(value: BABYLON.Color3);
  80233. /**
  80234. * Gets or sets control width
  80235. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80236. */
  80237. get width(): string | number;
  80238. set width(value: string | number);
  80239. /**
  80240. * Gets or sets control height
  80241. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80242. */
  80243. get height(): string | number;
  80244. /** Gets or sets control height */
  80245. set height(value: string | number);
  80246. /** Gets or sets control size */
  80247. get size(): string | number;
  80248. set size(value: string | number);
  80249. /**
  80250. * Creates a new ColorPicker
  80251. * @param name defines the control name
  80252. */
  80253. constructor(name?: string | undefined);
  80254. protected _getTypeName(): string;
  80255. /** @hidden */
  80256. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80257. private _updateSquareProps;
  80258. private _drawGradientSquare;
  80259. private _drawCircle;
  80260. private _createColorWheelCanvas;
  80261. /** @hidden */
  80262. _draw(context: CanvasRenderingContext2D): void;
  80263. private _pointerIsDown;
  80264. private _updateValueFromPointer;
  80265. private _isPointOnSquare;
  80266. private _isPointOnWheel;
  80267. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80268. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80269. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  80270. _onCanvasBlur(): void;
  80271. /**
  80272. * This function expands the color picker by creating a color picker dialog with manual
  80273. * color value input and the ability to save colors into an array to be used later in
  80274. * subsequent launches of the dialogue.
  80275. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  80276. * @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.
  80277. * @returns picked color as a hex string and the saved colors array as hex strings.
  80278. */
  80279. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  80280. pickerWidth?: string;
  80281. pickerHeight?: string;
  80282. headerHeight?: string;
  80283. lastColor?: string;
  80284. swatchLimit?: number;
  80285. numSwatchesPerLine?: number;
  80286. savedColors?: Array<string>;
  80287. }): Promise<{
  80288. savedColors?: string[];
  80289. pickedColor: string;
  80290. }>;
  80291. }
  80292. }
  80293. declare module BABYLON.GUI {
  80294. /** Class used to create 2D ellipse containers */
  80295. export class Ellipse extends Container {
  80296. name?: string | undefined;
  80297. private _thickness;
  80298. /** Gets or sets border thickness */
  80299. get thickness(): number;
  80300. set thickness(value: number);
  80301. /**
  80302. * Creates a new Ellipse
  80303. * @param name defines the control name
  80304. */
  80305. constructor(name?: string | undefined);
  80306. protected _getTypeName(): string;
  80307. protected _localDraw(context: CanvasRenderingContext2D): void;
  80308. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80309. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  80310. }
  80311. }
  80312. declare module BABYLON.GUI {
  80313. /**
  80314. * Class used to create a password control
  80315. */
  80316. export class InputPassword extends InputText {
  80317. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  80318. }
  80319. }
  80320. declare module BABYLON.GUI {
  80321. /** Class used to render 2D lines */
  80322. export class Line extends Control {
  80323. name?: string | undefined;
  80324. private _lineWidth;
  80325. private _x1;
  80326. private _y1;
  80327. private _x2;
  80328. private _y2;
  80329. private _dash;
  80330. private _connectedControl;
  80331. private _connectedControlDirtyObserver;
  80332. /** Gets or sets the dash pattern */
  80333. get dash(): Array<number>;
  80334. set dash(value: Array<number>);
  80335. /** Gets or sets the control connected with the line end */
  80336. get connectedControl(): Control;
  80337. set connectedControl(value: Control);
  80338. /** Gets or sets start coordinates on X axis */
  80339. get x1(): string | number;
  80340. set x1(value: string | number);
  80341. /** Gets or sets start coordinates on Y axis */
  80342. get y1(): string | number;
  80343. set y1(value: string | number);
  80344. /** Gets or sets end coordinates on X axis */
  80345. get x2(): string | number;
  80346. set x2(value: string | number);
  80347. /** Gets or sets end coordinates on Y axis */
  80348. get y2(): string | number;
  80349. set y2(value: string | number);
  80350. /** Gets or sets line width */
  80351. get lineWidth(): number;
  80352. set lineWidth(value: number);
  80353. /** Gets or sets horizontal alignment */
  80354. set horizontalAlignment(value: number);
  80355. /** Gets or sets vertical alignment */
  80356. set verticalAlignment(value: number);
  80357. private get _effectiveX2();
  80358. private get _effectiveY2();
  80359. /**
  80360. * Creates a new Line
  80361. * @param name defines the control name
  80362. */
  80363. constructor(name?: string | undefined);
  80364. protected _getTypeName(): string;
  80365. _draw(context: CanvasRenderingContext2D): void;
  80366. _measure(): void;
  80367. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80368. /**
  80369. * Move one end of the line given 3D cartesian coordinates.
  80370. * @param position Targeted world position
  80371. * @param scene BABYLON.Scene
  80372. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80373. */
  80374. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  80375. /**
  80376. * Move one end of the line to a position in screen absolute space.
  80377. * @param projectedPosition Position in screen absolute space (X, Y)
  80378. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80379. */
  80380. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  80381. }
  80382. }
  80383. declare module BABYLON.GUI {
  80384. /**
  80385. * Class used to store a point for a MultiLine object.
  80386. * The point can be pure 2D coordinates, a mesh or a control
  80387. */
  80388. export class MultiLinePoint {
  80389. private _multiLine;
  80390. private _x;
  80391. private _y;
  80392. private _control;
  80393. private _mesh;
  80394. private _controlObserver;
  80395. private _meshObserver;
  80396. /** @hidden */
  80397. _point: BABYLON.Vector3;
  80398. /**
  80399. * Creates a new MultiLinePoint
  80400. * @param multiLine defines the source MultiLine object
  80401. */
  80402. constructor(multiLine: MultiLine);
  80403. /** Gets or sets x coordinate */
  80404. get x(): string | number;
  80405. set x(value: string | number);
  80406. /** Gets or sets y coordinate */
  80407. get y(): string | number;
  80408. set y(value: string | number);
  80409. /** Gets or sets the control associated with this point */
  80410. get control(): BABYLON.Nullable<Control>;
  80411. set control(value: BABYLON.Nullable<Control>);
  80412. /** Gets or sets the mesh associated with this point */
  80413. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80414. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  80415. /** Resets links */
  80416. resetLinks(): void;
  80417. /**
  80418. * Gets a translation vector with Z component
  80419. * @returns the translation vector
  80420. */
  80421. translate(): BABYLON.Vector3;
  80422. private _translatePoint;
  80423. /** Release associated resources */
  80424. dispose(): void;
  80425. }
  80426. }
  80427. declare module BABYLON.GUI {
  80428. /**
  80429. * Class used to create multi line control
  80430. */
  80431. export class MultiLine extends Control {
  80432. name?: string | undefined;
  80433. private _lineWidth;
  80434. private _dash;
  80435. private _points;
  80436. private _minX;
  80437. private _minY;
  80438. private _maxX;
  80439. private _maxY;
  80440. /**
  80441. * Creates a new MultiLine
  80442. * @param name defines the control name
  80443. */
  80444. constructor(name?: string | undefined);
  80445. /** Gets or sets dash pattern */
  80446. get dash(): Array<number>;
  80447. set dash(value: Array<number>);
  80448. /**
  80449. * Gets point stored at specified index
  80450. * @param index defines the index to look for
  80451. * @returns the requested point if found
  80452. */
  80453. getAt(index: number): MultiLinePoint;
  80454. /** Function called when a point is updated */
  80455. onPointUpdate: () => void;
  80456. /**
  80457. * Adds new points to the point collection
  80458. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  80459. * @returns the list of created MultiLinePoint
  80460. */
  80461. add(...items: (AbstractMesh | Control | {
  80462. x: string | number;
  80463. y: string | number;
  80464. })[]): MultiLinePoint[];
  80465. /**
  80466. * Adds a new point to the point collection
  80467. * @param item defines the item (mesh, control or 2d coordiantes) to add
  80468. * @returns the created MultiLinePoint
  80469. */
  80470. push(item?: (AbstractMesh | Control | {
  80471. x: string | number;
  80472. y: string | number;
  80473. })): MultiLinePoint;
  80474. /**
  80475. * Remove a specific value or point from the active point collection
  80476. * @param value defines the value or point to remove
  80477. */
  80478. remove(value: number | MultiLinePoint): void;
  80479. /**
  80480. * Resets this object to initial state (no point)
  80481. */
  80482. reset(): void;
  80483. /**
  80484. * Resets all links
  80485. */
  80486. resetLinks(): void;
  80487. /** Gets or sets line width */
  80488. get lineWidth(): number;
  80489. set lineWidth(value: number);
  80490. set horizontalAlignment(value: number);
  80491. set verticalAlignment(value: number);
  80492. protected _getTypeName(): string;
  80493. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80494. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80495. _measure(): void;
  80496. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80497. dispose(): void;
  80498. }
  80499. }
  80500. declare module BABYLON.GUI {
  80501. /**
  80502. * Class used to create radio button controls
  80503. */
  80504. export class RadioButton extends Control {
  80505. name?: string | undefined;
  80506. private _isChecked;
  80507. private _background;
  80508. private _checkSizeRatio;
  80509. private _thickness;
  80510. /** Gets or sets border thickness */
  80511. get thickness(): number;
  80512. set thickness(value: number);
  80513. /** Gets or sets group name */
  80514. group: string;
  80515. /** BABYLON.Observable raised when isChecked is changed */
  80516. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  80517. /** Gets or sets a value indicating the ratio between overall size and check size */
  80518. get checkSizeRatio(): number;
  80519. set checkSizeRatio(value: number);
  80520. /** Gets or sets background color */
  80521. get background(): string;
  80522. set background(value: string);
  80523. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  80524. get isChecked(): boolean;
  80525. set isChecked(value: boolean);
  80526. /**
  80527. * Creates a new RadioButton
  80528. * @param name defines the control name
  80529. */
  80530. constructor(name?: string | undefined);
  80531. protected _getTypeName(): string;
  80532. _draw(context: CanvasRenderingContext2D): void;
  80533. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80534. /**
  80535. * Utility function to easily create a radio button with a header
  80536. * @param title defines the label to use for the header
  80537. * @param group defines the group to use for the radio button
  80538. * @param isChecked defines the initial state of the radio button
  80539. * @param onValueChanged defines the callback to call when value changes
  80540. * @returns a StackPanel containing the radio button and a textBlock
  80541. */
  80542. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  80543. }
  80544. }
  80545. declare module BABYLON.GUI {
  80546. /**
  80547. * Class used to create slider controls
  80548. */
  80549. export class BaseSlider extends Control {
  80550. name?: string | undefined;
  80551. protected _thumbWidth: ValueAndUnit;
  80552. private _minimum;
  80553. private _maximum;
  80554. private _value;
  80555. private _isVertical;
  80556. protected _barOffset: ValueAndUnit;
  80557. private _isThumbClamped;
  80558. protected _displayThumb: boolean;
  80559. private _step;
  80560. private _lastPointerDownID;
  80561. protected _effectiveBarOffset: number;
  80562. protected _renderLeft: number;
  80563. protected _renderTop: number;
  80564. protected _renderWidth: number;
  80565. protected _renderHeight: number;
  80566. protected _backgroundBoxLength: number;
  80567. protected _backgroundBoxThickness: number;
  80568. protected _effectiveThumbThickness: number;
  80569. /** BABYLON.Observable raised when the sldier value changes */
  80570. onValueChangedObservable: BABYLON.Observable<number>;
  80571. /** Gets or sets a boolean indicating if the thumb must be rendered */
  80572. get displayThumb(): boolean;
  80573. set displayThumb(value: boolean);
  80574. /** Gets or sets a step to apply to values (0 by default) */
  80575. get step(): number;
  80576. set step(value: number);
  80577. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  80578. get barOffset(): string | number;
  80579. /** Gets main bar offset in pixels*/
  80580. get barOffsetInPixels(): number;
  80581. set barOffset(value: string | number);
  80582. /** Gets or sets thumb width */
  80583. get thumbWidth(): string | number;
  80584. /** Gets thumb width in pixels */
  80585. get thumbWidthInPixels(): number;
  80586. set thumbWidth(value: string | number);
  80587. /** Gets or sets minimum value */
  80588. get minimum(): number;
  80589. set minimum(value: number);
  80590. /** Gets or sets maximum value */
  80591. get maximum(): number;
  80592. set maximum(value: number);
  80593. /** Gets or sets current value */
  80594. get value(): number;
  80595. set value(value: number);
  80596. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  80597. get isVertical(): boolean;
  80598. set isVertical(value: boolean);
  80599. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  80600. get isThumbClamped(): boolean;
  80601. set isThumbClamped(value: boolean);
  80602. /**
  80603. * Creates a new BaseSlider
  80604. * @param name defines the control name
  80605. */
  80606. constructor(name?: string | undefined);
  80607. protected _getTypeName(): string;
  80608. protected _getThumbPosition(): number;
  80609. protected _getThumbThickness(type: string): number;
  80610. protected _prepareRenderingData(type: string): void;
  80611. private _pointerIsDown;
  80612. /** @hidden */
  80613. protected _updateValueFromPointer(x: number, y: number): void;
  80614. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80615. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80616. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80617. _onCanvasBlur(): void;
  80618. }
  80619. }
  80620. declare module BABYLON.GUI {
  80621. /**
  80622. * Class used to create slider controls
  80623. */
  80624. export class Slider extends BaseSlider {
  80625. name?: string | undefined;
  80626. private _background;
  80627. private _borderColor;
  80628. private _thumbColor;
  80629. private _isThumbCircle;
  80630. protected _displayValueBar: boolean;
  80631. /** Gets or sets a boolean indicating if the value bar must be rendered */
  80632. get displayValueBar(): boolean;
  80633. set displayValueBar(value: boolean);
  80634. /** Gets or sets border color */
  80635. get borderColor(): string;
  80636. set borderColor(value: string);
  80637. /** Gets or sets background color */
  80638. get background(): string;
  80639. set background(value: string);
  80640. /** Gets or sets thumb's color */
  80641. get thumbColor(): string;
  80642. set thumbColor(value: string);
  80643. /** Gets or sets a boolean indicating if the thumb should be round or square */
  80644. get isThumbCircle(): boolean;
  80645. set isThumbCircle(value: boolean);
  80646. /**
  80647. * Creates a new Slider
  80648. * @param name defines the control name
  80649. */
  80650. constructor(name?: string | undefined);
  80651. protected _getTypeName(): string;
  80652. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80653. }
  80654. }
  80655. declare module BABYLON.GUI {
  80656. /** Class used to create a RadioGroup
  80657. * which contains groups of radio buttons
  80658. */
  80659. export class SelectorGroup {
  80660. /** name of SelectorGroup */
  80661. name: string;
  80662. private _groupPanel;
  80663. private _selectors;
  80664. private _groupHeader;
  80665. /**
  80666. * Creates a new SelectorGroup
  80667. * @param name of group, used as a group heading
  80668. */
  80669. constructor(
  80670. /** name of SelectorGroup */
  80671. name: string);
  80672. /** Gets the groupPanel of the SelectorGroup */
  80673. get groupPanel(): StackPanel;
  80674. /** Gets the selectors array */
  80675. get selectors(): StackPanel[];
  80676. /** Gets and sets the group header */
  80677. get header(): string;
  80678. set header(label: string);
  80679. /** @hidden */
  80680. private _addGroupHeader;
  80681. /** @hidden*/
  80682. _getSelector(selectorNb: number): StackPanel | undefined;
  80683. /** Removes the selector at the given position
  80684. * @param selectorNb the position of the selector within the group
  80685. */
  80686. removeSelector(selectorNb: number): void;
  80687. }
  80688. /** Class used to create a CheckboxGroup
  80689. * which contains groups of checkbox buttons
  80690. */
  80691. export class CheckboxGroup extends SelectorGroup {
  80692. /** Adds a checkbox as a control
  80693. * @param text is the label for the selector
  80694. * @param func is the function called when the Selector is checked
  80695. * @param checked is true when Selector is checked
  80696. */
  80697. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  80698. /** @hidden */
  80699. _setSelectorLabel(selectorNb: number, label: string): void;
  80700. /** @hidden */
  80701. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80702. /** @hidden */
  80703. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80704. /** @hidden */
  80705. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80706. }
  80707. /** Class used to create a RadioGroup
  80708. * which contains groups of radio buttons
  80709. */
  80710. export class RadioGroup extends SelectorGroup {
  80711. private _selectNb;
  80712. /** Adds a radio button as a control
  80713. * @param label is the label for the selector
  80714. * @param func is the function called when the Selector is checked
  80715. * @param checked is true when Selector is checked
  80716. */
  80717. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  80718. /** @hidden */
  80719. _setSelectorLabel(selectorNb: number, label: string): void;
  80720. /** @hidden */
  80721. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80722. /** @hidden */
  80723. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80724. /** @hidden */
  80725. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80726. }
  80727. /** Class used to create a SliderGroup
  80728. * which contains groups of slider buttons
  80729. */
  80730. export class SliderGroup extends SelectorGroup {
  80731. /**
  80732. * Adds a slider to the SelectorGroup
  80733. * @param label is the label for the SliderBar
  80734. * @param func is the function called when the Slider moves
  80735. * @param unit is a string describing the units used, eg degrees or metres
  80736. * @param min is the minimum value for the Slider
  80737. * @param max is the maximum value for the Slider
  80738. * @param value is the start value for the Slider between min and max
  80739. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  80740. */
  80741. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  80742. /** @hidden */
  80743. _setSelectorLabel(selectorNb: number, label: string): void;
  80744. /** @hidden */
  80745. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80746. /** @hidden */
  80747. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80748. /** @hidden */
  80749. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80750. }
  80751. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  80752. * @see https://doc.babylonjs.com/how_to/selector
  80753. */
  80754. export class SelectionPanel extends Rectangle {
  80755. /** name of SelectionPanel */
  80756. name: string;
  80757. /** an array of SelectionGroups */
  80758. groups: SelectorGroup[];
  80759. private _panel;
  80760. private _buttonColor;
  80761. private _buttonBackground;
  80762. private _headerColor;
  80763. private _barColor;
  80764. private _barHeight;
  80765. private _spacerHeight;
  80766. private _labelColor;
  80767. private _groups;
  80768. private _bars;
  80769. /**
  80770. * Creates a new SelectionPanel
  80771. * @param name of SelectionPanel
  80772. * @param groups is an array of SelectionGroups
  80773. */
  80774. constructor(
  80775. /** name of SelectionPanel */
  80776. name: string,
  80777. /** an array of SelectionGroups */
  80778. groups?: SelectorGroup[]);
  80779. protected _getTypeName(): string;
  80780. /** Gets the (stack) panel of the SelectionPanel */
  80781. get panel(): StackPanel;
  80782. /** Gets or sets the headerColor */
  80783. get headerColor(): string;
  80784. set headerColor(color: string);
  80785. private _setHeaderColor;
  80786. /** Gets or sets the button color */
  80787. get buttonColor(): string;
  80788. set buttonColor(color: string);
  80789. private _setbuttonColor;
  80790. /** Gets or sets the label color */
  80791. get labelColor(): string;
  80792. set labelColor(color: string);
  80793. private _setLabelColor;
  80794. /** Gets or sets the button background */
  80795. get buttonBackground(): string;
  80796. set buttonBackground(color: string);
  80797. private _setButtonBackground;
  80798. /** Gets or sets the color of separator bar */
  80799. get barColor(): string;
  80800. set barColor(color: string);
  80801. private _setBarColor;
  80802. /** Gets or sets the height of separator bar */
  80803. get barHeight(): string;
  80804. set barHeight(value: string);
  80805. private _setBarHeight;
  80806. /** Gets or sets the height of spacers*/
  80807. get spacerHeight(): string;
  80808. set spacerHeight(value: string);
  80809. private _setSpacerHeight;
  80810. /** Adds a bar between groups */
  80811. private _addSpacer;
  80812. /** Add a group to the selection panel
  80813. * @param group is the selector group to add
  80814. */
  80815. addGroup(group: SelectorGroup): void;
  80816. /** Remove the group from the given position
  80817. * @param groupNb is the position of the group in the list
  80818. */
  80819. removeGroup(groupNb: number): void;
  80820. /** Change a group header label
  80821. * @param label is the new group header label
  80822. * @param groupNb is the number of the group to relabel
  80823. * */
  80824. setHeaderName(label: string, groupNb: number): void;
  80825. /** Change selector label to the one given
  80826. * @param label is the new selector label
  80827. * @param groupNb is the number of the groupcontaining the selector
  80828. * @param selectorNb is the number of the selector within a group to relabel
  80829. * */
  80830. relabel(label: string, groupNb: number, selectorNb: number): void;
  80831. /** For a given group position remove the selector at the given position
  80832. * @param groupNb is the number of the group to remove the selector from
  80833. * @param selectorNb is the number of the selector within the group
  80834. */
  80835. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  80836. /** For a given group position of correct type add a checkbox button
  80837. * @param groupNb is the number of the group to remove the selector from
  80838. * @param label is the label for the selector
  80839. * @param func is the function called when the Selector is checked
  80840. * @param checked is true when Selector is checked
  80841. */
  80842. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80843. /** For a given group position of correct type add a radio button
  80844. * @param groupNb is the number of the group to remove the selector from
  80845. * @param label is the label for the selector
  80846. * @param func is the function called when the Selector is checked
  80847. * @param checked is true when Selector is checked
  80848. */
  80849. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  80850. /**
  80851. * For a given slider group add a slider
  80852. * @param groupNb is the number of the group to add the slider to
  80853. * @param label is the label for the Slider
  80854. * @param func is the function called when the Slider moves
  80855. * @param unit is a string describing the units used, eg degrees or metres
  80856. * @param min is the minimum value for the Slider
  80857. * @param max is the maximum value for the Slider
  80858. * @param value is the start value for the Slider between min and max
  80859. * @param onVal is the function used to format the value displayed, eg radians to degrees
  80860. */
  80861. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  80862. }
  80863. }
  80864. declare module BABYLON.GUI {
  80865. /**
  80866. * Class used to hold a the container for ScrollViewer
  80867. * @hidden
  80868. */
  80869. export class _ScrollViewerWindow extends Container {
  80870. parentClientWidth: number;
  80871. parentClientHeight: number;
  80872. private _freezeControls;
  80873. private _parentMeasure;
  80874. private _oldLeft;
  80875. private _oldTop;
  80876. get freezeControls(): boolean;
  80877. set freezeControls(value: boolean);
  80878. private _bucketWidth;
  80879. private _bucketHeight;
  80880. private _buckets;
  80881. private _bucketLen;
  80882. get bucketWidth(): number;
  80883. get bucketHeight(): number;
  80884. setBucketSizes(width: number, height: number): void;
  80885. private _useBuckets;
  80886. private _makeBuckets;
  80887. private _dispatchInBuckets;
  80888. private _updateMeasures;
  80889. private _updateChildrenMeasures;
  80890. private _restoreMeasures;
  80891. /**
  80892. * Creates a new ScrollViewerWindow
  80893. * @param name of ScrollViewerWindow
  80894. */
  80895. constructor(name?: string);
  80896. protected _getTypeName(): string;
  80897. /** @hidden */
  80898. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80899. /** @hidden */
  80900. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  80901. private _scrollChildren;
  80902. private _scrollChildrenWithBuckets;
  80903. /** @hidden */
  80904. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  80905. protected _postMeasure(): void;
  80906. }
  80907. }
  80908. declare module BABYLON.GUI {
  80909. /**
  80910. * Class used to create slider controls
  80911. */
  80912. export class ScrollBar extends BaseSlider {
  80913. name?: string | undefined;
  80914. private _background;
  80915. private _borderColor;
  80916. private _tempMeasure;
  80917. /** Gets or sets border color */
  80918. get borderColor(): string;
  80919. set borderColor(value: string);
  80920. /** Gets or sets background color */
  80921. get background(): string;
  80922. set background(value: string);
  80923. /**
  80924. * Creates a new Slider
  80925. * @param name defines the control name
  80926. */
  80927. constructor(name?: string | undefined);
  80928. protected _getTypeName(): string;
  80929. protected _getThumbThickness(): number;
  80930. _draw(context: CanvasRenderingContext2D): void;
  80931. private _first;
  80932. private _originX;
  80933. private _originY;
  80934. /** @hidden */
  80935. protected _updateValueFromPointer(x: number, y: number): void;
  80936. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80937. }
  80938. }
  80939. declare module BABYLON.GUI {
  80940. /**
  80941. * Class used to create slider controls
  80942. */
  80943. export class ImageScrollBar extends BaseSlider {
  80944. name?: string | undefined;
  80945. private _backgroundBaseImage;
  80946. private _backgroundImage;
  80947. private _thumbImage;
  80948. private _thumbBaseImage;
  80949. private _thumbLength;
  80950. private _thumbHeight;
  80951. private _barImageHeight;
  80952. private _tempMeasure;
  80953. /** Number of 90° rotation to apply on the images when in vertical mode */
  80954. num90RotationInVerticalMode: number;
  80955. /**
  80956. * Gets or sets the image used to render the background for horizontal bar
  80957. */
  80958. get backgroundImage(): Image;
  80959. set backgroundImage(value: Image);
  80960. /**
  80961. * Gets or sets the image used to render the thumb
  80962. */
  80963. get thumbImage(): Image;
  80964. set thumbImage(value: Image);
  80965. /**
  80966. * Gets or sets the length of the thumb
  80967. */
  80968. get thumbLength(): number;
  80969. set thumbLength(value: number);
  80970. /**
  80971. * Gets or sets the height of the thumb
  80972. */
  80973. get thumbHeight(): number;
  80974. set thumbHeight(value: number);
  80975. /**
  80976. * Gets or sets the height of the bar image
  80977. */
  80978. get barImageHeight(): number;
  80979. set barImageHeight(value: number);
  80980. /**
  80981. * Creates a new ImageScrollBar
  80982. * @param name defines the control name
  80983. */
  80984. constructor(name?: string | undefined);
  80985. protected _getTypeName(): string;
  80986. protected _getThumbThickness(): number;
  80987. _draw(context: CanvasRenderingContext2D): void;
  80988. private _first;
  80989. private _originX;
  80990. private _originY;
  80991. /** @hidden */
  80992. protected _updateValueFromPointer(x: number, y: number): void;
  80993. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80994. }
  80995. }
  80996. declare module BABYLON.GUI {
  80997. /**
  80998. * Class used to hold a viewer window and sliders in a grid
  80999. */
  81000. export class ScrollViewer extends Rectangle {
  81001. private _grid;
  81002. private _horizontalBarSpace;
  81003. private _verticalBarSpace;
  81004. private _dragSpace;
  81005. private _horizontalBar;
  81006. private _verticalBar;
  81007. private _barColor;
  81008. private _barBackground;
  81009. private _barImage;
  81010. private _horizontalBarImage;
  81011. private _verticalBarImage;
  81012. private _barBackgroundImage;
  81013. private _horizontalBarBackgroundImage;
  81014. private _verticalBarBackgroundImage;
  81015. private _barSize;
  81016. private _window;
  81017. private _pointerIsOver;
  81018. private _wheelPrecision;
  81019. private _onWheelObserver;
  81020. private _clientWidth;
  81021. private _clientHeight;
  81022. private _useImageBar;
  81023. private _thumbLength;
  81024. private _thumbHeight;
  81025. private _barImageHeight;
  81026. private _horizontalBarImageHeight;
  81027. private _verticalBarImageHeight;
  81028. private _oldWindowContentsWidth;
  81029. private _oldWindowContentsHeight;
  81030. /**
  81031. * Gets the horizontal scrollbar
  81032. */
  81033. get horizontalBar(): ScrollBar | ImageScrollBar;
  81034. /**
  81035. * Gets the vertical scrollbar
  81036. */
  81037. get verticalBar(): ScrollBar | ImageScrollBar;
  81038. /**
  81039. * Adds a new control to the current container
  81040. * @param control defines the control to add
  81041. * @returns the current container
  81042. */
  81043. addControl(control: BABYLON.Nullable<Control>): Container;
  81044. /**
  81045. * Removes a control from the current container
  81046. * @param control defines the control to remove
  81047. * @returns the current container
  81048. */
  81049. removeControl(control: Control): Container;
  81050. /** Gets the list of children */
  81051. get children(): Control[];
  81052. _flagDescendantsAsMatrixDirty(): void;
  81053. /**
  81054. * Freezes or unfreezes the controls in the window.
  81055. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  81056. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  81057. */
  81058. get freezeControls(): boolean;
  81059. set freezeControls(value: boolean);
  81060. /** Gets the bucket width */
  81061. get bucketWidth(): number;
  81062. /** Gets the bucket height */
  81063. get bucketHeight(): number;
  81064. /**
  81065. * Sets the bucket sizes.
  81066. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  81067. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  81068. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  81069. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  81070. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  81071. * used), that's why it is not enabled by default.
  81072. * @param width width of the bucket
  81073. * @param height height of the bucket
  81074. */
  81075. setBucketSizes(width: number, height: number): void;
  81076. private _forceHorizontalBar;
  81077. private _forceVerticalBar;
  81078. /**
  81079. * Forces the horizontal scroll bar to be displayed
  81080. */
  81081. get forceHorizontalBar(): boolean;
  81082. set forceHorizontalBar(value: boolean);
  81083. /**
  81084. * Forces the vertical scroll bar to be displayed
  81085. */
  81086. get forceVerticalBar(): boolean;
  81087. set forceVerticalBar(value: boolean);
  81088. /**
  81089. * Creates a new ScrollViewer
  81090. * @param name of ScrollViewer
  81091. */
  81092. constructor(name?: string, isImageBased?: boolean);
  81093. /** Reset the scroll viewer window to initial size */
  81094. resetWindow(): void;
  81095. protected _getTypeName(): string;
  81096. private _buildClientSizes;
  81097. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  81098. protected _postMeasure(): void;
  81099. /**
  81100. * Gets or sets the mouse wheel precision
  81101. * from 0 to 1 with a default value of 0.05
  81102. * */
  81103. get wheelPrecision(): number;
  81104. set wheelPrecision(value: number);
  81105. /** Gets or sets the scroll bar container background color */
  81106. get scrollBackground(): string;
  81107. set scrollBackground(color: string);
  81108. /** Gets or sets the bar color */
  81109. get barColor(): string;
  81110. set barColor(color: string);
  81111. /** Gets or sets the bar image */
  81112. get thumbImage(): Image;
  81113. set thumbImage(value: Image);
  81114. /** Gets or sets the horizontal bar image */
  81115. get horizontalThumbImage(): Image;
  81116. set horizontalThumbImage(value: Image);
  81117. /** Gets or sets the vertical bar image */
  81118. get verticalThumbImage(): Image;
  81119. set verticalThumbImage(value: Image);
  81120. /** Gets or sets the size of the bar */
  81121. get barSize(): number;
  81122. set barSize(value: number);
  81123. /** Gets or sets the length of the thumb */
  81124. get thumbLength(): number;
  81125. set thumbLength(value: number);
  81126. /** Gets or sets the height of the thumb */
  81127. get thumbHeight(): number;
  81128. set thumbHeight(value: number);
  81129. /** Gets or sets the height of the bar image */
  81130. get barImageHeight(): number;
  81131. set barImageHeight(value: number);
  81132. /** Gets or sets the height of the horizontal bar image */
  81133. get horizontalBarImageHeight(): number;
  81134. set horizontalBarImageHeight(value: number);
  81135. /** Gets or sets the height of the vertical bar image */
  81136. get verticalBarImageHeight(): number;
  81137. set verticalBarImageHeight(value: number);
  81138. /** Gets or sets the bar background */
  81139. get barBackground(): string;
  81140. set barBackground(color: string);
  81141. /** Gets or sets the bar background image */
  81142. get barImage(): Image;
  81143. set barImage(value: Image);
  81144. /** Gets or sets the horizontal bar background image */
  81145. get horizontalBarImage(): Image;
  81146. set horizontalBarImage(value: Image);
  81147. /** Gets or sets the vertical bar background image */
  81148. get verticalBarImage(): Image;
  81149. set verticalBarImage(value: Image);
  81150. private _setWindowPosition;
  81151. /** @hidden */
  81152. private _updateScroller;
  81153. _link(host: AdvancedDynamicTexture): void;
  81154. /** @hidden */
  81155. private _addBar;
  81156. /** @hidden */
  81157. private _attachWheel;
  81158. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  81159. /** Releases associated resources */
  81160. dispose(): void;
  81161. }
  81162. }
  81163. declare module BABYLON.GUI {
  81164. /** Class used to render a grid */
  81165. export class DisplayGrid extends Control {
  81166. name?: string | undefined;
  81167. private _cellWidth;
  81168. private _cellHeight;
  81169. private _minorLineTickness;
  81170. private _minorLineColor;
  81171. private _majorLineTickness;
  81172. private _majorLineColor;
  81173. private _majorLineFrequency;
  81174. private _background;
  81175. private _displayMajorLines;
  81176. private _displayMinorLines;
  81177. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  81178. get displayMinorLines(): boolean;
  81179. set displayMinorLines(value: boolean);
  81180. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  81181. get displayMajorLines(): boolean;
  81182. set displayMajorLines(value: boolean);
  81183. /** Gets or sets background color (Black by default) */
  81184. get background(): string;
  81185. set background(value: string);
  81186. /** Gets or sets the width of each cell (20 by default) */
  81187. get cellWidth(): number;
  81188. set cellWidth(value: number);
  81189. /** Gets or sets the height of each cell (20 by default) */
  81190. get cellHeight(): number;
  81191. set cellHeight(value: number);
  81192. /** Gets or sets the tickness of minor lines (1 by default) */
  81193. get minorLineTickness(): number;
  81194. set minorLineTickness(value: number);
  81195. /** Gets or sets the color of minor lines (DarkGray by default) */
  81196. get minorLineColor(): string;
  81197. set minorLineColor(value: string);
  81198. /** Gets or sets the tickness of major lines (2 by default) */
  81199. get majorLineTickness(): number;
  81200. set majorLineTickness(value: number);
  81201. /** Gets or sets the color of major lines (White by default) */
  81202. get majorLineColor(): string;
  81203. set majorLineColor(value: string);
  81204. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  81205. get majorLineFrequency(): number;
  81206. set majorLineFrequency(value: number);
  81207. /**
  81208. * Creates a new GridDisplayRectangle
  81209. * @param name defines the control name
  81210. */
  81211. constructor(name?: string | undefined);
  81212. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81213. protected _getTypeName(): string;
  81214. }
  81215. }
  81216. declare module BABYLON.GUI {
  81217. /**
  81218. * Class used to create slider controls based on images
  81219. */
  81220. export class ImageBasedSlider extends BaseSlider {
  81221. name?: string | undefined;
  81222. private _backgroundImage;
  81223. private _thumbImage;
  81224. private _valueBarImage;
  81225. private _tempMeasure;
  81226. get displayThumb(): boolean;
  81227. set displayThumb(value: boolean);
  81228. /**
  81229. * Gets or sets the image used to render the background
  81230. */
  81231. get backgroundImage(): Image;
  81232. set backgroundImage(value: Image);
  81233. /**
  81234. * Gets or sets the image used to render the value bar
  81235. */
  81236. get valueBarImage(): Image;
  81237. set valueBarImage(value: Image);
  81238. /**
  81239. * Gets or sets the image used to render the thumb
  81240. */
  81241. get thumbImage(): Image;
  81242. set thumbImage(value: Image);
  81243. /**
  81244. * Creates a new ImageBasedSlider
  81245. * @param name defines the control name
  81246. */
  81247. constructor(name?: string | undefined);
  81248. protected _getTypeName(): string;
  81249. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81250. }
  81251. }
  81252. declare module BABYLON.GUI {
  81253. /**
  81254. * Forcing an export so that this code will execute
  81255. * @hidden
  81256. */
  81257. const name = "Statics";
  81258. }
  81259. declare module BABYLON.GUI {
  81260. /**
  81261. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  81262. */
  81263. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  81264. /**
  81265. * Define the instrumented AdvancedDynamicTexture.
  81266. */
  81267. texture: AdvancedDynamicTexture;
  81268. private _captureRenderTime;
  81269. private _renderTime;
  81270. private _captureLayoutTime;
  81271. private _layoutTime;
  81272. private _onBeginRenderObserver;
  81273. private _onEndRenderObserver;
  81274. private _onBeginLayoutObserver;
  81275. private _onEndLayoutObserver;
  81276. /**
  81277. * Gets the perf counter used to capture render time
  81278. */
  81279. get renderTimeCounter(): BABYLON.PerfCounter;
  81280. /**
  81281. * Gets the perf counter used to capture layout time
  81282. */
  81283. get layoutTimeCounter(): BABYLON.PerfCounter;
  81284. /**
  81285. * Enable or disable the render time capture
  81286. */
  81287. get captureRenderTime(): boolean;
  81288. set captureRenderTime(value: boolean);
  81289. /**
  81290. * Enable or disable the layout time capture
  81291. */
  81292. get captureLayoutTime(): boolean;
  81293. set captureLayoutTime(value: boolean);
  81294. /**
  81295. * Instantiates a new advanced dynamic texture instrumentation.
  81296. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  81297. * @param texture Defines the AdvancedDynamicTexture to instrument
  81298. */
  81299. constructor(
  81300. /**
  81301. * Define the instrumented AdvancedDynamicTexture.
  81302. */
  81303. texture: AdvancedDynamicTexture);
  81304. /**
  81305. * Dispose and release associated resources.
  81306. */
  81307. dispose(): void;
  81308. }
  81309. }
  81310. declare module BABYLON.GUI {
  81311. /**
  81312. * Class used to load GUI via XML.
  81313. */
  81314. export class XmlLoader {
  81315. private _nodes;
  81316. private _nodeTypes;
  81317. private _isLoaded;
  81318. private _objectAttributes;
  81319. private _parentClass;
  81320. /**
  81321. * Create a new xml loader
  81322. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  81323. */
  81324. constructor(parentClass?: null);
  81325. private _getChainElement;
  81326. private _getClassAttribute;
  81327. private _createGuiElement;
  81328. private _parseGrid;
  81329. private _parseElement;
  81330. private _prepareSourceElement;
  81331. private _parseElementsFromSource;
  81332. private _parseXml;
  81333. /**
  81334. * Gets if the loading has finished.
  81335. * @returns whether the loading has finished or not
  81336. */
  81337. isLoaded(): boolean;
  81338. /**
  81339. * Gets a loaded node / control by id.
  81340. * @param id the Controls id set in the xml
  81341. * @returns element of type Control
  81342. */
  81343. getNodeById(id: string): any;
  81344. /**
  81345. * Gets all loaded nodes / controls
  81346. * @returns Array of controls
  81347. */
  81348. getNodes(): any;
  81349. /**
  81350. * Initiates the xml layout loading
  81351. * @param xmlFile defines the xml layout to load
  81352. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  81353. * @param callback defines the callback called on layout load.
  81354. */
  81355. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  81356. }
  81357. }
  81358. declare module BABYLON.GUI {
  81359. /**
  81360. * Class used to create containers for controls
  81361. */
  81362. export class Container3D extends Control3D {
  81363. private _blockLayout;
  81364. /**
  81365. * Gets the list of child controls
  81366. */
  81367. protected _children: Control3D[];
  81368. /**
  81369. * Gets the list of child controls
  81370. */
  81371. get children(): Array<Control3D>;
  81372. /**
  81373. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  81374. * This is helpful to optimize layout operation when adding multiple children in a row
  81375. */
  81376. get blockLayout(): boolean;
  81377. set blockLayout(value: boolean);
  81378. /**
  81379. * Creates a new container
  81380. * @param name defines the container name
  81381. */
  81382. constructor(name?: string);
  81383. /**
  81384. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  81385. * @returns the current container
  81386. */
  81387. updateLayout(): Container3D;
  81388. /**
  81389. * Gets a boolean indicating if the given control is in the children of this control
  81390. * @param control defines the control to check
  81391. * @returns true if the control is in the child list
  81392. */
  81393. containsControl(control: Control3D): boolean;
  81394. /**
  81395. * Adds a control to the children of this control
  81396. * @param control defines the control to add
  81397. * @returns the current container
  81398. */
  81399. addControl(control: Control3D): Container3D;
  81400. /**
  81401. * This function will be called everytime a new control is added
  81402. */
  81403. protected _arrangeChildren(): void;
  81404. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81405. /**
  81406. * Removes a control from the children of this control
  81407. * @param control defines the control to remove
  81408. * @returns the current container
  81409. */
  81410. removeControl(control: Control3D): Container3D;
  81411. protected _getTypeName(): string;
  81412. /**
  81413. * Releases all associated resources
  81414. */
  81415. dispose(): void;
  81416. /** Control rotation will remain unchanged */
  81417. static readonly UNSET_ORIENTATION: number;
  81418. /** Control will rotate to make it look at sphere central axis */
  81419. static readonly FACEORIGIN_ORIENTATION: number;
  81420. /** Control will rotate to make it look back at sphere central axis */
  81421. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  81422. /** Control will rotate to look at z axis (0, 0, 1) */
  81423. static readonly FACEFORWARD_ORIENTATION: number;
  81424. /** Control will rotate to look at negative z axis (0, 0, -1) */
  81425. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  81426. }
  81427. }
  81428. declare module BABYLON.GUI {
  81429. /**
  81430. * Class used to manage 3D user interface
  81431. * @see https://doc.babylonjs.com/how_to/gui3d
  81432. */
  81433. export class GUI3DManager implements BABYLON.IDisposable {
  81434. private _scene;
  81435. private _sceneDisposeObserver;
  81436. private _utilityLayer;
  81437. private _rootContainer;
  81438. private _pointerObserver;
  81439. private _pointerOutObserver;
  81440. /** @hidden */
  81441. _lastPickedControl: Control3D;
  81442. /** @hidden */
  81443. _lastControlOver: {
  81444. [pointerId: number]: Control3D;
  81445. };
  81446. /** @hidden */
  81447. _lastControlDown: {
  81448. [pointerId: number]: Control3D;
  81449. };
  81450. /**
  81451. * BABYLON.Observable raised when the point picked by the pointer events changed
  81452. */
  81453. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  81454. /** @hidden */
  81455. _sharedMaterials: {
  81456. [key: string]: BABYLON.Material;
  81457. };
  81458. /** Gets the hosting scene */
  81459. get scene(): BABYLON.Scene;
  81460. /** Gets associated utility layer */
  81461. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  81462. /**
  81463. * Creates a new GUI3DManager
  81464. * @param scene
  81465. */
  81466. constructor(scene?: BABYLON.Scene);
  81467. private _handlePointerOut;
  81468. private _doPicking;
  81469. /**
  81470. * Gets the root container
  81471. */
  81472. get rootContainer(): Container3D;
  81473. /**
  81474. * Gets a boolean indicating if the given control is in the root child list
  81475. * @param control defines the control to check
  81476. * @returns true if the control is in the root child list
  81477. */
  81478. containsControl(control: Control3D): boolean;
  81479. /**
  81480. * Adds a control to the root child list
  81481. * @param control defines the control to add
  81482. * @returns the current manager
  81483. */
  81484. addControl(control: Control3D): GUI3DManager;
  81485. /**
  81486. * Removes a control from the root child list
  81487. * @param control defines the control to remove
  81488. * @returns the current container
  81489. */
  81490. removeControl(control: Control3D): GUI3DManager;
  81491. /**
  81492. * Releases all associated resources
  81493. */
  81494. dispose(): void;
  81495. }
  81496. }
  81497. declare module BABYLON.GUI {
  81498. /**
  81499. * Class used to transport BABYLON.Vector3 information for pointer events
  81500. */
  81501. export class Vector3WithInfo extends BABYLON.Vector3 {
  81502. /** defines the current mouse button index */
  81503. buttonIndex: number;
  81504. /**
  81505. * Creates a new Vector3WithInfo
  81506. * @param source defines the vector3 data to transport
  81507. * @param buttonIndex defines the current mouse button index
  81508. */
  81509. constructor(source: BABYLON.Vector3,
  81510. /** defines the current mouse button index */
  81511. buttonIndex?: number);
  81512. }
  81513. }
  81514. declare module BABYLON.GUI {
  81515. /**
  81516. * Class used as base class for controls
  81517. */
  81518. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  81519. /** Defines the control name */
  81520. name?: string | undefined;
  81521. /** @hidden */
  81522. _host: GUI3DManager;
  81523. private _node;
  81524. private _downCount;
  81525. private _enterCount;
  81526. private _downPointerIds;
  81527. private _isVisible;
  81528. /** Gets or sets the control position in world space */
  81529. get position(): BABYLON.Vector3;
  81530. set position(value: BABYLON.Vector3);
  81531. /** Gets or sets the control scaling in world space */
  81532. get scaling(): BABYLON.Vector3;
  81533. set scaling(value: BABYLON.Vector3);
  81534. /** Callback used to start pointer enter animation */
  81535. pointerEnterAnimation: () => void;
  81536. /** Callback used to start pointer out animation */
  81537. pointerOutAnimation: () => void;
  81538. /** Callback used to start pointer down animation */
  81539. pointerDownAnimation: () => void;
  81540. /** Callback used to start pointer up animation */
  81541. pointerUpAnimation: () => void;
  81542. /**
  81543. * An event triggered when the pointer move over the control
  81544. */
  81545. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  81546. /**
  81547. * An event triggered when the pointer move out of the control
  81548. */
  81549. onPointerOutObservable: BABYLON.Observable<Control3D>;
  81550. /**
  81551. * An event triggered when the pointer taps the control
  81552. */
  81553. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  81554. /**
  81555. * An event triggered when pointer is up
  81556. */
  81557. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  81558. /**
  81559. * An event triggered when a control is clicked on (with a mouse)
  81560. */
  81561. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  81562. /**
  81563. * An event triggered when pointer enters the control
  81564. */
  81565. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  81566. /**
  81567. * Gets or sets the parent container
  81568. */
  81569. parent: BABYLON.Nullable<Container3D>;
  81570. private _behaviors;
  81571. /**
  81572. * Gets the list of attached behaviors
  81573. * @see https://doc.babylonjs.com/features/behaviour
  81574. */
  81575. get behaviors(): BABYLON.Behavior<Control3D>[];
  81576. /**
  81577. * Attach a behavior to the control
  81578. * @see https://doc.babylonjs.com/features/behaviour
  81579. * @param behavior defines the behavior to attach
  81580. * @returns the current control
  81581. */
  81582. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81583. /**
  81584. * Remove an attached behavior
  81585. * @see https://doc.babylonjs.com/features/behaviour
  81586. * @param behavior defines the behavior to attach
  81587. * @returns the current control
  81588. */
  81589. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81590. /**
  81591. * Gets an attached behavior by name
  81592. * @param name defines the name of the behavior to look for
  81593. * @see https://doc.babylonjs.com/features/behaviour
  81594. * @returns null if behavior was not found else the requested behavior
  81595. */
  81596. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  81597. /** Gets or sets a boolean indicating if the control is visible */
  81598. get isVisible(): boolean;
  81599. set isVisible(value: boolean);
  81600. /**
  81601. * Creates a new control
  81602. * @param name defines the control name
  81603. */
  81604. constructor(
  81605. /** Defines the control name */
  81606. name?: string | undefined);
  81607. /**
  81608. * Gets a string representing the class name
  81609. */
  81610. get typeName(): string;
  81611. /**
  81612. * Get the current class name of the control.
  81613. * @returns current class name
  81614. */
  81615. getClassName(): string;
  81616. protected _getTypeName(): string;
  81617. /**
  81618. * Gets the transform node used by this control
  81619. */
  81620. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  81621. /**
  81622. * Gets the mesh used to render this control
  81623. */
  81624. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  81625. /**
  81626. * Link the control as child of the given node
  81627. * @param node defines the node to link to. Use null to unlink the control
  81628. * @returns the current control
  81629. */
  81630. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  81631. /** @hidden **/
  81632. _prepareNode(scene: BABYLON.Scene): void;
  81633. /**
  81634. * Node creation.
  81635. * Can be overriden by children
  81636. * @param scene defines the scene where the node must be attached
  81637. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  81638. */
  81639. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81640. /**
  81641. * Affect a material to the given mesh
  81642. * @param mesh defines the mesh which will represent the control
  81643. */
  81644. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81645. /** @hidden */
  81646. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  81647. /** @hidden */
  81648. _onPointerEnter(target: Control3D): boolean;
  81649. /** @hidden */
  81650. _onPointerOut(target: Control3D): void;
  81651. /** @hidden */
  81652. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81653. /** @hidden */
  81654. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  81655. /** @hidden */
  81656. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  81657. /** @hidden */
  81658. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81659. /** @hidden */
  81660. _disposeNode(): void;
  81661. /**
  81662. * Releases all associated resources
  81663. */
  81664. dispose(): void;
  81665. }
  81666. }
  81667. declare module BABYLON.GUI {
  81668. /**
  81669. * Class used as a root to all buttons
  81670. */
  81671. export class AbstractButton3D extends Control3D {
  81672. /**
  81673. * Creates a new button
  81674. * @param name defines the control name
  81675. */
  81676. constructor(name?: string);
  81677. protected _getTypeName(): string;
  81678. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81679. }
  81680. }
  81681. declare module BABYLON.GUI {
  81682. /**
  81683. * Class used to create a button in 3D
  81684. */
  81685. export class Button3D extends AbstractButton3D {
  81686. /** @hidden */
  81687. protected _currentMaterial: BABYLON.Material;
  81688. private _facadeTexture;
  81689. private _content;
  81690. private _contentResolution;
  81691. private _contentScaleRatio;
  81692. /**
  81693. * Gets or sets the texture resolution used to render content (512 by default)
  81694. */
  81695. get contentResolution(): BABYLON.int;
  81696. set contentResolution(value: BABYLON.int);
  81697. /**
  81698. * Gets or sets the texture scale ratio used to render content (2 by default)
  81699. */
  81700. get contentScaleRatio(): number;
  81701. set contentScaleRatio(value: number);
  81702. protected _disposeFacadeTexture(): void;
  81703. protected _resetContent(): void;
  81704. /**
  81705. * Creates a new button
  81706. * @param name defines the control name
  81707. */
  81708. constructor(name?: string);
  81709. /**
  81710. * Gets or sets the GUI 2D content used to display the button's facade
  81711. */
  81712. get content(): Control;
  81713. set content(value: Control);
  81714. /**
  81715. * Apply the facade texture (created from the content property).
  81716. * This function can be overloaded by child classes
  81717. * @param facadeTexture defines the AdvancedDynamicTexture to use
  81718. */
  81719. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81720. protected _getTypeName(): string;
  81721. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81722. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81723. /**
  81724. * Releases all associated resources
  81725. */
  81726. dispose(): void;
  81727. }
  81728. }
  81729. declare module BABYLON.GUI {
  81730. /**
  81731. * Abstract class used to create a container panel deployed on the surface of a volume
  81732. */
  81733. export abstract class VolumeBasedPanel extends Container3D {
  81734. private _columns;
  81735. private _rows;
  81736. private _rowThenColum;
  81737. private _orientation;
  81738. protected _cellWidth: number;
  81739. protected _cellHeight: number;
  81740. /**
  81741. * Gets or sets the distance between elements
  81742. */
  81743. margin: number;
  81744. /**
  81745. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  81746. * | Value | Type | Description |
  81747. * | ----- | ----------------------------------- | ----------- |
  81748. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  81749. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  81750. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  81751. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  81752. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  81753. */
  81754. get orientation(): number;
  81755. set orientation(value: number);
  81756. /**
  81757. * Gets or sets the number of columns requested (10 by default).
  81758. * The panel will automatically compute the number of rows based on number of child controls.
  81759. */
  81760. get columns(): BABYLON.int;
  81761. set columns(value: BABYLON.int);
  81762. /**
  81763. * Gets or sets a the number of rows requested.
  81764. * The panel will automatically compute the number of columns based on number of child controls.
  81765. */
  81766. get rows(): BABYLON.int;
  81767. set rows(value: BABYLON.int);
  81768. /**
  81769. * Creates new VolumeBasedPanel
  81770. */
  81771. constructor();
  81772. protected _arrangeChildren(): void;
  81773. /** Child classes must implement this function to provide correct control positioning */
  81774. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81775. /** Child classes can implement this function to provide additional processing */
  81776. protected _finalProcessing(): void;
  81777. }
  81778. }
  81779. declare module BABYLON.GUI {
  81780. /**
  81781. * Class used to create a container panel deployed on the surface of a cylinder
  81782. */
  81783. export class CylinderPanel extends VolumeBasedPanel {
  81784. private _radius;
  81785. /**
  81786. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  81787. */
  81788. get radius(): BABYLON.float;
  81789. set radius(value: BABYLON.float);
  81790. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81791. private _cylindricalMapping;
  81792. }
  81793. }
  81794. declare module BABYLON.GUI {
  81795. /** @hidden */
  81796. export var fluentVertexShader: {
  81797. name: string;
  81798. shader: string;
  81799. };
  81800. }
  81801. declare module BABYLON.GUI {
  81802. /** @hidden */
  81803. export var fluentPixelShader: {
  81804. name: string;
  81805. shader: string;
  81806. };
  81807. }
  81808. declare module BABYLON.GUI {
  81809. /** @hidden */
  81810. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  81811. INNERGLOW: boolean;
  81812. BORDER: boolean;
  81813. HOVERLIGHT: boolean;
  81814. TEXTURE: boolean;
  81815. constructor();
  81816. }
  81817. /**
  81818. * Class used to render controls with fluent desgin
  81819. */
  81820. export class FluentMaterial extends BABYLON.PushMaterial {
  81821. /**
  81822. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  81823. */
  81824. innerGlowColorIntensity: number;
  81825. /**
  81826. * Gets or sets the inner glow color (white by default)
  81827. */
  81828. innerGlowColor: BABYLON.Color3;
  81829. /**
  81830. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  81831. */
  81832. albedoColor: BABYLON.Color3;
  81833. /**
  81834. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  81835. */
  81836. renderBorders: boolean;
  81837. /**
  81838. * Gets or sets border width (default is 0.5)
  81839. */
  81840. borderWidth: number;
  81841. /**
  81842. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  81843. */
  81844. edgeSmoothingValue: number;
  81845. /**
  81846. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  81847. */
  81848. borderMinValue: number;
  81849. /**
  81850. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  81851. */
  81852. renderHoverLight: boolean;
  81853. /**
  81854. * Gets or sets the radius used to render the hover light (default is 1.0)
  81855. */
  81856. hoverRadius: number;
  81857. /**
  81858. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  81859. */
  81860. hoverColor: BABYLON.Color4;
  81861. /**
  81862. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  81863. */
  81864. hoverPosition: BABYLON.Vector3;
  81865. private _albedoTexture;
  81866. /** Gets or sets the texture to use for albedo color */
  81867. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81868. /**
  81869. * Creates a new Fluent material
  81870. * @param name defines the name of the material
  81871. * @param scene defines the hosting scene
  81872. */
  81873. constructor(name: string, scene: BABYLON.Scene);
  81874. needAlphaBlending(): boolean;
  81875. needAlphaTesting(): boolean;
  81876. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81877. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81878. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81879. getActiveTextures(): BABYLON.BaseTexture[];
  81880. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81881. dispose(forceDisposeEffect?: boolean): void;
  81882. clone(name: string): FluentMaterial;
  81883. serialize(): any;
  81884. getClassName(): string;
  81885. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  81886. }
  81887. }
  81888. declare module BABYLON.GUI {
  81889. /**
  81890. * Class used to create a holographic button in 3D
  81891. */
  81892. export class HolographicButton extends Button3D {
  81893. private _backPlate;
  81894. private _textPlate;
  81895. private _frontPlate;
  81896. private _text;
  81897. private _imageUrl;
  81898. private _shareMaterials;
  81899. private _frontMaterial;
  81900. private _backMaterial;
  81901. private _plateMaterial;
  81902. private _pickedPointObserver;
  81903. private _tooltipFade;
  81904. private _tooltipTextBlock;
  81905. private _tooltipTexture;
  81906. private _tooltipMesh;
  81907. private _tooltipHoverObserver;
  81908. private _tooltipOutObserver;
  81909. private _disposeTooltip;
  81910. /**
  81911. * Rendering ground id of all the mesh in the button
  81912. */
  81913. set renderingGroupId(id: number);
  81914. get renderingGroupId(): number;
  81915. /**
  81916. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  81917. */
  81918. set tooltipText(text: BABYLON.Nullable<string>);
  81919. get tooltipText(): BABYLON.Nullable<string>;
  81920. /**
  81921. * Gets or sets text for the button
  81922. */
  81923. get text(): string;
  81924. set text(value: string);
  81925. /**
  81926. * Gets or sets the image url for the button
  81927. */
  81928. get imageUrl(): string;
  81929. set imageUrl(value: string);
  81930. /**
  81931. * Gets the back material used by this button
  81932. */
  81933. get backMaterial(): FluentMaterial;
  81934. /**
  81935. * Gets the front material used by this button
  81936. */
  81937. get frontMaterial(): FluentMaterial;
  81938. /**
  81939. * Gets the plate material used by this button
  81940. */
  81941. get plateMaterial(): BABYLON.StandardMaterial;
  81942. /**
  81943. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  81944. */
  81945. get shareMaterials(): boolean;
  81946. /**
  81947. * Creates a new button
  81948. * @param name defines the control name
  81949. */
  81950. constructor(name?: string, shareMaterials?: boolean);
  81951. protected _getTypeName(): string;
  81952. private _rebuildContent;
  81953. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81954. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81955. private _createBackMaterial;
  81956. private _createFrontMaterial;
  81957. private _createPlateMaterial;
  81958. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  81959. /**
  81960. * Releases all associated resources
  81961. */
  81962. dispose(): void;
  81963. }
  81964. }
  81965. declare module BABYLON.GUI {
  81966. /**
  81967. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  81968. */
  81969. export class MeshButton3D extends Button3D {
  81970. /** @hidden */
  81971. protected _currentMesh: BABYLON.Mesh;
  81972. /**
  81973. * Creates a new 3D button based on a mesh
  81974. * @param mesh mesh to become a 3D button
  81975. * @param name defines the control name
  81976. */
  81977. constructor(mesh: BABYLON.Mesh, name?: string);
  81978. protected _getTypeName(): string;
  81979. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81980. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81981. }
  81982. }
  81983. declare module BABYLON.GUI {
  81984. /**
  81985. * Class used to create a container panel deployed on the surface of a plane
  81986. */
  81987. export class PlanePanel extends VolumeBasedPanel {
  81988. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81989. }
  81990. }
  81991. declare module BABYLON.GUI {
  81992. /**
  81993. * Class used to create a container panel where items get randomized planar mapping
  81994. */
  81995. export class ScatterPanel extends VolumeBasedPanel {
  81996. private _iteration;
  81997. /**
  81998. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  81999. */
  82000. get iteration(): BABYLON.float;
  82001. set iteration(value: BABYLON.float);
  82002. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82003. private _scatterMapping;
  82004. protected _finalProcessing(): void;
  82005. }
  82006. }
  82007. declare module BABYLON.GUI {
  82008. /**
  82009. * Class used to create a container panel deployed on the surface of a sphere
  82010. */
  82011. export class SpherePanel extends VolumeBasedPanel {
  82012. private _radius;
  82013. /**
  82014. * Gets or sets the radius of the sphere where to project controls (5 by default)
  82015. */
  82016. get radius(): BABYLON.float;
  82017. set radius(value: BABYLON.float);
  82018. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82019. private _sphericalMapping;
  82020. }
  82021. }
  82022. declare module BABYLON.GUI {
  82023. /**
  82024. * Class used to create a stack panel in 3D on XY plane
  82025. */
  82026. export class StackPanel3D extends Container3D {
  82027. private _isVertical;
  82028. /**
  82029. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  82030. */
  82031. get isVertical(): boolean;
  82032. set isVertical(value: boolean);
  82033. /**
  82034. * Gets or sets the distance between elements
  82035. */
  82036. margin: number;
  82037. /**
  82038. * Creates new StackPanel
  82039. * @param isVertical
  82040. */
  82041. constructor(isVertical?: boolean);
  82042. protected _arrangeChildren(): void;
  82043. }
  82044. }
  82045. declare module BABYLON {
  82046. /**
  82047. * Configuration for glTF validation
  82048. */
  82049. export interface IGLTFValidationConfiguration {
  82050. /**
  82051. * The url of the glTF validator.
  82052. */
  82053. url: string;
  82054. }
  82055. /**
  82056. * glTF validation
  82057. */
  82058. export class GLTFValidation {
  82059. /**
  82060. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  82061. */
  82062. static Configuration: IGLTFValidationConfiguration;
  82063. private static _LoadScriptPromise;
  82064. /**
  82065. * Validate a glTF asset using the glTF-Validator.
  82066. * @param data The JSON of a glTF or the array buffer of a binary glTF
  82067. * @param rootUrl The root url for the glTF
  82068. * @param fileName The file name for the glTF
  82069. * @param getExternalResource The callback to get external resources for the glTF validator
  82070. * @returns A promise that resolves with the glTF validation results once complete
  82071. */
  82072. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  82073. }
  82074. }
  82075. declare module BABYLON {
  82076. /**
  82077. * Mode that determines the coordinate system to use.
  82078. */
  82079. export enum GLTFLoaderCoordinateSystemMode {
  82080. /**
  82081. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  82082. */
  82083. AUTO = 0,
  82084. /**
  82085. * Sets the useRightHandedSystem flag on the scene.
  82086. */
  82087. FORCE_RIGHT_HANDED = 1
  82088. }
  82089. /**
  82090. * Mode that determines what animations will start.
  82091. */
  82092. export enum GLTFLoaderAnimationStartMode {
  82093. /**
  82094. * No animation will start.
  82095. */
  82096. NONE = 0,
  82097. /**
  82098. * The first animation will start.
  82099. */
  82100. FIRST = 1,
  82101. /**
  82102. * All animations will start.
  82103. */
  82104. ALL = 2
  82105. }
  82106. /**
  82107. * Interface that contains the data for the glTF asset.
  82108. */
  82109. export interface IGLTFLoaderData {
  82110. /**
  82111. * The object that represents the glTF JSON.
  82112. */
  82113. json: Object;
  82114. /**
  82115. * The BIN chunk of a binary glTF.
  82116. */
  82117. bin: Nullable<IDataBuffer>;
  82118. }
  82119. /**
  82120. * Interface for extending the loader.
  82121. */
  82122. export interface IGLTFLoaderExtension {
  82123. /**
  82124. * The name of this extension.
  82125. */
  82126. readonly name: string;
  82127. /**
  82128. * Defines whether this extension is enabled.
  82129. */
  82130. enabled: boolean;
  82131. /**
  82132. * Defines the order of this extension.
  82133. * The loader sorts the extensions using these values when loading.
  82134. */
  82135. order?: number;
  82136. }
  82137. /**
  82138. * Loader state.
  82139. */
  82140. export enum GLTFLoaderState {
  82141. /**
  82142. * The asset is loading.
  82143. */
  82144. LOADING = 0,
  82145. /**
  82146. * The asset is ready for rendering.
  82147. */
  82148. READY = 1,
  82149. /**
  82150. * The asset is completely loaded.
  82151. */
  82152. COMPLETE = 2
  82153. }
  82154. /** @hidden */
  82155. export interface IGLTFLoader extends IDisposable {
  82156. readonly state: Nullable<GLTFLoaderState>;
  82157. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  82158. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  82159. }
  82160. /**
  82161. * File loader for loading glTF files into a scene.
  82162. */
  82163. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82164. /** @hidden */
  82165. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82166. /** @hidden */
  82167. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82168. /**
  82169. * Raised when the asset has been parsed
  82170. */
  82171. onParsedObservable: Observable<IGLTFLoaderData>;
  82172. private _onParsedObserver;
  82173. /**
  82174. * Raised when the asset has been parsed
  82175. */
  82176. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  82177. /**
  82178. * 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.
  82179. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  82180. * Defaults to true.
  82181. * @hidden
  82182. */
  82183. static IncrementalLoading: boolean;
  82184. /**
  82185. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  82186. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  82187. * @hidden
  82188. */
  82189. static HomogeneousCoordinates: boolean;
  82190. /**
  82191. * The coordinate system mode. Defaults to AUTO.
  82192. */
  82193. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  82194. /**
  82195. * The animation start mode. Defaults to FIRST.
  82196. */
  82197. animationStartMode: GLTFLoaderAnimationStartMode;
  82198. /**
  82199. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  82200. */
  82201. compileMaterials: boolean;
  82202. /**
  82203. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  82204. */
  82205. useClipPlane: boolean;
  82206. /**
  82207. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  82208. */
  82209. compileShadowGenerators: boolean;
  82210. /**
  82211. * Defines if the Alpha blended materials are only applied as coverage.
  82212. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  82213. * If true, no extra effects are applied to transparent pixels.
  82214. */
  82215. transparencyAsCoverage: boolean;
  82216. /**
  82217. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  82218. * Enabling will disable offline support and glTF validator.
  82219. * Defaults to false.
  82220. */
  82221. useRangeRequests: boolean;
  82222. /**
  82223. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  82224. */
  82225. createInstances: boolean;
  82226. /**
  82227. * 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.
  82228. */
  82229. alwaysComputeBoundingBox: boolean;
  82230. /**
  82231. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  82232. */
  82233. loadAllMaterials: boolean;
  82234. /**
  82235. * Function called before loading a url referenced by the asset.
  82236. */
  82237. preprocessUrlAsync: (url: string) => Promise<string>;
  82238. /**
  82239. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82240. * 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, ...)
  82241. */
  82242. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  82243. private _onMeshLoadedObserver;
  82244. /**
  82245. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82246. * 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, ...)
  82247. */
  82248. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  82249. /**
  82250. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  82251. */
  82252. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  82253. private _onTextureLoadedObserver;
  82254. /**
  82255. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  82256. */
  82257. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  82258. /**
  82259. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  82260. */
  82261. readonly onMaterialLoadedObservable: Observable<Material>;
  82262. private _onMaterialLoadedObserver;
  82263. /**
  82264. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  82265. */
  82266. set onMaterialLoaded(callback: (material: Material) => void);
  82267. /**
  82268. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  82269. */
  82270. readonly onCameraLoadedObservable: Observable<Camera>;
  82271. private _onCameraLoadedObserver;
  82272. /**
  82273. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  82274. */
  82275. set onCameraLoaded(callback: (camera: Camera) => void);
  82276. /**
  82277. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  82278. * For assets with LODs, raised when all of the LODs are complete.
  82279. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82280. */
  82281. readonly onCompleteObservable: Observable<void>;
  82282. private _onCompleteObserver;
  82283. /**
  82284. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  82285. * For assets with LODs, raised when all of the LODs are complete.
  82286. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82287. */
  82288. set onComplete(callback: () => void);
  82289. /**
  82290. * Observable raised when an error occurs.
  82291. */
  82292. readonly onErrorObservable: Observable<any>;
  82293. private _onErrorObserver;
  82294. /**
  82295. * Callback raised when an error occurs.
  82296. */
  82297. set onError(callback: (reason: any) => void);
  82298. /**
  82299. * Observable raised after the loader is disposed.
  82300. */
  82301. readonly onDisposeObservable: Observable<void>;
  82302. private _onDisposeObserver;
  82303. /**
  82304. * Callback raised after the loader is disposed.
  82305. */
  82306. set onDispose(callback: () => void);
  82307. /**
  82308. * Observable raised after a loader extension is created.
  82309. * Set additional options for a loader extension in this event.
  82310. */
  82311. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  82312. private _onExtensionLoadedObserver;
  82313. /**
  82314. * Callback raised after a loader extension is created.
  82315. */
  82316. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  82317. /**
  82318. * Defines if the loader logging is enabled.
  82319. */
  82320. get loggingEnabled(): boolean;
  82321. set loggingEnabled(value: boolean);
  82322. /**
  82323. * Defines if the loader should capture performance counters.
  82324. */
  82325. get capturePerformanceCounters(): boolean;
  82326. set capturePerformanceCounters(value: boolean);
  82327. /**
  82328. * Defines if the loader should validate the asset.
  82329. */
  82330. validate: boolean;
  82331. /**
  82332. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  82333. */
  82334. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  82335. private _onValidatedObserver;
  82336. /**
  82337. * Callback raised after a loader extension is created.
  82338. */
  82339. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  82340. private _loader;
  82341. private _progressCallback?;
  82342. private _requests;
  82343. private static magicBase64Encoded;
  82344. /**
  82345. * Name of the loader ("gltf")
  82346. */
  82347. name: string;
  82348. /** @hidden */
  82349. extensions: ISceneLoaderPluginExtensions;
  82350. /**
  82351. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  82352. */
  82353. dispose(): void;
  82354. /** @hidden */
  82355. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82356. /** @hidden */
  82357. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82358. /** @hidden */
  82359. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  82360. /** @hidden */
  82361. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82362. /** @hidden */
  82363. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82364. /** @hidden */
  82365. canDirectLoad(data: string): boolean;
  82366. /** @hidden */
  82367. directLoad(scene: Scene, data: string): Promise<any>;
  82368. /**
  82369. * The callback that allows custom handling of the root url based on the response url.
  82370. * @param rootUrl the original root url
  82371. * @param responseURL the response url if available
  82372. * @returns the new root url
  82373. */
  82374. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  82375. /** @hidden */
  82376. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  82377. /**
  82378. * The loader state or null if the loader is not active.
  82379. */
  82380. get loaderState(): Nullable<GLTFLoaderState>;
  82381. /**
  82382. * Returns a promise that resolves when the asset is completely loaded.
  82383. * @returns a promise that resolves when the asset is completely loaded.
  82384. */
  82385. whenCompleteAsync(): Promise<void>;
  82386. /** @hidden */
  82387. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  82388. /** @hidden */
  82389. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  82390. private _onProgress;
  82391. private _validate;
  82392. private _getLoader;
  82393. private _parseJson;
  82394. private _unpackBinaryAsync;
  82395. private _unpackBinaryV1Async;
  82396. private _unpackBinaryV2Async;
  82397. private static _parseVersion;
  82398. private static _compareVersion;
  82399. private static readonly _logSpaces;
  82400. private _logIndentLevel;
  82401. private _loggingEnabled;
  82402. /** @hidden */
  82403. _log: (message: string) => void;
  82404. /** @hidden */
  82405. _logOpen(message: string): void;
  82406. /** @hidden */
  82407. _logClose(): void;
  82408. private _logEnabled;
  82409. private _logDisabled;
  82410. private _capturePerformanceCounters;
  82411. /** @hidden */
  82412. _startPerformanceCounter: (counterName: string) => void;
  82413. /** @hidden */
  82414. _endPerformanceCounter: (counterName: string) => void;
  82415. private _startPerformanceCounterEnabled;
  82416. private _startPerformanceCounterDisabled;
  82417. private _endPerformanceCounterEnabled;
  82418. private _endPerformanceCounterDisabled;
  82419. }
  82420. }
  82421. declare module BABYLON.GLTF1 {
  82422. /**
  82423. * Enums
  82424. * @hidden
  82425. */
  82426. export enum EComponentType {
  82427. BYTE = 5120,
  82428. UNSIGNED_BYTE = 5121,
  82429. SHORT = 5122,
  82430. UNSIGNED_SHORT = 5123,
  82431. FLOAT = 5126
  82432. }
  82433. /** @hidden */
  82434. export enum EShaderType {
  82435. FRAGMENT = 35632,
  82436. VERTEX = 35633
  82437. }
  82438. /** @hidden */
  82439. export enum EParameterType {
  82440. BYTE = 5120,
  82441. UNSIGNED_BYTE = 5121,
  82442. SHORT = 5122,
  82443. UNSIGNED_SHORT = 5123,
  82444. INT = 5124,
  82445. UNSIGNED_INT = 5125,
  82446. FLOAT = 5126,
  82447. FLOAT_VEC2 = 35664,
  82448. FLOAT_VEC3 = 35665,
  82449. FLOAT_VEC4 = 35666,
  82450. INT_VEC2 = 35667,
  82451. INT_VEC3 = 35668,
  82452. INT_VEC4 = 35669,
  82453. BOOL = 35670,
  82454. BOOL_VEC2 = 35671,
  82455. BOOL_VEC3 = 35672,
  82456. BOOL_VEC4 = 35673,
  82457. FLOAT_MAT2 = 35674,
  82458. FLOAT_MAT3 = 35675,
  82459. FLOAT_MAT4 = 35676,
  82460. SAMPLER_2D = 35678
  82461. }
  82462. /** @hidden */
  82463. export enum ETextureWrapMode {
  82464. CLAMP_TO_EDGE = 33071,
  82465. MIRRORED_REPEAT = 33648,
  82466. REPEAT = 10497
  82467. }
  82468. /** @hidden */
  82469. export enum ETextureFilterType {
  82470. NEAREST = 9728,
  82471. LINEAR = 9728,
  82472. NEAREST_MIPMAP_NEAREST = 9984,
  82473. LINEAR_MIPMAP_NEAREST = 9985,
  82474. NEAREST_MIPMAP_LINEAR = 9986,
  82475. LINEAR_MIPMAP_LINEAR = 9987
  82476. }
  82477. /** @hidden */
  82478. export enum ETextureFormat {
  82479. ALPHA = 6406,
  82480. RGB = 6407,
  82481. RGBA = 6408,
  82482. LUMINANCE = 6409,
  82483. LUMINANCE_ALPHA = 6410
  82484. }
  82485. /** @hidden */
  82486. export enum ECullingType {
  82487. FRONT = 1028,
  82488. BACK = 1029,
  82489. FRONT_AND_BACK = 1032
  82490. }
  82491. /** @hidden */
  82492. export enum EBlendingFunction {
  82493. ZERO = 0,
  82494. ONE = 1,
  82495. SRC_COLOR = 768,
  82496. ONE_MINUS_SRC_COLOR = 769,
  82497. DST_COLOR = 774,
  82498. ONE_MINUS_DST_COLOR = 775,
  82499. SRC_ALPHA = 770,
  82500. ONE_MINUS_SRC_ALPHA = 771,
  82501. DST_ALPHA = 772,
  82502. ONE_MINUS_DST_ALPHA = 773,
  82503. CONSTANT_COLOR = 32769,
  82504. ONE_MINUS_CONSTANT_COLOR = 32770,
  82505. CONSTANT_ALPHA = 32771,
  82506. ONE_MINUS_CONSTANT_ALPHA = 32772,
  82507. SRC_ALPHA_SATURATE = 776
  82508. }
  82509. /** @hidden */
  82510. export interface IGLTFProperty {
  82511. extensions?: {
  82512. [key: string]: any;
  82513. };
  82514. extras?: Object;
  82515. }
  82516. /** @hidden */
  82517. export interface IGLTFChildRootProperty extends IGLTFProperty {
  82518. name?: string;
  82519. }
  82520. /** @hidden */
  82521. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  82522. bufferView: string;
  82523. byteOffset: number;
  82524. byteStride: number;
  82525. count: number;
  82526. type: string;
  82527. componentType: EComponentType;
  82528. max?: number[];
  82529. min?: number[];
  82530. name?: string;
  82531. }
  82532. /** @hidden */
  82533. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  82534. buffer: string;
  82535. byteOffset: number;
  82536. byteLength: number;
  82537. byteStride: number;
  82538. target?: number;
  82539. }
  82540. /** @hidden */
  82541. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  82542. uri: string;
  82543. byteLength?: number;
  82544. type?: string;
  82545. }
  82546. /** @hidden */
  82547. export interface IGLTFShader extends IGLTFChildRootProperty {
  82548. uri: string;
  82549. type: EShaderType;
  82550. }
  82551. /** @hidden */
  82552. export interface IGLTFProgram extends IGLTFChildRootProperty {
  82553. attributes: string[];
  82554. fragmentShader: string;
  82555. vertexShader: string;
  82556. }
  82557. /** @hidden */
  82558. export interface IGLTFTechniqueParameter {
  82559. type: number;
  82560. count?: number;
  82561. semantic?: string;
  82562. node?: string;
  82563. value?: number | boolean | string | Array<any>;
  82564. source?: string;
  82565. babylonValue?: any;
  82566. }
  82567. /** @hidden */
  82568. export interface IGLTFTechniqueCommonProfile {
  82569. lightingModel: string;
  82570. texcoordBindings: Object;
  82571. parameters?: Array<any>;
  82572. }
  82573. /** @hidden */
  82574. export interface IGLTFTechniqueStatesFunctions {
  82575. blendColor?: number[];
  82576. blendEquationSeparate?: number[];
  82577. blendFuncSeparate?: number[];
  82578. colorMask: boolean[];
  82579. cullFace: number[];
  82580. }
  82581. /** @hidden */
  82582. export interface IGLTFTechniqueStates {
  82583. enable: number[];
  82584. functions: IGLTFTechniqueStatesFunctions;
  82585. }
  82586. /** @hidden */
  82587. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  82588. parameters: {
  82589. [key: string]: IGLTFTechniqueParameter;
  82590. };
  82591. program: string;
  82592. attributes: {
  82593. [key: string]: string;
  82594. };
  82595. uniforms: {
  82596. [key: string]: string;
  82597. };
  82598. states: IGLTFTechniqueStates;
  82599. }
  82600. /** @hidden */
  82601. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  82602. technique?: string;
  82603. values: string[];
  82604. }
  82605. /** @hidden */
  82606. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  82607. attributes: {
  82608. [key: string]: string;
  82609. };
  82610. indices: string;
  82611. material: string;
  82612. mode?: number;
  82613. }
  82614. /** @hidden */
  82615. export interface IGLTFMesh extends IGLTFChildRootProperty {
  82616. primitives: IGLTFMeshPrimitive[];
  82617. }
  82618. /** @hidden */
  82619. export interface IGLTFImage extends IGLTFChildRootProperty {
  82620. uri: string;
  82621. }
  82622. /** @hidden */
  82623. export interface IGLTFSampler extends IGLTFChildRootProperty {
  82624. magFilter?: number;
  82625. minFilter?: number;
  82626. wrapS?: number;
  82627. wrapT?: number;
  82628. }
  82629. /** @hidden */
  82630. export interface IGLTFTexture extends IGLTFChildRootProperty {
  82631. sampler: string;
  82632. source: string;
  82633. format?: ETextureFormat;
  82634. internalFormat?: ETextureFormat;
  82635. target?: number;
  82636. type?: number;
  82637. babylonTexture?: Texture;
  82638. }
  82639. /** @hidden */
  82640. export interface IGLTFAmbienLight {
  82641. color?: number[];
  82642. }
  82643. /** @hidden */
  82644. export interface IGLTFDirectionalLight {
  82645. color?: number[];
  82646. }
  82647. /** @hidden */
  82648. export interface IGLTFPointLight {
  82649. color?: number[];
  82650. constantAttenuation?: number;
  82651. linearAttenuation?: number;
  82652. quadraticAttenuation?: number;
  82653. }
  82654. /** @hidden */
  82655. export interface IGLTFSpotLight {
  82656. color?: number[];
  82657. constantAttenuation?: number;
  82658. fallOfAngle?: number;
  82659. fallOffExponent?: number;
  82660. linearAttenuation?: number;
  82661. quadraticAttenuation?: number;
  82662. }
  82663. /** @hidden */
  82664. export interface IGLTFLight extends IGLTFChildRootProperty {
  82665. type: string;
  82666. }
  82667. /** @hidden */
  82668. export interface IGLTFCameraOrthographic {
  82669. xmag: number;
  82670. ymag: number;
  82671. zfar: number;
  82672. znear: number;
  82673. }
  82674. /** @hidden */
  82675. export interface IGLTFCameraPerspective {
  82676. aspectRatio: number;
  82677. yfov: number;
  82678. zfar: number;
  82679. znear: number;
  82680. }
  82681. /** @hidden */
  82682. export interface IGLTFCamera extends IGLTFChildRootProperty {
  82683. type: string;
  82684. }
  82685. /** @hidden */
  82686. export interface IGLTFAnimationChannelTarget {
  82687. id: string;
  82688. path: string;
  82689. }
  82690. /** @hidden */
  82691. export interface IGLTFAnimationChannel {
  82692. sampler: string;
  82693. target: IGLTFAnimationChannelTarget;
  82694. }
  82695. /** @hidden */
  82696. export interface IGLTFAnimationSampler {
  82697. input: string;
  82698. output: string;
  82699. interpolation?: string;
  82700. }
  82701. /** @hidden */
  82702. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  82703. channels?: IGLTFAnimationChannel[];
  82704. parameters?: {
  82705. [key: string]: string;
  82706. };
  82707. samplers?: {
  82708. [key: string]: IGLTFAnimationSampler;
  82709. };
  82710. }
  82711. /** @hidden */
  82712. export interface IGLTFNodeInstanceSkin {
  82713. skeletons: string[];
  82714. skin: string;
  82715. meshes: string[];
  82716. }
  82717. /** @hidden */
  82718. export interface IGLTFSkins extends IGLTFChildRootProperty {
  82719. bindShapeMatrix: number[];
  82720. inverseBindMatrices: string;
  82721. jointNames: string[];
  82722. babylonSkeleton?: Skeleton;
  82723. }
  82724. /** @hidden */
  82725. export interface IGLTFNode extends IGLTFChildRootProperty {
  82726. camera?: string;
  82727. children: string[];
  82728. skin?: string;
  82729. jointName?: string;
  82730. light?: string;
  82731. matrix: number[];
  82732. mesh?: string;
  82733. meshes?: string[];
  82734. rotation?: number[];
  82735. scale?: number[];
  82736. translation?: number[];
  82737. babylonNode?: Node;
  82738. }
  82739. /** @hidden */
  82740. export interface IGLTFScene extends IGLTFChildRootProperty {
  82741. nodes: string[];
  82742. }
  82743. /** @hidden */
  82744. export interface IGLTFRuntime {
  82745. extensions: {
  82746. [key: string]: any;
  82747. };
  82748. accessors: {
  82749. [key: string]: IGLTFAccessor;
  82750. };
  82751. buffers: {
  82752. [key: string]: IGLTFBuffer;
  82753. };
  82754. bufferViews: {
  82755. [key: string]: IGLTFBufferView;
  82756. };
  82757. meshes: {
  82758. [key: string]: IGLTFMesh;
  82759. };
  82760. lights: {
  82761. [key: string]: IGLTFLight;
  82762. };
  82763. cameras: {
  82764. [key: string]: IGLTFCamera;
  82765. };
  82766. nodes: {
  82767. [key: string]: IGLTFNode;
  82768. };
  82769. images: {
  82770. [key: string]: IGLTFImage;
  82771. };
  82772. textures: {
  82773. [key: string]: IGLTFTexture;
  82774. };
  82775. shaders: {
  82776. [key: string]: IGLTFShader;
  82777. };
  82778. programs: {
  82779. [key: string]: IGLTFProgram;
  82780. };
  82781. samplers: {
  82782. [key: string]: IGLTFSampler;
  82783. };
  82784. techniques: {
  82785. [key: string]: IGLTFTechnique;
  82786. };
  82787. materials: {
  82788. [key: string]: IGLTFMaterial;
  82789. };
  82790. animations: {
  82791. [key: string]: IGLTFAnimation;
  82792. };
  82793. skins: {
  82794. [key: string]: IGLTFSkins;
  82795. };
  82796. currentScene?: Object;
  82797. scenes: {
  82798. [key: string]: IGLTFScene;
  82799. };
  82800. extensionsUsed: string[];
  82801. extensionsRequired?: string[];
  82802. buffersCount: number;
  82803. shaderscount: number;
  82804. scene: Scene;
  82805. rootUrl: string;
  82806. loadedBufferCount: number;
  82807. loadedBufferViews: {
  82808. [name: string]: ArrayBufferView;
  82809. };
  82810. loadedShaderCount: number;
  82811. importOnlyMeshes: boolean;
  82812. importMeshesNames?: string[];
  82813. dummyNodes: Node[];
  82814. forAssetContainer: boolean;
  82815. }
  82816. /** @hidden */
  82817. export interface INodeToRoot {
  82818. bone: Bone;
  82819. node: IGLTFNode;
  82820. id: string;
  82821. }
  82822. /** @hidden */
  82823. export interface IJointNode {
  82824. node: IGLTFNode;
  82825. id: string;
  82826. }
  82827. }
  82828. declare module BABYLON.GLTF1 {
  82829. /**
  82830. * Utils functions for GLTF
  82831. * @hidden
  82832. */
  82833. export class GLTFUtils {
  82834. /**
  82835. * Sets the given "parameter" matrix
  82836. * @param scene: the Scene object
  82837. * @param source: the source node where to pick the matrix
  82838. * @param parameter: the GLTF technique parameter
  82839. * @param uniformName: the name of the shader's uniform
  82840. * @param shaderMaterial: the shader material
  82841. */
  82842. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  82843. /**
  82844. * Sets the given "parameter" matrix
  82845. * @param shaderMaterial: the shader material
  82846. * @param uniform: the name of the shader's uniform
  82847. * @param value: the value of the uniform
  82848. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  82849. */
  82850. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  82851. /**
  82852. * Returns the wrap mode of the texture
  82853. * @param mode: the mode value
  82854. */
  82855. static GetWrapMode(mode: number): number;
  82856. /**
  82857. * Returns the byte stride giving an accessor
  82858. * @param accessor: the GLTF accessor objet
  82859. */
  82860. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  82861. /**
  82862. * Returns the texture filter mode giving a mode value
  82863. * @param mode: the filter mode value
  82864. */
  82865. static GetTextureFilterMode(mode: number): ETextureFilterType;
  82866. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  82867. /**
  82868. * Returns a buffer from its accessor
  82869. * @param gltfRuntime: the GLTF runtime
  82870. * @param accessor: the GLTF accessor
  82871. */
  82872. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  82873. /**
  82874. * Decodes a buffer view into a string
  82875. * @param view: the buffer view
  82876. */
  82877. static DecodeBufferToText(view: ArrayBufferView): string;
  82878. /**
  82879. * Returns the default material of gltf. Related to
  82880. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  82881. * @param scene: the Babylon.js scene
  82882. */
  82883. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  82884. private static _DefaultMaterial;
  82885. }
  82886. }
  82887. declare module BABYLON.GLTF1 {
  82888. /**
  82889. * Implementation of the base glTF spec
  82890. * @hidden
  82891. */
  82892. export class GLTFLoaderBase {
  82893. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  82894. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82895. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  82896. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82897. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  82898. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82899. }
  82900. /**
  82901. * glTF V1 Loader
  82902. * @hidden
  82903. */
  82904. export class GLTFLoader implements IGLTFLoader {
  82905. static Extensions: {
  82906. [name: string]: GLTFLoaderExtension;
  82907. };
  82908. static RegisterExtension(extension: GLTFLoaderExtension): void;
  82909. state: Nullable<GLTFLoaderState>;
  82910. dispose(): void;
  82911. private _importMeshAsync;
  82912. /**
  82913. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  82914. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82915. * @param scene the scene the meshes should be added to
  82916. * @param forAssetContainer defines if the entities must be stored in the scene
  82917. * @param data gltf data containing information of the meshes in a loaded file
  82918. * @param rootUrl root url to load from
  82919. * @param onProgress event that fires when loading progress has occured
  82920. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82921. */
  82922. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  82923. private _loadAsync;
  82924. /**
  82925. * Imports all objects from a loaded gltf file and adds them to the scene
  82926. * @param scene the scene the objects should be added to
  82927. * @param data gltf data containing information of the meshes in a loaded file
  82928. * @param rootUrl root url to load from
  82929. * @param onProgress event that fires when loading progress has occured
  82930. * @returns a promise which completes when objects have been loaded to the scene
  82931. */
  82932. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  82933. private _loadShadersAsync;
  82934. private _loadBuffersAsync;
  82935. private _createNodes;
  82936. }
  82937. /** @hidden */
  82938. export abstract class GLTFLoaderExtension {
  82939. private _name;
  82940. constructor(name: string);
  82941. get name(): string;
  82942. /**
  82943. * Defines an override for loading the runtime
  82944. * Return true to stop further extensions from loading the runtime
  82945. */
  82946. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  82947. /**
  82948. * Defines an onverride for creating gltf runtime
  82949. * Return true to stop further extensions from creating the runtime
  82950. */
  82951. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  82952. /**
  82953. * Defines an override for loading buffers
  82954. * Return true to stop further extensions from loading this buffer
  82955. */
  82956. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  82957. /**
  82958. * Defines an override for loading texture buffers
  82959. * Return true to stop further extensions from loading this texture data
  82960. */
  82961. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82962. /**
  82963. * Defines an override for creating textures
  82964. * Return true to stop further extensions from loading this texture
  82965. */
  82966. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  82967. /**
  82968. * Defines an override for loading shader strings
  82969. * Return true to stop further extensions from loading this shader data
  82970. */
  82971. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82972. /**
  82973. * Defines an override for loading materials
  82974. * Return true to stop further extensions from loading this material
  82975. */
  82976. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82977. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82978. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82979. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82980. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82981. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82982. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82983. private static LoadTextureBufferAsync;
  82984. private static CreateTextureAsync;
  82985. private static ApplyExtensions;
  82986. }
  82987. }
  82988. declare module BABYLON.GLTF1 {
  82989. /** @hidden */
  82990. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82991. private _bin;
  82992. constructor();
  82993. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82994. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82995. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82996. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82997. }
  82998. }
  82999. declare module BABYLON.GLTF1 {
  83000. /** @hidden */
  83001. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  83002. constructor();
  83003. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  83004. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  83005. private _loadTexture;
  83006. }
  83007. }
  83008. declare module BABYLON.GLTF2.Loader {
  83009. /**
  83010. * Loader interface with an index field.
  83011. */
  83012. export interface IArrayItem {
  83013. /**
  83014. * The index of this item in the array.
  83015. */
  83016. index: number;
  83017. }
  83018. /**
  83019. * Loader interface with additional members.
  83020. */
  83021. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  83022. /** @hidden */
  83023. _data?: Promise<ArrayBufferView>;
  83024. /** @hidden */
  83025. _babylonVertexBuffer?: Promise<VertexBuffer>;
  83026. }
  83027. /**
  83028. * Loader interface with additional members.
  83029. */
  83030. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  83031. }
  83032. /** @hidden */
  83033. export interface _IAnimationSamplerData {
  83034. input: Float32Array;
  83035. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  83036. output: Float32Array;
  83037. }
  83038. /**
  83039. * Loader interface with additional members.
  83040. */
  83041. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  83042. /** @hidden */
  83043. _data?: Promise<_IAnimationSamplerData>;
  83044. }
  83045. /**
  83046. * Loader interface with additional members.
  83047. */
  83048. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  83049. channels: IAnimationChannel[];
  83050. samplers: IAnimationSampler[];
  83051. /** @hidden */
  83052. _babylonAnimationGroup?: AnimationGroup;
  83053. }
  83054. /**
  83055. * Loader interface with additional members.
  83056. */
  83057. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  83058. /** @hidden */
  83059. _data?: Promise<ArrayBufferView>;
  83060. }
  83061. /**
  83062. * Loader interface with additional members.
  83063. */
  83064. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  83065. /** @hidden */
  83066. _data?: Promise<ArrayBufferView>;
  83067. /** @hidden */
  83068. _babylonBuffer?: Promise<Buffer>;
  83069. }
  83070. /**
  83071. * Loader interface with additional members.
  83072. */
  83073. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  83074. }
  83075. /**
  83076. * Loader interface with additional members.
  83077. */
  83078. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  83079. /** @hidden */
  83080. _data?: Promise<ArrayBufferView>;
  83081. }
  83082. /**
  83083. * Loader interface with additional members.
  83084. */
  83085. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  83086. }
  83087. /**
  83088. * Loader interface with additional members.
  83089. */
  83090. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  83091. }
  83092. /**
  83093. * Loader interface with additional members.
  83094. */
  83095. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  83096. baseColorTexture?: ITextureInfo;
  83097. metallicRoughnessTexture?: ITextureInfo;
  83098. }
  83099. /**
  83100. * Loader interface with additional members.
  83101. */
  83102. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  83103. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83104. normalTexture?: IMaterialNormalTextureInfo;
  83105. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83106. emissiveTexture?: ITextureInfo;
  83107. /** @hidden */
  83108. _data?: {
  83109. [babylonDrawMode: number]: {
  83110. babylonMaterial: Material;
  83111. babylonMeshes: AbstractMesh[];
  83112. promise: Promise<void>;
  83113. };
  83114. };
  83115. }
  83116. /**
  83117. * Loader interface with additional members.
  83118. */
  83119. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  83120. primitives: IMeshPrimitive[];
  83121. }
  83122. /**
  83123. * Loader interface with additional members.
  83124. */
  83125. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  83126. /** @hidden */
  83127. _instanceData?: {
  83128. babylonSourceMesh: Mesh;
  83129. promise: Promise<any>;
  83130. };
  83131. }
  83132. /**
  83133. * Loader interface with additional members.
  83134. */
  83135. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  83136. /**
  83137. * The parent glTF node.
  83138. */
  83139. parent?: INode;
  83140. /** @hidden */
  83141. _babylonTransformNode?: TransformNode;
  83142. /** @hidden */
  83143. _primitiveBabylonMeshes?: AbstractMesh[];
  83144. /** @hidden */
  83145. _babylonBones?: Bone[];
  83146. /** @hidden */
  83147. _numMorphTargets?: number;
  83148. }
  83149. /** @hidden */
  83150. export interface _ISamplerData {
  83151. noMipMaps: boolean;
  83152. samplingMode: number;
  83153. wrapU: number;
  83154. wrapV: number;
  83155. }
  83156. /**
  83157. * Loader interface with additional members.
  83158. */
  83159. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  83160. /** @hidden */
  83161. _data?: _ISamplerData;
  83162. }
  83163. /**
  83164. * Loader interface with additional members.
  83165. */
  83166. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  83167. }
  83168. /**
  83169. * Loader interface with additional members.
  83170. */
  83171. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  83172. /** @hidden */
  83173. _data?: {
  83174. babylonSkeleton: Skeleton;
  83175. promise: Promise<void>;
  83176. };
  83177. }
  83178. /**
  83179. * Loader interface with additional members.
  83180. */
  83181. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  83182. /** @hidden */
  83183. _textureInfo: ITextureInfo;
  83184. }
  83185. /**
  83186. * Loader interface with additional members.
  83187. */
  83188. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  83189. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  83190. nonColorData?: boolean;
  83191. }
  83192. /**
  83193. * Loader interface with additional members.
  83194. */
  83195. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  83196. accessors?: IAccessor[];
  83197. animations?: IAnimation[];
  83198. buffers?: IBuffer[];
  83199. bufferViews?: IBufferView[];
  83200. cameras?: ICamera[];
  83201. images?: IImage[];
  83202. materials?: IMaterial[];
  83203. meshes?: IMesh[];
  83204. nodes?: INode[];
  83205. samplers?: ISampler[];
  83206. scenes?: IScene[];
  83207. skins?: ISkin[];
  83208. textures?: ITexture[];
  83209. }
  83210. }
  83211. declare module BABYLON.GLTF2 {
  83212. /**
  83213. * Interface for a glTF loader extension.
  83214. */
  83215. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  83216. /**
  83217. * Called after the loader state changes to LOADING.
  83218. */
  83219. onLoading?(): void;
  83220. /**
  83221. * Called after the loader state changes to READY.
  83222. */
  83223. onReady?(): void;
  83224. /**
  83225. * Define this method to modify the default behavior when loading scenes.
  83226. * @param context The context when loading the asset
  83227. * @param scene The glTF scene property
  83228. * @returns A promise that resolves when the load is complete or null if not handled
  83229. */
  83230. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  83231. /**
  83232. * Define this method to modify the default behavior when loading nodes.
  83233. * @param context The context when loading the asset
  83234. * @param node The glTF node property
  83235. * @param assign A function called synchronously after parsing the glTF properties
  83236. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  83237. */
  83238. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83239. /**
  83240. * Define this method to modify the default behavior when loading cameras.
  83241. * @param context The context when loading the asset
  83242. * @param camera The glTF camera property
  83243. * @param assign A function called synchronously after parsing the glTF properties
  83244. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  83245. */
  83246. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83247. /**
  83248. * @hidden
  83249. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  83250. * @param context The context when loading the asset
  83251. * @param primitive The glTF mesh primitive property
  83252. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  83253. */
  83254. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83255. /**
  83256. * @hidden
  83257. * Define this method to modify the default behavior when loading data for mesh primitives.
  83258. * @param context The context when loading the asset
  83259. * @param name The mesh name when loading the asset
  83260. * @param node The glTF node when loading the asset
  83261. * @param mesh The glTF mesh when loading the asset
  83262. * @param primitive The glTF mesh primitive property
  83263. * @param assign A function called synchronously after parsing the glTF properties
  83264. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83265. */
  83266. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83267. /**
  83268. * @hidden
  83269. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  83270. * @param context The context when loading the asset
  83271. * @param material The glTF material property
  83272. * @param assign A function called synchronously after parsing the glTF properties
  83273. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  83274. */
  83275. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83276. /**
  83277. * Define this method to modify the default behavior when creating materials.
  83278. * @param context The context when loading the asset
  83279. * @param material The glTF material property
  83280. * @param babylonDrawMode The draw mode for the Babylon material
  83281. * @returns The Babylon material or null if not handled
  83282. */
  83283. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83284. /**
  83285. * Define this method to modify the default behavior when loading material properties.
  83286. * @param context The context when loading the asset
  83287. * @param material The glTF material property
  83288. * @param babylonMaterial The Babylon material
  83289. * @returns A promise that resolves when the load is complete or null if not handled
  83290. */
  83291. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83292. /**
  83293. * Define this method to modify the default behavior when loading texture infos.
  83294. * @param context The context when loading the asset
  83295. * @param textureInfo The glTF texture info property
  83296. * @param assign A function called synchronously after parsing the glTF properties
  83297. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83298. */
  83299. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83300. /**
  83301. * @hidden
  83302. * Define this method to modify the default behavior when loading textures.
  83303. * @param context The context when loading the asset
  83304. * @param texture The glTF texture property
  83305. * @param assign A function called synchronously after parsing the glTF properties
  83306. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83307. */
  83308. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83309. /**
  83310. * Define this method to modify the default behavior when loading animations.
  83311. * @param context The context when loading the asset
  83312. * @param animation The glTF animation property
  83313. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  83314. */
  83315. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83316. /**
  83317. * @hidden
  83318. * Define this method to modify the default behavior when loading skins.
  83319. * @param context The context when loading the asset
  83320. * @param node The glTF node property
  83321. * @param skin The glTF skin property
  83322. * @returns A promise that resolves when the load is complete or null if not handled
  83323. */
  83324. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  83325. /**
  83326. * @hidden
  83327. * Define this method to modify the default behavior when loading uris.
  83328. * @param context The context when loading the asset
  83329. * @param property The glTF property associated with the uri
  83330. * @param uri The uri to load
  83331. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83332. */
  83333. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83334. /**
  83335. * Define this method to modify the default behavior when loading buffer views.
  83336. * @param context The context when loading the asset
  83337. * @param bufferView The glTF buffer view property
  83338. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83339. */
  83340. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  83341. /**
  83342. * Define this method to modify the default behavior when loading buffers.
  83343. * @param context The context when loading the asset
  83344. * @param buffer The glTF buffer property
  83345. * @param byteOffset The byte offset to load
  83346. * @param byteLength The byte length to load
  83347. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83348. */
  83349. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83350. }
  83351. }
  83352. declare module BABYLON.GLTF2 {
  83353. /**
  83354. * Helper class for working with arrays when loading the glTF asset
  83355. */
  83356. export class ArrayItem {
  83357. /**
  83358. * Gets an item from the given array.
  83359. * @param context The context when loading the asset
  83360. * @param array The array to get the item from
  83361. * @param index The index to the array
  83362. * @returns The array item
  83363. */
  83364. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  83365. /**
  83366. * Assign an `index` field to each item of the given array.
  83367. * @param array The array of items
  83368. */
  83369. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  83370. }
  83371. /**
  83372. * The glTF 2.0 loader
  83373. */
  83374. export class GLTFLoader implements IGLTFLoader {
  83375. /** @hidden */
  83376. _completePromises: Promise<any>[];
  83377. /** @hidden */
  83378. _forAssetContainer: boolean;
  83379. /** Storage */
  83380. _babylonLights: Light[];
  83381. /** @hidden */
  83382. _disableInstancedMesh: number;
  83383. private _disposed;
  83384. private _parent;
  83385. private _state;
  83386. private _extensions;
  83387. private _rootUrl;
  83388. private _fileName;
  83389. private _uniqueRootUrl;
  83390. private _gltf;
  83391. private _bin;
  83392. private _babylonScene;
  83393. private _rootBabylonMesh;
  83394. private _defaultBabylonMaterialData;
  83395. private static _RegisteredExtensions;
  83396. /**
  83397. * The default glTF sampler.
  83398. */
  83399. static readonly DefaultSampler: ISampler;
  83400. /**
  83401. * Registers a loader extension.
  83402. * @param name The name of the loader extension.
  83403. * @param factory The factory function that creates the loader extension.
  83404. */
  83405. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  83406. /**
  83407. * Unregisters a loader extension.
  83408. * @param name The name of the loader extension.
  83409. * @returns A boolean indicating whether the extension has been unregistered
  83410. */
  83411. static UnregisterExtension(name: string): boolean;
  83412. /**
  83413. * The loader state.
  83414. */
  83415. get state(): Nullable<GLTFLoaderState>;
  83416. /**
  83417. * The object that represents the glTF JSON.
  83418. */
  83419. get gltf(): IGLTF;
  83420. /**
  83421. * The BIN chunk of a binary glTF.
  83422. */
  83423. get bin(): Nullable<IDataBuffer>;
  83424. /**
  83425. * The parent file loader.
  83426. */
  83427. get parent(): GLTFFileLoader;
  83428. /**
  83429. * The Babylon scene when loading the asset.
  83430. */
  83431. get babylonScene(): Scene;
  83432. /**
  83433. * The root Babylon mesh when loading the asset.
  83434. */
  83435. get rootBabylonMesh(): Mesh;
  83436. /** @hidden */
  83437. constructor(parent: GLTFFileLoader);
  83438. /** @hidden */
  83439. dispose(): void;
  83440. /** @hidden */
  83441. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  83442. /** @hidden */
  83443. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83444. private _loadAsync;
  83445. private _loadData;
  83446. private _setupData;
  83447. private _loadExtensions;
  83448. private _checkExtensions;
  83449. private _setState;
  83450. private _createRootNode;
  83451. /**
  83452. * Loads a glTF scene.
  83453. * @param context The context when loading the asset
  83454. * @param scene The glTF scene property
  83455. * @returns A promise that resolves when the load is complete
  83456. */
  83457. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  83458. private _forEachPrimitive;
  83459. private _getGeometries;
  83460. private _getMeshes;
  83461. private _getTransformNodes;
  83462. private _getSkeletons;
  83463. private _getAnimationGroups;
  83464. private _startAnimations;
  83465. /**
  83466. * Loads a glTF node.
  83467. * @param context The context when loading the asset
  83468. * @param node The glTF node property
  83469. * @param assign A function called synchronously after parsing the glTF properties
  83470. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  83471. */
  83472. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  83473. private _loadMeshAsync;
  83474. /**
  83475. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  83476. * @param context The context when loading the asset
  83477. * @param name The mesh name when loading the asset
  83478. * @param node The glTF node when loading the asset
  83479. * @param mesh The glTF mesh when loading the asset
  83480. * @param primitive The glTF mesh primitive property
  83481. * @param assign A function called synchronously after parsing the glTF properties
  83482. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83483. */
  83484. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  83485. private _loadVertexDataAsync;
  83486. private _createMorphTargets;
  83487. private _loadMorphTargetsAsync;
  83488. private _loadMorphTargetVertexDataAsync;
  83489. private static _LoadTransform;
  83490. private _loadSkinAsync;
  83491. private _loadBones;
  83492. private _loadBone;
  83493. private _loadSkinInverseBindMatricesDataAsync;
  83494. private _updateBoneMatrices;
  83495. private _getNodeMatrix;
  83496. /**
  83497. * Loads a glTF camera.
  83498. * @param context The context when loading the asset
  83499. * @param camera The glTF camera property
  83500. * @param assign A function called synchronously after parsing the glTF properties
  83501. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  83502. */
  83503. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  83504. private _loadAnimationsAsync;
  83505. /**
  83506. * Loads a glTF animation.
  83507. * @param context The context when loading the asset
  83508. * @param animation The glTF animation property
  83509. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  83510. */
  83511. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  83512. /**
  83513. * @hidden Loads a glTF animation channel.
  83514. * @param context The context when loading the asset
  83515. * @param animationContext The context of the animation when loading the asset
  83516. * @param animation The glTF animation property
  83517. * @param channel The glTF animation channel property
  83518. * @param babylonAnimationGroup The babylon animation group property
  83519. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  83520. * @returns A void promise when the channel load is complete
  83521. */
  83522. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  83523. private _loadAnimationSamplerAsync;
  83524. private _loadBufferAsync;
  83525. /**
  83526. * Loads a glTF buffer view.
  83527. * @param context The context when loading the asset
  83528. * @param bufferView The glTF buffer view property
  83529. * @returns A promise that resolves with the loaded data when the load is complete
  83530. */
  83531. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  83532. private _loadAccessorAsync;
  83533. /** @hidden */
  83534. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  83535. private _loadIndicesAccessorAsync;
  83536. private _loadVertexBufferViewAsync;
  83537. private _loadVertexAccessorAsync;
  83538. private _loadMaterialMetallicRoughnessPropertiesAsync;
  83539. /** @hidden */
  83540. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  83541. private _createDefaultMaterial;
  83542. /**
  83543. * Creates a Babylon material from a glTF material.
  83544. * @param context The context when loading the asset
  83545. * @param material The glTF material property
  83546. * @param babylonDrawMode The draw mode for the Babylon material
  83547. * @returns The Babylon material
  83548. */
  83549. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  83550. /**
  83551. * Loads properties from a glTF material into a Babylon material.
  83552. * @param context The context when loading the asset
  83553. * @param material The glTF material property
  83554. * @param babylonMaterial The Babylon material
  83555. * @returns A promise that resolves when the load is complete
  83556. */
  83557. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83558. /**
  83559. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  83560. * @param context The context when loading the asset
  83561. * @param material The glTF material property
  83562. * @param babylonMaterial The Babylon material
  83563. * @returns A promise that resolves when the load is complete
  83564. */
  83565. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83566. /**
  83567. * Loads the alpha properties from a glTF material into a Babylon material.
  83568. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  83569. * @param context The context when loading the asset
  83570. * @param material The glTF material property
  83571. * @param babylonMaterial The Babylon material
  83572. */
  83573. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  83574. /**
  83575. * Loads a glTF texture info.
  83576. * @param context The context when loading the asset
  83577. * @param textureInfo The glTF texture info property
  83578. * @param assign A function called synchronously after parsing the glTF properties
  83579. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  83580. */
  83581. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83582. /** @hidden */
  83583. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83584. /** @hidden */
  83585. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  83586. private _loadSampler;
  83587. /**
  83588. * Loads a glTF image.
  83589. * @param context The context when loading the asset
  83590. * @param image The glTF image property
  83591. * @returns A promise that resolves with the loaded data when the load is complete
  83592. */
  83593. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  83594. /**
  83595. * Loads a glTF uri.
  83596. * @param context The context when loading the asset
  83597. * @param property The glTF property associated with the uri
  83598. * @param uri The base64 or relative uri
  83599. * @returns A promise that resolves with the loaded data when the load is complete
  83600. */
  83601. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  83602. /**
  83603. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  83604. * @param babylonObject the Babylon object with metadata
  83605. * @param pointer the JSON pointer
  83606. */
  83607. static AddPointerMetadata(babylonObject: {
  83608. metadata: any;
  83609. }, pointer: string): void;
  83610. private static _GetTextureWrapMode;
  83611. private static _GetTextureSamplingMode;
  83612. private static _GetTypedArrayConstructor;
  83613. private static _GetTypedArray;
  83614. private static _GetNumComponents;
  83615. private static _ValidateUri;
  83616. /** @hidden */
  83617. static _GetDrawMode(context: string, mode: number | undefined): number;
  83618. private _compileMaterialsAsync;
  83619. private _compileShadowGeneratorsAsync;
  83620. private _forEachExtensions;
  83621. private _applyExtensions;
  83622. private _extensionsOnLoading;
  83623. private _extensionsOnReady;
  83624. private _extensionsLoadSceneAsync;
  83625. private _extensionsLoadNodeAsync;
  83626. private _extensionsLoadCameraAsync;
  83627. private _extensionsLoadVertexDataAsync;
  83628. private _extensionsLoadMeshPrimitiveAsync;
  83629. private _extensionsLoadMaterialAsync;
  83630. private _extensionsCreateMaterial;
  83631. private _extensionsLoadMaterialPropertiesAsync;
  83632. private _extensionsLoadTextureInfoAsync;
  83633. private _extensionsLoadTextureAsync;
  83634. private _extensionsLoadAnimationAsync;
  83635. private _extensionsLoadSkinAsync;
  83636. private _extensionsLoadUriAsync;
  83637. private _extensionsLoadBufferViewAsync;
  83638. private _extensionsLoadBufferAsync;
  83639. /**
  83640. * Helper method called by a loader extension to load an glTF extension.
  83641. * @param context The context when loading the asset
  83642. * @param property The glTF property to load the extension from
  83643. * @param extensionName The name of the extension to load
  83644. * @param actionAsync The action to run
  83645. * @returns The promise returned by actionAsync or null if the extension does not exist
  83646. */
  83647. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83648. /**
  83649. * Helper method called by a loader extension to load a glTF extra.
  83650. * @param context The context when loading the asset
  83651. * @param property The glTF property to load the extra from
  83652. * @param extensionName The name of the extension to load
  83653. * @param actionAsync The action to run
  83654. * @returns The promise returned by actionAsync or null if the extra does not exist
  83655. */
  83656. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83657. /**
  83658. * Checks for presence of an extension.
  83659. * @param name The name of the extension to check
  83660. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  83661. */
  83662. isExtensionUsed(name: string): boolean;
  83663. /**
  83664. * Increments the indentation level and logs a message.
  83665. * @param message The message to log
  83666. */
  83667. logOpen(message: string): void;
  83668. /**
  83669. * Decrements the indentation level.
  83670. */
  83671. logClose(): void;
  83672. /**
  83673. * Logs a message
  83674. * @param message The message to log
  83675. */
  83676. log(message: string): void;
  83677. /**
  83678. * Starts a performance counter.
  83679. * @param counterName The name of the performance counter
  83680. */
  83681. startPerformanceCounter(counterName: string): void;
  83682. /**
  83683. * Ends a performance counter.
  83684. * @param counterName The name of the performance counter
  83685. */
  83686. endPerformanceCounter(counterName: string): void;
  83687. }
  83688. }
  83689. declare module BABYLON.GLTF2.Loader.Extensions {
  83690. /** @hidden */
  83691. interface IEXTLightsImageBased_LightImageBased {
  83692. _babylonTexture?: BaseTexture;
  83693. _loaded?: Promise<void>;
  83694. }
  83695. /**
  83696. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  83697. */
  83698. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  83699. /**
  83700. * The name of this extension.
  83701. */
  83702. readonly name: string;
  83703. /**
  83704. * Defines whether this extension is enabled.
  83705. */
  83706. enabled: boolean;
  83707. private _loader;
  83708. private _lights?;
  83709. /** @hidden */
  83710. constructor(loader: GLTFLoader);
  83711. /** @hidden */
  83712. dispose(): void;
  83713. /** @hidden */
  83714. onLoading(): void;
  83715. /** @hidden */
  83716. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83717. private _loadLightAsync;
  83718. }
  83719. }
  83720. declare module BABYLON.GLTF2.Loader.Extensions {
  83721. /**
  83722. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  83723. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  83724. * !!! Experimental Extension Subject to Changes !!!
  83725. */
  83726. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  83727. /**
  83728. * The name of this extension.
  83729. */
  83730. readonly name: string;
  83731. /**
  83732. * Defines whether this extension is enabled.
  83733. */
  83734. enabled: boolean;
  83735. private _loader;
  83736. /** @hidden */
  83737. constructor(loader: GLTFLoader);
  83738. /** @hidden */
  83739. dispose(): void;
  83740. /** @hidden */
  83741. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83742. }
  83743. }
  83744. declare module BABYLON.GLTF2.Loader.Extensions {
  83745. /**
  83746. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  83747. */
  83748. export class EXT_texture_webp implements IGLTFLoaderExtension {
  83749. /** The name of this extension. */
  83750. readonly name: string;
  83751. /** Defines whether this extension is enabled. */
  83752. enabled: boolean;
  83753. private _loader;
  83754. /** @hidden */
  83755. constructor(loader: GLTFLoader);
  83756. /** @hidden */
  83757. dispose(): void;
  83758. /** @hidden */
  83759. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83760. }
  83761. }
  83762. declare module BABYLON.GLTF2.Loader.Extensions {
  83763. /**
  83764. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  83765. */
  83766. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  83767. /**
  83768. * The name of this extension.
  83769. */
  83770. readonly name: string;
  83771. /**
  83772. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  83773. */
  83774. dracoCompression?: DracoCompression;
  83775. /**
  83776. * Defines whether this extension is enabled.
  83777. */
  83778. enabled: boolean;
  83779. private _loader;
  83780. /** @hidden */
  83781. constructor(loader: GLTFLoader);
  83782. /** @hidden */
  83783. dispose(): void;
  83784. /** @hidden */
  83785. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83786. }
  83787. }
  83788. declare module BABYLON.GLTF2.Loader.Extensions {
  83789. /**
  83790. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  83791. */
  83792. export class KHR_lights implements IGLTFLoaderExtension {
  83793. /**
  83794. * The name of this extension.
  83795. */
  83796. readonly name: string;
  83797. /**
  83798. * Defines whether this extension is enabled.
  83799. */
  83800. enabled: boolean;
  83801. private _loader;
  83802. private _lights?;
  83803. /** @hidden */
  83804. constructor(loader: GLTFLoader);
  83805. /** @hidden */
  83806. dispose(): void;
  83807. /** @hidden */
  83808. onLoading(): void;
  83809. /** @hidden */
  83810. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83811. }
  83812. }
  83813. declare module BABYLON.GLTF2.Loader.Extensions {
  83814. /**
  83815. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  83816. */
  83817. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  83818. /**
  83819. * The name of this extension.
  83820. */
  83821. readonly name: string;
  83822. /**
  83823. * Defines whether this extension is enabled.
  83824. */
  83825. enabled: boolean;
  83826. /**
  83827. * Defines a number that determines the order the extensions are applied.
  83828. */
  83829. order: number;
  83830. private _loader;
  83831. /** @hidden */
  83832. constructor(loader: GLTFLoader);
  83833. /** @hidden */
  83834. dispose(): void;
  83835. /** @hidden */
  83836. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83837. private _loadSpecularGlossinessPropertiesAsync;
  83838. }
  83839. }
  83840. declare module BABYLON.GLTF2.Loader.Extensions {
  83841. /**
  83842. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  83843. */
  83844. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  83845. /**
  83846. * The name of this extension.
  83847. */
  83848. readonly name: string;
  83849. /**
  83850. * Defines whether this extension is enabled.
  83851. */
  83852. enabled: boolean;
  83853. /**
  83854. * Defines a number that determines the order the extensions are applied.
  83855. */
  83856. order: number;
  83857. private _loader;
  83858. /** @hidden */
  83859. constructor(loader: GLTFLoader);
  83860. /** @hidden */
  83861. dispose(): void;
  83862. /** @hidden */
  83863. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83864. private _loadUnlitPropertiesAsync;
  83865. }
  83866. }
  83867. declare module BABYLON.GLTF2.Loader.Extensions {
  83868. /**
  83869. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  83870. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  83871. */
  83872. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  83873. /**
  83874. * The name of this extension.
  83875. */
  83876. readonly name: string;
  83877. /**
  83878. * Defines whether this extension is enabled.
  83879. */
  83880. enabled: boolean;
  83881. /**
  83882. * Defines a number that determines the order the extensions are applied.
  83883. */
  83884. order: number;
  83885. private _loader;
  83886. /** @hidden */
  83887. constructor(loader: GLTFLoader);
  83888. /** @hidden */
  83889. dispose(): void;
  83890. /** @hidden */
  83891. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83892. private _loadClearCoatPropertiesAsync;
  83893. }
  83894. }
  83895. declare module BABYLON.GLTF2.Loader.Extensions {
  83896. /**
  83897. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  83898. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  83899. * !!! Experimental Extension Subject to Changes !!!
  83900. */
  83901. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  83902. /**
  83903. * The name of this extension.
  83904. */
  83905. readonly name: string;
  83906. /**
  83907. * Defines whether this extension is enabled.
  83908. */
  83909. enabled: boolean;
  83910. /**
  83911. * Defines a number that determines the order the extensions are applied.
  83912. */
  83913. order: number;
  83914. private _loader;
  83915. /** @hidden */
  83916. constructor(loader: GLTFLoader);
  83917. /** @hidden */
  83918. dispose(): void;
  83919. /** @hidden */
  83920. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83921. private _loadSheenPropertiesAsync;
  83922. }
  83923. }
  83924. declare module BABYLON.GLTF2.Loader.Extensions {
  83925. /**
  83926. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  83927. * !!! Experimental Extension Subject to Changes !!!
  83928. */
  83929. export class KHR_materials_specular implements IGLTFLoaderExtension {
  83930. /**
  83931. * The name of this extension.
  83932. */
  83933. readonly name: string;
  83934. /**
  83935. * Defines whether this extension is enabled.
  83936. */
  83937. enabled: boolean;
  83938. /**
  83939. * Defines a number that determines the order the extensions are applied.
  83940. */
  83941. order: number;
  83942. private _loader;
  83943. /** @hidden */
  83944. constructor(loader: GLTFLoader);
  83945. /** @hidden */
  83946. dispose(): void;
  83947. /** @hidden */
  83948. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83949. private _loadSpecularPropertiesAsync;
  83950. }
  83951. }
  83952. declare module BABYLON.GLTF2.Loader.Extensions {
  83953. /**
  83954. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  83955. * !!! Experimental Extension Subject to Changes !!!
  83956. */
  83957. export class KHR_materials_ior implements IGLTFLoaderExtension {
  83958. /**
  83959. * Default ior Value from the spec.
  83960. */
  83961. private static readonly _DEFAULT_IOR;
  83962. /**
  83963. * The name of this extension.
  83964. */
  83965. readonly name: string;
  83966. /**
  83967. * Defines whether this extension is enabled.
  83968. */
  83969. enabled: boolean;
  83970. /**
  83971. * Defines a number that determines the order the extensions are applied.
  83972. */
  83973. order: number;
  83974. private _loader;
  83975. /** @hidden */
  83976. constructor(loader: GLTFLoader);
  83977. /** @hidden */
  83978. dispose(): void;
  83979. /** @hidden */
  83980. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83981. private _loadIorPropertiesAsync;
  83982. }
  83983. }
  83984. declare module BABYLON.GLTF2.Loader.Extensions {
  83985. /**
  83986. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83987. * !!! Experimental Extension Subject to Changes !!!
  83988. */
  83989. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83990. /**
  83991. * The name of this extension.
  83992. */
  83993. readonly name: string;
  83994. /**
  83995. * Defines whether this extension is enabled.
  83996. */
  83997. enabled: boolean;
  83998. private _loader;
  83999. private _variants?;
  84000. /** @hidden */
  84001. constructor(loader: GLTFLoader);
  84002. /** @hidden */
  84003. dispose(): void;
  84004. /**
  84005. * Gets the list of available variant names for this asset.
  84006. * @param rootMesh The glTF root mesh
  84007. * @returns the list of all the variant names for this model
  84008. */
  84009. static GetAvailableVariants(rootMesh: Mesh): string[];
  84010. /**
  84011. * Gets the list of available variant names for this asset.
  84012. * @param rootMesh The glTF root mesh
  84013. * @returns the list of all the variant names for this model
  84014. */
  84015. getAvailableVariants(rootMesh: Mesh): string[];
  84016. /**
  84017. * Select a variant given a variant name or a list of variant names.
  84018. * @param rootMesh The glTF root mesh
  84019. * @param variantName The variant name(s) to select.
  84020. */
  84021. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  84022. /**
  84023. * Select a variant given a variant name or a list of variant names.
  84024. * @param rootMesh The glTF root mesh
  84025. * @param variantName The variant name(s) to select.
  84026. */
  84027. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  84028. /**
  84029. * Reset back to the original before selecting a variant.
  84030. * @param rootMesh The glTF root mesh
  84031. */
  84032. static Reset(rootMesh: Mesh): void;
  84033. /**
  84034. * Reset back to the original before selecting a variant.
  84035. * @param rootMesh The glTF root mesh
  84036. */
  84037. reset(rootMesh: Mesh): void;
  84038. /**
  84039. * Gets the last selected variant name(s) or null if original.
  84040. * @param rootMesh The glTF root mesh
  84041. * @returns The selected variant name(s).
  84042. */
  84043. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  84044. /**
  84045. * Gets the last selected variant name(s) or null if original.
  84046. * @param rootMesh The glTF root mesh
  84047. * @returns The selected variant name(s).
  84048. */
  84049. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  84050. private static _GetExtensionMetadata;
  84051. /** @hidden */
  84052. onLoading(): void;
  84053. /** @hidden */
  84054. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  84055. }
  84056. }
  84057. declare module BABYLON.GLTF2.Loader.Extensions {
  84058. /**
  84059. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  84060. * !!! Experimental Extension Subject to Changes !!!
  84061. */
  84062. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  84063. /**
  84064. * The name of this extension.
  84065. */
  84066. readonly name: string;
  84067. /**
  84068. * Defines whether this extension is enabled.
  84069. */
  84070. enabled: boolean;
  84071. /**
  84072. * Defines a number that determines the order the extensions are applied.
  84073. */
  84074. order: number;
  84075. private _loader;
  84076. /** @hidden */
  84077. constructor(loader: GLTFLoader);
  84078. /** @hidden */
  84079. dispose(): void;
  84080. /** @hidden */
  84081. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84082. private _loadTransparentPropertiesAsync;
  84083. }
  84084. }
  84085. declare module BABYLON.GLTF2.Loader.Extensions {
  84086. /**
  84087. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  84088. * !!! Experimental Extension Subject to Changes !!!
  84089. */
  84090. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  84091. /**
  84092. * The name of this extension.
  84093. */
  84094. readonly name: string;
  84095. /**
  84096. * Defines whether this extension is enabled.
  84097. */
  84098. enabled: boolean;
  84099. /**
  84100. * Defines a number that determines the order the extensions are applied.
  84101. */
  84102. order: number;
  84103. private _loader;
  84104. /** @hidden */
  84105. constructor(loader: GLTFLoader);
  84106. /** @hidden */
  84107. dispose(): void;
  84108. /** @hidden */
  84109. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84110. private _loadTranslucentPropertiesAsync;
  84111. }
  84112. }
  84113. declare module BABYLON.GLTF2.Loader.Extensions {
  84114. /**
  84115. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  84116. */
  84117. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  84118. /**
  84119. * The name of this extension.
  84120. */
  84121. readonly name: string;
  84122. /**
  84123. * Defines whether this extension is enabled.
  84124. */
  84125. enabled: boolean;
  84126. /** @hidden */
  84127. constructor(loader: GLTFLoader);
  84128. /** @hidden */
  84129. dispose(): void;
  84130. }
  84131. }
  84132. declare module BABYLON.GLTF2.Loader.Extensions {
  84133. /**
  84134. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  84135. * !!! Experimental Extension Subject to Changes !!!
  84136. */
  84137. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  84138. /** The name of this extension. */
  84139. readonly name: string;
  84140. /** Defines whether this extension is enabled. */
  84141. enabled: boolean;
  84142. private _loader;
  84143. /** @hidden */
  84144. constructor(loader: GLTFLoader);
  84145. /** @hidden */
  84146. dispose(): void;
  84147. /** @hidden */
  84148. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84149. }
  84150. }
  84151. declare module BABYLON.GLTF2.Loader.Extensions {
  84152. /**
  84153. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  84154. */
  84155. export class KHR_texture_transform implements IGLTFLoaderExtension {
  84156. /**
  84157. * The name of this extension.
  84158. */
  84159. readonly name: string;
  84160. /**
  84161. * Defines whether this extension is enabled.
  84162. */
  84163. enabled: boolean;
  84164. private _loader;
  84165. /** @hidden */
  84166. constructor(loader: GLTFLoader);
  84167. /** @hidden */
  84168. dispose(): void;
  84169. /** @hidden */
  84170. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84171. }
  84172. }
  84173. declare module BABYLON.GLTF2.Loader.Extensions {
  84174. /**
  84175. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  84176. */
  84177. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  84178. /**
  84179. * The name of this extension.
  84180. */
  84181. readonly name: string;
  84182. /**
  84183. * Defines whether this extension is enabled.
  84184. */
  84185. enabled: boolean;
  84186. private _loader;
  84187. private _clips;
  84188. private _emitters;
  84189. /** @hidden */
  84190. constructor(loader: GLTFLoader);
  84191. /** @hidden */
  84192. dispose(): void;
  84193. /** @hidden */
  84194. onLoading(): void;
  84195. /** @hidden */
  84196. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84197. /** @hidden */
  84198. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84199. /** @hidden */
  84200. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  84201. private _loadClipAsync;
  84202. private _loadEmitterAsync;
  84203. private _getEventAction;
  84204. private _loadAnimationEventAsync;
  84205. }
  84206. }
  84207. declare module BABYLON.GLTF2.Loader.Extensions {
  84208. /**
  84209. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  84210. */
  84211. export class MSFT_lod implements IGLTFLoaderExtension {
  84212. /**
  84213. * The name of this extension.
  84214. */
  84215. readonly name: string;
  84216. /**
  84217. * Defines whether this extension is enabled.
  84218. */
  84219. enabled: boolean;
  84220. /**
  84221. * Defines a number that determines the order the extensions are applied.
  84222. */
  84223. order: number;
  84224. /**
  84225. * Maximum number of LODs to load, starting from the lowest LOD.
  84226. */
  84227. maxLODsToLoad: number;
  84228. /**
  84229. * Observable raised when all node LODs of one level are loaded.
  84230. * The event data is the index of the loaded LOD starting from zero.
  84231. * Dispose the loader to cancel the loading of the next level of LODs.
  84232. */
  84233. onNodeLODsLoadedObservable: Observable<number>;
  84234. /**
  84235. * Observable raised when all material LODs of one level are loaded.
  84236. * The event data is the index of the loaded LOD starting from zero.
  84237. * Dispose the loader to cancel the loading of the next level of LODs.
  84238. */
  84239. onMaterialLODsLoadedObservable: Observable<number>;
  84240. private _loader;
  84241. private _bufferLODs;
  84242. private _nodeIndexLOD;
  84243. private _nodeSignalLODs;
  84244. private _nodePromiseLODs;
  84245. private _nodeBufferLODs;
  84246. private _materialIndexLOD;
  84247. private _materialSignalLODs;
  84248. private _materialPromiseLODs;
  84249. private _materialBufferLODs;
  84250. /** @hidden */
  84251. constructor(loader: GLTFLoader);
  84252. /** @hidden */
  84253. dispose(): void;
  84254. /** @hidden */
  84255. onReady(): void;
  84256. /** @hidden */
  84257. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84258. /** @hidden */
  84259. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84260. /** @hidden */
  84261. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  84262. /** @hidden */
  84263. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  84264. /** @hidden */
  84265. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  84266. private _loadBufferLOD;
  84267. /**
  84268. * Gets an array of LOD properties from lowest to highest.
  84269. */
  84270. private _getLODs;
  84271. private _disposeTransformNode;
  84272. private _disposeMaterials;
  84273. }
  84274. }
  84275. declare module BABYLON.GLTF2.Loader.Extensions {
  84276. /** @hidden */
  84277. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  84278. readonly name: string;
  84279. enabled: boolean;
  84280. private _loader;
  84281. constructor(loader: GLTFLoader);
  84282. dispose(): void;
  84283. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84284. }
  84285. }
  84286. declare module BABYLON.GLTF2.Loader.Extensions {
  84287. /** @hidden */
  84288. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  84289. readonly name: string;
  84290. enabled: boolean;
  84291. private _loader;
  84292. constructor(loader: GLTFLoader);
  84293. dispose(): void;
  84294. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84295. }
  84296. }
  84297. declare module BABYLON.GLTF2.Loader.Extensions {
  84298. /**
  84299. * Store glTF extras (if present) in BJS objects' metadata
  84300. */
  84301. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  84302. /**
  84303. * The name of this extension.
  84304. */
  84305. readonly name: string;
  84306. /**
  84307. * Defines whether this extension is enabled.
  84308. */
  84309. enabled: boolean;
  84310. private _loader;
  84311. private _assignExtras;
  84312. /** @hidden */
  84313. constructor(loader: GLTFLoader);
  84314. /** @hidden */
  84315. dispose(): void;
  84316. /** @hidden */
  84317. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84318. /** @hidden */
  84319. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  84320. /** @hidden */
  84321. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  84322. }
  84323. }
  84324. declare module BABYLON {
  84325. /**
  84326. * Class reading and parsing the MTL file bundled with the obj file.
  84327. */
  84328. export class MTLFileLoader {
  84329. /**
  84330. * Invert Y-Axis of referenced textures on load
  84331. */
  84332. static INVERT_TEXTURE_Y: boolean;
  84333. /**
  84334. * All material loaded from the mtl will be set here
  84335. */
  84336. materials: StandardMaterial[];
  84337. /**
  84338. * This function will read the mtl file and create each material described inside
  84339. * This function could be improve by adding :
  84340. * -some component missing (Ni, Tf...)
  84341. * -including the specific options available
  84342. *
  84343. * @param scene defines the scene the material will be created in
  84344. * @param data defines the mtl data to parse
  84345. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  84346. * @param forAssetContainer defines if the material should be registered in the scene
  84347. */
  84348. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  84349. /**
  84350. * Gets the texture for the material.
  84351. *
  84352. * If the material is imported from input file,
  84353. * We sanitize the url to ensure it takes the textre from aside the material.
  84354. *
  84355. * @param rootUrl The root url to load from
  84356. * @param value The value stored in the mtl
  84357. * @return The Texture
  84358. */
  84359. private static _getTexture;
  84360. }
  84361. }
  84362. declare module BABYLON {
  84363. /**
  84364. * Options for loading OBJ/MTL files
  84365. */
  84366. type MeshLoadOptions = {
  84367. /**
  84368. * Defines if UVs are optimized by default during load.
  84369. */
  84370. OptimizeWithUV: boolean;
  84371. /**
  84372. * Defines custom scaling of UV coordinates of loaded meshes.
  84373. */
  84374. UVScaling: Vector2;
  84375. /**
  84376. * Invert model on y-axis (does a model scaling inversion)
  84377. */
  84378. InvertY: boolean;
  84379. /**
  84380. * Invert Y-Axis of referenced textures on load
  84381. */
  84382. InvertTextureY: boolean;
  84383. /**
  84384. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84385. */
  84386. ImportVertexColors: boolean;
  84387. /**
  84388. * Compute the normals for the model, even if normals are present in the file.
  84389. */
  84390. ComputeNormals: boolean;
  84391. /**
  84392. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84393. */
  84394. SkipMaterials: boolean;
  84395. /**
  84396. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84397. */
  84398. MaterialLoadingFailsSilently: boolean;
  84399. };
  84400. /**
  84401. * OBJ file type loader.
  84402. * This is a babylon scene loader plugin.
  84403. */
  84404. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  84405. /**
  84406. * Defines if UVs are optimized by default during load.
  84407. */
  84408. static OPTIMIZE_WITH_UV: boolean;
  84409. /**
  84410. * Invert model on y-axis (does a model scaling inversion)
  84411. */
  84412. static INVERT_Y: boolean;
  84413. /**
  84414. * Invert Y-Axis of referenced textures on load
  84415. */
  84416. static get INVERT_TEXTURE_Y(): boolean;
  84417. static set INVERT_TEXTURE_Y(value: boolean);
  84418. /**
  84419. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84420. */
  84421. static IMPORT_VERTEX_COLORS: boolean;
  84422. /**
  84423. * Compute the normals for the model, even if normals are present in the file.
  84424. */
  84425. static COMPUTE_NORMALS: boolean;
  84426. /**
  84427. * Defines custom scaling of UV coordinates of loaded meshes.
  84428. */
  84429. static UV_SCALING: Vector2;
  84430. /**
  84431. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84432. */
  84433. static SKIP_MATERIALS: boolean;
  84434. /**
  84435. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84436. *
  84437. * Defaults to true for backwards compatibility.
  84438. */
  84439. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  84440. /**
  84441. * Defines the name of the plugin.
  84442. */
  84443. name: string;
  84444. /**
  84445. * Defines the extension the plugin is able to load.
  84446. */
  84447. extensions: string;
  84448. /** @hidden */
  84449. obj: RegExp;
  84450. /** @hidden */
  84451. group: RegExp;
  84452. /** @hidden */
  84453. mtllib: RegExp;
  84454. /** @hidden */
  84455. usemtl: RegExp;
  84456. /** @hidden */
  84457. smooth: RegExp;
  84458. /** @hidden */
  84459. vertexPattern: RegExp;
  84460. /** @hidden */
  84461. normalPattern: RegExp;
  84462. /** @hidden */
  84463. uvPattern: RegExp;
  84464. /** @hidden */
  84465. facePattern1: RegExp;
  84466. /** @hidden */
  84467. facePattern2: RegExp;
  84468. /** @hidden */
  84469. facePattern3: RegExp;
  84470. /** @hidden */
  84471. facePattern4: RegExp;
  84472. /** @hidden */
  84473. facePattern5: RegExp;
  84474. private _forAssetContainer;
  84475. private _meshLoadOptions;
  84476. /**
  84477. * Creates loader for .OBJ files
  84478. *
  84479. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  84480. */
  84481. constructor(meshLoadOptions?: MeshLoadOptions);
  84482. private static get currentMeshLoadOptions();
  84483. /**
  84484. * Calls synchronously the MTL file attached to this obj.
  84485. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  84486. * Without this function materials are not displayed in the first frame (but displayed after).
  84487. * In consequence it is impossible to get material information in your HTML file
  84488. *
  84489. * @param url The URL of the MTL file
  84490. * @param rootUrl
  84491. * @param onSuccess Callback function to be called when the MTL file is loaded
  84492. * @private
  84493. */
  84494. private _loadMTL;
  84495. /**
  84496. * Instantiates a OBJ file loader plugin.
  84497. * @returns the created plugin
  84498. */
  84499. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  84500. /**
  84501. * If the data string can be loaded directly.
  84502. *
  84503. * @param data string containing the file data
  84504. * @returns if the data can be loaded directly
  84505. */
  84506. canDirectLoad(data: string): boolean;
  84507. /**
  84508. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  84509. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  84510. * @param scene the scene the meshes should be added to
  84511. * @param data the OBJ data to load
  84512. * @param rootUrl root url to load from
  84513. * @param onProgress event that fires when loading progress has occured
  84514. * @param fileName Defines the name of the file to load
  84515. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  84516. */
  84517. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  84518. /**
  84519. * Imports all objects from the loaded OBJ data and adds them to the scene
  84520. * @param scene the scene the objects should be added to
  84521. * @param data the OBJ data to load
  84522. * @param rootUrl root url to load from
  84523. * @param onProgress event that fires when loading progress has occured
  84524. * @param fileName Defines the name of the file to load
  84525. * @returns a promise which completes when objects have been loaded to the scene
  84526. */
  84527. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  84528. /**
  84529. * Load into an asset container.
  84530. * @param scene The scene to load into
  84531. * @param data The data to import
  84532. * @param rootUrl The root url for scene and resources
  84533. * @param onProgress The callback when the load progresses
  84534. * @param fileName Defines the name of the file to load
  84535. * @returns The loaded asset container
  84536. */
  84537. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  84538. /**
  84539. * Read the OBJ file and create an Array of meshes.
  84540. * Each mesh contains all information given by the OBJ and the MTL file.
  84541. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  84542. *
  84543. * @param meshesNames
  84544. * @param scene Scene The scene where are displayed the data
  84545. * @param data String The content of the obj file
  84546. * @param rootUrl String The path to the folder
  84547. * @returns Array<AbstractMesh>
  84548. * @private
  84549. */
  84550. private _parseSolid;
  84551. }
  84552. }
  84553. declare module BABYLON {
  84554. /**
  84555. * STL file type loader.
  84556. * This is a babylon scene loader plugin.
  84557. */
  84558. export class STLFileLoader implements ISceneLoaderPlugin {
  84559. /** @hidden */
  84560. solidPattern: RegExp;
  84561. /** @hidden */
  84562. facetsPattern: RegExp;
  84563. /** @hidden */
  84564. normalPattern: RegExp;
  84565. /** @hidden */
  84566. vertexPattern: RegExp;
  84567. /**
  84568. * Defines the name of the plugin.
  84569. */
  84570. name: string;
  84571. /**
  84572. * Defines the extensions the stl loader is able to load.
  84573. * force data to come in as an ArrayBuffer
  84574. * we'll convert to string if it looks like it's an ASCII .stl
  84575. */
  84576. extensions: ISceneLoaderPluginExtensions;
  84577. /**
  84578. * Import meshes into a scene.
  84579. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  84580. * @param scene The scene to import into
  84581. * @param data The data to import
  84582. * @param rootUrl The root url for scene and resources
  84583. * @param meshes The meshes array to import into
  84584. * @param particleSystems The particle systems array to import into
  84585. * @param skeletons The skeletons array to import into
  84586. * @param onError The callback when import fails
  84587. * @returns True if successful or false otherwise
  84588. */
  84589. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  84590. /**
  84591. * Load into a scene.
  84592. * @param scene The scene to load into
  84593. * @param data The data to import
  84594. * @param rootUrl The root url for scene and resources
  84595. * @param onError The callback when import fails
  84596. * @returns true if successful or false otherwise
  84597. */
  84598. load(scene: Scene, data: any, rootUrl: string): boolean;
  84599. /**
  84600. * Load into an asset container.
  84601. * @param scene The scene to load into
  84602. * @param data The data to import
  84603. * @param rootUrl The root url for scene and resources
  84604. * @param onError The callback when import fails
  84605. * @returns The loaded asset container
  84606. */
  84607. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  84608. private _isBinary;
  84609. private _parseBinary;
  84610. private _parseASCII;
  84611. }
  84612. }
  84613. declare module BABYLON {
  84614. /**
  84615. * Class for generating OBJ data from a Babylon scene.
  84616. */
  84617. export class OBJExport {
  84618. /**
  84619. * Exports the geometry of a Mesh array in .OBJ file format (text)
  84620. * @param mesh defines the list of meshes to serialize
  84621. * @param materials defines if materials should be exported
  84622. * @param matlibname defines the name of the associated mtl file
  84623. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  84624. * @returns the OBJ content
  84625. */
  84626. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  84627. /**
  84628. * Exports the material(s) of a mesh in .MTL file format (text)
  84629. * @param mesh defines the mesh to extract the material from
  84630. * @returns the mtl content
  84631. */
  84632. static MTL(mesh: Mesh): string;
  84633. }
  84634. }
  84635. declare module BABYLON {
  84636. /** @hidden */
  84637. export var __IGLTFExporterExtension: number;
  84638. /**
  84639. * Interface for extending the exporter
  84640. * @hidden
  84641. */
  84642. export interface IGLTFExporterExtension {
  84643. /**
  84644. * The name of this extension
  84645. */
  84646. readonly name: string;
  84647. /**
  84648. * Defines whether this extension is enabled
  84649. */
  84650. enabled: boolean;
  84651. /**
  84652. * Defines whether this extension is required
  84653. */
  84654. required: boolean;
  84655. }
  84656. }
  84657. declare module BABYLON.GLTF2.Exporter {
  84658. /** @hidden */
  84659. export var __IGLTFExporterExtensionV2: number;
  84660. /**
  84661. * Interface for a glTF exporter extension
  84662. * @hidden
  84663. */
  84664. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  84665. /**
  84666. * Define this method to modify the default behavior before exporting a texture
  84667. * @param context The context when loading the asset
  84668. * @param babylonTexture The Babylon.js texture
  84669. * @param mimeType The mime-type of the generated image
  84670. * @returns A promise that resolves with the exported texture
  84671. */
  84672. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  84673. /**
  84674. * Define this method to get notified when a texture info is created
  84675. * @param context The context when loading the asset
  84676. * @param textureInfo The glTF texture info
  84677. * @param babylonTexture The Babylon.js texture
  84678. */
  84679. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84680. /**
  84681. * Define this method to modify the default behavior when exporting texture info
  84682. * @param context The context when loading the asset
  84683. * @param meshPrimitive glTF mesh primitive
  84684. * @param babylonSubMesh Babylon submesh
  84685. * @param binaryWriter glTF serializer binary writer instance
  84686. * @returns nullable IMeshPrimitive promise
  84687. */
  84688. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  84689. /**
  84690. * Define this method to modify the default behavior when exporting a node
  84691. * @param context The context when exporting the node
  84692. * @param node glTF node
  84693. * @param babylonNode BabylonJS node
  84694. * @returns nullable INode promise
  84695. */
  84696. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84697. [key: number]: number;
  84698. }): Promise<Nullable<INode>>;
  84699. /**
  84700. * Define this method to modify the default behavior when exporting a material
  84701. * @param material glTF material
  84702. * @param babylonMaterial BabylonJS material
  84703. * @returns nullable IMaterial promise
  84704. */
  84705. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  84706. /**
  84707. * Define this method to return additional textures to export from a material
  84708. * @param material glTF material
  84709. * @param babylonMaterial BabylonJS material
  84710. * @returns List of textures
  84711. */
  84712. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84713. /** Gets a boolean indicating that this extension was used */
  84714. wasUsed: boolean;
  84715. /** Gets a boolean indicating that this extension is required for the file to work */
  84716. required: boolean;
  84717. /**
  84718. * Called after the exporter state changes to EXPORTING
  84719. */
  84720. onExporting?(): void;
  84721. }
  84722. }
  84723. declare module BABYLON.GLTF2.Exporter {
  84724. /**
  84725. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  84726. * @hidden
  84727. */
  84728. export class _GLTFMaterialExporter {
  84729. /**
  84730. * Represents the dielectric specular values for R, G and B
  84731. */
  84732. private static readonly _DielectricSpecular;
  84733. /**
  84734. * Allows the maximum specular power to be defined for material calculations
  84735. */
  84736. private static readonly _MaxSpecularPower;
  84737. /**
  84738. * Mapping to store textures
  84739. */
  84740. private _textureMap;
  84741. /**
  84742. * Numeric tolerance value
  84743. */
  84744. private static readonly _Epsilon;
  84745. /**
  84746. * Reference to the glTF Exporter
  84747. */
  84748. private _exporter;
  84749. constructor(exporter: _Exporter);
  84750. /**
  84751. * Specifies if two colors are approximately equal in value
  84752. * @param color1 first color to compare to
  84753. * @param color2 second color to compare to
  84754. * @param epsilon threshold value
  84755. */
  84756. private static FuzzyEquals;
  84757. /**
  84758. * Gets the materials from a Babylon scene and converts them to glTF materials
  84759. * @param scene babylonjs scene
  84760. * @param mimeType texture mime type
  84761. * @param images array of images
  84762. * @param textures array of textures
  84763. * @param materials array of materials
  84764. * @param imageData mapping of texture names to base64 textures
  84765. * @param hasTextureCoords specifies if texture coordinates are present on the material
  84766. */
  84767. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  84768. /**
  84769. * Makes a copy of the glTF material without the texture parameters
  84770. * @param originalMaterial original glTF material
  84771. * @returns glTF material without texture parameters
  84772. */
  84773. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  84774. /**
  84775. * Specifies if the material has any texture parameters present
  84776. * @param material glTF Material
  84777. * @returns boolean specifying if texture parameters are present
  84778. */
  84779. _hasTexturesPresent(material: IMaterial): boolean;
  84780. /**
  84781. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  84782. * @param babylonStandardMaterial
  84783. * @returns glTF Metallic Roughness Material representation
  84784. */
  84785. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  84786. /**
  84787. * Computes the metallic factor
  84788. * @param diffuse diffused value
  84789. * @param specular specular value
  84790. * @param oneMinusSpecularStrength one minus the specular strength
  84791. * @returns metallic value
  84792. */
  84793. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  84794. /**
  84795. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  84796. * @param glTFMaterial glTF material
  84797. * @param babylonMaterial Babylon material
  84798. */
  84799. private static _SetAlphaMode;
  84800. /**
  84801. * Converts a Babylon Standard Material to a glTF Material
  84802. * @param babylonStandardMaterial BJS Standard Material
  84803. * @param mimeType mime type to use for the textures
  84804. * @param images array of glTF image interfaces
  84805. * @param textures array of glTF texture interfaces
  84806. * @param materials array of glTF material interfaces
  84807. * @param imageData map of image file name to data
  84808. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84809. */
  84810. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84811. private _finishMaterial;
  84812. /**
  84813. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84814. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  84815. * @param mimeType mime type to use for the textures
  84816. * @param images array of glTF image interfaces
  84817. * @param textures array of glTF texture interfaces
  84818. * @param materials array of glTF material interfaces
  84819. * @param imageData map of image file name to data
  84820. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84821. */
  84822. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84823. /**
  84824. * Converts an image typed array buffer to a base64 image
  84825. * @param buffer typed array buffer
  84826. * @param width width of the image
  84827. * @param height height of the image
  84828. * @param mimeType mimetype of the image
  84829. * @returns base64 image string
  84830. */
  84831. private _createBase64FromCanvasAsync;
  84832. /**
  84833. * Generates a white texture based on the specified width and height
  84834. * @param width width of the texture in pixels
  84835. * @param height height of the texture in pixels
  84836. * @param scene babylonjs scene
  84837. * @returns white texture
  84838. */
  84839. private _createWhiteTexture;
  84840. /**
  84841. * 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
  84842. * @param texture1 first texture to resize
  84843. * @param texture2 second texture to resize
  84844. * @param scene babylonjs scene
  84845. * @returns resized textures or null
  84846. */
  84847. private _resizeTexturesToSameDimensions;
  84848. /**
  84849. * Converts an array of pixels to a Float32Array
  84850. * Throws an error if the pixel format is not supported
  84851. * @param pixels - array buffer containing pixel values
  84852. * @returns Float32 of pixels
  84853. */
  84854. private _convertPixelArrayToFloat32;
  84855. /**
  84856. * Convert Specular Glossiness Textures to Metallic Roughness
  84857. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  84858. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  84859. * @param diffuseTexture texture used to store diffuse information
  84860. * @param specularGlossinessTexture texture used to store specular and glossiness information
  84861. * @param factors specular glossiness material factors
  84862. * @param mimeType the mime type to use for the texture
  84863. * @returns pbr metallic roughness interface or null
  84864. */
  84865. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  84866. /**
  84867. * Converts specular glossiness material properties to metallic roughness
  84868. * @param specularGlossiness interface with specular glossiness material properties
  84869. * @returns interface with metallic roughness material properties
  84870. */
  84871. private _convertSpecularGlossinessToMetallicRoughness;
  84872. /**
  84873. * Calculates the surface reflectance, independent of lighting conditions
  84874. * @param color Color source to calculate brightness from
  84875. * @returns number representing the perceived brightness, or zero if color is undefined
  84876. */
  84877. private _getPerceivedBrightness;
  84878. /**
  84879. * Returns the maximum color component value
  84880. * @param color
  84881. * @returns maximum color component value, or zero if color is null or undefined
  84882. */
  84883. private _getMaxComponent;
  84884. /**
  84885. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  84886. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84887. * @param mimeType mime type to use for the textures
  84888. * @param images array of glTF image interfaces
  84889. * @param textures array of glTF texture interfaces
  84890. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84891. * @param imageData map of image file name to data
  84892. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84893. * @returns glTF PBR Metallic Roughness factors
  84894. */
  84895. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  84896. private _getGLTFTextureSampler;
  84897. private _getGLTFTextureWrapMode;
  84898. private _getGLTFTextureWrapModesSampler;
  84899. /**
  84900. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  84901. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84902. * @param mimeType mime type to use for the textures
  84903. * @param images array of glTF image interfaces
  84904. * @param textures array of glTF texture interfaces
  84905. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  84906. * @param imageData map of image file name to data
  84907. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84908. * @returns glTF PBR Metallic Roughness factors
  84909. */
  84910. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  84911. /**
  84912. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  84913. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  84914. * @param mimeType mime type to use for the textures
  84915. * @param images array of glTF image interfaces
  84916. * @param textures array of glTF texture interfaces
  84917. * @param materials array of glTF material interfaces
  84918. * @param imageData map of image file name to data
  84919. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  84920. */
  84921. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  84922. private setMetallicRoughnessPbrMaterial;
  84923. private getPixelsFromTexture;
  84924. /**
  84925. * Extracts a texture from a Babylon texture into file data and glTF data
  84926. * @param babylonTexture Babylon texture to extract
  84927. * @param mimeType Mime Type of the babylonTexture
  84928. * @return glTF texture info, or null if the texture format is not supported
  84929. */
  84930. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84931. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  84932. /**
  84933. * Builds a texture from base64 string
  84934. * @param base64Texture base64 texture string
  84935. * @param baseTextureName Name to use for the texture
  84936. * @param mimeType image mime type for the texture
  84937. * @param images array of images
  84938. * @param textures array of textures
  84939. * @param imageData map of image data
  84940. * @returns glTF texture info, or null if the texture format is not supported
  84941. */
  84942. private _getTextureInfoFromBase64;
  84943. }
  84944. }
  84945. declare module BABYLON {
  84946. /**
  84947. * Class for holding and downloading glTF file data
  84948. */
  84949. export class GLTFData {
  84950. /**
  84951. * Object which contains the file name as the key and its data as the value
  84952. */
  84953. glTFFiles: {
  84954. [fileName: string]: string | Blob;
  84955. };
  84956. /**
  84957. * Initializes the glTF file object
  84958. */
  84959. constructor();
  84960. /**
  84961. * Downloads the glTF data as files based on their names and data
  84962. */
  84963. downloadFiles(): void;
  84964. }
  84965. }
  84966. declare module BABYLON {
  84967. /**
  84968. * Holds a collection of exporter options and parameters
  84969. */
  84970. export interface IExportOptions {
  84971. /**
  84972. * Function which indicates whether a babylon node should be exported or not
  84973. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  84974. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84975. */
  84976. shouldExportNode?(node: Node): boolean;
  84977. /**
  84978. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84979. * @param metadata source metadata to read from
  84980. * @returns the data to store to glTF node extras
  84981. */
  84982. metadataSelector?(metadata: any): any;
  84983. /**
  84984. * The sample rate to bake animation curves
  84985. */
  84986. animationSampleRate?: number;
  84987. /**
  84988. * Begin serialization without waiting for the scene to be ready
  84989. */
  84990. exportWithoutWaitingForScene?: boolean;
  84991. /**
  84992. * Indicates if coordinate system swapping root nodes should be included in export
  84993. */
  84994. includeCoordinateSystemConversionNodes?: boolean;
  84995. }
  84996. /**
  84997. * Class for generating glTF data from a Babylon scene.
  84998. */
  84999. export class GLTF2Export {
  85000. /**
  85001. * Exports the geometry of the scene to .gltf file format asynchronously
  85002. * @param scene Babylon scene with scene hierarchy information
  85003. * @param filePrefix File prefix to use when generating the glTF file
  85004. * @param options Exporter options
  85005. * @returns Returns an object with a .gltf file and associates texture names
  85006. * as keys and their data and paths as values
  85007. */
  85008. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  85009. private static _PreExportAsync;
  85010. private static _PostExportAsync;
  85011. /**
  85012. * Exports the geometry of the scene to .glb file format asychronously
  85013. * @param scene Babylon scene with scene hierarchy information
  85014. * @param filePrefix File prefix to use when generating glb file
  85015. * @param options Exporter options
  85016. * @returns Returns an object with a .glb filename as key and data as value
  85017. */
  85018. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  85019. }
  85020. }
  85021. declare module BABYLON.GLTF2.Exporter {
  85022. /**
  85023. * @hidden
  85024. */
  85025. export class _GLTFUtilities {
  85026. /**
  85027. * Creates a buffer view based on the supplied arguments
  85028. * @param bufferIndex index value of the specified buffer
  85029. * @param byteOffset byte offset value
  85030. * @param byteLength byte length of the bufferView
  85031. * @param byteStride byte distance between conequential elements
  85032. * @param name name of the buffer view
  85033. * @returns bufferView for glTF
  85034. */
  85035. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  85036. /**
  85037. * Creates an accessor based on the supplied arguments
  85038. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  85039. * @param name The name of the accessor
  85040. * @param type The type of the accessor
  85041. * @param componentType The datatype of components in the attribute
  85042. * @param count The number of attributes referenced by this accessor
  85043. * @param byteOffset The offset relative to the start of the bufferView in bytes
  85044. * @param min Minimum value of each component in this attribute
  85045. * @param max Maximum value of each component in this attribute
  85046. * @returns accessor for glTF
  85047. */
  85048. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  85049. /**
  85050. * Calculates the minimum and maximum values of an array of position floats
  85051. * @param positions Positions array of a mesh
  85052. * @param vertexStart Starting vertex offset to calculate min and max values
  85053. * @param vertexCount Number of vertices to check for min and max values
  85054. * @returns min number array and max number array
  85055. */
  85056. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  85057. min: number[];
  85058. max: number[];
  85059. };
  85060. /**
  85061. * Converts a new right-handed Vector3
  85062. * @param vector vector3 array
  85063. * @returns right-handed Vector3
  85064. */
  85065. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  85066. /**
  85067. * Converts a Vector3 to right-handed
  85068. * @param vector Vector3 to convert to right-handed
  85069. */
  85070. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  85071. /**
  85072. * Converts a three element number array to right-handed
  85073. * @param vector number array to convert to right-handed
  85074. */
  85075. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  85076. /**
  85077. * Converts a new right-handed Vector3
  85078. * @param vector vector3 array
  85079. * @returns right-handed Vector3
  85080. */
  85081. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  85082. /**
  85083. * Converts a Vector3 to right-handed
  85084. * @param vector Vector3 to convert to right-handed
  85085. */
  85086. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  85087. /**
  85088. * Converts a three element number array to right-handed
  85089. * @param vector number array to convert to right-handed
  85090. */
  85091. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  85092. /**
  85093. * Converts a Vector4 to right-handed
  85094. * @param vector Vector4 to convert to right-handed
  85095. */
  85096. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  85097. /**
  85098. * Converts a Vector4 to right-handed
  85099. * @param vector Vector4 to convert to right-handed
  85100. */
  85101. static _GetRightHandedArray4FromRef(vector: number[]): void;
  85102. /**
  85103. * Converts a Quaternion to right-handed
  85104. * @param quaternion Source quaternion to convert to right-handed
  85105. */
  85106. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  85107. /**
  85108. * Converts a Quaternion to right-handed
  85109. * @param quaternion Source quaternion to convert to right-handed
  85110. */
  85111. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  85112. static _NormalizeTangentFromRef(tangent: Vector4): void;
  85113. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  85114. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  85115. }
  85116. }
  85117. declare module BABYLON.GLTF2.Exporter {
  85118. /**
  85119. * Converts Babylon Scene into glTF 2.0.
  85120. * @hidden
  85121. */
  85122. export class _Exporter {
  85123. /**
  85124. * Stores the glTF to export
  85125. */
  85126. _glTF: IGLTF;
  85127. /**
  85128. * Stores all generated buffer views, which represents views into the main glTF buffer data
  85129. */
  85130. _bufferViews: IBufferView[];
  85131. /**
  85132. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  85133. */
  85134. _accessors: IAccessor[];
  85135. /**
  85136. * Stores all the generated nodes, which contains transform and/or mesh information per node
  85137. */
  85138. _nodes: INode[];
  85139. /**
  85140. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  85141. */
  85142. private _scenes;
  85143. /**
  85144. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  85145. */
  85146. private _meshes;
  85147. /**
  85148. * Stores all the generated material information, which represents the appearance of each primitive
  85149. */
  85150. _materials: IMaterial[];
  85151. _materialMap: {
  85152. [materialID: number]: number;
  85153. };
  85154. /**
  85155. * Stores all the generated texture information, which is referenced by glTF materials
  85156. */
  85157. _textures: ITexture[];
  85158. /**
  85159. * Stores all the generated image information, which is referenced by glTF textures
  85160. */
  85161. _images: IImage[];
  85162. /**
  85163. * Stores all the texture samplers
  85164. */
  85165. _samplers: ISampler[];
  85166. /**
  85167. * Stores all the generated glTF skins
  85168. */
  85169. _skins: ISkin[];
  85170. /**
  85171. * Stores all the generated animation samplers, which is referenced by glTF animations
  85172. */
  85173. /**
  85174. * Stores the animations for glTF models
  85175. */
  85176. private _animations;
  85177. /**
  85178. * Stores the total amount of bytes stored in the glTF buffer
  85179. */
  85180. private _totalByteLength;
  85181. /**
  85182. * Stores a reference to the Babylon scene containing the source geometry and material information
  85183. */
  85184. _babylonScene: Scene;
  85185. /**
  85186. * Stores a map of the image data, where the key is the file name and the value
  85187. * is the image data
  85188. */
  85189. _imageData: {
  85190. [fileName: string]: {
  85191. data: Uint8Array;
  85192. mimeType: ImageMimeType;
  85193. };
  85194. };
  85195. protected _orderedImageData: Array<{
  85196. data: Uint8Array;
  85197. mimeType: ImageMimeType;
  85198. }>;
  85199. /**
  85200. * Stores a map of the unique id of a node to its index in the node array
  85201. */
  85202. _nodeMap: {
  85203. [key: number]: number;
  85204. };
  85205. /**
  85206. * Specifies if the source Babylon scene was left handed, and needed conversion.
  85207. */
  85208. _convertToRightHandedSystem: boolean;
  85209. /**
  85210. * Specifies if a Babylon node should be converted to right-handed on export
  85211. */
  85212. _convertToRightHandedSystemMap: {
  85213. [nodeId: number]: boolean;
  85214. };
  85215. _includeCoordinateSystemConversionNodes: boolean;
  85216. /**
  85217. * Baked animation sample rate
  85218. */
  85219. private _animationSampleRate;
  85220. private _options;
  85221. private _localEngine;
  85222. _glTFMaterialExporter: _GLTFMaterialExporter;
  85223. private _extensions;
  85224. private static _ExtensionNames;
  85225. private static _ExtensionFactories;
  85226. private _applyExtension;
  85227. private _applyExtensions;
  85228. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  85229. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  85230. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85231. [key: number]: number;
  85232. }): Promise<Nullable<INode>>;
  85233. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  85234. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  85235. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  85236. private _forEachExtensions;
  85237. private _extensionsOnExporting;
  85238. /**
  85239. * Load glTF serializer extensions
  85240. */
  85241. private _loadExtensions;
  85242. /**
  85243. * Creates a glTF Exporter instance, which can accept optional exporter options
  85244. * @param babylonScene Babylon scene object
  85245. * @param options Options to modify the behavior of the exporter
  85246. */
  85247. constructor(babylonScene: Scene, options?: IExportOptions);
  85248. dispose(): void;
  85249. /**
  85250. * Registers a glTF exporter extension
  85251. * @param name Name of the extension to export
  85252. * @param factory The factory function that creates the exporter extension
  85253. */
  85254. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  85255. /**
  85256. * Un-registers an exporter extension
  85257. * @param name The name fo the exporter extension
  85258. * @returns A boolean indicating whether the extension has been un-registered
  85259. */
  85260. static UnregisterExtension(name: string): boolean;
  85261. /**
  85262. * Lazy load a local engine
  85263. */
  85264. _getLocalEngine(): Engine;
  85265. private reorderIndicesBasedOnPrimitiveMode;
  85266. /**
  85267. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  85268. * clock-wise during export to glTF
  85269. * @param submesh BabylonJS submesh
  85270. * @param primitiveMode Primitive mode of the mesh
  85271. * @param sideOrientation the winding order of the submesh
  85272. * @param vertexBufferKind The type of vertex attribute
  85273. * @param meshAttributeArray The vertex attribute data
  85274. * @param byteOffset The offset to the binary data
  85275. * @param binaryWriter The binary data for the glTF file
  85276. * @param convertToRightHandedSystem Converts the values to right-handed
  85277. */
  85278. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  85279. /**
  85280. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  85281. * clock-wise during export to glTF
  85282. * @param submesh BabylonJS submesh
  85283. * @param primitiveMode Primitive mode of the mesh
  85284. * @param sideOrientation the winding order of the submesh
  85285. * @param vertexBufferKind The type of vertex attribute
  85286. * @param meshAttributeArray The vertex attribute data
  85287. * @param byteOffset The offset to the binary data
  85288. * @param binaryWriter The binary data for the glTF file
  85289. * @param convertToRightHandedSystem Converts the values to right-handed
  85290. */
  85291. private reorderTriangleFillMode;
  85292. /**
  85293. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  85294. * clock-wise during export to glTF
  85295. * @param submesh BabylonJS submesh
  85296. * @param primitiveMode Primitive mode of the mesh
  85297. * @param sideOrientation the winding order of the submesh
  85298. * @param vertexBufferKind The type of vertex attribute
  85299. * @param meshAttributeArray The vertex attribute data
  85300. * @param byteOffset The offset to the binary data
  85301. * @param binaryWriter The binary data for the glTF file
  85302. * @param convertToRightHandedSystem Converts the values to right-handed
  85303. */
  85304. private reorderTriangleStripDrawMode;
  85305. /**
  85306. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  85307. * clock-wise during export to glTF
  85308. * @param submesh BabylonJS submesh
  85309. * @param primitiveMode Primitive mode of the mesh
  85310. * @param sideOrientation the winding order of the submesh
  85311. * @param vertexBufferKind The type of vertex attribute
  85312. * @param meshAttributeArray The vertex attribute data
  85313. * @param byteOffset The offset to the binary data
  85314. * @param binaryWriter The binary data for the glTF file
  85315. * @param convertToRightHandedSystem Converts the values to right-handed
  85316. */
  85317. private reorderTriangleFanMode;
  85318. /**
  85319. * Writes the vertex attribute data to binary
  85320. * @param vertices The vertices to write to the binary writer
  85321. * @param byteOffset The offset into the binary writer to overwrite binary data
  85322. * @param vertexAttributeKind The vertex attribute type
  85323. * @param meshAttributeArray The vertex attribute data
  85324. * @param binaryWriter The writer containing the binary data
  85325. * @param convertToRightHandedSystem Converts the values to right-handed
  85326. */
  85327. private writeVertexAttributeData;
  85328. /**
  85329. * Writes mesh attribute data to a data buffer
  85330. * Returns the bytelength of the data
  85331. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85332. * @param meshAttributeArray Array containing the attribute data
  85333. * @param byteStride Specifies the space between data
  85334. * @param binaryWriter The buffer to write the binary data to
  85335. * @param convertToRightHandedSystem Converts the values to right-handed
  85336. */
  85337. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  85338. /**
  85339. * Writes mesh attribute data to a data buffer
  85340. * Returns the bytelength of the data
  85341. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85342. * @param meshAttributeArray Array containing the attribute data
  85343. * @param byteStride Specifies the space between data
  85344. * @param binaryWriter The buffer to write the binary data to
  85345. * @param convertToRightHandedSystem Converts the values to right-handed
  85346. */
  85347. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  85348. /**
  85349. * Generates glTF json data
  85350. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  85351. * @param glTFPrefix Text to use when prefixing a glTF file
  85352. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  85353. * @returns json data as string
  85354. */
  85355. private generateJSON;
  85356. /**
  85357. * Generates data for .gltf and .bin files based on the glTF prefix string
  85358. * @param glTFPrefix Text to use when prefixing a glTF file
  85359. * @param dispose Dispose the exporter
  85360. * @returns GLTFData with glTF file data
  85361. */
  85362. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85363. /**
  85364. * Creates a binary buffer for glTF
  85365. * @returns array buffer for binary data
  85366. */
  85367. private _generateBinaryAsync;
  85368. /**
  85369. * Pads the number to a multiple of 4
  85370. * @param num number to pad
  85371. * @returns padded number
  85372. */
  85373. private _getPadding;
  85374. /**
  85375. * @hidden
  85376. */
  85377. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85378. /**
  85379. * Sets the TRS for each node
  85380. * @param node glTF Node for storing the transformation data
  85381. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  85382. * @param convertToRightHandedSystem Converts the values to right-handed
  85383. */
  85384. private setNodeTransformation;
  85385. private getVertexBufferFromMesh;
  85386. /**
  85387. * Creates a bufferview based on the vertices type for the Babylon mesh
  85388. * @param kind Indicates the type of vertices data
  85389. * @param componentType Indicates the numerical type used to store the data
  85390. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  85391. * @param binaryWriter The buffer to write the bufferview data to
  85392. * @param convertToRightHandedSystem Converts the values to right-handed
  85393. */
  85394. private createBufferViewKind;
  85395. /**
  85396. * Creates a bufferview based on the vertices type for the Babylon mesh
  85397. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  85398. * @param babylonMorphTarget the morph target to be exported
  85399. * @param binaryWriter The buffer to write the bufferview data to
  85400. * @param convertToRightHandedSystem Converts the values to right-handed
  85401. */
  85402. private setMorphTargetAttributes;
  85403. /**
  85404. * The primitive mode of the Babylon mesh
  85405. * @param babylonMesh The BabylonJS mesh
  85406. */
  85407. private getMeshPrimitiveMode;
  85408. /**
  85409. * Sets the primitive mode of the glTF mesh primitive
  85410. * @param meshPrimitive glTF mesh primitive
  85411. * @param primitiveMode The primitive mode
  85412. */
  85413. private setPrimitiveMode;
  85414. /**
  85415. * Sets the vertex attribute accessor based of the glTF mesh primitive
  85416. * @param meshPrimitive glTF mesh primitive
  85417. * @param attributeKind vertex attribute
  85418. * @returns boolean specifying if uv coordinates are present
  85419. */
  85420. private setAttributeKind;
  85421. /**
  85422. * Sets data for the primitive attributes of each submesh
  85423. * @param mesh glTF Mesh object to store the primitive attribute information
  85424. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  85425. * @param binaryWriter Buffer to write the attribute data to
  85426. * @param convertToRightHandedSystem Converts the values to right-handed
  85427. */
  85428. private setPrimitiveAttributesAsync;
  85429. /**
  85430. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  85431. * @param node The node to check
  85432. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  85433. */
  85434. private isBabylonCoordinateSystemConvertingNode;
  85435. /**
  85436. * Creates a glTF scene based on the array of meshes
  85437. * Returns the the total byte offset
  85438. * @param babylonScene Babylon scene to get the mesh data from
  85439. * @param binaryWriter Buffer to write binary data to
  85440. */
  85441. private createSceneAsync;
  85442. /**
  85443. * Creates a mapping of Node unique id to node index and handles animations
  85444. * @param babylonScene Babylon Scene
  85445. * @param nodes Babylon transform nodes
  85446. * @param binaryWriter Buffer to write binary data to
  85447. * @returns Node mapping of unique id to index
  85448. */
  85449. private createNodeMapAndAnimationsAsync;
  85450. /**
  85451. * Creates a glTF node from a Babylon mesh
  85452. * @param babylonMesh Source Babylon mesh
  85453. * @param binaryWriter Buffer for storing geometry data
  85454. * @param convertToRightHandedSystem Converts the values to right-handed
  85455. * @param nodeMap Node mapping of unique id to glTF node index
  85456. * @returns glTF node
  85457. */
  85458. private createNodeAsync;
  85459. /**
  85460. * Creates a glTF skin from a Babylon skeleton
  85461. * @param babylonScene Babylon Scene
  85462. * @param nodes Babylon transform nodes
  85463. * @param binaryWriter Buffer to write binary data to
  85464. * @returns Node mapping of unique id to index
  85465. */
  85466. private createSkinsAsync;
  85467. }
  85468. /**
  85469. * @hidden
  85470. *
  85471. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  85472. */
  85473. export class _BinaryWriter {
  85474. /**
  85475. * Array buffer which stores all binary data
  85476. */
  85477. private _arrayBuffer;
  85478. /**
  85479. * View of the array buffer
  85480. */
  85481. private _dataView;
  85482. /**
  85483. * byte offset of data in array buffer
  85484. */
  85485. private _byteOffset;
  85486. /**
  85487. * Initialize binary writer with an initial byte length
  85488. * @param byteLength Initial byte length of the array buffer
  85489. */
  85490. constructor(byteLength: number);
  85491. /**
  85492. * Resize the array buffer to the specified byte length
  85493. * @param byteLength
  85494. */
  85495. private resizeBuffer;
  85496. /**
  85497. * Get an array buffer with the length of the byte offset
  85498. * @returns ArrayBuffer resized to the byte offset
  85499. */
  85500. getArrayBuffer(): ArrayBuffer;
  85501. /**
  85502. * Get the byte offset of the array buffer
  85503. * @returns byte offset
  85504. */
  85505. getByteOffset(): number;
  85506. /**
  85507. * Stores an UInt8 in the array buffer
  85508. * @param entry
  85509. * @param byteOffset If defined, specifies where to set the value as an offset.
  85510. */
  85511. setUInt8(entry: number, byteOffset?: number): void;
  85512. /**
  85513. * Stores an UInt16 in the array buffer
  85514. * @param entry
  85515. * @param byteOffset If defined, specifies where to set the value as an offset.
  85516. */
  85517. setUInt16(entry: number, byteOffset?: number): void;
  85518. /**
  85519. * Gets an UInt32 in the array buffer
  85520. * @param entry
  85521. * @param byteOffset If defined, specifies where to set the value as an offset.
  85522. */
  85523. getUInt32(byteOffset: number): number;
  85524. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85525. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85526. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85527. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85528. /**
  85529. * Stores a Float32 in the array buffer
  85530. * @param entry
  85531. */
  85532. setFloat32(entry: number, byteOffset?: number): void;
  85533. /**
  85534. * Stores an UInt32 in the array buffer
  85535. * @param entry
  85536. * @param byteOffset If defined, specifies where to set the value as an offset.
  85537. */
  85538. setUInt32(entry: number, byteOffset?: number): void;
  85539. }
  85540. }
  85541. declare module BABYLON.GLTF2.Exporter {
  85542. /**
  85543. * @hidden
  85544. * Interface to store animation data.
  85545. */
  85546. export interface _IAnimationData {
  85547. /**
  85548. * Keyframe data.
  85549. */
  85550. inputs: number[];
  85551. /**
  85552. * Value data.
  85553. */
  85554. outputs: number[][];
  85555. /**
  85556. * Animation interpolation data.
  85557. */
  85558. samplerInterpolation: AnimationSamplerInterpolation;
  85559. /**
  85560. * Minimum keyframe value.
  85561. */
  85562. inputsMin: number;
  85563. /**
  85564. * Maximum keyframe value.
  85565. */
  85566. inputsMax: number;
  85567. }
  85568. /**
  85569. * @hidden
  85570. */
  85571. export interface _IAnimationInfo {
  85572. /**
  85573. * The target channel for the animation
  85574. */
  85575. animationChannelTargetPath: AnimationChannelTargetPath;
  85576. /**
  85577. * The glTF accessor type for the data.
  85578. */
  85579. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  85580. /**
  85581. * Specifies if quaternions should be used.
  85582. */
  85583. useQuaternion: boolean;
  85584. }
  85585. /**
  85586. * @hidden
  85587. * Utility class for generating glTF animation data from BabylonJS.
  85588. */
  85589. export class _GLTFAnimation {
  85590. /**
  85591. * @ignore
  85592. *
  85593. * Creates glTF channel animation from BabylonJS animation.
  85594. * @param babylonTransformNode - BabylonJS mesh.
  85595. * @param animation - animation.
  85596. * @param animationChannelTargetPath - The target animation channel.
  85597. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  85598. * @param useQuaternion - Specifies if quaternions are used.
  85599. * @returns nullable IAnimationData
  85600. */
  85601. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  85602. private static _DeduceAnimationInfo;
  85603. /**
  85604. * @ignore
  85605. * Create node animations from the transform node animations
  85606. * @param babylonNode
  85607. * @param runtimeGLTFAnimation
  85608. * @param idleGLTFAnimations
  85609. * @param nodeMap
  85610. * @param nodes
  85611. * @param binaryWriter
  85612. * @param bufferViews
  85613. * @param accessors
  85614. * @param convertToRightHandedSystem
  85615. * @param animationSampleRate
  85616. */
  85617. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85618. [key: number]: number;
  85619. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85620. /**
  85621. * @ignore
  85622. * Create individual morph animations from the mesh's morph target animation tracks
  85623. * @param babylonNode
  85624. * @param runtimeGLTFAnimation
  85625. * @param idleGLTFAnimations
  85626. * @param nodeMap
  85627. * @param nodes
  85628. * @param binaryWriter
  85629. * @param bufferViews
  85630. * @param accessors
  85631. * @param convertToRightHandedSystem
  85632. * @param animationSampleRate
  85633. */
  85634. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85635. [key: number]: number;
  85636. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85637. /**
  85638. * @ignore
  85639. * Create node and morph animations from the animation groups
  85640. * @param babylonScene
  85641. * @param glTFAnimations
  85642. * @param nodeMap
  85643. * @param nodes
  85644. * @param binaryWriter
  85645. * @param bufferViews
  85646. * @param accessors
  85647. * @param convertToRightHandedSystemMap
  85648. * @param animationSampleRate
  85649. */
  85650. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  85651. [key: number]: number;
  85652. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  85653. [nodeId: number]: boolean;
  85654. }, animationSampleRate: number): void;
  85655. private static AddAnimation;
  85656. /**
  85657. * Create a baked animation
  85658. * @param babylonTransformNode BabylonJS mesh
  85659. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  85660. * @param animationChannelTargetPath animation target channel
  85661. * @param minFrame minimum animation frame
  85662. * @param maxFrame maximum animation frame
  85663. * @param fps frames per second of the animation
  85664. * @param inputs input key frames of the animation
  85665. * @param outputs output key frame data of the animation
  85666. * @param convertToRightHandedSystem converts the values to right-handed
  85667. * @param useQuaternion specifies if quaternions should be used
  85668. */
  85669. private static _CreateBakedAnimation;
  85670. private static _ConvertFactorToVector3OrQuaternion;
  85671. private static _SetInterpolatedValue;
  85672. /**
  85673. * Creates linear animation from the animation key frames
  85674. * @param babylonTransformNode BabylonJS mesh
  85675. * @param animation BabylonJS animation
  85676. * @param animationChannelTargetPath The target animation channel
  85677. * @param frameDelta The difference between the last and first frame of the animation
  85678. * @param inputs Array to store the key frame times
  85679. * @param outputs Array to store the key frame data
  85680. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85681. * @param useQuaternion Specifies if quaternions are used in the animation
  85682. */
  85683. private static _CreateLinearOrStepAnimation;
  85684. /**
  85685. * Creates cubic spline animation from the animation key frames
  85686. * @param babylonTransformNode BabylonJS mesh
  85687. * @param animation BabylonJS animation
  85688. * @param animationChannelTargetPath The target animation channel
  85689. * @param frameDelta The difference between the last and first frame of the animation
  85690. * @param inputs Array to store the key frame times
  85691. * @param outputs Array to store the key frame data
  85692. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85693. * @param useQuaternion Specifies if quaternions are used in the animation
  85694. */
  85695. private static _CreateCubicSplineAnimation;
  85696. private static _GetBasePositionRotationOrScale;
  85697. /**
  85698. * Adds a key frame value
  85699. * @param keyFrame
  85700. * @param animation
  85701. * @param outputs
  85702. * @param animationChannelTargetPath
  85703. * @param basePositionRotationOrScale
  85704. * @param convertToRightHandedSystem
  85705. * @param useQuaternion
  85706. */
  85707. private static _AddKeyframeValue;
  85708. /**
  85709. * Determine the interpolation based on the key frames
  85710. * @param keyFrames
  85711. * @param animationChannelTargetPath
  85712. * @param useQuaternion
  85713. */
  85714. private static _DeduceInterpolation;
  85715. /**
  85716. * Adds an input tangent or output tangent to the output data
  85717. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  85718. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  85719. * @param outputs The animation data by keyframe
  85720. * @param animationChannelTargetPath The target animation channel
  85721. * @param interpolation The interpolation type
  85722. * @param keyFrame The key frame with the animation data
  85723. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  85724. * @param useQuaternion Specifies if quaternions are used
  85725. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  85726. */
  85727. private static AddSplineTangent;
  85728. /**
  85729. * Get the minimum and maximum key frames' frame values
  85730. * @param keyFrames animation key frames
  85731. * @returns the minimum and maximum key frame value
  85732. */
  85733. private static calculateMinMaxKeyFrames;
  85734. }
  85735. }
  85736. declare module BABYLON.GLTF2.Exporter {
  85737. /** @hidden */
  85738. export var textureTransformPixelShader: {
  85739. name: string;
  85740. shader: string;
  85741. };
  85742. }
  85743. declare module BABYLON.GLTF2.Exporter.Extensions {
  85744. /**
  85745. * @hidden
  85746. */
  85747. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  85748. private _recordedTextures;
  85749. /** Name of this extension */
  85750. readonly name: string;
  85751. /** Defines whether this extension is enabled */
  85752. enabled: boolean;
  85753. /** Defines whether this extension is required */
  85754. required: boolean;
  85755. /** Reference to the glTF exporter */
  85756. private _wasUsed;
  85757. constructor(exporter: _Exporter);
  85758. dispose(): void;
  85759. /** @hidden */
  85760. get wasUsed(): boolean;
  85761. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85762. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  85763. /**
  85764. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  85765. * @param babylonTexture
  85766. * @param offset
  85767. * @param rotation
  85768. * @param scale
  85769. * @param scene
  85770. */
  85771. private _textureTransformTextureAsync;
  85772. }
  85773. }
  85774. declare module BABYLON.GLTF2.Exporter.Extensions {
  85775. /**
  85776. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  85777. */
  85778. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  85779. /** The name of this extension. */
  85780. readonly name: string;
  85781. /** Defines whether this extension is enabled. */
  85782. enabled: boolean;
  85783. /** Defines whether this extension is required */
  85784. required: boolean;
  85785. /** Reference to the glTF exporter */
  85786. private _exporter;
  85787. private _lights;
  85788. /** @hidden */
  85789. constructor(exporter: _Exporter);
  85790. /** @hidden */
  85791. dispose(): void;
  85792. /** @hidden */
  85793. get wasUsed(): boolean;
  85794. /** @hidden */
  85795. onExporting(): void;
  85796. /**
  85797. * Define this method to modify the default behavior when exporting a node
  85798. * @param context The context when exporting the node
  85799. * @param node glTF node
  85800. * @param babylonNode BabylonJS node
  85801. * @param nodeMap Node mapping of unique id to glTF node index
  85802. * @returns nullable INode promise
  85803. */
  85804. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85805. [key: number]: number;
  85806. }): Promise<Nullable<INode>>;
  85807. }
  85808. }
  85809. declare module BABYLON.GLTF2.Exporter.Extensions {
  85810. /**
  85811. * @hidden
  85812. */
  85813. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  85814. /** Name of this extension */
  85815. readonly name: string;
  85816. /** Defines whether this extension is enabled */
  85817. enabled: boolean;
  85818. /** Defines whether this extension is required */
  85819. required: boolean;
  85820. /** Reference to the glTF exporter */
  85821. private _textureInfos;
  85822. private _exportedTextures;
  85823. private _wasUsed;
  85824. constructor(exporter: _Exporter);
  85825. dispose(): void;
  85826. /** @hidden */
  85827. get wasUsed(): boolean;
  85828. private _getTextureIndex;
  85829. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  85830. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  85831. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85832. }
  85833. }
  85834. declare module BABYLON.GLTF2.Exporter.Extensions {
  85835. /**
  85836. * @hidden
  85837. */
  85838. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  85839. /** Name of this extension */
  85840. readonly name: string;
  85841. /** Defines whether this extension is enabled */
  85842. enabled: boolean;
  85843. /** Defines whether this extension is required */
  85844. required: boolean;
  85845. private _wasUsed;
  85846. constructor(exporter: _Exporter);
  85847. /** @hidden */
  85848. get wasUsed(): boolean;
  85849. dispose(): void;
  85850. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  85851. }
  85852. }
  85853. declare module BABYLON {
  85854. /**
  85855. * Class for generating STL data from a Babylon scene.
  85856. */
  85857. export class STLExport {
  85858. /**
  85859. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  85860. * @param meshes list defines the mesh to serialize
  85861. * @param download triggers the automatic download of the file.
  85862. * @param fileName changes the downloads fileName.
  85863. * @param binary changes the STL to a binary type.
  85864. * @param isLittleEndian toggle for binary type exporter.
  85865. * @returns the STL as UTF8 string
  85866. */
  85867. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  85868. }
  85869. }
  85870. declare module "babylonjs-gltf2interface" {
  85871. export = BABYLON.GLTF2;
  85872. }
  85873. /**
  85874. * Module for glTF 2.0 Interface
  85875. */
  85876. declare module BABYLON.GLTF2 {
  85877. /**
  85878. * The datatype of the components in the attribute
  85879. */
  85880. const enum AccessorComponentType {
  85881. /**
  85882. * Byte
  85883. */
  85884. BYTE = 5120,
  85885. /**
  85886. * Unsigned Byte
  85887. */
  85888. UNSIGNED_BYTE = 5121,
  85889. /**
  85890. * Short
  85891. */
  85892. SHORT = 5122,
  85893. /**
  85894. * Unsigned Short
  85895. */
  85896. UNSIGNED_SHORT = 5123,
  85897. /**
  85898. * Unsigned Int
  85899. */
  85900. UNSIGNED_INT = 5125,
  85901. /**
  85902. * Float
  85903. */
  85904. FLOAT = 5126,
  85905. }
  85906. /**
  85907. * Specifies if the attirbute is a scalar, vector, or matrix
  85908. */
  85909. const enum AccessorType {
  85910. /**
  85911. * Scalar
  85912. */
  85913. SCALAR = "SCALAR",
  85914. /**
  85915. * Vector2
  85916. */
  85917. VEC2 = "VEC2",
  85918. /**
  85919. * Vector3
  85920. */
  85921. VEC3 = "VEC3",
  85922. /**
  85923. * Vector4
  85924. */
  85925. VEC4 = "VEC4",
  85926. /**
  85927. * Matrix2x2
  85928. */
  85929. MAT2 = "MAT2",
  85930. /**
  85931. * Matrix3x3
  85932. */
  85933. MAT3 = "MAT3",
  85934. /**
  85935. * Matrix4x4
  85936. */
  85937. MAT4 = "MAT4",
  85938. }
  85939. /**
  85940. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85941. */
  85942. const enum AnimationChannelTargetPath {
  85943. /**
  85944. * Translation
  85945. */
  85946. TRANSLATION = "translation",
  85947. /**
  85948. * Rotation
  85949. */
  85950. ROTATION = "rotation",
  85951. /**
  85952. * Scale
  85953. */
  85954. SCALE = "scale",
  85955. /**
  85956. * Weights
  85957. */
  85958. WEIGHTS = "weights",
  85959. }
  85960. /**
  85961. * Interpolation algorithm
  85962. */
  85963. const enum AnimationSamplerInterpolation {
  85964. /**
  85965. * The animated values are linearly interpolated between keyframes
  85966. */
  85967. LINEAR = "LINEAR",
  85968. /**
  85969. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  85970. */
  85971. STEP = "STEP",
  85972. /**
  85973. * The animation's interpolation is computed using a cubic spline with specified tangents
  85974. */
  85975. CUBICSPLINE = "CUBICSPLINE",
  85976. }
  85977. /**
  85978. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85979. */
  85980. const enum CameraType {
  85981. /**
  85982. * A perspective camera containing properties to create a perspective projection matrix
  85983. */
  85984. PERSPECTIVE = "perspective",
  85985. /**
  85986. * An orthographic camera containing properties to create an orthographic projection matrix
  85987. */
  85988. ORTHOGRAPHIC = "orthographic",
  85989. }
  85990. /**
  85991. * The mime-type of the image
  85992. */
  85993. const enum ImageMimeType {
  85994. /**
  85995. * JPEG Mime-type
  85996. */
  85997. JPEG = "image/jpeg",
  85998. /**
  85999. * PNG Mime-type
  86000. */
  86001. PNG = "image/png",
  86002. }
  86003. /**
  86004. * The alpha rendering mode of the material
  86005. */
  86006. const enum MaterialAlphaMode {
  86007. /**
  86008. * The alpha value is ignored and the rendered output is fully opaque
  86009. */
  86010. OPAQUE = "OPAQUE",
  86011. /**
  86012. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  86013. */
  86014. MASK = "MASK",
  86015. /**
  86016. * 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)
  86017. */
  86018. BLEND = "BLEND",
  86019. }
  86020. /**
  86021. * The type of the primitives to render
  86022. */
  86023. const enum MeshPrimitiveMode {
  86024. /**
  86025. * Points
  86026. */
  86027. POINTS = 0,
  86028. /**
  86029. * Lines
  86030. */
  86031. LINES = 1,
  86032. /**
  86033. * Line Loop
  86034. */
  86035. LINE_LOOP = 2,
  86036. /**
  86037. * Line Strip
  86038. */
  86039. LINE_STRIP = 3,
  86040. /**
  86041. * Triangles
  86042. */
  86043. TRIANGLES = 4,
  86044. /**
  86045. * Triangle Strip
  86046. */
  86047. TRIANGLE_STRIP = 5,
  86048. /**
  86049. * Triangle Fan
  86050. */
  86051. TRIANGLE_FAN = 6,
  86052. }
  86053. /**
  86054. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86055. */
  86056. const enum TextureMagFilter {
  86057. /**
  86058. * Nearest
  86059. */
  86060. NEAREST = 9728,
  86061. /**
  86062. * Linear
  86063. */
  86064. LINEAR = 9729,
  86065. }
  86066. /**
  86067. * Minification filter. All valid values correspond to WebGL enums
  86068. */
  86069. const enum TextureMinFilter {
  86070. /**
  86071. * Nearest
  86072. */
  86073. NEAREST = 9728,
  86074. /**
  86075. * Linear
  86076. */
  86077. LINEAR = 9729,
  86078. /**
  86079. * Nearest Mip-Map Nearest
  86080. */
  86081. NEAREST_MIPMAP_NEAREST = 9984,
  86082. /**
  86083. * Linear Mipmap Nearest
  86084. */
  86085. LINEAR_MIPMAP_NEAREST = 9985,
  86086. /**
  86087. * Nearest Mipmap Linear
  86088. */
  86089. NEAREST_MIPMAP_LINEAR = 9986,
  86090. /**
  86091. * Linear Mipmap Linear
  86092. */
  86093. LINEAR_MIPMAP_LINEAR = 9987,
  86094. }
  86095. /**
  86096. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86097. */
  86098. const enum TextureWrapMode {
  86099. /**
  86100. * Clamp to Edge
  86101. */
  86102. CLAMP_TO_EDGE = 33071,
  86103. /**
  86104. * Mirrored Repeat
  86105. */
  86106. MIRRORED_REPEAT = 33648,
  86107. /**
  86108. * Repeat
  86109. */
  86110. REPEAT = 10497,
  86111. }
  86112. /**
  86113. * glTF Property
  86114. */
  86115. interface IProperty {
  86116. /**
  86117. * Dictionary object with extension-specific objects
  86118. */
  86119. extensions?: {
  86120. [key: string]: any;
  86121. };
  86122. /**
  86123. * Application-Specific data
  86124. */
  86125. extras?: any;
  86126. }
  86127. /**
  86128. * glTF Child of Root Property
  86129. */
  86130. interface IChildRootProperty extends IProperty {
  86131. /**
  86132. * The user-defined name of this object
  86133. */
  86134. name?: string;
  86135. }
  86136. /**
  86137. * Indices of those attributes that deviate from their initialization value
  86138. */
  86139. interface IAccessorSparseIndices extends IProperty {
  86140. /**
  86141. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86142. */
  86143. bufferView: number;
  86144. /**
  86145. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86146. */
  86147. byteOffset?: number;
  86148. /**
  86149. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  86150. */
  86151. componentType: AccessorComponentType;
  86152. }
  86153. /**
  86154. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  86155. */
  86156. interface IAccessorSparseValues extends IProperty {
  86157. /**
  86158. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86159. */
  86160. bufferView: number;
  86161. /**
  86162. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86163. */
  86164. byteOffset?: number;
  86165. }
  86166. /**
  86167. * Sparse storage of attributes that deviate from their initialization value
  86168. */
  86169. interface IAccessorSparse extends IProperty {
  86170. /**
  86171. * The number of attributes encoded in this sparse accessor
  86172. */
  86173. count: number;
  86174. /**
  86175. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  86176. */
  86177. indices: IAccessorSparseIndices;
  86178. /**
  86179. * 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
  86180. */
  86181. values: IAccessorSparseValues;
  86182. }
  86183. /**
  86184. * 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
  86185. */
  86186. interface IAccessor extends IChildRootProperty {
  86187. /**
  86188. * The index of the bufferview
  86189. */
  86190. bufferView?: number;
  86191. /**
  86192. * The offset relative to the start of the bufferView in bytes
  86193. */
  86194. byteOffset?: number;
  86195. /**
  86196. * The datatype of components in the attribute
  86197. */
  86198. componentType: AccessorComponentType;
  86199. /**
  86200. * Specifies whether integer data values should be normalized
  86201. */
  86202. normalized?: boolean;
  86203. /**
  86204. * The number of attributes referenced by this accessor
  86205. */
  86206. count: number;
  86207. /**
  86208. * Specifies if the attribute is a scalar, vector, or matrix
  86209. */
  86210. type: AccessorType;
  86211. /**
  86212. * Maximum value of each component in this attribute
  86213. */
  86214. max?: number[];
  86215. /**
  86216. * Minimum value of each component in this attribute
  86217. */
  86218. min?: number[];
  86219. /**
  86220. * Sparse storage of attributes that deviate from their initialization value
  86221. */
  86222. sparse?: IAccessorSparse;
  86223. }
  86224. /**
  86225. * Targets an animation's sampler at a node's property
  86226. */
  86227. interface IAnimationChannel extends IProperty {
  86228. /**
  86229. * The index of a sampler in this animation used to compute the value for the target
  86230. */
  86231. sampler: number;
  86232. /**
  86233. * The index of the node and TRS property to target
  86234. */
  86235. target: IAnimationChannelTarget;
  86236. }
  86237. /**
  86238. * The index of the node and TRS property that an animation channel targets
  86239. */
  86240. interface IAnimationChannelTarget extends IProperty {
  86241. /**
  86242. * The index of the node to target
  86243. */
  86244. node: number;
  86245. /**
  86246. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  86247. */
  86248. path: AnimationChannelTargetPath;
  86249. }
  86250. /**
  86251. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86252. */
  86253. interface IAnimationSampler extends IProperty {
  86254. /**
  86255. * The index of an accessor containing keyframe input values, e.g., time
  86256. */
  86257. input: number;
  86258. /**
  86259. * Interpolation algorithm
  86260. */
  86261. interpolation?: AnimationSamplerInterpolation;
  86262. /**
  86263. * The index of an accessor, containing keyframe output values
  86264. */
  86265. output: number;
  86266. }
  86267. /**
  86268. * A keyframe animation
  86269. */
  86270. interface IAnimation extends IChildRootProperty {
  86271. /**
  86272. * An array of channels, each of which targets an animation's sampler at a node's property
  86273. */
  86274. channels: IAnimationChannel[];
  86275. /**
  86276. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86277. */
  86278. samplers: IAnimationSampler[];
  86279. }
  86280. /**
  86281. * Metadata about the glTF asset
  86282. */
  86283. interface IAsset extends IChildRootProperty {
  86284. /**
  86285. * A copyright message suitable for display to credit the content creator
  86286. */
  86287. copyright?: string;
  86288. /**
  86289. * Tool that generated this glTF model. Useful for debugging
  86290. */
  86291. generator?: string;
  86292. /**
  86293. * The glTF version that this asset targets
  86294. */
  86295. version: string;
  86296. /**
  86297. * The minimum glTF version that this asset targets
  86298. */
  86299. minVersion?: string;
  86300. }
  86301. /**
  86302. * A buffer points to binary geometry, animation, or skins
  86303. */
  86304. interface IBuffer extends IChildRootProperty {
  86305. /**
  86306. * 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
  86307. */
  86308. uri?: string;
  86309. /**
  86310. * The length of the buffer in bytes
  86311. */
  86312. byteLength: number;
  86313. }
  86314. /**
  86315. * A view into a buffer generally representing a subset of the buffer
  86316. */
  86317. interface IBufferView extends IChildRootProperty {
  86318. /**
  86319. * The index of the buffer
  86320. */
  86321. buffer: number;
  86322. /**
  86323. * The offset into the buffer in bytes
  86324. */
  86325. byteOffset?: number;
  86326. /**
  86327. * The lenth of the bufferView in bytes
  86328. */
  86329. byteLength: number;
  86330. /**
  86331. * The stride, in bytes
  86332. */
  86333. byteStride?: number;
  86334. }
  86335. /**
  86336. * An orthographic camera containing properties to create an orthographic projection matrix
  86337. */
  86338. interface ICameraOrthographic extends IProperty {
  86339. /**
  86340. * The floating-point horizontal magnification of the view. Must not be zero
  86341. */
  86342. xmag: number;
  86343. /**
  86344. * The floating-point vertical magnification of the view. Must not be zero
  86345. */
  86346. ymag: number;
  86347. /**
  86348. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  86349. */
  86350. zfar: number;
  86351. /**
  86352. * The floating-point distance to the near clipping plane
  86353. */
  86354. znear: number;
  86355. }
  86356. /**
  86357. * A perspective camera containing properties to create a perspective projection matrix
  86358. */
  86359. interface ICameraPerspective extends IProperty {
  86360. /**
  86361. * The floating-point aspect ratio of the field of view
  86362. */
  86363. aspectRatio?: number;
  86364. /**
  86365. * The floating-point vertical field of view in radians
  86366. */
  86367. yfov: number;
  86368. /**
  86369. * The floating-point distance to the far clipping plane
  86370. */
  86371. zfar?: number;
  86372. /**
  86373. * The floating-point distance to the near clipping plane
  86374. */
  86375. znear: number;
  86376. }
  86377. /**
  86378. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86379. */
  86380. interface ICamera extends IChildRootProperty {
  86381. /**
  86382. * An orthographic camera containing properties to create an orthographic projection matrix
  86383. */
  86384. orthographic?: ICameraOrthographic;
  86385. /**
  86386. * A perspective camera containing properties to create a perspective projection matrix
  86387. */
  86388. perspective?: ICameraPerspective;
  86389. /**
  86390. * Specifies if the camera uses a perspective or orthographic projection
  86391. */
  86392. type: CameraType;
  86393. }
  86394. /**
  86395. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  86396. */
  86397. interface IImage extends IChildRootProperty {
  86398. /**
  86399. * 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
  86400. */
  86401. uri?: string;
  86402. /**
  86403. * The image's MIME type
  86404. */
  86405. mimeType?: ImageMimeType;
  86406. /**
  86407. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  86408. */
  86409. bufferView?: number;
  86410. }
  86411. /**
  86412. * Material Normal Texture Info
  86413. */
  86414. interface IMaterialNormalTextureInfo extends ITextureInfo {
  86415. /**
  86416. * The scalar multiplier applied to each normal vector of the normal texture
  86417. */
  86418. scale?: number;
  86419. }
  86420. /**
  86421. * Material Occlusion Texture Info
  86422. */
  86423. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  86424. /**
  86425. * A scalar multiplier controlling the amount of occlusion applied
  86426. */
  86427. strength?: number;
  86428. }
  86429. /**
  86430. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  86431. */
  86432. interface IMaterialPbrMetallicRoughness {
  86433. /**
  86434. * The material's base color factor
  86435. */
  86436. baseColorFactor?: number[];
  86437. /**
  86438. * The base color texture
  86439. */
  86440. baseColorTexture?: ITextureInfo;
  86441. /**
  86442. * The metalness of the material
  86443. */
  86444. metallicFactor?: number;
  86445. /**
  86446. * The roughness of the material
  86447. */
  86448. roughnessFactor?: number;
  86449. /**
  86450. * The metallic-roughness texture
  86451. */
  86452. metallicRoughnessTexture?: ITextureInfo;
  86453. }
  86454. /**
  86455. * The material appearance of a primitive
  86456. */
  86457. interface IMaterial extends IChildRootProperty {
  86458. /**
  86459. * 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
  86460. */
  86461. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86462. /**
  86463. * The normal map texture
  86464. */
  86465. normalTexture?: IMaterialNormalTextureInfo;
  86466. /**
  86467. * The occlusion map texture
  86468. */
  86469. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86470. /**
  86471. * The emissive map texture
  86472. */
  86473. emissiveTexture?: ITextureInfo;
  86474. /**
  86475. * 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
  86476. */
  86477. emissiveFactor?: number[];
  86478. /**
  86479. * The alpha rendering mode of the material
  86480. */
  86481. alphaMode?: MaterialAlphaMode;
  86482. /**
  86483. * The alpha cutoff value of the material
  86484. */
  86485. alphaCutoff?: number;
  86486. /**
  86487. * Specifies whether the material is double sided
  86488. */
  86489. doubleSided?: boolean;
  86490. }
  86491. /**
  86492. * Geometry to be rendered with the given material
  86493. */
  86494. interface IMeshPrimitive extends IProperty {
  86495. /**
  86496. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  86497. */
  86498. attributes: {
  86499. [name: string]: number;
  86500. };
  86501. /**
  86502. * The index of the accessor that contains the indices
  86503. */
  86504. indices?: number;
  86505. /**
  86506. * The index of the material to apply to this primitive when rendering
  86507. */
  86508. material?: number;
  86509. /**
  86510. * The type of primitives to render. All valid values correspond to WebGL enums
  86511. */
  86512. mode?: MeshPrimitiveMode;
  86513. /**
  86514. * 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
  86515. */
  86516. targets?: {
  86517. [name: string]: number;
  86518. }[];
  86519. }
  86520. /**
  86521. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  86522. */
  86523. interface IMesh extends IChildRootProperty {
  86524. /**
  86525. * An array of primitives, each defining geometry to be rendered with a material
  86526. */
  86527. primitives: IMeshPrimitive[];
  86528. /**
  86529. * Array of weights to be applied to the Morph Targets
  86530. */
  86531. weights?: number[];
  86532. }
  86533. /**
  86534. * A node in the node hierarchy
  86535. */
  86536. interface INode extends IChildRootProperty {
  86537. /**
  86538. * The index of the camera referenced by this node
  86539. */
  86540. camera?: number;
  86541. /**
  86542. * The indices of this node's children
  86543. */
  86544. children?: number[];
  86545. /**
  86546. * The index of the skin referenced by this node
  86547. */
  86548. skin?: number;
  86549. /**
  86550. * A floating-point 4x4 transformation matrix stored in column-major order
  86551. */
  86552. matrix?: number[];
  86553. /**
  86554. * The index of the mesh in this node
  86555. */
  86556. mesh?: number;
  86557. /**
  86558. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  86559. */
  86560. rotation?: number[];
  86561. /**
  86562. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  86563. */
  86564. scale?: number[];
  86565. /**
  86566. * The node's translation along the x, y, and z axes
  86567. */
  86568. translation?: number[];
  86569. /**
  86570. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  86571. */
  86572. weights?: number[];
  86573. }
  86574. /**
  86575. * Texture sampler properties for filtering and wrapping modes
  86576. */
  86577. interface ISampler extends IChildRootProperty {
  86578. /**
  86579. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86580. */
  86581. magFilter?: TextureMagFilter;
  86582. /**
  86583. * Minification filter. All valid values correspond to WebGL enums
  86584. */
  86585. minFilter?: TextureMinFilter;
  86586. /**
  86587. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86588. */
  86589. wrapS?: TextureWrapMode;
  86590. /**
  86591. * T (V) wrapping mode. All valid values correspond to WebGL enums
  86592. */
  86593. wrapT?: TextureWrapMode;
  86594. }
  86595. /**
  86596. * The root nodes of a scene
  86597. */
  86598. interface IScene extends IChildRootProperty {
  86599. /**
  86600. * The indices of each root node
  86601. */
  86602. nodes: number[];
  86603. }
  86604. /**
  86605. * Joints and matrices defining a skin
  86606. */
  86607. interface ISkin extends IChildRootProperty {
  86608. /**
  86609. * 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
  86610. */
  86611. inverseBindMatrices?: number;
  86612. /**
  86613. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  86614. */
  86615. skeleton?: number;
  86616. /**
  86617. * 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)
  86618. */
  86619. joints: number[];
  86620. }
  86621. /**
  86622. * A texture and its sampler
  86623. */
  86624. interface ITexture extends IChildRootProperty {
  86625. /**
  86626. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  86627. */
  86628. sampler?: number;
  86629. /**
  86630. * The index of the image used by this texture
  86631. */
  86632. source: number;
  86633. }
  86634. /**
  86635. * Reference to a texture
  86636. */
  86637. interface ITextureInfo extends IProperty {
  86638. /**
  86639. * The index of the texture
  86640. */
  86641. index: number;
  86642. /**
  86643. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  86644. */
  86645. texCoord?: number;
  86646. }
  86647. /**
  86648. * The root object for a glTF asset
  86649. */
  86650. interface IGLTF extends IProperty {
  86651. /**
  86652. * An array of accessors. An accessor is a typed view into a bufferView
  86653. */
  86654. accessors?: IAccessor[];
  86655. /**
  86656. * An array of keyframe animations
  86657. */
  86658. animations?: IAnimation[];
  86659. /**
  86660. * Metadata about the glTF asset
  86661. */
  86662. asset: IAsset;
  86663. /**
  86664. * An array of buffers. A buffer points to binary geometry, animation, or skins
  86665. */
  86666. buffers?: IBuffer[];
  86667. /**
  86668. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  86669. */
  86670. bufferViews?: IBufferView[];
  86671. /**
  86672. * An array of cameras
  86673. */
  86674. cameras?: ICamera[];
  86675. /**
  86676. * Names of glTF extensions used somewhere in this asset
  86677. */
  86678. extensionsUsed?: string[];
  86679. /**
  86680. * Names of glTF extensions required to properly load this asset
  86681. */
  86682. extensionsRequired?: string[];
  86683. /**
  86684. * An array of images. An image defines data used to create a texture
  86685. */
  86686. images?: IImage[];
  86687. /**
  86688. * An array of materials. A material defines the appearance of a primitive
  86689. */
  86690. materials?: IMaterial[];
  86691. /**
  86692. * An array of meshes. A mesh is a set of primitives to be rendered
  86693. */
  86694. meshes?: IMesh[];
  86695. /**
  86696. * An array of nodes
  86697. */
  86698. nodes?: INode[];
  86699. /**
  86700. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  86701. */
  86702. samplers?: ISampler[];
  86703. /**
  86704. * The index of the default scene
  86705. */
  86706. scene?: number;
  86707. /**
  86708. * An array of scenes
  86709. */
  86710. scenes?: IScene[];
  86711. /**
  86712. * An array of skins. A skin is defined by joints and matrices
  86713. */
  86714. skins?: ISkin[];
  86715. /**
  86716. * An array of textures
  86717. */
  86718. textures?: ITexture[];
  86719. }
  86720. /**
  86721. * The glTF validation results
  86722. * @ignore
  86723. */
  86724. interface IGLTFValidationResults {
  86725. info: {
  86726. generator: string;
  86727. hasAnimations: boolean;
  86728. hasDefaultScene: boolean;
  86729. hasMaterials: boolean;
  86730. hasMorphTargets: boolean;
  86731. hasSkins: boolean;
  86732. hasTextures: boolean;
  86733. maxAttributesUsed: number;
  86734. primitivesCount: number
  86735. };
  86736. issues: {
  86737. messages: Array<string>;
  86738. numErrors: number;
  86739. numHints: number;
  86740. numInfos: number;
  86741. numWarnings: number;
  86742. truncated: boolean
  86743. };
  86744. mimeType: string;
  86745. uri: string;
  86746. validatedAt: string;
  86747. validatorVersion: string;
  86748. }
  86749. /**
  86750. * The glTF validation options
  86751. */
  86752. interface IGLTFValidationOptions {
  86753. /** Uri to use */
  86754. uri?: string;
  86755. /** Function used to load external resources */
  86756. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  86757. /** Boolean indicating that we need to validate accessor data */
  86758. validateAccessorData?: boolean;
  86759. /** max number of issues allowed */
  86760. maxIssues?: number;
  86761. /** Ignored issues */
  86762. ignoredIssues?: Array<string>;
  86763. /** Value to override severy settings */
  86764. severityOverrides?: Object;
  86765. }
  86766. /**
  86767. * The glTF validator object
  86768. * @ignore
  86769. */
  86770. interface IGLTFValidator {
  86771. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86772. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  86773. }
  86774. /**
  86775. * Interfaces from the EXT_lights_image_based extension
  86776. */
  86777. /** @hidden */
  86778. interface IEXTLightsImageBased_LightReferenceImageBased {
  86779. light: number;
  86780. }
  86781. /** @hidden */
  86782. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  86783. intensity: number;
  86784. rotation: number[];
  86785. specularImageSize: number;
  86786. specularImages: number[][];
  86787. irradianceCoefficients: number[][];
  86788. }
  86789. /** @hidden */
  86790. interface IEXTLightsImageBased {
  86791. lights: IEXTLightsImageBased_LightImageBased[];
  86792. }
  86793. /**
  86794. * Interfaces from the EXT_mesh_gpu_instancing extension
  86795. * !!! Experimental Extension Subject to Changes !!!
  86796. */
  86797. /** @hidden */
  86798. interface IEXTMeshGpuInstancing {
  86799. mesh?: number;
  86800. attributes: { [name: string]: number };
  86801. }
  86802. /**
  86803. * Interfaces from the KHR_draco_mesh_compression extension
  86804. */
  86805. /** @hidden */
  86806. interface IKHRDracoMeshCompression {
  86807. bufferView: number;
  86808. attributes: { [name: string]: number };
  86809. }
  86810. /**
  86811. * Interfaces from the KHR_lights_punctual extension
  86812. */
  86813. /** @hidden */
  86814. const enum IKHRLightsPunctual_LightType {
  86815. DIRECTIONAL = "directional",
  86816. POINT = "point",
  86817. SPOT = "spot"
  86818. }
  86819. /** @hidden */
  86820. interface IKHRLightsPunctual_LightReference {
  86821. light: number;
  86822. }
  86823. /** @hidden */
  86824. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  86825. type: IKHRLightsPunctual_LightType;
  86826. color?: number[];
  86827. intensity?: number;
  86828. range?: number;
  86829. spot?: {
  86830. innerConeAngle?: number;
  86831. outerConeAngle?: number;
  86832. };
  86833. }
  86834. /** @hidden */
  86835. interface IKHRLightsPunctual {
  86836. lights: IKHRLightsPunctual_Light[];
  86837. }
  86838. /**
  86839. * Interfaces from the KHR_materials_clearcoat extension
  86840. * !!! Experimental Extension Subject to Changes !!!
  86841. */
  86842. /** @hidden */
  86843. interface IKHRMaterialsClearcoat {
  86844. clearcoatFactor: number;
  86845. clearcoatTexture: ITextureInfo;
  86846. clearcoatRoughnessFactor: number;
  86847. clearcoatRoughnessTexture: ITextureInfo;
  86848. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  86849. }
  86850. /**
  86851. * Interfaces from the KHR_materials_ior extension
  86852. * !!! Experimental Extension Subject to Changes !!!
  86853. */
  86854. /** @hidden */
  86855. interface IKHRMaterialsIor {
  86856. ior: number;
  86857. }
  86858. /**
  86859. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  86860. */
  86861. /** @hidden */
  86862. interface IKHRMaterialsPbrSpecularGlossiness {
  86863. diffuseFactor: number[];
  86864. diffuseTexture: ITextureInfo;
  86865. specularFactor: number[];
  86866. glossinessFactor: number;
  86867. specularGlossinessTexture: ITextureInfo;
  86868. }
  86869. /**
  86870. * Interfaces from the KHR_materials_sheen extension
  86871. * !!! Experimental Extension Subject to Changes !!!
  86872. */
  86873. /** @hidden */
  86874. interface IKHRMaterialsSheen {
  86875. sheenColorFactor?: number[];
  86876. sheenColorTexture?: ITextureInfo;
  86877. sheenRoughnessFactor?: number;
  86878. sheenRoughnessTexture?: ITextureInfo;
  86879. }
  86880. /**
  86881. * Interfaces from the KHR_materials_specular extension
  86882. * !!! Experimental Extension Subject to Changes !!!
  86883. */
  86884. /** @hidden */
  86885. interface IKHRMaterialsSpecular {
  86886. specularFactor: number;
  86887. specularColorFactor: number[];
  86888. specularTexture: ITextureInfo;
  86889. }
  86890. /**
  86891. * Interfaces from the KHR_materials_transmission extension
  86892. * !!! Experimental Extension Subject to Changes !!!
  86893. */
  86894. /** @hidden */
  86895. interface IKHRMaterialsTransmission {
  86896. transmissionFactor?: number;
  86897. transmissionTexture?: ITextureInfo;
  86898. }
  86899. /**
  86900. * Interfaces from the KHR_materials_translucency extension
  86901. * !!! Experimental Extension Subject to Changes !!!
  86902. */
  86903. /** @hidden */
  86904. interface IKHRMaterialsTranslucency {
  86905. translucencyFactor?: number;
  86906. translucencyTexture?: ITextureInfo;
  86907. }
  86908. /**
  86909. * Interfaces from the KHR_materials_variants extension
  86910. * !!! Experimental Extension Subject to Changes !!!
  86911. */
  86912. /** @hidden */
  86913. interface IKHRMaterialVariants_Mapping extends IProperty {
  86914. mappings: Array<{
  86915. variants: number[];
  86916. material: number;
  86917. }>;
  86918. }
  86919. /** @hidden */
  86920. interface IKHRMaterialVariants_Variant extends IProperty {
  86921. name: string;
  86922. }
  86923. /** @hidden */
  86924. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  86925. variants: Array<IKHRMaterialVariants_Variant>;
  86926. }
  86927. /**
  86928. * Interfaces from the KHR_texture_basisu extension
  86929. * !!! Experimental Extension Subject to Changes !!!
  86930. */
  86931. /** @hidden */
  86932. interface IKHRTextureBasisU {
  86933. source: number;
  86934. }
  86935. /**
  86936. * Interfaces from the EXT_texture_webp extension
  86937. */
  86938. /** @hidden */
  86939. interface IEXTTextureWebP {
  86940. source: number;
  86941. }
  86942. /**
  86943. * Interfaces from the KHR_texture_transform extension
  86944. */
  86945. /** @hidden */
  86946. interface IKHRTextureTransform {
  86947. offset?: number[];
  86948. rotation?: number;
  86949. scale?: number[];
  86950. texCoord?: number;
  86951. }
  86952. /**
  86953. * Interfaces from the KHR_xmp extension
  86954. * !!! Experimental Extension Subject to Changes !!!
  86955. */
  86956. /** @hidden */
  86957. interface IKHRXmp_Data {
  86958. [key: string]: unknown;
  86959. }
  86960. /** @hidden */
  86961. interface IKHRXmp_Gltf {
  86962. packets: IKHRXmp_Data[];
  86963. }
  86964. /** @hidden */
  86965. interface IKHRXmp_Node {
  86966. packet: number;
  86967. }
  86968. /**
  86969. * Interfaces from the MSFT_audio_emitter extension
  86970. */
  86971. /** @hidden */
  86972. interface IMSFTAudioEmitter_ClipReference {
  86973. clip: number;
  86974. weight?: number;
  86975. }
  86976. /** @hidden */
  86977. interface IMSFTAudioEmitter_EmittersReference {
  86978. emitters: number[];
  86979. }
  86980. /** @hidden */
  86981. const enum IMSFTAudioEmitter_DistanceModel {
  86982. linear = "linear",
  86983. inverse = "inverse",
  86984. exponential = "exponential",
  86985. }
  86986. /** @hidden */
  86987. interface IMSFTAudioEmitter_Emitter {
  86988. name?: string;
  86989. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86990. refDistance?: number;
  86991. maxDistance?: number;
  86992. rolloffFactor?: number;
  86993. innerAngle?: number;
  86994. outerAngle?: number;
  86995. loop?: boolean;
  86996. volume?: number;
  86997. clips: IMSFTAudioEmitter_ClipReference[];
  86998. }
  86999. /** @hidden */
  87000. const enum IMSFTAudioEmitter_AudioMimeType {
  87001. WAV = "audio/wav",
  87002. }
  87003. /** @hidden */
  87004. interface IMSFTAudioEmitter_Clip extends IProperty {
  87005. uri?: string;
  87006. bufferView?: number;
  87007. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  87008. }
  87009. /** @hidden */
  87010. const enum IMSFTAudioEmitter_AnimationEventAction {
  87011. play = "play",
  87012. pause = "pause",
  87013. stop = "stop",
  87014. }
  87015. /** @hidden */
  87016. interface IMSFTAudioEmitter_AnimationEvent {
  87017. action: IMSFTAudioEmitter_AnimationEventAction;
  87018. emitter: number;
  87019. time: number;
  87020. startOffset?: number;
  87021. }
  87022. /**
  87023. * Interfaces from the MSFT_lod extension
  87024. */
  87025. /** @hidden */
  87026. interface IMSFTLOD {
  87027. ids: number[];
  87028. }
  87029. }
  87030. declare module BABYLON {
  87031. /** @hidden */
  87032. export var cellPixelShader: {
  87033. name: string;
  87034. shader: string;
  87035. };
  87036. }
  87037. declare module BABYLON {
  87038. /** @hidden */
  87039. export var cellVertexShader: {
  87040. name: string;
  87041. shader: string;
  87042. };
  87043. }
  87044. declare module BABYLON {
  87045. export class CellMaterial extends BABYLON.PushMaterial {
  87046. private _diffuseTexture;
  87047. diffuseTexture: BABYLON.BaseTexture;
  87048. diffuseColor: BABYLON.Color3;
  87049. _computeHighLevel: boolean;
  87050. computeHighLevel: boolean;
  87051. private _disableLighting;
  87052. disableLighting: boolean;
  87053. private _maxSimultaneousLights;
  87054. maxSimultaneousLights: number;
  87055. constructor(name: string, scene: BABYLON.Scene);
  87056. needAlphaBlending(): boolean;
  87057. needAlphaTesting(): boolean;
  87058. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87059. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87060. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87061. getAnimatables(): BABYLON.IAnimatable[];
  87062. getActiveTextures(): BABYLON.BaseTexture[];
  87063. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87064. dispose(forceDisposeEffect?: boolean): void;
  87065. getClassName(): string;
  87066. clone(name: string): CellMaterial;
  87067. serialize(): any;
  87068. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  87069. }
  87070. }
  87071. declare module BABYLON {
  87072. export class CustomShaderStructure {
  87073. FragmentStore: string;
  87074. VertexStore: string;
  87075. constructor();
  87076. }
  87077. export class ShaderSpecialParts {
  87078. constructor();
  87079. Fragment_Begin: string;
  87080. Fragment_Definitions: string;
  87081. Fragment_MainBegin: string;
  87082. Fragment_Custom_Diffuse: string;
  87083. Fragment_Before_Lights: string;
  87084. Fragment_Before_Fog: string;
  87085. Fragment_Custom_Alpha: string;
  87086. Fragment_Before_FragColor: string;
  87087. Vertex_Begin: string;
  87088. Vertex_Definitions: string;
  87089. Vertex_MainBegin: string;
  87090. Vertex_Before_PositionUpdated: string;
  87091. Vertex_Before_NormalUpdated: string;
  87092. Vertex_After_WorldPosComputed: string;
  87093. Vertex_MainEnd: string;
  87094. }
  87095. export class CustomMaterial extends BABYLON.StandardMaterial {
  87096. static ShaderIndexer: number;
  87097. CustomParts: ShaderSpecialParts;
  87098. _isCreatedShader: boolean;
  87099. _createdShaderName: string;
  87100. _customUniform: string[];
  87101. _newUniforms: string[];
  87102. _newUniformInstances: {
  87103. [name: string]: any;
  87104. };
  87105. _newSamplerInstances: {
  87106. [name: string]: BABYLON.Texture;
  87107. };
  87108. _customAttributes: string[];
  87109. FragmentShader: string;
  87110. VertexShader: string;
  87111. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87112. ReviewUniform(name: string, arr: string[]): string[];
  87113. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87114. constructor(name: string, scene: BABYLON.Scene);
  87115. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  87116. AddAttribute(name: string): CustomMaterial;
  87117. Fragment_Begin(shaderPart: string): CustomMaterial;
  87118. Fragment_Definitions(shaderPart: string): CustomMaterial;
  87119. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  87120. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  87121. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  87122. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  87123. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  87124. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  87125. Vertex_Begin(shaderPart: string): CustomMaterial;
  87126. Vertex_Definitions(shaderPart: string): CustomMaterial;
  87127. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  87128. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  87129. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  87130. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  87131. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  87132. }
  87133. }
  87134. declare module BABYLON {
  87135. export class ShaderAlebdoParts {
  87136. constructor();
  87137. Fragment_Begin: string;
  87138. Fragment_Definitions: string;
  87139. Fragment_MainBegin: string;
  87140. Fragment_Custom_Albedo: string;
  87141. Fragment_Before_Lights: string;
  87142. Fragment_Custom_MetallicRoughness: string;
  87143. Fragment_Custom_MicroSurface: string;
  87144. Fragment_Before_Fog: string;
  87145. Fragment_Custom_Alpha: string;
  87146. Fragment_Before_FragColor: string;
  87147. Vertex_Begin: string;
  87148. Vertex_Definitions: string;
  87149. Vertex_MainBegin: string;
  87150. Vertex_Before_PositionUpdated: string;
  87151. Vertex_Before_NormalUpdated: string;
  87152. Vertex_After_WorldPosComputed: string;
  87153. Vertex_MainEnd: string;
  87154. }
  87155. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  87156. static ShaderIndexer: number;
  87157. CustomParts: ShaderAlebdoParts;
  87158. _isCreatedShader: boolean;
  87159. _createdShaderName: string;
  87160. _customUniform: string[];
  87161. _newUniforms: string[];
  87162. _newUniformInstances: {
  87163. [name: string]: any;
  87164. };
  87165. _newSamplerInstances: {
  87166. [name: string]: BABYLON.Texture;
  87167. };
  87168. _customAttributes: string[];
  87169. FragmentShader: string;
  87170. VertexShader: string;
  87171. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87172. ReviewUniform(name: string, arr: string[]): string[];
  87173. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87174. constructor(name: string, scene: BABYLON.Scene);
  87175. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  87176. AddAttribute(name: string): PBRCustomMaterial;
  87177. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  87178. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  87179. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  87180. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  87181. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  87182. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  87183. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  87184. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  87185. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  87186. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  87187. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  87188. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  87189. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  87190. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  87191. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  87192. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  87193. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  87194. }
  87195. }
  87196. declare module BABYLON {
  87197. /** @hidden */
  87198. export var firePixelShader: {
  87199. name: string;
  87200. shader: string;
  87201. };
  87202. }
  87203. declare module BABYLON {
  87204. /** @hidden */
  87205. export var fireVertexShader: {
  87206. name: string;
  87207. shader: string;
  87208. };
  87209. }
  87210. declare module BABYLON {
  87211. export class FireMaterial extends BABYLON.PushMaterial {
  87212. private _diffuseTexture;
  87213. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87214. private _distortionTexture;
  87215. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87216. private _opacityTexture;
  87217. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87218. diffuseColor: BABYLON.Color3;
  87219. speed: number;
  87220. private _scaledDiffuse;
  87221. private _lastTime;
  87222. constructor(name: string, scene: BABYLON.Scene);
  87223. needAlphaBlending(): boolean;
  87224. needAlphaTesting(): boolean;
  87225. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87226. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87227. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87228. getAnimatables(): BABYLON.IAnimatable[];
  87229. getActiveTextures(): BABYLON.BaseTexture[];
  87230. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87231. getClassName(): string;
  87232. dispose(forceDisposeEffect?: boolean): void;
  87233. clone(name: string): FireMaterial;
  87234. serialize(): any;
  87235. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  87236. }
  87237. }
  87238. declare module BABYLON {
  87239. /** @hidden */
  87240. export var furPixelShader: {
  87241. name: string;
  87242. shader: string;
  87243. };
  87244. }
  87245. declare module BABYLON {
  87246. /** @hidden */
  87247. export var furVertexShader: {
  87248. name: string;
  87249. shader: string;
  87250. };
  87251. }
  87252. declare module BABYLON {
  87253. export class FurMaterial extends BABYLON.PushMaterial {
  87254. private _diffuseTexture;
  87255. diffuseTexture: BABYLON.BaseTexture;
  87256. private _heightTexture;
  87257. heightTexture: BABYLON.BaseTexture;
  87258. diffuseColor: BABYLON.Color3;
  87259. furLength: number;
  87260. furAngle: number;
  87261. furColor: BABYLON.Color3;
  87262. furOffset: number;
  87263. furSpacing: number;
  87264. furGravity: BABYLON.Vector3;
  87265. furSpeed: number;
  87266. furDensity: number;
  87267. furOcclusion: number;
  87268. furTexture: BABYLON.DynamicTexture;
  87269. private _disableLighting;
  87270. disableLighting: boolean;
  87271. private _maxSimultaneousLights;
  87272. maxSimultaneousLights: number;
  87273. highLevelFur: boolean;
  87274. _meshes: BABYLON.AbstractMesh[];
  87275. private _furTime;
  87276. constructor(name: string, scene: BABYLON.Scene);
  87277. get furTime(): number;
  87278. set furTime(furTime: number);
  87279. needAlphaBlending(): boolean;
  87280. needAlphaTesting(): boolean;
  87281. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87282. updateFur(): void;
  87283. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87284. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87285. getAnimatables(): BABYLON.IAnimatable[];
  87286. getActiveTextures(): BABYLON.BaseTexture[];
  87287. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87288. dispose(forceDisposeEffect?: boolean): void;
  87289. clone(name: string): FurMaterial;
  87290. serialize(): any;
  87291. getClassName(): string;
  87292. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  87293. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  87294. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  87295. }
  87296. }
  87297. declare module BABYLON {
  87298. /** @hidden */
  87299. export var gradientPixelShader: {
  87300. name: string;
  87301. shader: string;
  87302. };
  87303. }
  87304. declare module BABYLON {
  87305. /** @hidden */
  87306. export var gradientVertexShader: {
  87307. name: string;
  87308. shader: string;
  87309. };
  87310. }
  87311. declare module BABYLON {
  87312. export class GradientMaterial extends BABYLON.PushMaterial {
  87313. private _maxSimultaneousLights;
  87314. maxSimultaneousLights: number;
  87315. topColor: BABYLON.Color3;
  87316. topColorAlpha: number;
  87317. bottomColor: BABYLON.Color3;
  87318. bottomColorAlpha: number;
  87319. offset: number;
  87320. scale: number;
  87321. smoothness: number;
  87322. private _disableLighting;
  87323. disableLighting: boolean;
  87324. constructor(name: string, scene: BABYLON.Scene);
  87325. needAlphaBlending(): boolean;
  87326. needAlphaTesting(): boolean;
  87327. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87328. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87329. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87330. getAnimatables(): BABYLON.IAnimatable[];
  87331. dispose(forceDisposeEffect?: boolean): void;
  87332. clone(name: string): GradientMaterial;
  87333. serialize(): any;
  87334. getClassName(): string;
  87335. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  87336. }
  87337. }
  87338. declare module BABYLON {
  87339. /** @hidden */
  87340. export var gridPixelShader: {
  87341. name: string;
  87342. shader: string;
  87343. };
  87344. }
  87345. declare module BABYLON {
  87346. /** @hidden */
  87347. export var gridVertexShader: {
  87348. name: string;
  87349. shader: string;
  87350. };
  87351. }
  87352. declare module BABYLON {
  87353. /**
  87354. * The grid materials allows you to wrap any shape with a grid.
  87355. * Colors are customizable.
  87356. */
  87357. export class GridMaterial extends BABYLON.PushMaterial {
  87358. /**
  87359. * Main color of the grid (e.g. between lines)
  87360. */
  87361. mainColor: BABYLON.Color3;
  87362. /**
  87363. * Color of the grid lines.
  87364. */
  87365. lineColor: BABYLON.Color3;
  87366. /**
  87367. * The scale of the grid compared to unit.
  87368. */
  87369. gridRatio: number;
  87370. /**
  87371. * Allows setting an offset for the grid lines.
  87372. */
  87373. gridOffset: BABYLON.Vector3;
  87374. /**
  87375. * The frequency of thicker lines.
  87376. */
  87377. majorUnitFrequency: number;
  87378. /**
  87379. * The visibility of minor units in the grid.
  87380. */
  87381. minorUnitVisibility: number;
  87382. /**
  87383. * The grid opacity outside of the lines.
  87384. */
  87385. opacity: number;
  87386. /**
  87387. * Determine RBG output is premultiplied by alpha value.
  87388. */
  87389. preMultiplyAlpha: boolean;
  87390. private _opacityTexture;
  87391. opacityTexture: BABYLON.BaseTexture;
  87392. private _gridControl;
  87393. /**
  87394. * constructor
  87395. * @param name The name given to the material in order to identify it afterwards.
  87396. * @param scene The scene the material is used in.
  87397. */
  87398. constructor(name: string, scene: BABYLON.Scene);
  87399. /**
  87400. * Returns wehter or not the grid requires alpha blending.
  87401. */
  87402. needAlphaBlending(): boolean;
  87403. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87404. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87405. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87406. /**
  87407. * Dispose the material and its associated resources.
  87408. * @param forceDisposeEffect will also dispose the used effect when true
  87409. */
  87410. dispose(forceDisposeEffect?: boolean): void;
  87411. clone(name: string): GridMaterial;
  87412. serialize(): any;
  87413. getClassName(): string;
  87414. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  87415. }
  87416. }
  87417. declare module BABYLON {
  87418. /** @hidden */
  87419. export var lavaPixelShader: {
  87420. name: string;
  87421. shader: string;
  87422. };
  87423. }
  87424. declare module BABYLON {
  87425. /** @hidden */
  87426. export var lavaVertexShader: {
  87427. name: string;
  87428. shader: string;
  87429. };
  87430. }
  87431. declare module BABYLON {
  87432. export class LavaMaterial extends BABYLON.PushMaterial {
  87433. private _diffuseTexture;
  87434. diffuseTexture: BABYLON.BaseTexture;
  87435. noiseTexture: BABYLON.BaseTexture;
  87436. fogColor: BABYLON.Color3;
  87437. speed: number;
  87438. movingSpeed: number;
  87439. lowFrequencySpeed: number;
  87440. fogDensity: number;
  87441. private _lastTime;
  87442. diffuseColor: BABYLON.Color3;
  87443. private _disableLighting;
  87444. disableLighting: boolean;
  87445. private _unlit;
  87446. unlit: boolean;
  87447. private _maxSimultaneousLights;
  87448. maxSimultaneousLights: number;
  87449. private _scaledDiffuse;
  87450. constructor(name: string, scene: BABYLON.Scene);
  87451. needAlphaBlending(): boolean;
  87452. needAlphaTesting(): boolean;
  87453. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87454. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87455. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87456. getAnimatables(): BABYLON.IAnimatable[];
  87457. getActiveTextures(): BABYLON.BaseTexture[];
  87458. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87459. dispose(forceDisposeEffect?: boolean): void;
  87460. clone(name: string): LavaMaterial;
  87461. serialize(): any;
  87462. getClassName(): string;
  87463. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  87464. }
  87465. }
  87466. declare module BABYLON {
  87467. /** @hidden */
  87468. export var mixPixelShader: {
  87469. name: string;
  87470. shader: string;
  87471. };
  87472. }
  87473. declare module BABYLON {
  87474. /** @hidden */
  87475. export var mixVertexShader: {
  87476. name: string;
  87477. shader: string;
  87478. };
  87479. }
  87480. declare module BABYLON {
  87481. export class MixMaterial extends BABYLON.PushMaterial {
  87482. /**
  87483. * Mix textures
  87484. */
  87485. private _mixTexture1;
  87486. mixTexture1: BABYLON.BaseTexture;
  87487. private _mixTexture2;
  87488. mixTexture2: BABYLON.BaseTexture;
  87489. /**
  87490. * Diffuse textures
  87491. */
  87492. private _diffuseTexture1;
  87493. diffuseTexture1: BABYLON.Texture;
  87494. private _diffuseTexture2;
  87495. diffuseTexture2: BABYLON.Texture;
  87496. private _diffuseTexture3;
  87497. diffuseTexture3: BABYLON.Texture;
  87498. private _diffuseTexture4;
  87499. diffuseTexture4: BABYLON.Texture;
  87500. private _diffuseTexture5;
  87501. diffuseTexture5: BABYLON.Texture;
  87502. private _diffuseTexture6;
  87503. diffuseTexture6: BABYLON.Texture;
  87504. private _diffuseTexture7;
  87505. diffuseTexture7: BABYLON.Texture;
  87506. private _diffuseTexture8;
  87507. diffuseTexture8: BABYLON.Texture;
  87508. /**
  87509. * Uniforms
  87510. */
  87511. diffuseColor: BABYLON.Color3;
  87512. specularColor: BABYLON.Color3;
  87513. specularPower: number;
  87514. private _disableLighting;
  87515. disableLighting: boolean;
  87516. private _maxSimultaneousLights;
  87517. maxSimultaneousLights: number;
  87518. constructor(name: string, scene: BABYLON.Scene);
  87519. needAlphaBlending(): boolean;
  87520. needAlphaTesting(): boolean;
  87521. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87522. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87523. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87524. getAnimatables(): BABYLON.IAnimatable[];
  87525. getActiveTextures(): BABYLON.BaseTexture[];
  87526. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87527. dispose(forceDisposeEffect?: boolean): void;
  87528. clone(name: string): MixMaterial;
  87529. serialize(): any;
  87530. getClassName(): string;
  87531. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  87532. }
  87533. }
  87534. declare module BABYLON {
  87535. /** @hidden */
  87536. export var normalPixelShader: {
  87537. name: string;
  87538. shader: string;
  87539. };
  87540. }
  87541. declare module BABYLON {
  87542. /** @hidden */
  87543. export var normalVertexShader: {
  87544. name: string;
  87545. shader: string;
  87546. };
  87547. }
  87548. declare module BABYLON {
  87549. export class NormalMaterial extends BABYLON.PushMaterial {
  87550. private _diffuseTexture;
  87551. diffuseTexture: BABYLON.BaseTexture;
  87552. diffuseColor: BABYLON.Color3;
  87553. private _disableLighting;
  87554. disableLighting: boolean;
  87555. private _maxSimultaneousLights;
  87556. maxSimultaneousLights: number;
  87557. constructor(name: string, scene: BABYLON.Scene);
  87558. needAlphaBlending(): boolean;
  87559. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87560. needAlphaTesting(): boolean;
  87561. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87562. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87563. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87564. getAnimatables(): BABYLON.IAnimatable[];
  87565. getActiveTextures(): BABYLON.BaseTexture[];
  87566. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87567. dispose(forceDisposeEffect?: boolean): void;
  87568. clone(name: string): NormalMaterial;
  87569. serialize(): any;
  87570. getClassName(): string;
  87571. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  87572. }
  87573. }
  87574. declare module BABYLON {
  87575. /** @hidden */
  87576. export var shadowOnlyPixelShader: {
  87577. name: string;
  87578. shader: string;
  87579. };
  87580. }
  87581. declare module BABYLON {
  87582. /** @hidden */
  87583. export var shadowOnlyVertexShader: {
  87584. name: string;
  87585. shader: string;
  87586. };
  87587. }
  87588. declare module BABYLON {
  87589. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  87590. private _activeLight;
  87591. private _needAlphaBlending;
  87592. constructor(name: string, scene: BABYLON.Scene);
  87593. shadowColor: BABYLON.Color3;
  87594. needAlphaBlending(): boolean;
  87595. needAlphaTesting(): boolean;
  87596. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87597. get activeLight(): BABYLON.IShadowLight;
  87598. set activeLight(light: BABYLON.IShadowLight);
  87599. private _getFirstShadowLightForMesh;
  87600. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87601. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87602. clone(name: string): ShadowOnlyMaterial;
  87603. serialize(): any;
  87604. getClassName(): string;
  87605. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  87606. }
  87607. }
  87608. declare module BABYLON {
  87609. /** @hidden */
  87610. export var simplePixelShader: {
  87611. name: string;
  87612. shader: string;
  87613. };
  87614. }
  87615. declare module BABYLON {
  87616. /** @hidden */
  87617. export var simpleVertexShader: {
  87618. name: string;
  87619. shader: string;
  87620. };
  87621. }
  87622. declare module BABYLON {
  87623. export class SimpleMaterial extends BABYLON.PushMaterial {
  87624. private _diffuseTexture;
  87625. diffuseTexture: BABYLON.BaseTexture;
  87626. diffuseColor: BABYLON.Color3;
  87627. private _disableLighting;
  87628. disableLighting: boolean;
  87629. private _maxSimultaneousLights;
  87630. maxSimultaneousLights: number;
  87631. constructor(name: string, scene: BABYLON.Scene);
  87632. needAlphaBlending(): boolean;
  87633. needAlphaTesting(): boolean;
  87634. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87635. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87636. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87637. getAnimatables(): BABYLON.IAnimatable[];
  87638. getActiveTextures(): BABYLON.BaseTexture[];
  87639. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87640. dispose(forceDisposeEffect?: boolean): void;
  87641. clone(name: string): SimpleMaterial;
  87642. serialize(): any;
  87643. getClassName(): string;
  87644. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  87645. }
  87646. }
  87647. declare module BABYLON {
  87648. /** @hidden */
  87649. export var skyPixelShader: {
  87650. name: string;
  87651. shader: string;
  87652. };
  87653. }
  87654. declare module BABYLON {
  87655. /** @hidden */
  87656. export var skyVertexShader: {
  87657. name: string;
  87658. shader: string;
  87659. };
  87660. }
  87661. declare module BABYLON {
  87662. /**
  87663. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  87664. * @see https://doc.babylonjs.com/extensions/sky
  87665. */
  87666. export class SkyMaterial extends BABYLON.PushMaterial {
  87667. /**
  87668. * Defines the overall luminance of sky in interval ]0, 1[.
  87669. */
  87670. luminance: number;
  87671. /**
  87672. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  87673. */
  87674. turbidity: number;
  87675. /**
  87676. * Defines the sky appearance (light intensity).
  87677. */
  87678. rayleigh: number;
  87679. /**
  87680. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  87681. */
  87682. mieCoefficient: number;
  87683. /**
  87684. * Defines the amount of haze particles following the Mie scattering theory.
  87685. */
  87686. mieDirectionalG: number;
  87687. /**
  87688. * Defines the distance of the sun according to the active scene camera.
  87689. */
  87690. distance: number;
  87691. /**
  87692. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  87693. * "inclined".
  87694. */
  87695. inclination: number;
  87696. /**
  87697. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  87698. * an object direction and a reference direction.
  87699. */
  87700. azimuth: number;
  87701. /**
  87702. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  87703. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  87704. */
  87705. sunPosition: BABYLON.Vector3;
  87706. /**
  87707. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  87708. * .sunPosition property.
  87709. */
  87710. useSunPosition: boolean;
  87711. /**
  87712. * Defines an offset vector used to get a horizon offset.
  87713. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  87714. */
  87715. cameraOffset: BABYLON.Vector3;
  87716. private _cameraPosition;
  87717. /**
  87718. * Instantiates a new sky material.
  87719. * This material allows to create dynamic and texture free
  87720. * effects for skyboxes by taking care of the atmosphere state.
  87721. * @see https://doc.babylonjs.com/extensions/sky
  87722. * @param name Define the name of the material in the scene
  87723. * @param scene Define the scene the material belong to
  87724. */
  87725. constructor(name: string, scene: BABYLON.Scene);
  87726. /**
  87727. * Specifies if the material will require alpha blending
  87728. * @returns a boolean specifying if alpha blending is needed
  87729. */
  87730. needAlphaBlending(): boolean;
  87731. /**
  87732. * Specifies if this material should be rendered in alpha test mode
  87733. * @returns false as the sky material doesn't need alpha testing.
  87734. */
  87735. needAlphaTesting(): boolean;
  87736. /**
  87737. * Get the texture used for alpha test purpose.
  87738. * @returns null as the sky material has no texture.
  87739. */
  87740. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87741. /**
  87742. * Get if the submesh is ready to be used and all its information available.
  87743. * Child classes can use it to update shaders
  87744. * @param mesh defines the mesh to check
  87745. * @param subMesh defines which submesh to check
  87746. * @param useInstances specifies that instances should be used
  87747. * @returns a boolean indicating that the submesh is ready or not
  87748. */
  87749. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87750. /**
  87751. * Binds the submesh to this material by preparing the effect and shader to draw
  87752. * @param world defines the world transformation matrix
  87753. * @param mesh defines the mesh containing the submesh
  87754. * @param subMesh defines the submesh to bind the material to
  87755. */
  87756. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87757. /**
  87758. * Get the list of animatables in the material.
  87759. * @returns the list of animatables object used in the material
  87760. */
  87761. getAnimatables(): BABYLON.IAnimatable[];
  87762. /**
  87763. * Disposes the material
  87764. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87765. */
  87766. dispose(forceDisposeEffect?: boolean): void;
  87767. /**
  87768. * Makes a duplicate of the material, and gives it a new name
  87769. * @param name defines the new name for the duplicated material
  87770. * @returns the cloned material
  87771. */
  87772. clone(name: string): SkyMaterial;
  87773. /**
  87774. * Serializes this material in a JSON representation
  87775. * @returns the serialized material object
  87776. */
  87777. serialize(): any;
  87778. /**
  87779. * Gets the current class name of the material e.g. "SkyMaterial"
  87780. * Mainly use in serialization.
  87781. * @returns the class name
  87782. */
  87783. getClassName(): string;
  87784. /**
  87785. * Creates a sky material from parsed material data
  87786. * @param source defines the JSON representation of the material
  87787. * @param scene defines the hosting scene
  87788. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  87789. * @returns a new sky material
  87790. */
  87791. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  87792. }
  87793. }
  87794. declare module BABYLON {
  87795. /** @hidden */
  87796. export var terrainPixelShader: {
  87797. name: string;
  87798. shader: string;
  87799. };
  87800. }
  87801. declare module BABYLON {
  87802. /** @hidden */
  87803. export var terrainVertexShader: {
  87804. name: string;
  87805. shader: string;
  87806. };
  87807. }
  87808. declare module BABYLON {
  87809. export class TerrainMaterial extends BABYLON.PushMaterial {
  87810. private _mixTexture;
  87811. mixTexture: BABYLON.BaseTexture;
  87812. private _diffuseTexture1;
  87813. diffuseTexture1: BABYLON.Texture;
  87814. private _diffuseTexture2;
  87815. diffuseTexture2: BABYLON.Texture;
  87816. private _diffuseTexture3;
  87817. diffuseTexture3: BABYLON.Texture;
  87818. private _bumpTexture1;
  87819. bumpTexture1: BABYLON.Texture;
  87820. private _bumpTexture2;
  87821. bumpTexture2: BABYLON.Texture;
  87822. private _bumpTexture3;
  87823. bumpTexture3: BABYLON.Texture;
  87824. diffuseColor: BABYLON.Color3;
  87825. specularColor: BABYLON.Color3;
  87826. specularPower: number;
  87827. private _disableLighting;
  87828. disableLighting: boolean;
  87829. private _maxSimultaneousLights;
  87830. maxSimultaneousLights: number;
  87831. constructor(name: string, scene: BABYLON.Scene);
  87832. needAlphaBlending(): boolean;
  87833. needAlphaTesting(): boolean;
  87834. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87835. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87836. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87837. getAnimatables(): BABYLON.IAnimatable[];
  87838. getActiveTextures(): BABYLON.BaseTexture[];
  87839. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87840. dispose(forceDisposeEffect?: boolean): void;
  87841. clone(name: string): TerrainMaterial;
  87842. serialize(): any;
  87843. getClassName(): string;
  87844. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  87845. }
  87846. }
  87847. declare module BABYLON {
  87848. /** @hidden */
  87849. export var triplanarPixelShader: {
  87850. name: string;
  87851. shader: string;
  87852. };
  87853. }
  87854. declare module BABYLON {
  87855. /** @hidden */
  87856. export var triplanarVertexShader: {
  87857. name: string;
  87858. shader: string;
  87859. };
  87860. }
  87861. declare module BABYLON {
  87862. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  87863. mixTexture: BABYLON.BaseTexture;
  87864. private _diffuseTextureX;
  87865. diffuseTextureX: BABYLON.BaseTexture;
  87866. private _diffuseTextureY;
  87867. diffuseTextureY: BABYLON.BaseTexture;
  87868. private _diffuseTextureZ;
  87869. diffuseTextureZ: BABYLON.BaseTexture;
  87870. private _normalTextureX;
  87871. normalTextureX: BABYLON.BaseTexture;
  87872. private _normalTextureY;
  87873. normalTextureY: BABYLON.BaseTexture;
  87874. private _normalTextureZ;
  87875. normalTextureZ: BABYLON.BaseTexture;
  87876. tileSize: number;
  87877. diffuseColor: BABYLON.Color3;
  87878. specularColor: BABYLON.Color3;
  87879. specularPower: number;
  87880. private _disableLighting;
  87881. disableLighting: boolean;
  87882. private _maxSimultaneousLights;
  87883. maxSimultaneousLights: number;
  87884. constructor(name: string, scene: BABYLON.Scene);
  87885. needAlphaBlending(): boolean;
  87886. needAlphaTesting(): boolean;
  87887. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87888. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87889. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87890. getAnimatables(): BABYLON.IAnimatable[];
  87891. getActiveTextures(): BABYLON.BaseTexture[];
  87892. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87893. dispose(forceDisposeEffect?: boolean): void;
  87894. clone(name: string): TriPlanarMaterial;
  87895. serialize(): any;
  87896. getClassName(): string;
  87897. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  87898. }
  87899. }
  87900. declare module BABYLON {
  87901. /** @hidden */
  87902. export var waterPixelShader: {
  87903. name: string;
  87904. shader: string;
  87905. };
  87906. }
  87907. declare module BABYLON {
  87908. /** @hidden */
  87909. export var waterVertexShader: {
  87910. name: string;
  87911. shader: string;
  87912. };
  87913. }
  87914. declare module BABYLON {
  87915. export class WaterMaterial extends BABYLON.PushMaterial {
  87916. renderTargetSize: BABYLON.Vector2;
  87917. private _bumpTexture;
  87918. bumpTexture: BABYLON.BaseTexture;
  87919. diffuseColor: BABYLON.Color3;
  87920. specularColor: BABYLON.Color3;
  87921. specularPower: number;
  87922. private _disableLighting;
  87923. disableLighting: boolean;
  87924. private _maxSimultaneousLights;
  87925. maxSimultaneousLights: number;
  87926. /**
  87927. * Defines the wind force.
  87928. */
  87929. windForce: number;
  87930. /**
  87931. * Defines the direction of the wind in the plane (X, Z).
  87932. */
  87933. windDirection: BABYLON.Vector2;
  87934. /**
  87935. * Defines the height of the waves.
  87936. */
  87937. waveHeight: number;
  87938. /**
  87939. * Defines the bump height related to the bump map.
  87940. */
  87941. bumpHeight: number;
  87942. /**
  87943. * Defines wether or not: to add a smaller moving bump to less steady waves.
  87944. */
  87945. private _bumpSuperimpose;
  87946. bumpSuperimpose: boolean;
  87947. /**
  87948. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  87949. */
  87950. private _fresnelSeparate;
  87951. fresnelSeparate: boolean;
  87952. /**
  87953. * Defines wether or not bump Wwves modify the reflection.
  87954. */
  87955. private _bumpAffectsReflection;
  87956. bumpAffectsReflection: boolean;
  87957. /**
  87958. * Defines the water color blended with the refraction (near).
  87959. */
  87960. waterColor: BABYLON.Color3;
  87961. /**
  87962. * Defines the blend factor related to the water color.
  87963. */
  87964. colorBlendFactor: number;
  87965. /**
  87966. * Defines the water color blended with the reflection (far).
  87967. */
  87968. waterColor2: BABYLON.Color3;
  87969. /**
  87970. * Defines the blend factor related to the water color (reflection, far).
  87971. */
  87972. colorBlendFactor2: number;
  87973. /**
  87974. * Defines the maximum length of a wave.
  87975. */
  87976. waveLength: number;
  87977. /**
  87978. * Defines the waves speed.
  87979. */
  87980. waveSpeed: number;
  87981. /**
  87982. * 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.
  87983. */
  87984. waveCount: number;
  87985. /**
  87986. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  87987. * will avoid calculating useless pixels in the pixel shader of the water material.
  87988. */
  87989. disableClipPlane: boolean;
  87990. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87991. private _mesh;
  87992. private _refractionRTT;
  87993. private _reflectionRTT;
  87994. private _reflectionTransform;
  87995. private _lastTime;
  87996. private _lastDeltaTime;
  87997. private _useLogarithmicDepth;
  87998. private _waitingRenderList;
  87999. private _imageProcessingConfiguration;
  88000. private _imageProcessingObserver;
  88001. /**
  88002. * Gets a boolean indicating that current material needs to register RTT
  88003. */
  88004. get hasRenderTargetTextures(): boolean;
  88005. /**
  88006. * Constructor
  88007. */
  88008. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  88009. get useLogarithmicDepth(): boolean;
  88010. set useLogarithmicDepth(value: boolean);
  88011. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  88012. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  88013. addToRenderList(node: any): void;
  88014. enableRenderTargets(enable: boolean): void;
  88015. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  88016. get renderTargetsEnabled(): boolean;
  88017. needAlphaBlending(): boolean;
  88018. needAlphaTesting(): boolean;
  88019. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  88020. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  88021. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  88022. private _createRenderTargets;
  88023. getAnimatables(): BABYLON.IAnimatable[];
  88024. getActiveTextures(): BABYLON.BaseTexture[];
  88025. hasTexture(texture: BABYLON.BaseTexture): boolean;
  88026. dispose(forceDisposeEffect?: boolean): void;
  88027. clone(name: string): WaterMaterial;
  88028. serialize(): any;
  88029. getClassName(): string;
  88030. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  88031. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  88032. }
  88033. }
  88034. declare module BABYLON {
  88035. /** @hidden */
  88036. export var asciiartPixelShader: {
  88037. name: string;
  88038. shader: string;
  88039. };
  88040. }
  88041. declare module BABYLON {
  88042. /**
  88043. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  88044. *
  88045. * It basically takes care rendering the font front the given font size to a texture.
  88046. * This is used later on in the postprocess.
  88047. */
  88048. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  88049. private _font;
  88050. private _text;
  88051. private _charSize;
  88052. /**
  88053. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88054. */
  88055. get charSize(): number;
  88056. /**
  88057. * Create a new instance of the Ascii Art FontTexture class
  88058. * @param name the name of the texture
  88059. * @param font the font to use, use the W3C CSS notation
  88060. * @param text the caracter set to use in the rendering.
  88061. * @param scene the scene that owns the texture
  88062. */
  88063. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88064. /**
  88065. * Gets the max char width of a font.
  88066. * @param font the font to use, use the W3C CSS notation
  88067. * @return the max char width
  88068. */
  88069. private getFontWidth;
  88070. /**
  88071. * Gets the max char height of a font.
  88072. * @param font the font to use, use the W3C CSS notation
  88073. * @return the max char height
  88074. */
  88075. private getFontHeight;
  88076. /**
  88077. * Clones the current AsciiArtTexture.
  88078. * @return the clone of the texture.
  88079. */
  88080. clone(): AsciiArtFontTexture;
  88081. /**
  88082. * Parses a json object representing the texture and returns an instance of it.
  88083. * @param source the source JSON representation
  88084. * @param scene the scene to create the texture for
  88085. * @return the parsed texture
  88086. */
  88087. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  88088. }
  88089. /**
  88090. * Option available in the Ascii Art Post Process.
  88091. */
  88092. export interface IAsciiArtPostProcessOptions {
  88093. /**
  88094. * The font to use following the w3c font definition.
  88095. */
  88096. font?: string;
  88097. /**
  88098. * The character set to use in the postprocess.
  88099. */
  88100. characterSet?: string;
  88101. /**
  88102. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88103. * This number is defined between 0 and 1;
  88104. */
  88105. mixToTile?: number;
  88106. /**
  88107. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88108. * This number is defined between 0 and 1;
  88109. */
  88110. mixToNormal?: number;
  88111. }
  88112. /**
  88113. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  88114. *
  88115. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88116. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  88117. */
  88118. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  88119. /**
  88120. * The font texture used to render the char in the post process.
  88121. */
  88122. private _asciiArtFontTexture;
  88123. /**
  88124. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88125. * This number is defined between 0 and 1;
  88126. */
  88127. mixToTile: number;
  88128. /**
  88129. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88130. * This number is defined between 0 and 1;
  88131. */
  88132. mixToNormal: number;
  88133. /**
  88134. * Instantiates a new Ascii Art Post Process.
  88135. * @param name the name to give to the postprocess
  88136. * @camera the camera to apply the post process to.
  88137. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  88138. */
  88139. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  88140. }
  88141. }
  88142. declare module BABYLON {
  88143. /** @hidden */
  88144. export var digitalrainPixelShader: {
  88145. name: string;
  88146. shader: string;
  88147. };
  88148. }
  88149. declare module BABYLON {
  88150. /**
  88151. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  88152. *
  88153. * It basically takes care rendering the font front the given font size to a texture.
  88154. * This is used later on in the postprocess.
  88155. */
  88156. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  88157. private _font;
  88158. private _text;
  88159. private _charSize;
  88160. /**
  88161. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88162. */
  88163. get charSize(): number;
  88164. /**
  88165. * Create a new instance of the Digital Rain FontTexture class
  88166. * @param name the name of the texture
  88167. * @param font the font to use, use the W3C CSS notation
  88168. * @param text the caracter set to use in the rendering.
  88169. * @param scene the scene that owns the texture
  88170. */
  88171. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88172. /**
  88173. * Gets the max char width of a font.
  88174. * @param font the font to use, use the W3C CSS notation
  88175. * @return the max char width
  88176. */
  88177. private getFontWidth;
  88178. /**
  88179. * Gets the max char height of a font.
  88180. * @param font the font to use, use the W3C CSS notation
  88181. * @return the max char height
  88182. */
  88183. private getFontHeight;
  88184. /**
  88185. * Clones the current DigitalRainFontTexture.
  88186. * @return the clone of the texture.
  88187. */
  88188. clone(): DigitalRainFontTexture;
  88189. /**
  88190. * Parses a json object representing the texture and returns an instance of it.
  88191. * @param source the source JSON representation
  88192. * @param scene the scene to create the texture for
  88193. * @return the parsed texture
  88194. */
  88195. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  88196. }
  88197. /**
  88198. * Option available in the Digital Rain Post Process.
  88199. */
  88200. export interface IDigitalRainPostProcessOptions {
  88201. /**
  88202. * The font to use following the w3c font definition.
  88203. */
  88204. font?: string;
  88205. /**
  88206. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88207. * This number is defined between 0 and 1;
  88208. */
  88209. mixToTile?: number;
  88210. /**
  88211. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88212. * This number is defined between 0 and 1;
  88213. */
  88214. mixToNormal?: number;
  88215. }
  88216. /**
  88217. * DigitalRainPostProcess helps rendering everithing in digital rain.
  88218. *
  88219. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88220. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  88221. */
  88222. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  88223. /**
  88224. * The font texture used to render the char in the post process.
  88225. */
  88226. private _digitalRainFontTexture;
  88227. /**
  88228. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88229. * This number is defined between 0 and 1;
  88230. */
  88231. mixToTile: number;
  88232. /**
  88233. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88234. * This number is defined between 0 and 1;
  88235. */
  88236. mixToNormal: number;
  88237. /**
  88238. * Instantiates a new Digital Rain Post Process.
  88239. * @param name the name to give to the postprocess
  88240. * @camera the camera to apply the post process to.
  88241. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  88242. */
  88243. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  88244. }
  88245. }
  88246. declare module BABYLON {
  88247. /** @hidden */
  88248. export var brickProceduralTexturePixelShader: {
  88249. name: string;
  88250. shader: string;
  88251. };
  88252. }
  88253. declare module BABYLON {
  88254. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  88255. private _numberOfBricksHeight;
  88256. private _numberOfBricksWidth;
  88257. private _jointColor;
  88258. private _brickColor;
  88259. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88260. updateShaderUniforms(): void;
  88261. get numberOfBricksHeight(): number;
  88262. set numberOfBricksHeight(value: number);
  88263. get numberOfBricksWidth(): number;
  88264. set numberOfBricksWidth(value: number);
  88265. get jointColor(): BABYLON.Color3;
  88266. set jointColor(value: BABYLON.Color3);
  88267. get brickColor(): BABYLON.Color3;
  88268. set brickColor(value: BABYLON.Color3);
  88269. /**
  88270. * Serializes this brick procedural texture
  88271. * @returns a serialized brick procedural texture object
  88272. */
  88273. serialize(): any;
  88274. /**
  88275. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  88276. * @param parsedTexture defines parsed texture data
  88277. * @param scene defines the current scene
  88278. * @param rootUrl defines the root URL containing brick procedural texture information
  88279. * @returns a parsed Brick Procedural BABYLON.Texture
  88280. */
  88281. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  88282. }
  88283. }
  88284. declare module BABYLON {
  88285. /** @hidden */
  88286. export var cloudProceduralTexturePixelShader: {
  88287. name: string;
  88288. shader: string;
  88289. };
  88290. }
  88291. declare module BABYLON {
  88292. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  88293. private _skyColor;
  88294. private _cloudColor;
  88295. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88296. updateShaderUniforms(): void;
  88297. get skyColor(): BABYLON.Color4;
  88298. set skyColor(value: BABYLON.Color4);
  88299. get cloudColor(): BABYLON.Color4;
  88300. set cloudColor(value: BABYLON.Color4);
  88301. /**
  88302. * Serializes this cloud procedural texture
  88303. * @returns a serialized cloud procedural texture object
  88304. */
  88305. serialize(): any;
  88306. /**
  88307. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  88308. * @param parsedTexture defines parsed texture data
  88309. * @param scene defines the current scene
  88310. * @param rootUrl defines the root URL containing cloud procedural texture information
  88311. * @returns a parsed Cloud Procedural BABYLON.Texture
  88312. */
  88313. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  88314. }
  88315. }
  88316. declare module BABYLON {
  88317. /** @hidden */
  88318. export var fireProceduralTexturePixelShader: {
  88319. name: string;
  88320. shader: string;
  88321. };
  88322. }
  88323. declare module BABYLON {
  88324. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  88325. private _time;
  88326. private _speed;
  88327. private _autoGenerateTime;
  88328. private _fireColors;
  88329. private _alphaThreshold;
  88330. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88331. updateShaderUniforms(): void;
  88332. render(useCameraPostProcess?: boolean): void;
  88333. static get PurpleFireColors(): BABYLON.Color3[];
  88334. static get GreenFireColors(): BABYLON.Color3[];
  88335. static get RedFireColors(): BABYLON.Color3[];
  88336. static get BlueFireColors(): BABYLON.Color3[];
  88337. get autoGenerateTime(): boolean;
  88338. set autoGenerateTime(value: boolean);
  88339. get fireColors(): BABYLON.Color3[];
  88340. set fireColors(value: BABYLON.Color3[]);
  88341. get time(): number;
  88342. set time(value: number);
  88343. get speed(): BABYLON.Vector2;
  88344. set speed(value: BABYLON.Vector2);
  88345. get alphaThreshold(): number;
  88346. set alphaThreshold(value: number);
  88347. /**
  88348. * Serializes this fire procedural texture
  88349. * @returns a serialized fire procedural texture object
  88350. */
  88351. serialize(): any;
  88352. /**
  88353. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  88354. * @param parsedTexture defines parsed texture data
  88355. * @param scene defines the current scene
  88356. * @param rootUrl defines the root URL containing fire procedural texture information
  88357. * @returns a parsed Fire Procedural BABYLON.Texture
  88358. */
  88359. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  88360. }
  88361. }
  88362. declare module BABYLON {
  88363. /** @hidden */
  88364. export var grassProceduralTexturePixelShader: {
  88365. name: string;
  88366. shader: string;
  88367. };
  88368. }
  88369. declare module BABYLON {
  88370. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  88371. private _grassColors;
  88372. private _groundColor;
  88373. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88374. updateShaderUniforms(): void;
  88375. get grassColors(): BABYLON.Color3[];
  88376. set grassColors(value: BABYLON.Color3[]);
  88377. get groundColor(): BABYLON.Color3;
  88378. set groundColor(value: BABYLON.Color3);
  88379. /**
  88380. * Serializes this grass procedural texture
  88381. * @returns a serialized grass procedural texture object
  88382. */
  88383. serialize(): any;
  88384. /**
  88385. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  88386. * @param parsedTexture defines parsed texture data
  88387. * @param scene defines the current scene
  88388. * @param rootUrl defines the root URL containing grass procedural texture information
  88389. * @returns a parsed Grass Procedural BABYLON.Texture
  88390. */
  88391. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  88392. }
  88393. }
  88394. declare module BABYLON {
  88395. /** @hidden */
  88396. export var marbleProceduralTexturePixelShader: {
  88397. name: string;
  88398. shader: string;
  88399. };
  88400. }
  88401. declare module BABYLON {
  88402. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  88403. private _numberOfTilesHeight;
  88404. private _numberOfTilesWidth;
  88405. private _amplitude;
  88406. private _jointColor;
  88407. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88408. updateShaderUniforms(): void;
  88409. get numberOfTilesHeight(): number;
  88410. set numberOfTilesHeight(value: number);
  88411. get amplitude(): number;
  88412. set amplitude(value: number);
  88413. get numberOfTilesWidth(): number;
  88414. set numberOfTilesWidth(value: number);
  88415. get jointColor(): BABYLON.Color3;
  88416. set jointColor(value: BABYLON.Color3);
  88417. /**
  88418. * Serializes this marble procedural texture
  88419. * @returns a serialized marble procedural texture object
  88420. */
  88421. serialize(): any;
  88422. /**
  88423. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  88424. * @param parsedTexture defines parsed texture data
  88425. * @param scene defines the current scene
  88426. * @param rootUrl defines the root URL containing marble procedural texture information
  88427. * @returns a parsed Marble Procedural BABYLON.Texture
  88428. */
  88429. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  88430. }
  88431. }
  88432. declare module BABYLON {
  88433. /** @hidden */
  88434. export var normalMapProceduralTexturePixelShader: {
  88435. name: string;
  88436. shader: string;
  88437. };
  88438. }
  88439. declare module BABYLON {
  88440. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  88441. private _baseTexture;
  88442. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88443. updateShaderUniforms(): void;
  88444. render(useCameraPostProcess?: boolean): void;
  88445. resize(size: any, generateMipMaps: any): void;
  88446. get baseTexture(): BABYLON.Texture;
  88447. set baseTexture(texture: BABYLON.Texture);
  88448. /**
  88449. * Serializes this normal map procedural texture
  88450. * @returns a serialized normal map procedural texture object
  88451. */
  88452. serialize(): any;
  88453. /**
  88454. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  88455. * @param parsedTexture defines parsed texture data
  88456. * @param scene defines the current scene
  88457. * @param rootUrl defines the root URL containing normal map procedural texture information
  88458. * @returns a parsed Normal Map Procedural BABYLON.Texture
  88459. */
  88460. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  88461. }
  88462. }
  88463. declare module BABYLON {
  88464. /** @hidden */
  88465. export var perlinNoiseProceduralTexturePixelShader: {
  88466. name: string;
  88467. shader: string;
  88468. };
  88469. }
  88470. declare module BABYLON {
  88471. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  88472. time: number;
  88473. timeScale: number;
  88474. translationSpeed: number;
  88475. private _currentTranslation;
  88476. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88477. updateShaderUniforms(): void;
  88478. render(useCameraPostProcess?: boolean): void;
  88479. resize(size: any, generateMipMaps: any): void;
  88480. /**
  88481. * Serializes this perlin noise procedural texture
  88482. * @returns a serialized perlin noise procedural texture object
  88483. */
  88484. serialize(): any;
  88485. /**
  88486. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  88487. * @param parsedTexture defines parsed texture data
  88488. * @param scene defines the current scene
  88489. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  88490. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  88491. */
  88492. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  88493. }
  88494. }
  88495. declare module BABYLON {
  88496. /** @hidden */
  88497. export var roadProceduralTexturePixelShader: {
  88498. name: string;
  88499. shader: string;
  88500. };
  88501. }
  88502. declare module BABYLON {
  88503. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  88504. private _roadColor;
  88505. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88506. updateShaderUniforms(): void;
  88507. get roadColor(): BABYLON.Color3;
  88508. set roadColor(value: BABYLON.Color3);
  88509. /**
  88510. * Serializes this road procedural texture
  88511. * @returns a serialized road procedural texture object
  88512. */
  88513. serialize(): any;
  88514. /**
  88515. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  88516. * @param parsedTexture defines parsed texture data
  88517. * @param scene defines the current scene
  88518. * @param rootUrl defines the root URL containing road procedural texture information
  88519. * @returns a parsed Road Procedural BABYLON.Texture
  88520. */
  88521. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  88522. }
  88523. }
  88524. declare module BABYLON {
  88525. /** @hidden */
  88526. export var starfieldProceduralTexturePixelShader: {
  88527. name: string;
  88528. shader: string;
  88529. };
  88530. }
  88531. declare module BABYLON {
  88532. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  88533. private _time;
  88534. private _alpha;
  88535. private _beta;
  88536. private _zoom;
  88537. private _formuparam;
  88538. private _stepsize;
  88539. private _tile;
  88540. private _brightness;
  88541. private _darkmatter;
  88542. private _distfading;
  88543. private _saturation;
  88544. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88545. updateShaderUniforms(): void;
  88546. get time(): number;
  88547. set time(value: number);
  88548. get alpha(): number;
  88549. set alpha(value: number);
  88550. get beta(): number;
  88551. set beta(value: number);
  88552. get formuparam(): number;
  88553. set formuparam(value: number);
  88554. get stepsize(): number;
  88555. set stepsize(value: number);
  88556. get zoom(): number;
  88557. set zoom(value: number);
  88558. get tile(): number;
  88559. set tile(value: number);
  88560. get brightness(): number;
  88561. set brightness(value: number);
  88562. get darkmatter(): number;
  88563. set darkmatter(value: number);
  88564. get distfading(): number;
  88565. set distfading(value: number);
  88566. get saturation(): number;
  88567. set saturation(value: number);
  88568. /**
  88569. * Serializes this starfield procedural texture
  88570. * @returns a serialized starfield procedural texture object
  88571. */
  88572. serialize(): any;
  88573. /**
  88574. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  88575. * @param parsedTexture defines parsed texture data
  88576. * @param scene defines the current scene
  88577. * @param rootUrl defines the root URL containing startfield procedural texture information
  88578. * @returns a parsed Starfield Procedural BABYLON.Texture
  88579. */
  88580. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  88581. }
  88582. }
  88583. declare module BABYLON {
  88584. /** @hidden */
  88585. export var woodProceduralTexturePixelShader: {
  88586. name: string;
  88587. shader: string;
  88588. };
  88589. }
  88590. declare module BABYLON {
  88591. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  88592. private _ampScale;
  88593. private _woodColor;
  88594. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88595. updateShaderUniforms(): void;
  88596. get ampScale(): number;
  88597. set ampScale(value: number);
  88598. get woodColor(): BABYLON.Color3;
  88599. set woodColor(value: BABYLON.Color3);
  88600. /**
  88601. * Serializes this wood procedural texture
  88602. * @returns a serialized wood procedural texture object
  88603. */
  88604. serialize(): any;
  88605. /**
  88606. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  88607. * @param parsedTexture defines parsed texture data
  88608. * @param scene defines the current scene
  88609. * @param rootUrl defines the root URL containing wood procedural texture information
  88610. * @returns a parsed Wood Procedural BABYLON.Texture
  88611. */
  88612. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  88613. }
  88614. }